]> git.sesse.net Git - ffmpeg/commitdiff
lavfi/gradfun: fix rounding in MMX code.
authorClément Bœsch <ubitux@gmail.com>
Thu, 6 Dec 2012 23:36:29 +0000 (00:36 +0100)
committerAnton Khirnov <anton@khirnov.net>
Thu, 28 Mar 2013 06:59:04 +0000 (07:59 +0100)
Current code divides before increasing precision.

Also reduce upper bound for strength from 255 to 64.  This will prevent
an overflow in the SSSE3 and MMX filter_line code: delta is expressed as
an u16 being shifted by 2 to the left. If it overflows, having a
strength not above 64 will make sure that m is set to 0 (making the
m*m*delta >> 14 expression void).

A value above 64 should not make any sense unless gradfun is used as
a blur filter.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
doc/filters.texi
libavfilter/vf_gradfun.c
libavfilter/x86/vf_gradfun.c

index 9b39ea50efead8cffa6cd10102621279319c7ea0..88888c60e389165c18c2a338d1c9d4e4a6fbe4f0 100644 (file)
@@ -1142,7 +1142,7 @@ The filter takes two optional parameters, separated by ':':
 
 @var{strength} is the maximum amount by which the filter will change
 any one pixel. Also the threshold for detecting nearly flat
-regions. Acceptable values range from .51 to 255, default value is
+regions. Acceptable values range from .51 to 64, default value is
 1.2, out-of-range values will be clipped to the valid range.
 
 @var{radius} is the neighborhood to fit the gradient to. A larger
index 80b7e412e31ecb467978752ab63ed60da0ac975c..900ef604e8df5d4057ceaac2a6d672b40803e30f 100644 (file)
@@ -128,7 +128,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
     if (args)
         sscanf(args, "%f:%d", &thresh, &radius);
 
-    thresh = av_clipf(thresh, 0.51, 255);
+    thresh = av_clipf(thresh, 0.51, 64);
     gf->thresh = (1 << 15) / thresh;
     gf->radius = av_clip((radius + 1) & ~1, 4, 32);
 
index b4ca86c617137022f3fa906ed7f5d8a40c73ebba..75c117a9a206a8966f1bcb6a4d1492a16dfdffd5 100644 (file)
@@ -62,8 +62,8 @@ static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc,
         "pminsw     %%mm7, %%mm2 \n" // m = -max(0, 127-m)
         "pmullw     %%mm2, %%mm2 \n"
         "paddw      %%mm4, %%mm0 \n" // pix += dither
-        "pmulhw     %%mm2, %%mm1 \n"
         "psllw         $2, %%mm1 \n" // m = m*m*delta >> 14
+        "pmulhw     %%mm2, %%mm1 \n"
         "paddw      %%mm1, %%mm0 \n" // pix += m
         "psraw         $7, %%mm0 \n"
         "packuswb   %%mm0, %%mm0 \n"