diff options
author | jstebbins <[email protected]> | 2011-08-08 20:24:30 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2011-08-08 20:24:30 +0000 |
commit | 8f930a4ecbf1bbb3f658fae5bdeb7c272ff4250e (patch) | |
tree | c1cbcd43e43f8e18d5c0db89e5ae51eb3d02b04e /libhb/encx264.c | |
parent | 1a10eb0fcb770aa7eab1a08e0ebd03646bb6bfdc (diff) |
libhb: allow changing colorimetry in x264 options
Setting "colorprim", "transfer", or "colormarix" in the x264 advanced
options will no longer be ignored and will propagate to the mp4 muxer
where those values also get set in the container.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4164 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/encx264.c')
-rw-r--r-- | libhb/encx264.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/libhb/encx264.c b/libhb/encx264.c index 350b3a76c..e42a3be21 100644 --- a/libhb/encx264.c +++ b/libhb/encx264.c @@ -132,6 +132,31 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) param.i_log_level = X264_LOG_INFO; + /* set up the VUI color model & gamma to match what the COLR atom + * set in muxmp4.c says. See libhb/muxmp4.c for notes. */ + if( job->color_matrix_code == 3 ) + { + // Custom + param.vui.i_colorprim = job->color_prim; + param.vui.i_transfer = job->color_transfer; + param.vui.i_colmatrix = job->color_matrix; + } + else if( ( job->color_matrix_code == 2 ) || + ( job->color_matrix_code == 0 && ( job->title->width >= 1280 || job->title->height >= 720 ) ) ) + { + // ITU BT.709 HD content + param.vui.i_colorprim = 1; + param.vui.i_transfer = 1; + param.vui.i_colmatrix = 1; + } + else + { + // ITU BT.601 DVD or SD TV content + param.vui.i_colorprim = 6; + param.vui.i_transfer = 1; + param.vui.i_colmatrix = 6; + } + /* This section passes the string advanced_opts to libx264 for parsing into parameter names and values. @@ -185,6 +210,13 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) free(x264opts_start); } + /* Reload colorimetry settings in case custom values were set + * in the advanced_opts string */ + job->color_matrix_code = 3; + job->color_prim = param.vui.i_colorprim; + job->color_transfer = param.vui.i_transfer; + job->color_matrix = param.vui.i_colmatrix; + /* B-frames are on by default.*/ job->areBframes = 1; @@ -228,37 +260,6 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) hb_log( "encx264: min-keyint: %s, keyint: %s", min, max ); } - /* set up the VUI color model & gamma to match what the COLR atom - * set in muxmp4.c says. See libhb/muxmp4.c for notes. */ - if( job->color_matrix == 1 ) - { - // ITU BT.601 DVD or SD TV content - param.vui.i_colorprim = 6; - param.vui.i_transfer = 1; - param.vui.i_colmatrix = 6; - } - else if( job->color_matrix == 2 ) - { - // ITU BT.709 HD content - param.vui.i_colorprim = 1; - param.vui.i_transfer = 1; - param.vui.i_colmatrix = 1; - } - else if ( job->title->width >= 1280 || job->title->height >= 720 ) - { - // we guess that 720p or above is ITU BT.709 HD content - param.vui.i_colorprim = 1; - param.vui.i_transfer = 1; - param.vui.i_colmatrix = 1; - } - else - { - // ITU BT.601 DVD or SD TV content - param.vui.i_colorprim = 6; - param.vui.i_transfer = 1; - param.vui.i_colmatrix = 6; - } - if( job->anamorphic.mode ) { param.vui.i_sar_width = job->anamorphic.par_width; |