[FFmpeg-devel] [PATCH] Add lut filter.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Jun 7 18:16:43 CEST 2011



On 7 Jun 2011, at 10:34, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:

> On date Tuesday 2011-06-07 08:32:37 +0100, Mark Himsley encoded:
>> On 06/06/2011 20:42, Stefano Sabatini wrote:
>> 
>>> +        /* compute the lut */
>>> +        lut->var_values[VAR_MAXVAL] = max[comp];
>>> +        lut->var_values[VAR_MINVAL] = min[comp];
>>> +
>>> +        for (val = 0; val < 256; val++) {
>>> +            lut->var_values[VAR_VAL] = av_clip(val, min[comp], max[comp]);
>>> +            lut->var_values[VAR_INVVAL] =
>>> +                av_clip(min[comp] + max[comp] - lut->var_values[VAR_VAL],
>>> +                        min[comp], max[comp]);
>>> +
>>> +            res = av_expr_eval(lut->comp_expr[comp], lut->var_values, lut);
>>> +            if (isnan(res)) {
>>> +                av_log(ctx, AV_LOG_ERROR,
>>> +                       "Error when evaluating the expression '%s' for the value %d for the component #%d.\n",
>>> +                       lut->comp_expr_str[comp], val, comp);
>>> +                return AVERROR(EINVAL);
>>> +            }
>>> +            lut->lut[comp][val] = av_clip((int)res, min[comp], max[comp]);
>>> +            av_log(ctx, AV_LOG_DEBUG, "val[%d][%d] = %d\n", comp, val, lut->lut[comp][val]);
>>> +        }
>> 
>> Another thought - studio level video is allowed to have excursions below
>> 'black' and above 'white'. Am I right in my understanding that this
>> filter will clip at black and white?
> 
> That's correct. I did it since that was resulting in artifacts for
> out-of-band values with gamma correction (this was resulting in
> negative gamma-corrected values for out-of-band values). We may find a
> better solution or disable clipping through an option.

Shouldn't it always be possible to have the clipping explicitly in the given formula?
That would make that kind of implicit clipping just a pointless limitation of what can be done with the filter...


More information about the ffmpeg-devel mailing list