int crf;
char *x264opts;
int areBframes;
+ int color_matrix;
/* List of audio settings. */
hb_list_t * list_audio;
/* 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;
// 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);
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" );
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;
{
job->crf = 1;
}
+
+ if( color_matrix )
+ {
+ job->color_matrix = color_matrix;
+ }
if( x264opts != NULL && *x264opts != '\0' )
{
" <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"
{ "preset-list", no_argument, NULL, 'z' },
{ "aname", required_argument, NULL, 'A' },
+ { "color-matrix",required_argument, NULL, 'M' },
{ 0, 0, 0, 0 }
};
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 )
{
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;