diff options
author | Clément Bœsch <ubitux@gmail.com> | 2012-12-07 00:39:31 +0100 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2012-12-19 03:13:25 +0100 |
commit | 60ba9a9a88fe8e041386962057a755bb599e511c (patch) | |
tree | 0a5e6db55a8b9bb548ff095af6ddf84dce614e4d /libavfilter/x86 | |
parent | 49de902a1e074133583dd5d8599aa057ed1d1485 (diff) | |
download | ffmpeg-60ba9a9a88fe8e041386962057a755bb599e511c.tar.gz |
lavfi/gradfun: fix dithering in MMX code.
Current dithering only use the first 4w instead of the whole 8 random values.
Diffstat (limited to 'libavfilter/x86')
-rw-r--r-- | libavfilter/x86/gradfun.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/libavfilter/x86/gradfun.c b/libavfilter/x86/gradfun.c index 1ca5928241..be3e6a9a8e 100644 --- a/libavfilter/x86/gradfun.c +++ b/libavfilter/x86/gradfun.c @@ -46,7 +46,9 @@ static void gradfun_filter_line_mmxext(uint8_t *dst, const uint8_t *src, const u "pxor %%mm7, %%mm7 \n" "pshufw $0, %%mm5, %%mm5 \n" "movq %6, %%mm6 \n" - "movq %5, %%mm4 \n" + "movq (%5), %%mm3 \n" + "movq 8(%5), %%mm4 \n" + "1: \n" "movd (%2,%0), %%mm0 \n" "movd (%3,%0), %%mm1 \n" @@ -61,6 +63,29 @@ static void gradfun_filter_line_mmxext(uint8_t *dst, const uint8_t *src, const u "psubw %%mm6, %%mm2 \n" "pminsw %%mm7, %%mm2 \n" // m = -max(0, 127-m) "pmullw %%mm2, %%mm2 \n" + "paddw %%mm3, %%mm0 \n" // pix += dither + "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" + "movd %%mm0, (%1,%0) \n" // dst = clip(pix>>7) + "add $4, %0 \n" + "jnl 2f \n" + + "movd (%2,%0), %%mm0 \n" + "movd (%3,%0), %%mm1 \n" + "punpcklbw %%mm7, %%mm0 \n" + "punpcklwd %%mm1, %%mm1 \n" + "psllw $7, %%mm0 \n" + "pxor %%mm2, %%mm2 \n" + "psubw %%mm0, %%mm1 \n" // delta = dc - pix + "psubw %%mm1, %%mm2 \n" + "pmaxsw %%mm1, %%mm2 \n" + "pmulhuw %%mm5, %%mm2 \n" // m = abs(delta) * thresh >> 16 + "psubw %%mm6, %%mm2 \n" + "pminsw %%mm7, %%mm2 \n" // m = -max(0, 127-m) + "pmullw %%mm2, %%mm2 \n" "paddw %%mm4, %%mm0 \n" // pix += dither "psllw $2, %%mm1 \n" // m = m*m*delta >> 14 "pmulhw %%mm2, %%mm1 \n" @@ -70,10 +95,12 @@ static void gradfun_filter_line_mmxext(uint8_t *dst, const uint8_t *src, const u "movd %%mm0, (%1,%0) \n" // dst = clip(pix>>7) "add $4, %0 \n" "jl 1b \n" + + "2: \n" "emms \n" :"+r"(x) :"r"(dst+width), "r"(src+width), "r"(dc+width/2), - "rm"(thresh), "m"(*dithers), "m"(*pw_7f) + "rm"(thresh), "r"(dithers), "m"(*pw_7f) :"memory" ); } |