diff options
author | jstebbins <[email protected]> | 2014-08-26 22:13:17 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2014-08-26 22:13:17 +0000 |
commit | d3911e0217f0c7aa8c775e14d718dd22a50563fe (patch) | |
tree | cde9cf478564238cc080e7599522fd4c16ef29bb | |
parent | 8a162f6cba7e30e1f1150922cc99456069a867ac (diff) |
x265: enable 2-pass ABR encoding
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6366 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | gtk/src/hb-backend.c | 4 | ||||
-rw-r--r-- | libhb/encx265.c | 60 | ||||
-rw-r--r-- | libhb/work.c | 13 |
3 files changed, 52 insertions, 25 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index f7630454b..c200a5bdd 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -4748,8 +4748,8 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) /* * If turbo options have been selected then set job->fastfirstpass */ - if( ghb_settings_get_boolean(js, "VideoTurboTwoPass") && - job->vcodec == HB_VCODEC_X264 ) + if(ghb_settings_get_boolean(js, "VideoTurboTwoPass") && + (job->vcodec == HB_VCODEC_X264 || job->vcodec == HB_VCODEC_X265)) { job->fastfirstpass = 1; } diff --git a/libhb/encx265.c b/libhb/encx265.c index c21caf89d..60c1b38aa 100644 --- a/libhb/encx265.c +++ b/libhb/encx265.c @@ -64,6 +64,24 @@ struct chapter_s int64_t start; }; +static int param_parse(x265_param *param, const char *key, const char *value) +{ + int ret = x265_param_parse(param, key, value); + // let x265 sanity check the options for us + switch (ret) + { + case X265_PARAM_BAD_NAME: + hb_log("encx265: unknown option '%s'", key); + break; + case X265_PARAM_BAD_VALUE: + hb_log("encx265: bad argument '%s=%s'", key, value ? value : "(null)"); + break; + default: + break; + } + return ret; +} + /*********************************************************************** * hb_work_encx265_init *********************************************************************** @@ -156,11 +174,10 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job) snprintf(colormatrix, sizeof(colormatrix), "%d", job->title->color_matrix); break; } - if (x265_param_parse(param, "colorprim", colorprim) || - x265_param_parse(param, "transfer", transfer) || - x265_param_parse(param, "colormatrix", colormatrix)) + if (param_parse(param, "colorprim", colorprim) || + param_parse(param, "transfer", transfer) || + param_parse(param, "colormatrix", colormatrix)) { - hb_error("encx265: failed to set VUI color description"); goto fail; } @@ -170,19 +187,10 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job) while ((entry = hb_dict_next(x265_opts, entry)) != NULL) { // here's where the strings are passed to libx265 for parsing - ret = x265_param_parse(param, entry->key, entry->value); - // let x265 sanity check the options for us - switch (ret) + if (param_parse(param, entry->key, entry->value)) { - case X265_PARAM_BAD_NAME: - hb_log("encx265: unknown option '%s'", entry->key); - break; - case X265_PARAM_BAD_VALUE: - hb_log("encx265: bad argument '%s=%s'", entry->key, - entry->value ? entry->value : "(null)"); - break; - default: - break; + hb_dict_free(&x265_opts); + goto fail; } } hb_dict_free(&x265_opts); @@ -212,9 +220,8 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job) char sar[22]; snprintf(sar, sizeof(sar), "%d:%d", job->anamorphic.par_width, job->anamorphic.par_height); - if (x265_param_parse(param, "sar", sar)) + if (param_parse(param, "sar", sar)) { - hb_error("encx265: failed to set SAR"); goto fail; } } @@ -228,6 +235,23 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job) { param->rc.rateControlMode = X265_RC_ABR; param->rc.bitrate = job->vbitrate; + if (job->pass > 0 && job->pass < 3) + { + char stats_file[1024] = ""; + char pass[2]; + snprintf(pass, sizeof(pass), "%d", job->pass); + hb_get_tempory_filename(job->h, stats_file, "x265.log"); + if (param_parse(param, "stats", stats_file) || + param_parse(param, "pass", pass)) + { + goto fail; + } + if (job->pass == 1 && job->fastfirstpass == 0 && + param_parse(param, "slow-firstpass", "1")) + { + goto fail; + } + } } /* statsfile (but not 2-pass) */ diff --git a/libhb/work.c b/libhb/work.c index 88f4be248..7e117df30 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -366,13 +366,16 @@ void hb_display_job_info(hb_job_t *job) else { hb_log( " + bitrate: %d kbps, pass: %d", job->vbitrate, job->pass ); - if( job->pass == 1 && job->fastfirstpass == 1 && - job->vcodec == HB_VCODEC_X264 ) + if(job->pass == 1 && job->fastfirstpass == 1 && + (job->vcodec == HB_VCODEC_X264 || job->vcodec == HB_VCODEC_X265)) { hb_log( " + fast first pass" ); - hb_log( " + options: ref=1:8x8dct=0:me=dia:trellis=0" ); - hb_log( " analyse=i4x4 (if originally enabled, else analyse=none)" ); - hb_log( " subq=2 (if originally greater than 2, else subq unchanged)" ); + if (job->vcodec == HB_VCODEC_X264) + { + hb_log( " + options: ref=1:8x8dct=0:me=dia:trellis=0" ); + hb_log( " analyse=i4x4 (if originally enabled, else analyse=none)" ); + hb_log( " subq=2 (if originally greater than 2, else subq unchanged)" ); + } } } |