summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhb/common.h3
-rw-r--r--libhb/encx264.c63
-rw-r--r--libhb/muxmp4.c16
-rw-r--r--libhb/work.c4
-rw-r--r--test/test.c10
5 files changed, 48 insertions, 48 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:
diff --git a/test/test.c b/test/test.c
index 4fd728537..55144dd3a 100644
--- a/test/test.c
+++ b/test/test.c
@@ -123,7 +123,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;
+static int color_matrix_code = 0;
static int preview_count = 10;
static int store_previews = 0;
static int start_at_preview = 0;
@@ -2229,9 +2229,9 @@ static int HandleEvents( hb_handle_t * h )
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' )
@@ -3461,9 +3461,9 @@ static int ParseOptions( int argc, char ** argv )
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 );