[FFmpeg-devel] FATE gradfun

Clément Bœsch ubitux at gmail.com
Wed Dec 5 20:17:43 CET 2012


I recently added gradfun filter test, which was failing quite badly, sorry
about that. The test is currently disabled, and I'm looking into the

The filter has 2 filtering function: filter_line() and blur_line().
AFAICT, blur_line() is not affected. OTOH, there are differences between
the C, MMX and SSSE3 version of filter_line.

First, I think there is a bug in the C version of filter line. the DC used
are following the scheme: "A BB CC DD E" instead of "AA BB CC DD EE" like
in the ASM version. It can be fixed easily with something like:

--- a/libavfilter/vf_gradfun.c
+++ b/libavfilter/vf_gradfun.c
@@ -56,7 +56,7 @@ DECLARE_ALIGNED(16, static const uint16_t, dither)[8][8] = {
 void ff_gradfun_filter_line_c(uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int th
     int x;
-    for (x = 0; x < width; x++, dc += x & 1) {
+    for (x = 0; x < width; dc += x & 1, x++) {
         int pix = src[x] << 7;
         int delta = dc[0] - pix;
         int m = abs(delta) * thresh >> 16;

This reduces the diff a little.

Now in the SSSE3 version, the operation
    m = (m * m * delta) >> 14
is done with the rounding of pmulhrsw, which is equivalent to
    m = (((((m*m)<<1) * delta) >> 14) + 1) >> 1

If the C is changed to that expression, C and SSSE3 results will match. I
guess here the best choice will be to set some FUZZ to the test,
especially when the MMX version seems to be closer to the C expression
than the SSSE3 one.

Concerning the MMX version, it seems there is a difference in the
dithering: while the C and SSSE3 versions seem to use whole 8B line of
dither, the MMX one will only use the first 4 (2 times). I'm not sure
about how to solve that issue.

Any comment?

Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121205/c93459cb/attachment.asc>

More information about the ffmpeg-devel mailing list