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

Stefano Sabatini stefano.sabatini-lala at poste.it
Tue Jun 7 10:34:36 CEST 2011


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.
-- 
FFmpeg = Frenzy and Fascinating Mind-dumbing Practical Elected Game


More information about the ffmpeg-devel mailing list