summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhb/common.c27
-rw-r--r--libhb/decavcodec.c8
-rw-r--r--libhb/enc_qsv.c12
-rw-r--r--libhb/encavcodec.c12
-rw-r--r--libhb/encx264.c12
-rw-r--r--libhb/encx265.c12
-rw-r--r--libhb/handbrake/common.h4
-rw-r--r--libhb/hb_json.c20
-rw-r--r--libhb/preset.c6
-rw-r--r--libhb/work.c6
-rw-r--r--test/test.c2
11 files changed, 86 insertions, 35 deletions
diff --git a/libhb/common.c b/libhb/common.c
index a270f03e0..cda3683ee 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -3841,6 +3841,9 @@ static void job_setup(hb_job_t * job, hb_title_t * title)
job->color_transfer = title->color_transfer;
job->color_matrix = title->color_matrix;
job->color_range = title->color_range;
+ job->color_prim_override = HB_COLR_PRI_UNDEF;
+ job->color_transfer_override = HB_COLR_TRA_UNDEF;
+ job->color_matrix_override = HB_COLR_MAT_UNDEF;
job->mux = HB_MUX_MP4;
@@ -3859,6 +3862,30 @@ static void job_setup(hb_job_t * job, hb_title_t * title)
#endif
}
+int hb_output_color_prim(hb_job_t * job)
+{
+ if (job->color_prim_override != HB_COLR_PRI_UNDEF)
+ return job->color_prim_override;
+ else
+ return job->color_prim;
+}
+
+int hb_output_color_transfer(hb_job_t * job)
+{
+ if (job->color_transfer_override != HB_COLR_TRA_UNDEF)
+ return job->color_transfer_override;
+ else
+ return job->color_transfer;
+}
+
+int hb_output_color_matrix(hb_job_t * job)
+{
+ if (job->color_matrix_override != HB_COLR_MAT_UNDEF)
+ return job->color_matrix_override;
+ else
+ return job->color_matrix;
+}
+
static void job_clean( hb_job_t * job )
{
if (job)
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index b64fcb2b2..1e4d94d38 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -963,11 +963,11 @@ static hb_buffer_t *copy_frame( hb_work_private_t *pv )
}
// Make sure every frame is tagged.
- if (pv->job)
+ if (out->f.color_prim == HB_COLR_PRI_UNDEF || out->f.color_transfer == HB_COLR_TRA_UNDEF || out->f.color_matrix == HB_COLR_MAT_UNDEF)
{
- out->f.color_prim = pv->job->color_prim;
- out->f.color_transfer = pv->job->color_transfer;
- out->f.color_matrix = pv->job->color_matrix;
+ out->f.color_prim = pv->title->color_prim;
+ out->f.color_transfer = pv->title->color_transfer;
+ out->f.color_matrix = pv->title->color_matrix;
}
if (pv->frame->pts != AV_NOPTS_VALUE)
diff --git a/libhb/enc_qsv.c b/libhb/enc_qsv.c
index 3790d42d1..be18d3048 100644
--- a/libhb/enc_qsv.c
+++ b/libhb/enc_qsv.c
@@ -1058,9 +1058,9 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job)
pv->param.videoParam->AsyncDepth = job->qsv.async_depth;
// set and enable colorimetry (video signal information)
- pv->param.videoSignalInfo.ColourPrimaries = job->color_prim;
- pv->param.videoSignalInfo.TransferCharacteristics = job->color_transfer;
- pv->param.videoSignalInfo.MatrixCoefficients = job->color_matrix;
+ pv->param.videoSignalInfo.ColourPrimaries = hb_output_color_prim(job);
+ pv->param.videoSignalInfo.TransferCharacteristics = hb_output_color_transfer(job);
+ pv->param.videoSignalInfo.MatrixCoefficients = hb_output_color_matrix(job);
pv->param.videoSignalInfo.ColourDescriptionPresent = 1;
// parse user-specified encoder options, if present
@@ -1117,9 +1117,9 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job)
// reload colorimetry in case values were set in encoder_options
if (pv->param.videoSignalInfo.ColourDescriptionPresent)
{
- job->color_prim = pv->param.videoSignalInfo.ColourPrimaries;
- job->color_transfer = pv->param.videoSignalInfo.TransferCharacteristics;
- job->color_matrix = pv->param.videoSignalInfo.MatrixCoefficients;
+ job->color_prim_override = pv->param.videoSignalInfo.ColourPrimaries;
+ job->color_transfer_override = pv->param.videoSignalInfo.TransferCharacteristics;
+ job->color_matrix_override = pv->param.videoSignalInfo.MatrixCoefficients;
}
// sanitize values that may exceed the Media SDK variable size
diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c
index 6cc01136e..e42198abb 100644
--- a/libhb/encavcodec.c
+++ b/libhb/encavcodec.c
@@ -441,9 +441,9 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
job->par.num, job->par.den );
// set colorimetry
- context->color_primaries = job->color_prim;
- context->color_trc = job->color_transfer;
- context->colorspace = job->color_matrix;
+ context->color_primaries = hb_output_color_prim(job);
+ context->color_trc = hb_output_color_transfer(job);
+ context->colorspace = hb_output_color_matrix(job);
if (!job->inline_parameter_sets)
{
@@ -656,9 +656,9 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
* Reload colorimetry settings in case custom
* values were set in the encoder_options string.
*/
- job->color_prim = context->color_primaries;
- job->color_transfer = context->color_trc;
- job->color_matrix = context->colorspace;
+ job->color_prim_override = context->color_primaries;
+ job->color_transfer_override = context->color_trc;
+ job->color_matrix_override = context->colorspace;
if (job->pass_id == HB_PASS_ENCODE_1ST &&
context->stats_out != NULL)
diff --git a/libhb/encx264.c b/libhb/encx264.c
index f4e382266..514774c7a 100644
--- a/libhb/encx264.c
+++ b/libhb/encx264.c
@@ -389,9 +389,9 @@ 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. */
- param.vui.i_colorprim = job->color_prim;
- param.vui.i_transfer = job->color_transfer;
- param.vui.i_colmatrix = job->color_matrix;
+ param.vui.i_colorprim = hb_output_color_prim(job);
+ param.vui.i_transfer = hb_output_color_transfer(job);
+ param.vui.i_colmatrix = hb_output_color_matrix(job);
/* place job->encoder_options in an hb_dict_t for convenience */
hb_dict_t * x264_opts = NULL;
@@ -425,9 +425,9 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
/* Reload colorimetry settings in case custom values were set
* in the encoder_options string */
- job->color_prim = param.vui.i_colorprim;
- job->color_transfer = param.vui.i_transfer;
- job->color_matrix = param.vui.i_colmatrix;
+ job->color_prim_override = param.vui.i_colorprim;
+ job->color_transfer_override = param.vui.i_transfer;
+ job->color_matrix_override = param.vui.i_colmatrix;
/* For 25 fps sources, HandBrake's explicit keyints will match the x264 defaults:
* min-keyint 25 (same as auto), keyint 250. */
diff --git a/libhb/encx265.c b/libhb/encx265.c
index e7f58be16..fe6ef34ca 100644
--- a/libhb/encx265.c
+++ b/libhb/encx265.c
@@ -184,9 +184,9 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job)
* flags, if any, should be set in the x265_param struct).
*/
char colorprim[11], transfer[11], colormatrix[11];
- snprintf(colorprim, sizeof(colorprim), "%d", job->color_prim);
- snprintf(transfer, sizeof(transfer), "%d", job->color_transfer);
- snprintf(colormatrix, sizeof(colormatrix), "%d", job->color_matrix);
+ snprintf(colorprim, sizeof(colorprim), "%d", hb_output_color_prim(job));
+ snprintf(transfer, sizeof(transfer), "%d", hb_output_color_transfer(job));
+ snprintf(colormatrix, sizeof(colormatrix), "%d", hb_output_color_matrix(job));
if (param_parse(pv, param, "colorprim", colorprim) ||
param_parse(pv, param, "transfer", transfer) ||
@@ -222,9 +222,9 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job)
* Reload colorimetry settings in case custom
* values were set in the encoder_options string.
*/
- job->color_prim = param->vui.colorPrimaries;
- job->color_transfer = param->vui.transferCharacteristics;
- job->color_matrix = param->vui.matrixCoeffs;
+ job->color_prim_override = param->vui.colorPrimaries;
+ job->color_transfer_override = param->vui.transferCharacteristics;
+ job->color_matrix_override = param->vui.matrixCoeffs;
/*
* Settings which can't be overridden in the encodeer_options string
diff --git a/libhb/handbrake/common.h b/libhb/handbrake/common.h
index 1c08f947c..8a1faa37f 100644
--- a/libhb/handbrake/common.h
+++ b/libhb/handbrake/common.h
@@ -572,6 +572,10 @@ struct hb_job_s
int color_transfer;
int color_matrix;
int color_range;
+
+ int color_prim_override;
+ int color_transfer_override;
+ int color_matrix_override;
// see https://developer.apple.com/library/content/technotes/tn2162/_index.html
// https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html#//apple_ref/doc/uid/TP40000939-CH205-125526
// libav pixfmt.h
diff --git a/libhb/hb_json.c b/libhb/hb_json.c
index 829b7fb01..3a40205a6 100644
--- a/libhb/hb_json.c
+++ b/libhb/hb_json.c
@@ -672,6 +672,21 @@ hb_dict_t* hb_job_to_dict( const hb_job_t * job )
hb_value_int(job->color_transfer));
hb_dict_set(video_dict, "ColorMatrix",
hb_value_int(job->color_matrix));
+ if (job->color_prim_override != HB_COLR_PRI_UNDEF)
+ {
+ hb_dict_set(video_dict, "ColorPrimariesOverride",
+ hb_value_int(job->color_prim_override));
+ }
+ if (job->color_transfer_override != HB_COLR_TRA_UNDEF)
+ {
+ hb_dict_set(video_dict, "ColorTransferOverride",
+ hb_value_int(job->color_transfer_override));
+ }
+ if (job->color_matrix_override != HB_COLR_MAT_UNDEF)
+ {
+ hb_dict_set(video_dict, "ColorMatrixOverride",
+ hb_value_int(job->color_matrix_override));
+ }
if (job->vquality > HB_INVALID_VIDEO_QUALITY)
{
@@ -1044,11 +1059,13 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict )
// TwoPass, Turbo,
// ColorFormat, ColorRange,
// ColorPrimaries, ColorTransfer, ColorMatrix,
+ // ColorPrimariesOverride, ColorTransferOverride, ColorMatrixOverride,
// QSV {Decode, AsyncDepth}}
"s:{s:o, s?F, s?i, s?s, s?s, s?s, s?s, s?s,"
" s?b, s?b,"
" s?i, s?i,"
" s?i, s?i, s?i,"
+ " s?i, s?i, s?i,"
" s?{s?b, s?i}},"
// Audio {CopyMask, FallbackEncoder, AudioList}
"s?{s?o, s?o, s?o},"
@@ -1096,6 +1113,9 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict )
"ColorPrimaries", unpack_i(&job->color_prim),
"ColorTransfer", unpack_i(&job->color_transfer),
"ColorMatrix", unpack_i(&job->color_matrix),
+ "ColorPrimariesOverride", unpack_i(&job->color_prim_override),
+ "ColorTransferOverride", unpack_i(&job->color_transfer_override),
+ "ColorMatrixOverride", unpack_i(&job->color_matrix_override),
"QSV",
"Decode", unpack_b(&job->qsv.decode),
"AsyncDepth", unpack_i(&job->qsv.async_depth),
diff --git a/libhb/preset.c b/libhb/preset.c
index 7219161cd..6fb400f72 100644
--- a/libhb/preset.c
+++ b/libhb/preset.c
@@ -1731,11 +1731,11 @@ int hb_preset_apply_video(const hb_dict_t *preset, hb_dict_t *job_dict)
break;
}
- hb_dict_set(video_dict, "ColorPrimaries",
+ hb_dict_set(video_dict, "ColorPrimariesOverride",
hb_value_int(color_prim));
- hb_dict_set(video_dict, "ColorTransfer",
+ hb_dict_set(video_dict, "ColorTransferOverride",
hb_value_int(color_transfer));
- hb_dict_set(video_dict, "ColorMatrix",
+ hb_dict_set(video_dict, "ColorMatrixOverride",
hb_value_int(color_matrix));
}
hb_dict_set(video_dict, "Encoder", hb_value_dup(vcodec_value));
diff --git a/libhb/work.c b/libhb/work.c
index ab068173f..28ccebcbf 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -1456,9 +1456,9 @@ static void do_job(hb_job_t *job)
init.pix_fmt = get_best_pix_ftm(job);
init.color_range = AVCOL_RANGE_MPEG;
- init.color_prim = job->color_prim;
- init.color_transfer = job->color_transfer;
- init.color_matrix = job->color_matrix;
+ init.color_prim = title->color_prim;
+ init.color_transfer = title->color_transfer;
+ init.color_matrix = title->color_matrix;
init.geometry.width = title->geometry.width;
init.geometry.height = title->geometry.height;
diff --git a/test/test.c b/test/test.c
index fc3c35897..9bf8e90bf 100644
--- a/test/test.c
+++ b/test/test.c
@@ -1667,7 +1667,7 @@ static void ShowHelp()
" Dimensions will be made divisible by this number.\n"
" (default: set by preset, typically 2)\n"
" -M, --color-matrix <string>\n"
-" Set the color space signaled by the input:\n"
+" Set the color space signaled by the output:\n"
" Overrides color signalling with no conversion.\n"
" 2020\n"
" 709\n"