[FFmpeg-devel] [PATCH] lavfi: port decimate libmpcodecs filter
Nicolas George
nicolas.george at normalesup.org
Tue Aug 21 11:24:06 CEST 2012
Le tridi 3 fructidor, an CCXX, Stefano Sabatini a écrit :
> > Maybe store it as an integer? That would help making the filter bit-exact.
> Please elaborate, also I'd like to keep compatibility with mp=decimate.
My suggestion would be to have "unsigned frac", with default value
1431655765 ((1<<32)/3) or 1417339208 ((1<<32)*0.33) and replace the
following code
> + int t = (w/16)*(h/16)*decimate->frac;
by:
int t = av_rescale((w/16)*(h/16), decimate->frac, 0x100000000);
In other words: frac_as_a_float = frac_as_an_unsigned / (float)(1 << 32),
but avoiding all floating-point arithmetic.
Since (w/16)*(h/16) should be way smaller than 1<<32 (if av_image_check_size
did its work, (w/16)*(h/16) < 1<<20), it will be accurate enough. And
without floating-point arithmetic, we can be sure the computation is
bit-exact across architectures and add FATE tests.
The /16 look very strange, though, as x and y are incremented by steps of 4.
> + char c1, c2, c3, c4;
> + int n = sscanf(args, "%d%c%d%c%d%c%f%c",
> + &decimate->max_drop_count, &c1,
> + &decimate->hi, &c2, &decimate->lo, &c3,
> + &decimate->frac, &c4);
> + if (n != 1 &&
> + (n != 3 || c1 != ':') &&
> + (n != 5 || c1 != ':' || c2 != ':') &&
> + (n != 7 || c1 != ':' || c2 != ':' || c3 != ':')) {
> + av_log(ctx, AV_LOG_ERROR,
> + "Invalid syntax for argument '%s': "
> + "must be in the form 'max:hi:lo:frac'\n", args);
> + return AVERROR(EINVAL);
This test look very clumsy, but I guess it comes from the original code.
No other remarks.
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120821/8bd5a839/attachment.asc>
More information about the ffmpeg-devel
mailing list