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.
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;
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;
// 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
static int cfr = 0;
static int mp4_optimize = 0;
static int ipod_atom = 0;
-static int color_matrix = 0;
+static int color_matrix_code = 0;
static int preview_count = 10;
static int store_previews = 0;
static int start_at_preview = 0;
job->file = strdup( output );
- if( color_matrix )
+ if( color_matrix_code )
{
- job->color_matrix = color_matrix;
+ job->color_matrix_code = color_matrix_code;
}
if( advanced_opts != NULL && *advanced_opts != '\0' )
break;
case 'M':
if( atoi( optarg ) == 601 )
- color_matrix = 1;
+ color_matrix_code = 1;
else if( atoi( optarg ) == 709 )
- color_matrix = 2;
+ color_matrix_code = 2;
break;
case MIN_DURATION:
min_title_duration = strtol( optarg, NULL, 0 );