diff options
-rw-r--r-- | libhb/common.h | 1 | ||||
-rw-r--r-- | libhb/encx264.c | 17 | ||||
-rw-r--r-- | libhb/muxmp4.c | 13 | ||||
-rw-r--r-- | libhb/work.c | 9 | ||||
-rw-r--r-- | test/test.c | 19 |
5 files changed, 54 insertions, 5 deletions
diff --git a/libhb/common.h b/libhb/common.h index 5c89430d3..c00268da1 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -187,6 +187,7 @@ struct hb_job_s int crf; char *x264opts; int areBframes; + int color_matrix; /* List of audio settings. */ hb_list_t * list_audio; diff --git a/libhb/encx264.c b/libhb/encx264.c index 4a831ba38..0e3edd040 100644 --- a/libhb/encx264.c +++ b/libhb/encx264.c @@ -195,8 +195,21 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) /* 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->title->height >= 720 ) + 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->width >= 720 ) { // we guess that 720p or above is ITU BT.709 HD content param.vui.i_colorprim = 1; diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c index a6ddedf5d..dfee48c54 100644 --- a/libhb/muxmp4.c +++ b/libhb/muxmp4.c @@ -251,10 +251,21 @@ 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 // 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->title->height >= 720 ) + if( job->color_matrix == 1 ) + { + // ITU BT.601 DVD or SD TV content + MP4AddColr(m->file, mux_data->track, 6, 1, 6); + } + else if( job->color_matrix == 2 ) + { + // 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); diff --git a/libhb/work.c b/libhb/work.c index f64738e52..6caa153e8 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -214,6 +214,15 @@ hb_display_job_info( hb_job_t * job ) title->width, title->height, job->width, job->height, job->crop[0], job->crop[1], job->crop[2], job->crop[3] ); } + + if( job->color_matrix ) + { + hb_log( " + color space: %s", job->color_matrix == 1 ? "ITU Bt.601 (SD)" : "ITU Bt.709 (HD)"); + } + else + { + hb_log( " + color space: %s", ( title->width < 1280 || title->height < 720 ) ? "ITU Bt.601 (SD)" : "ITU Bt.709 (HD)"); + } if ( job->grayscale ) hb_log( " + grayscale mode" ); diff --git a/test/test.c b/test/test.c index dc61c5793..a92be42f5 100644 --- a/test/test.c +++ b/test/test.c @@ -91,6 +91,7 @@ static char * preset_name = 0; static int cfr = 0; static int mp4_optimize = 0; static int ipod_atom = 0; +static int color_matrix = 0; /* Exit cleanly on Ctrl-C */ static volatile int die = 0; @@ -1302,6 +1303,11 @@ static int HandleEvents( hb_handle_t * h ) { job->crf = 1; } + + if( color_matrix ) + { + job->color_matrix = color_matrix; + } if( x264opts != NULL && *x264opts != '\0' ) { @@ -1605,6 +1611,9 @@ static void ShowHelp() " <MOD:PARX:PARY> Takes as optional arguments what number you want\n" " the dimensions to divide cleanly by (default 16)\n" " and the pixel ratio to use (default autodetected)\n" + " -M --color-matrix Set the color space signalled by the output\n" + " <601 or 709> (Bt.601 is mostly for SD content, Bt.709 for HD,\n" + " default: set by resolution)\n" "\n" @@ -1761,6 +1770,7 @@ static int ParseOptions( int argc, char ** argv ) { "preset-list", no_argument, NULL, 'z' }, { "aname", required_argument, NULL, 'A' }, + { "color-matrix",required_argument, NULL, 'M' }, { 0, 0, 0, 0 } }; @@ -1769,7 +1779,7 @@ static int ParseOptions( int argc, char ** argv ) int c; c = getopt_long( argc, argv, - "hv::uC:f:4i:Io:t:Lc:m::a:A:6:s:UFN:e:E:2dD:7895gpOP::w:l:n:b:q:S:B:r:R:Qx:TY:X:Z:z", + "hv::uC:f:4i:Io:t:Lc:m::M:a:A:6:s:UFN:e:E:2dD:7895gpOP::w:l:n:b:q:S:B:r:R:Qx:TY:X:Z:z", long_options, &option_index ); if( c < 0 ) { @@ -2106,7 +2116,12 @@ static int ParseOptions( int argc, char ** argv ) anames = strdup( optarg ); } break; - + case 'M': + if( atoi( optarg ) == 601 ) + color_matrix = 1; + else if( atoi( optarg ) == 709 ) + color_matrix = 2; + break; default: fprintf( stderr, "unknown option (%s)\n", argv[optind] ); return -1; |