summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhb/common.c4
-rw-r--r--libhb/common.h1
-rw-r--r--libhb/enc_qsv.c50
-rw-r--r--libhb/encavcodec.c5
-rw-r--r--libhb/encx264.c46
-rw-r--r--libhb/encx265.c38
-rw-r--r--libhb/hb_json.c20
-rw-r--r--libhb/preset.c44
-rw-r--r--libhb/work.c14
9 files changed, 73 insertions, 149 deletions
diff --git a/libhb/common.c b/libhb/common.c
index e1257c930..6b1d3e6cf 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -3743,6 +3743,10 @@ static void job_setup(hb_job_t * job, hb_title_t * title)
job->pass_id = HB_PASS_ENCODE;
job->vrate = title->vrate;
+ job->color_prim = title->color_prim;
+ job->color_transfer = title->color_transfer;
+ job->color_matrix = title->color_matrix;
+
job->mux = HB_MUX_MP4;
job->list_audio = hb_list_init();
diff --git a/libhb/common.h b/libhb/common.h
index 4fa370c03..c8bad6d5d 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -554,7 +554,6 @@ struct hb_job_s
char *encoder_level;
int areBframes;
- int color_matrix_code;
int color_prim;
int color_transfer;
int color_matrix;
diff --git a/libhb/enc_qsv.c b/libhb/enc_qsv.c
index fd4a253f9..4c2aa8e49 100644
--- a/libhb/enc_qsv.c
+++ b/libhb/enc_qsv.c
@@ -713,45 +713,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)
- switch (job->color_matrix_code)
- {
- case 5:
- // custom
- pv->param.videoSignalInfo.ColourPrimaries = job->color_prim;
- pv->param.videoSignalInfo.TransferCharacteristics = job->color_transfer;
- pv->param.videoSignalInfo.MatrixCoefficients = job->color_matrix;
- break;
- case 4:
- // ITU BT.2020 UHD content
- pv->param.videoSignalInfo.ColourPrimaries = HB_COLR_PRI_BT2020;
- pv->param.videoSignalInfo.TransferCharacteristics = HB_COLR_TRA_BT709;
- pv->param.videoSignalInfo.MatrixCoefficients = HB_COLR_MAT_BT2020_NCL;
- break;
- case 3:
- // ITU BT.709 HD content
- pv->param.videoSignalInfo.ColourPrimaries = HB_COLR_PRI_BT709;
- pv->param.videoSignalInfo.TransferCharacteristics = HB_COLR_TRA_BT709;
- pv->param.videoSignalInfo.MatrixCoefficients = HB_COLR_MAT_BT709;
- break;
- case 2:
- // ITU BT.601 DVD or SD TV content (PAL)
- pv->param.videoSignalInfo.ColourPrimaries = HB_COLR_PRI_EBUTECH;
- pv->param.videoSignalInfo.TransferCharacteristics = HB_COLR_TRA_BT709;
- pv->param.videoSignalInfo.MatrixCoefficients = HB_COLR_MAT_SMPTE170M;
- break;
- case 1:
- // ITU BT.601 DVD or SD TV content (NTSC)
- pv->param.videoSignalInfo.ColourPrimaries = HB_COLR_PRI_SMPTEC;
- pv->param.videoSignalInfo.TransferCharacteristics = HB_COLR_TRA_BT709;
- pv->param.videoSignalInfo.MatrixCoefficients = HB_COLR_MAT_SMPTE170M;
- break;
- default:
- // detected during scan
- pv->param.videoSignalInfo.ColourPrimaries = job->title->color_prim;
- pv->param.videoSignalInfo.TransferCharacteristics = job->title->color_transfer;
- pv->param.videoSignalInfo.MatrixCoefficients = job->title->color_matrix;
- break;
- }
+ pv->param.videoSignalInfo.ColourPrimaries = job->color_prim;
+ pv->param.videoSignalInfo.TransferCharacteristics = job->color_transfer;
+ pv->param.videoSignalInfo.MatrixCoefficients = job->color_matrix;
pv->param.videoSignalInfo.ColourDescriptionPresent = 1;
// parse user-specified encoder options, if present
@@ -799,18 +763,10 @@ 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_matrix_code = 4;
job->color_prim = pv->param.videoSignalInfo.ColourPrimaries;
job->color_transfer = pv->param.videoSignalInfo.TransferCharacteristics;
job->color_matrix = pv->param.videoSignalInfo.MatrixCoefficients;
}
- else
- {
- job->color_matrix_code = 0;
- job->color_prim = HB_COLR_PRI_UNDEF;
- job->color_transfer = HB_COLR_TRA_UNDEF;
- job->color_matrix = HB_COLR_MAT_UNDEF;
- }
// sanitize values that may exceed the Media SDK variable size
hb_rational_t par;
diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c
index cb7693082..5cdc5df38 100644
--- a/libhb/encavcodec.c
+++ b/libhb/encavcodec.c
@@ -395,6 +395,11 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
hb_log( "encavcodec: encoding with stored aspect %d/%d",
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;
+
if( job->mux & HB_MUX_MASK_MP4 )
{
context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
diff --git a/libhb/encx264.c b/libhb/encx264.c
index 6df1f9109..f0e9ddd7c 100644
--- a/libhb/encx264.c
+++ b/libhb/encx264.c
@@ -389,48 +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. */
- if( job->color_matrix_code == 5 )
- {
- // 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 == 4 )
- {
- // ITU BT.2020 UHD content
- param.vui.i_colorprim = HB_COLR_PRI_BT2020;
- param.vui.i_transfer = HB_COLR_TRA_BT709;
- param.vui.i_colmatrix = HB_COLR_MAT_BT2020_NCL;
- }
- else if( job->color_matrix_code == 3 )
- {
- // ITU BT.709 HD content
- param.vui.i_colorprim = HB_COLR_PRI_BT709;
- param.vui.i_transfer = HB_COLR_TRA_BT709;
- param.vui.i_colmatrix = HB_COLR_MAT_BT709;
- }
- else if( job->color_matrix_code == 2 )
- {
- // ITU BT.601 DVD or SD TV content (PAL)
- param.vui.i_colorprim = HB_COLR_PRI_EBUTECH;
- param.vui.i_transfer = HB_COLR_TRA_BT709;
- param.vui.i_colmatrix = HB_COLR_MAT_SMPTE170M;
- }
- else if( job->color_matrix_code == 1 )
- {
- // ITU BT.601 DVD or SD TV content (NTSC)
- param.vui.i_colorprim = HB_COLR_PRI_SMPTEC;
- param.vui.i_transfer = HB_COLR_TRA_BT709;
- param.vui.i_colmatrix = HB_COLR_MAT_SMPTE170M;
- }
- else
- {
- // detected during scan
- param.vui.i_colorprim = job->title->color_prim;
- param.vui.i_transfer = job->title->color_transfer;
- param.vui.i_colmatrix = job->title->color_matrix;
- }
+ param.vui.i_colorprim = job->color_prim;
+ param.vui.i_transfer = job->color_transfer;
+ param.vui.i_colmatrix = job->color_matrix;
/* place job->encoder_options in an hb_dict_t for convenience */
hb_dict_t * x264_opts = NULL;
@@ -464,7 +425,6 @@ 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_matrix_code = 4;
job->color_prim = param.vui.i_colorprim;
job->color_transfer = param.vui.i_transfer;
job->color_matrix = param.vui.i_colmatrix;
diff --git a/libhb/encx265.c b/libhb/encx265.c
index cce69e330..1cdf4f7c3 100644
--- a/libhb/encx265.c
+++ b/libhb/encx265.c
@@ -155,39 +155,10 @@ 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];
- switch (job->color_matrix_code)
- {
- case 1: // ITU BT.601 DVD or SD TV content (NTSC)
- strcpy(colorprim, "smpte170m");
- strcpy(transfer, "bt709");
- strcpy(colormatrix, "smpte170m");
- break;
- case 2: // ITU BT.601 DVD or SD TV content (PAL)
- strcpy(colorprim, "bt470bg");
- strcpy(transfer, "bt709");
- strcpy(colormatrix, "smpte170m");
- break;
- case 3: // ITU BT.709 HD content
- strcpy(colorprim, "bt709");
- strcpy(transfer, "bt709");
- strcpy(colormatrix, "bt709");
- break;
- case 4: // ITU BT.2020 UHD content
- strcpy(colorprim, "bt2020");
- strcpy(transfer, "bt709");
- strcpy(colormatrix, "bt2020nc");
- break;
- case 5: // custom
- snprintf(colorprim, sizeof(colorprim), "%d", job->color_prim);
- snprintf(transfer, sizeof(transfer), "%d", job->color_transfer);
- snprintf(colormatrix, sizeof(colormatrix), "%d", job->color_matrix);
- break;
- default: // detected during scan
- snprintf(colorprim, sizeof(colorprim), "%d", job->title->color_prim);
- snprintf(transfer, sizeof(transfer), "%d", job->title->color_transfer);
- snprintf(colormatrix, sizeof(colormatrix), "%d", job->title->color_matrix);
- break;
- }
+ snprintf(colorprim, sizeof(colorprim), "%d", job->color_prim);
+ snprintf(transfer, sizeof(transfer), "%d", job->color_transfer);
+ snprintf(colormatrix, sizeof(colormatrix), "%d", job->color_matrix);
+
if (param_parse(pv, param, "colorprim", colorprim) ||
param_parse(pv, param, "transfer", transfer) ||
param_parse(pv, param, "colormatrix", colormatrix))
@@ -219,7 +190,6 @@ 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_matrix_code = 4;
job->color_prim = param->vui.colorPrimaries;
job->color_transfer = param->vui.transferCharacteristics;
job->color_matrix = param->vui.matrixCoeffs;
diff --git a/libhb/hb_json.c b/libhb/hb_json.c
index 3ba9de13d..c74d85cd7 100644
--- a/libhb/hb_json.c
+++ b/libhb/hb_json.c
@@ -645,11 +645,13 @@ hb_dict_t* hb_job_to_dict( const hb_job_t * job )
hb_dict_set(source_dict, "Range", range_dict);
hb_dict_t *video_dict = hb_dict_get(dict, "Video");
- if (job->color_matrix_code > 0)
- {
- hb_dict_set(video_dict, "ColorMatrixCode",
- hb_value_int(job->color_matrix_code));
- }
+ hb_dict_set(video_dict, "ColorPrimaries",
+ hb_value_int(job->color_prim));
+ hb_dict_set(video_dict, "ColorTransfer",
+ hb_value_int(job->color_transfer));
+ hb_dict_set(video_dict, "ColorMatrix",
+ hb_value_int(job->color_matrix));
+
if (job->vquality > HB_INVALID_VIDEO_QUALITY)
{
hb_dict_set(video_dict, "Quality", hb_value_double(job->vquality));
@@ -994,10 +996,10 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict )
// PAR {Num, Den}
"s?{s:i, s:i},"
// Video {Codec, Quality, Bitrate, Preset, Tune, Profile, Level, Options
- // TwoPass, Turbo, ColorMatrixCode,
+ // TwoPass, Turbo, ColorPrimaries, ColorTransfer, ColorMatrix,
// 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?b, s?b, s?i, s?i, s?i,"
" s?{s?b, s?i}},"
// Audio {CopyMask, FallbackEncoder, AudioList}
"s?{s?o, s?o, s?o},"
@@ -1041,7 +1043,9 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict )
"Options", unpack_s(&video_options),
"TwoPass", unpack_b(&job->twopass),
"Turbo", unpack_b(&job->fastfirstpass),
- "ColorMatrixCode", unpack_i(&job->color_matrix_code),
+ "ColorPrimaries", unpack_i(&job->color_prim),
+ "ColorTransfer", unpack_i(&job->color_transfer),
+ "ColorMatrix", unpack_i(&job->color_matrix),
"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 03a93eb52..09839d68c 100644
--- a/libhb/preset.c
+++ b/libhb/preset.c
@@ -1573,8 +1573,8 @@ int hb_preset_apply_filters(const hb_dict_t *preset, hb_dict_t *job_dict)
int hb_preset_apply_video(const hb_dict_t *preset, hb_dict_t *job_dict)
{
hb_dict_t *dest_dict, *video_dict, *qsv;
- hb_value_t *value, *vcodec_value, *color_value;
- int mux, vcodec, vqtype;
+ hb_value_t *value, *vcodec_value;
+ int mux, vcodec, vqtype, color_matrix_code;
hb_encoder_t *encoder;
dest_dict = hb_dict_get(job_dict, "Destination");
@@ -1609,8 +1609,44 @@ int hb_preset_apply_video(const hb_dict_t *preset, hb_dict_t *job_dict)
video_dict = hb_dict_get(job_dict, "Video");
hb_dict_set(video_dict, "Encoder", hb_value_string(encoder->short_name));
- if ((color_value = hb_dict_get(preset, "VideoColorMatrixCode")) != NULL)
- hb_dict_set(video_dict, "ColorMatrixCode", hb_value_dup(color_value));
+ color_matrix_code = hb_value_get_int(hb_dict_get(preset, "VideoColorMatrixCode"));
+ if (color_matrix_code != 0)
+ {
+ int color_prim, color_transfer, color_matrix;
+
+ switch (color_matrix_code)
+ {
+ case 4:
+ // ITU BT.2020 UHD content
+ color_prim = HB_COLR_PRI_BT2020;
+ color_transfer = HB_COLR_TRA_BT709;
+ color_matrix = HB_COLR_MAT_BT2020_NCL;
+ break;
+ case 3:
+ // ITU BT.709 HD content
+ color_prim = HB_COLR_PRI_BT709;
+ color_transfer = HB_COLR_TRA_BT709;
+ color_matrix = HB_COLR_MAT_BT709;
+ break;
+ case 2:
+ // ITU BT.601 DVD or SD TV content (PAL)
+ color_prim = HB_COLR_PRI_EBUTECH;
+ color_transfer = HB_COLR_TRA_BT709;
+ color_matrix = HB_COLR_MAT_SMPTE170M;
+ break;
+ case 1:
+ default:
+ // ITU BT.601 DVD or SD TV content (NTSC)
+ color_prim = HB_COLR_PRI_SMPTEC;
+ color_transfer = HB_COLR_TRA_BT709;
+ color_matrix = HB_COLR_MAT_SMPTE170M;
+ break;
+ }
+
+ hb_dict_set(video_dict, "ColorPrimaries", hb_value_int(color_prim));
+ hb_dict_set(video_dict, "ColorTransfer", hb_value_int(color_transfer));
+ hb_dict_set(video_dict, "ColorMatrix", hb_value_int(color_matrix));
+ }
hb_dict_set(video_dict, "Encoder", hb_value_dup(vcodec_value));
if ((vcodec & HB_VCODEC_X264_MASK) &&
diff --git a/libhb/work.c b/libhb/work.c
index ceb185783..9a3eb55a7 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -566,18 +566,8 @@ void hb_display_job_info(hb_job_t *job)
}
}
- if (job->color_matrix_code &&
- ((job->vcodec & HB_VCODEC_X264_MASK) ||
- (job->vcodec & HB_VCODEC_X265_MASK)))
- {
- // color matrix is set:
- // 1) at the stream level (x264, x265, qsv only),
- hb_log(" + custom color matrix: %s",
- job->color_matrix_code == 1 ? "ITU Bt.601 (NTSC)" :
- job->color_matrix_code == 2 ? "ITU Bt.601 (PAL)" :
- job->color_matrix_code == 3 ? "ITU Bt.709 (HD)" :
- job->color_matrix_code == 4 ? "ITU Bt.2020 (UHD)" : "Custom");
- }
+ hb_log(" + color profile: %d-%d-%d",
+ job->color_prim, job->color_transfer, job->color_matrix);
}
if (job->indepth_scan)