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 | |
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')
-rw-r--r-- | libhb/common.h | 3 | ||||
-rw-r--r-- | libhb/encx264.c | 63 | ||||
-rw-r--r-- | libhb/muxmp4.c | 16 | ||||
-rw-r--r-- | libhb/work.c | 4 |
4 files changed, 43 insertions, 43 deletions
diff --git a/libhb/common.h b/libhb/common.h index 88bb8389d..a042c25fa 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -243,6 +243,9 @@ struct hb_job_s int pass; char *advanced_opts; int areBframes; + int color_matrix_code; + int color_prim; + int color_transfer; int color_matrix; /* List of audio settings. */ 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; diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c index 05bce561a..c1ac9994c 100644 --- a/libhb/muxmp4.c +++ b/libhb/muxmp4.c @@ -218,23 +218,19 @@ static int MP4Init( hb_mux_object_t * m ) // Per the notes at: // http://developer.apple.com/quicktime/icefloe/dispatch019.html#colr // http://forum.doom9.org/showthread.php?t=133982#post1090068 - // the user can set it from job->color_matrix, otherwise by default + // the user can set it from job->color_matrix_code, otherwise by default // we say anything that's likely to be HD content is ITU BT.709 and // DVD, SD TV & other content is ITU BT.601. We look at the title height // rather than the job height here to get uncropped input dimensions. - if( job->color_matrix == 1 ) + if( job->color_matrix_code == 3 ) { - // ITU BT.601 DVD or SD TV content - MP4AddColr(m->file, mux_data->track, 6, 1, 6); + // Custom + MP4AddColr(m->file, mux_data->track, job->color_prim, job->color_transfer, job->color_matrix); } - else if( job->color_matrix == 2 ) + 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 - MP4AddColr(m->file, mux_data->track, 1, 1, 1); - } - else if ( job->title->width >= 1280 || job->title->height >= 720 ) - { - // we guess that 720p or above is ITU BT.709 HD content MP4AddColr(m->file, mux_data->track, 1, 1, 1); } else diff --git a/libhb/work.c b/libhb/work.c index 222ae240f..9ab11fec9 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -194,8 +194,8 @@ void hb_display_job_info( hb_job_t * job ) if( job->mp4_optimize ) hb_log( " + optimized for progressive web downloads"); - if( job->color_matrix ) - hb_log( " + custom color matrix: %s", job->color_matrix == 1 ? "ITU Bt.601 (SD)" : "ITU Bt.709 (HD)"); + if( job->color_matrix_code ) + hb_log( " + custom color matrix: %s", job->color_matrix_code == 1 ? "ITU Bt.601 (SD)" : job->color_matrix_code == 2 ? "ITU Bt.709 (HD)" : "Custom" ); break; case HB_MUX_MKV: |