[FFmpeg-devel] [PATCH] avfilter: add normalize filter
Moritz Barsnick
barsnick at gmx.net
Mon Nov 20 13:05:08 EET 2017
On Mon, Nov 20, 2017 at 19:01:12 +1100, Richard Ling wrote:
> Patch attached.
You code nicely sticks to floats throughout, but at points like these:
> + min[c].smoothed = (min[c].smoothed * s->independence)
> + + (rgb_min_smoothed * (1.0 - s->independence));
> + max[c].smoothed = (max[c].smoothed * s->independence)
> + + (rgb_max_smoothed * (1.0 - s->independence));
and this:
> + min[c].out = (s->blackpt[c] * s->strength)
> + + (min[c].in * (1.0 - s->strength));
> + max[c].out = (s->whitept[c] * s->strength)
> + + (max[c].in * (1.0 - s->strength));
and this:
> + int out_val = (in_val - min[c].smoothed) * scale + min[c].out + 0.5;
your calculation gets promoted to double. You need to write e.g. "1.0f".
(This only matters on shitty old ARMs and similar processors, which are
really slow on doubles [soft emulation]. But just for sanity, please
let the compiler stick to float or double.)
> + { "smoothing", "amount of temporal smoothing of the input range, to reduce flicker", OFFSET(smoothing), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
[...]
> + s->history_len = (int)s->smoothing + 1;
Certainly a corner case, but this can overflow. And why do you cast an
int to an int? (Perhaps it was an unsigned int before?)
Cheers,
Moritz
More information about the ffmpeg-devel
mailing list