Skip to content

Commit 5c0030a

Browse files
committed
Convert color property to linear in more filters
1 parent abd6674 commit 5c0030a

5 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/modules/core/filter_autofade.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ static int filter_get_image(mlt_frame frame,
129129

130130
if (image_factor < 1.0) {
131131
mlt_color color = mlt_properties_get_color(filter_properties, "fade_color");
132+
color = mlt_color_convert_trc(color,
133+
mlt_properties_get(MLT_FRAME_PROPERTIES(frame), "color_trc"));
132134
float color_factor = 1.0 - image_factor;
133135
float r_value = color.r * color_factor;
134136
float g_value = color.g * color_factor;

src/modules/frei0r/frei0r_helper.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* frei0r_helper.c -- frei0r helper
33
* Copyright (c) 2008 Marco Gittler <g.marco@freenet.de>
4-
* Copyright (C) 2009-2023 Meltytech, LLC
4+
* Copyright (C) 2009-2025 Meltytech, LLC
55
*
66
* This library is free software; you can redistribute it and/or
77
* modify it under the terms of the GNU Lesser General Public
@@ -19,7 +19,6 @@
1919
*/
2020
#include "frei0r_helper.h"
2121
#include <frei0r.h>
22-
#include <stdlib.h>
2322
#include <string.h>
2423
#ifdef _WIN32
2524
#include <windows.h>
@@ -93,6 +92,7 @@ int process_frei0r_item(mlt_service service,
9392
{
9493
int i = 0;
9594
mlt_properties prop = MLT_SERVICE_PROPERTIES(service);
95+
mlt_properties frame_properties = MLT_FRAME_PROPERTIES(frame);
9696
f0r_instance_t (*f0r_construct)(unsigned int, unsigned int)
9797
= mlt_properties_get_data(prop, "f0r_construct", NULL);
9898
if (!f0r_construct) {
@@ -191,11 +191,11 @@ int process_frei0r_item(mlt_service service,
191191

192192
// Special cairoblend handling for an override from the cairoblend_mode filter.
193193
if (is_cairoblend && i == 1) {
194-
if (mlt_properties_get(MLT_FRAME_PROPERTIES(frame), CAIROBLEND_MODE_PROPERTY)) {
194+
if (mlt_properties_get(frame_properties, CAIROBLEND_MODE_PROPERTY)) {
195195
name = CAIROBLEND_MODE_PROPERTY;
196-
prop = MLT_FRAME_PROPERTIES(frame);
196+
prop = frame_properties;
197197
val = mlt_properties_get(prop, name);
198-
} else if (!val && !mlt_properties_get(MLT_FRAME_PROPERTIES(frame), name)) {
198+
} else if (!val && !mlt_properties_get(frame_properties, name)) {
199199
// Reset plugin back to its default value.
200200
char *default_val = "normal";
201201
char *plugin_val = NULL;
@@ -242,6 +242,10 @@ int process_frei0r_item(mlt_service service,
242242
= mlt_properties_get(prop, index)
243243
? mlt_properties_anim_get_color(prop, index, position, length)
244244
: mlt_properties_anim_get_color(prop, pinfo.name, position, length);
245+
if (type != mlt_service_producer_type) {
246+
const char *trc = mlt_properties_get(frame_properties, "color_trc");
247+
m_color = mlt_color_convert_trc(m_color, trc);
248+
}
245249
f_color.r = (float) m_color.r / 255.0f;
246250
f_color.g = (float) m_color.g / 255.0f;
247251
f_color.b = (float) m_color.b / 255.0f;

src/modules/opencv/filter_opencv_tracker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ static int filter_get_image(mlt_frame frame,
516516
if (shape_width != 0 && data->boundingBox.width > 0 && data->boundingBox.height > 0) {
517517
// Get the OpenCV image
518518
mlt_color shape_color = mlt_properties_get_color(filter_properties, "shape_color");
519+
shape_color = mlt_color_convert_trc(shape_color, mlt_properties_get(MLT_FRAME_PROPERTIES(frame), "color_trc"));
519520
switch (mlt_properties_get_int(filter_properties, "shape")) {
520521
case 2:
521522
// Arrow

src/modules/plusgpl/filter_outline.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ static int filter_get_image(mlt_frame frame,
120120
Mlt::Frame fr(frame);
121121
auto position = filter.get_position(fr);
122122
auto length = filter.get_length2(fr);
123-
slice_desc desc{.color = filter.anim_get_color("color", position, length),
123+
auto color = filter.anim_get_color("color", position, length);
124+
color = ::mlt_color_convert_trc(color, fr.get("color_trc"));
125+
slice_desc desc{.color = color,
124126
.thickness = filter.anim_get_double("thickness", position, length),
125127
.original = *image};
126128

src/modules/qt/filter_dropshadow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static int get_image(mlt_frame frame,
4747
mlt_position pos = filter.get_position(f);
4848
mlt_position len = filter.get_length2(f);
4949
auto color = filter.anim_get_color("color", pos, len);
50+
color = ::mlt_color_convert_trc(color, f.get("color_trc"));
5051
shadow->setColor(QColor(color.r, color.g, color.b, color.a));
5152
shadow->setBlurRadius(filter.anim_get_double("radius", pos, len));
5253
shadow->setXOffset(filter.anim_get_double("x", pos, len));

0 commit comments

Comments
 (0)