[MPlayer-dev-eng] [PATCH] new video filter : vf_deflicker

Reimar Döffinger Reimar.Doeffinger at gmx.de
Wed May 19 00:20:38 CEST 2010


On Tue, May 18, 2010 at 05:42:00AM +0200, alexandre wrote:
> +    if (vf->priv->nFrames >= vf->priv->nFrames) {

wrong condition.

> +        if (doMatch) {

doMatch seems to be always 1 currently?

> +            // current frame histogram
> +            for (n = 0; n < 256; n++)
> +                h1[n] = 0;

memset should be simpler and faster.

> +
> +            for (y = 0; y < mpi->h; y++) {
> +                for (x = 0; x < mpi->w; x++) {
> +                    h1[mpi->planes[0][x + mpi->stride[0] * y]]++;
> +                }
> +            }
> +            for (y = 0; y < mpi->h; y++) {
> +                for (x = 0; x < mpi->w; x++) {
> +                    h2[vf->priv->means[x + y * mpi->w]]++;
> +                }
> +            }

Both can be done in the loop that updates the means array, halving
the memory bandwidth use,

> +            // histogram matching
> +            k = 0;
> +            for (n = 0; n < 256; n++) {
> +                while (k < 255 && h1[n] > h2[k])
> +                    k++;
> +                L[n] = k;
> +            }

I think this has a bias towards higher values.
Maybe
int last_k = k;
while (k < 255 && h1[n] > h2[k])
    k++;
L[n] = (last_k + k + 1) >> 1;

would be more accurate?

And whereever you put the division for rescaling the means value:
you should use rounding, i.e. instead of a / b do (a + (b >> 1))/b



More information about the MPlayer-dev-eng mailing list