:: Re: [Frei0r] [PATCH] Add "colgate",…
Top Pagina
Delete this message
Reply to this message
Auteur: Dan Dennedy
Datum:  
Aan: Minimalistic plugin API for video effects
Onderwerp: Re: [Frei0r] [PATCH] Add "colgate", a new color correction plugin.
On Thu, Sep 20, 2012 at 11:50 AM, Steinar H. Gunderson
<sgunderson@???> wrote:
> On Thu, Sep 20, 2012 at 11:46:37AM -0700, Dan Dennedy wrote:
>> I guess you did not see my comment about the invalid parameter range
>> for Color Temperature? It needs to be mapped to [0, 1] per frei0r API
>> spec (see header comments). (I can do that if you are sick of dealing
>> with this.)
>
> Ah, sorry, I forgot that. If you could fix it and it's not too much work,
> I'll be happy; thanks :-)
>
> (I hope that Kdenlive can still show a reasonable range; I think I've seen
> controls for scaling, although maybe not for offset.)


This kdenlive effect description lets us represent the value in Kelvin
and enforce a minimum:

<!DOCTYPE kpartgui>
<group>
    <effect tag="frei0r.colgate" id="frei0r.colgate">
    <name>White Balance (LMS space)</name>
    <description>Do simple color correction, in a physically meaningful
way</description>
    <author>Steiner H. Gunderson</author>
    <parameter type="color" name="Neutral Color" default="0x7f7f7fff">
        <name>Neutral Color</name>
    </parameter>
    <parameter type="simplekeyframe" name="Color Temperature"
default="6500" min="1000" max="15000" factor="15000">
        <name>Color Temperature</name>
    </parameter>
    </effect>
</group>



But then we need to map [0, 15000], which only makes the bottom 6.6%
of the [0,1] range useless.


diff --git a/src/filter/colgate/colgate.c b/src/filter/colgate/colgate.c
index 878688c..2e461bb 100644
--- a/src/filter/colgate/colgate.c
+++ b/src/filter/colgate/colgate.c
@@ -479,7 +479,8 @@ void f0r_set_param_value(f0r_instance_t instance,
f0r_param_t param, int param_i
                break;


        case COLOR_TEMPERATURE:
-               inst->color_temperature = *((double *)param);
+               // map frei0r range [0, 1] to temperature range [0, 15000]
+               inst->color_temperature = *((double *)param) * 15000.0;
                if (inst->color_temperature < 1000.0 ||
inst->color_temperature > 15000.0) {
                        inst->color_temperature = 6500.0;
                }
@@ -499,7 +500,8 @@ void f0r_get_param_value(f0r_instance_t instance,
f0r_param_t param, int param_i
                break;


        case COLOR_TEMPERATURE:
-               *((double *)param) = inst->color_temperature;
+               // map temperature range [0, 15000] to frei0r range [0, 1]
+               *((double *)param) = inst->color_temperature / 15000.0;
                break;
        }
 }


OK?
--
+-DRD-+