Skip to content

Commit 66d6a09

Browse files
committed
Fix movit.convert gamma and color_trc
1 parent ad5dbe6 commit 66d6a09

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

src/modules/movit/filter_movit_convert.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,29 +109,25 @@ static GammaCurve getOutputGamma(mlt_properties properties)
109109
if (!color_trc_str)
110110
color_trc_str = mlt_properties_get(properties, "consumer.color_trc");
111111
mlt_color_trc color_trc = mlt_image_color_trc_id(color_trc_str);
112+
mlt_properties_set_int(properties, "color_trc", color_trc);
112113
switch (color_trc) {
113114
case mlt_color_trc_bt709:
114115
case mlt_color_trc_smpte170m:
115-
mlt_properties_set(properties, "color_trc", color_trc_str);
116116
return GAMMA_REC_709;
117117
case mlt_color_trc_linear:
118-
mlt_properties_set(properties, "color_trc", color_trc_str);
119118
return GAMMA_LINEAR;
120119
case mlt_color_trc_bt2020_10:
121-
mlt_properties_set(properties, "color_trc", color_trc_str);
122120
return GAMMA_REC_2020_10_BIT;
123121
case mlt_color_trc_bt2020_12:
124-
mlt_properties_set(properties, "color_trc", color_trc_str);
125122
return GAMMA_REC_2020_12_BIT;
126123
#if MOVIT_VERSION >= 1037
127124
case mlt_color_trc_arib_std_b67:
128-
mlt_properties_set(properties, "color_trc", color_trc_str);
129125
return GAMMA_HLG;
130126
#endif
131127
default:
132128
break;
133129
}
134-
return GAMMA_INVALID;
130+
return GAMMA_REC_709;
135131
}
136132

137133
static void get_format_from_properties(mlt_properties properties,
@@ -305,6 +301,7 @@ static void dispose_movit_effects(mlt_service service, mlt_frame frame)
305301
static void finalize_movit_chain(mlt_service leaf_service, mlt_frame frame, mlt_image_format format)
306302
{
307303
GlslChain *chain = GlslManager::get_chain(leaf_service);
304+
auto properties = MLT_FRAME_PROPERTIES(frame);
308305

309306
std::string new_fingerprint;
310307
build_fingerprint(chain, leaf_service, frame, &new_fingerprint);
@@ -329,10 +326,9 @@ static void finalize_movit_chain(mlt_service leaf_service, mlt_frame frame, mlt_
329326

330327
ImageFormat output_format;
331328
if (format == mlt_image_yuv444p10 || format == mlt_image_yuv420p10) {
332-
auto properties = MLT_FRAME_PROPERTIES(frame);
333329
YCbCrFormat ycbcr_format = {};
334330
get_format_from_properties(properties, &output_format, &ycbcr_format);
335-
output_format.gamma_curve = std::max(GAMMA_REC_709, getOutputGamma(properties));
331+
output_format.gamma_curve = getOutputGamma(properties);
336332
ycbcr_format.full_range = mlt_image_full_range(
337333
mlt_properties_get(properties, "consumer.color_range"));
338334
mlt_log_debug(nullptr,
@@ -350,8 +346,7 @@ static void finalize_movit_chain(mlt_service leaf_service, mlt_frame frame, mlt_
350346
chain->effect_chain->set_dither_bits(16);
351347
} else {
352348
output_format.color_space = COLORSPACE_sRGB;
353-
output_format.gamma_curve = std::max(GAMMA_REC_709,
354-
getOutputGamma(MLT_FRAME_PROPERTIES(frame)));
349+
output_format.gamma_curve = getOutputGamma(properties);
355350
chain->effect_chain->add_output(output_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED);
356351
chain->effect_chain->set_dither_bits(8);
357352
}
@@ -363,7 +358,6 @@ static void finalize_movit_chain(mlt_service leaf_service, mlt_frame frame, mlt_
363358
// Delete all the created Effect instances to avoid memory leaks.
364359
dispose_movit_effects(leaf_service, frame);
365360

366-
auto properties = MLT_FRAME_PROPERTIES(frame);
367361
getOutputGamma(properties);
368362
mlt_properties_set_int(properties,
369363
"full_range",

0 commit comments

Comments
 (0)