Commit 38a2f88d authored by Clément Bœsch's avatar Clément Bœsch Committed by Anton Khirnov

lavfi/gradfun: fix dithering in MMX code.

Current dithering only uses the first 4 instead of the whole 8 random values.
Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent 2d66fc54
...@@ -46,8 +46,33 @@ static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc, ...@@ -46,8 +46,33 @@ static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc,
"pxor %%mm7, %%mm7 \n" "pxor %%mm7, %%mm7 \n"
"pshufw $0, %%mm5, %%mm5 \n" "pshufw $0, %%mm5, %%mm5 \n"
"movq %6, %%mm6 \n" "movq %6, %%mm6 \n"
"movq %5, %%mm4 \n" "movq (%5), %%mm3 \n"
"movq 8(%5), %%mm4 \n"
"1: \n" "1: \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 %%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 (%2,%0), %%mm0 \n"
"movd (%3,%0), %%mm1 \n" "movd (%3,%0), %%mm1 \n"
"punpcklbw %%mm7, %%mm0 \n" "punpcklbw %%mm7, %%mm0 \n"
...@@ -70,10 +95,12 @@ static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc, ...@@ -70,10 +95,12 @@ static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc,
"movd %%mm0, (%1,%0) \n" // dst = clip(pix>>7) "movd %%mm0, (%1,%0) \n" // dst = clip(pix>>7)
"add $4, %0 \n" "add $4, %0 \n"
"jl 1b \n" "jl 1b \n"
"2: \n"
"emms \n" "emms \n"
:"+r"(x) :"+r"(x)
:"r"(dst+width), "r"(src+width), "r"(dc+width/2), :"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" :"memory"
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment