diff options
author | Tim Walker <[email protected]> | 2016-03-29 23:22:26 +0200 |
---|---|---|
committer | Tim Walker <[email protected]> | 2016-03-31 01:05:16 +0200 |
commit | f62eab7af77982d8a161d2714d237f3b7bda3cf8 (patch) | |
tree | 1388fe4e13257e8b503260b4f9e29b9205c7dd13 | |
parent | 0de684adbc17b445f93ed8e6f52951b44dc12063 (diff) |
libhb: fix incorrect assumption that video quality is always positive.
-rw-r--r-- | libhb/common.c | 2 | ||||
-rw-r--r-- | libhb/common.h | 5 | ||||
-rw-r--r-- | libhb/enc_qsv.c | 6 | ||||
-rw-r--r-- | libhb/encavcodec.c | 2 | ||||
-rw-r--r-- | libhb/enctheora.c | 2 | ||||
-rw-r--r-- | libhb/encx264.c | 2 | ||||
-rw-r--r-- | libhb/encx265.c | 2 | ||||
-rw-r--r-- | libhb/hb.c | 2 | ||||
-rw-r--r-- | libhb/hb_json.c | 2 | ||||
-rw-r--r-- | libhb/muxcommon.c | 2 | ||||
-rw-r--r-- | libhb/work.c | 2 |
11 files changed, 16 insertions, 13 deletions
diff --git a/libhb/common.c b/libhb/common.c index c3643daa1..87551e90f 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -3484,7 +3484,7 @@ static void job_setup(hb_job_t * job, hb_title_t * title) job->par = resultGeo.par; job->vcodec = HB_VCODEC_FFMPEG_MPEG4; - job->vquality = -1.0; + job->vquality = HB_INVALID_VIDEO_QUALITY; job->vbitrate = 1000; job->twopass = 0; job->pass_id = HB_PASS_ENCODE; diff --git a/libhb/common.h b/libhb/common.h index 5d99e2eb8..813b778ef 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -481,7 +481,7 @@ struct hb_job_s /* Video settings: vcodec: output codec - vquality: output quality (if < 0.0, bitrate is used instead) + vquality: output quality (if invalid, bitrate is used instead) vbitrate: output bitrate (Kbps) vrate: output framerate cfr: 0 (vfr), 1 (cfr), 2 (pfr) [see render.c] @@ -510,6 +510,9 @@ struct hb_job_s #define HB_VCODEC_X265_MASK 0x000F000 #define HB_VCODEC_H265_MASK (HB_VCODEC_X265_MASK|HB_VCODEC_QSV_H265) +/* define an invalid CQ value compatible with all CQ-capable codecs */ +#define HB_INVALID_VIDEO_QUALITY (-1000.) + int vcodec; double vquality; int vbitrate; diff --git a/libhb/enc_qsv.c b/libhb/enc_qsv.c index 48e4c845e..15d7b6bd5 100644 --- a/libhb/enc_qsv.c +++ b/libhb/enc_qsv.c @@ -888,7 +888,7 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job) } else { - pv->param.rc.icq = pv->param.rc.icq && job->vquality >= 0; + pv->param.rc.icq = pv->param.rc.icq && job->vquality > HB_INVALID_VIDEO_QUALITY; } // sanitize lookahead @@ -907,7 +907,7 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job) } else { - pv->param.rc.lookahead = pv->param.rc.lookahead && (pv->param.rc.icq || job->vquality < 0); + pv->param.rc.lookahead = pv->param.rc.lookahead && (pv->param.rc.icq || job->vquality <= HB_INVALID_VIDEO_QUALITY); } // set VBV here (this will be overridden for CQP and ignored for LA) @@ -932,7 +932,7 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job) } // set rate control paremeters - if (job->vquality >= 0) + if (job->vquality > HB_INVALID_VIDEO_QUALITY) { if (pv->param.rc.icq) { diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c index 3f416b244..129921d0b 100644 --- a/libhb/encavcodec.c +++ b/libhb/encavcodec.c @@ -182,7 +182,7 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) // Now set the things in context that we don't want to allow // the user to override. - if( job->vquality < 0.0 ) + if (job->vquality <= HB_INVALID_VIDEO_QUALITY) { /* Average bitrate */ context->bit_rate = 1000 * job->vbitrate; diff --git a/libhb/enctheora.c b/libhb/enctheora.c index 763e07f84..12438058f 100644 --- a/libhb/enctheora.c +++ b/libhb/enctheora.c @@ -77,7 +77,7 @@ int enctheoraInit( hb_work_object_t * w, hb_job_t * job ) ti.aspect_denominator = job->par.den; ti.colorspace = TH_CS_UNSPECIFIED; ti.pixel_fmt = TH_PF_420; - if (job->vquality < 0.0) + if (job->vquality <= HB_INVALID_VIDEO_QUALITY) { ti.target_bitrate = job->vbitrate * 1000; ti.quality = 0; diff --git a/libhb/encx264.c b/libhb/encx264.c index 84b13f421..30cee1096 100644 --- a/libhb/encx264.c +++ b/libhb/encx264.c @@ -484,7 +484,7 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) param.vui.i_sar_width = job->par.num; param.vui.i_sar_height = job->par.den; - if( job->vquality >= 0 ) + if (job->vquality > HB_INVALID_VIDEO_QUALITY) { /* Constant RF */ param.rc.i_rc_method = X264_RC_CRF; diff --git a/libhb/encx265.c b/libhb/encx265.c index d7c1c64b1..7cda7b71b 100644 --- a/libhb/encx265.c +++ b/libhb/encx265.c @@ -249,7 +249,7 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job) goto fail; } - if (job->vquality >= 0.) + if (job->vquality > HB_INVALID_VIDEO_QUALITY) { param->rc.rateControlMode = X265_RC_CRF; param->rc.rfConstant = job->vquality; diff --git a/libhb/hb.c b/libhb/hb.c index ac43a99c7..fdda96e77 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -1551,7 +1551,7 @@ int hb_add( hb_handle_t * h, hb_job_t * job ) void hb_job_setup_passes(hb_handle_t * h, hb_job_t * job, hb_list_t * list_pass) { - if (job->vquality >= 0) + if (job->vquality > HB_INVALID_VIDEO_QUALITY) { job->twopass = 0; } diff --git a/libhb/hb_json.c b/libhb/hb_json.c index 39f7392f3..716ced4ce 100644 --- a/libhb/hb_json.c +++ b/libhb/hb_json.c @@ -497,7 +497,7 @@ hb_dict_t* hb_job_to_dict( const hb_job_t * job ) hb_dict_set(video_dict, "ColorMatrixCode", hb_value_int(job->color_matrix_code)); } - if (job->vquality >= 0) + if (job->vquality > HB_INVALID_VIDEO_QUALITY) { hb_dict_set(video_dict, "Quality", hb_value_double(job->vquality)); } diff --git a/libhb/muxcommon.c b/libhb/muxcommon.c index 13d771289..0a846def1 100644 --- a/libhb/muxcommon.c +++ b/libhb/muxcommon.c @@ -536,7 +536,7 @@ static void muxClose( hb_work_object_t * muxer ) i, track->frames, track->bytes, 90000.0 * track->bytes / mux->pts / 125, track->mf.flen ); - if( !i && job->vquality < 0 ) + if (!i && job->vquality <= HB_INVALID_VIDEO_QUALITY) { /* Video */ hb_deep_log( 2, "mux: video bitrate error, %+"PRId64" bytes", diff --git a/libhb/work.c b/libhb/work.c index 4fca293fb..4b09144b2 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -493,7 +493,7 @@ void hb_display_job_info(hb_job_t *job) } } - if (job->vquality >= 0) + if (job->vquality > HB_INVALID_VIDEO_QUALITY) { hb_log(" + quality: %.2f (%s)", job->vquality, hb_video_quality_get_name(job->vcodec)); |