Commit 036e966a authored by lorenm's avatar lorenm

40% faster yuv420 to rgb24 mmx.

It is now faster than the old gpl version on conroe.


git-svn-id: file:///var/local/repositories/mplayer/trunk/libswscale@31180 b3059339-0415-0410-9bf9-f77b7e298cf2
parent 2e2e9987
...@@ -124,16 +124,16 @@ ...@@ -124,16 +124,16 @@
"paddsw %%mm6, %%mm0\n\t" \ "paddsw %%mm6, %%mm0\n\t" \
"paddsw %%mm6, %%mm1\n\t" \ "paddsw %%mm6, %%mm1\n\t" \
"paddsw %%mm6, %%mm2\n\t" \ "paddsw %%mm6, %%mm2\n\t" \
\
#define RGB_PACK_INTERLEAVE \
/* pack and interleave even/odd pixels */ \ /* pack and interleave even/odd pixels */ \
"packuswb %%mm0, %%mm0\n\t" \ "packuswb %%mm1, %%mm0\n\t" \
"packuswb %%mm1, %%mm1\n\t" \ "packuswb %%mm5, %%mm3\n\t" \
"packuswb %%mm2, %%mm2\n\t" \ "packuswb %%mm2, %%mm2\n\t" \
"packuswb %%mm3, %%mm3\n\t" \ "movq %%mm0, %%mm1\n\n" \
"packuswb %%mm5, %%mm5\n\t" \
"packuswb %%mm7, %%mm7\n\t" \ "packuswb %%mm7, %%mm7\n\t" \
"punpcklbw %%mm3, %%mm0\n\t" \ "punpcklbw %%mm3, %%mm0\n\t" \
"punpcklbw %%mm5, %%mm1\n\t" \ "punpckhbw %%mm3, %%mm1\n\t" \
"punpcklbw %%mm7, %%mm2\n\t" \ "punpcklbw %%mm7, %%mm2\n\t" \
#define YUV2RGB_ENDLOOP(depth) \ #define YUV2RGB_ENDLOOP(depth) \
...@@ -210,6 +210,7 @@ static inline int RENAME(yuv420_rgb15)(SwsContext *c, const uint8_t *src[], ...@@ -210,6 +210,7 @@ static inline int RENAME(yuv420_rgb15)(SwsContext *c, const uint8_t *src[],
YUV2RGB_INITIAL_LOAD YUV2RGB_INITIAL_LOAD
YUV2RGB YUV2RGB
RGB_PACK_INTERLEAVE
#ifdef DITHER1XBPP #ifdef DITHER1XBPP
DITHER_RGB DITHER_RGB
#endif #endif
...@@ -237,6 +238,7 @@ static inline int RENAME(yuv420_rgb16)(SwsContext *c, const uint8_t *src[], ...@@ -237,6 +238,7 @@ static inline int RENAME(yuv420_rgb16)(SwsContext *c, const uint8_t *src[],
YUV2RGB_INITIAL_LOAD YUV2RGB_INITIAL_LOAD
YUV2RGB YUV2RGB
RGB_PACK_INTERLEAVE
#ifdef DITHER1XBPP #ifdef DITHER1XBPP
DITHER_RGB DITHER_RGB
#endif #endif
...@@ -247,73 +249,66 @@ static inline int RENAME(yuv420_rgb16)(SwsContext *c, const uint8_t *src[], ...@@ -247,73 +249,66 @@ static inline int RENAME(yuv420_rgb16)(SwsContext *c, const uint8_t *src[],
YUV2RGB_ENDFUNC YUV2RGB_ENDFUNC
} }
#define RGB_PACK24(blue, red)\
"packuswb %%mm3, %%mm0 \n" /* R0 R2 R4 R6 R1 R3 R5 R7 */\
"packuswb %%mm5, %%mm1 \n" /* B0 B2 B4 B6 B1 B3 B5 B7 */\
"packuswb %%mm7, %%mm2 \n" /* G0 G2 G4 G6 G1 G3 G5 G7 */\
"movq %%mm"red", %%mm3 \n"\
"movq %%mm"blue", %%mm6 \n"\
"psrlq $32, %%mm"red" \n" /* R1 R3 R5 R7 */\
"punpcklbw %%mm2, %%mm3 \n" /* R0 G0 R2 G2 R4 G4 R6 G6 */\
"punpcklbw %%mm"red", %%mm6 \n" /* B0 R1 B2 R3 B4 R5 B6 R7 */\
"movq %%mm3, %%mm5 \n"\
"punpckhbw %%mm"blue", %%mm2 \n" /* G1 B1 G3 B3 G5 B5 G7 B7 */\
"punpcklwd %%mm6, %%mm3 \n" /* R0 G0 B0 R1 R2 G2 B2 R3 */\
"punpckhwd %%mm6, %%mm5 \n" /* R4 G4 B4 R5 R6 G6 B6 R7 */\
RGB_PACK24_B
#define RGB_PACK24(red, blue) \ #if HAVE_MMX2
/* generate first packed RGB octet */ \ DECLARE_ASM_CONST(8, int16_t, mask1101[4]) = {-1,-1, 0,-1};
"movq %%mm2, %%mm5\n\t" \ DECLARE_ASM_CONST(8, int16_t, mask0010[4]) = { 0, 0,-1, 0};
"movq %%mm"blue", %%mm6\n\t" \ DECLARE_ASM_CONST(8, int16_t, mask0110[4]) = { 0,-1,-1, 0};
"movq %%mm"red", %%mm7\n\t" \ DECLARE_ASM_CONST(8, int16_t, mask1001[4]) = {-1, 0, 0,-1};
"punpcklbw %%mm5, %%mm6\n\t" \ DECLARE_ASM_CONST(8, int16_t, mask0100[4]) = { 0,-1, 0, 0};
"punpcklbw %%mm4, %%mm7\n\t" \ #undef RGB_PACK24_B
"movq %%mm6, %%mm3\n\t" \ #define RGB_PACK24_B\
"punpcklwd %%mm7, %%mm6\n\t" \ "pshufw $0xc6, %%mm2, %%mm1 \n"\
"psrlq $32, %%mm3\n\t" \ "pshufw $0x84, %%mm3, %%mm6 \n"\
"movq %%mm6, %%mm5\n\t" \ "pshufw $0x38, %%mm5, %%mm7 \n"\
"psllq $40, %%mm6\n\t" \ "pand "MANGLE(mask1101)", %%mm6 \n" /* R0 G0 B0 R1 -- -- R2 G2 */\
"psllq $48, %%mm3\n\t" \ "movq %%mm1, %%mm0 \n"\
"psrlq $32, %%mm5\n\t" \ "pand "MANGLE(mask0110)", %%mm7 \n" /* -- -- R6 G6 B6 R7 -- -- */\
"psrlq $40, %%mm6\n\t" \ "movq %%mm1, %%mm2 \n"\
"psllq $24, %%mm5\n\t" \ "pand "MANGLE(mask0100)", %%mm1 \n" /* -- -- G3 B3 -- -- -- -- */\
"por %%mm3, %%mm6\n\t" \ "psrlq $48, %%mm3 \n" /* B2 R3 -- -- -- -- -- -- */\
"por %%mm5, %%mm6\n\t" \ "pand "MANGLE(mask0010)", %%mm0 \n" /* -- -- -- -- G1 B1 -- -- */\
MOVNTQ " %%mm6, (%1)\n\t" \ "psllq $32, %%mm5 \n" /* -- -- -- -- R4 G4 B4 R5 */\
\ "pand "MANGLE(mask1001)", %%mm2 \n" /* G5 B5 -- -- -- -- G7 B7 */\
/* generate second packed RGB octet */ \ "por %%mm3, %%mm1 \n"\
"movq %%mm"red", %%mm7\n\t" \ "por %%mm6, %%mm0 \n"\
"movq %%mm2, %%mm5\n\t" \ "por %%mm5, %%mm1 \n"\
"movq %%mm"blue", %%mm6\n\t" \ "por %%mm7, %%mm2 \n"\
"punpcklbw %%mm4, %%mm7\n\t" \ MOVNTQ" %%mm0, (%1) \n"\
"punpcklbw %%mm5, %%mm6\n\t" \ MOVNTQ" %%mm1, 8(%1) \n"\
"movq %%mm7, %%mm3\n\t" \ MOVNTQ" %%mm2, 16(%1) \n"\
"punpckhwd %%mm7, %%mm6\n\t" \
"psllq $16, %%mm3\n\t" \ #else
"psrlq $32, %%mm6\n\t" \ #undef RGB_PACK24_B
"psrlq $48, %%mm3\n\t" \ #define RGB_PACK24_B\
"psllq $8, %%mm6\n\t" \ "movd %%mm3, (%1) \n" /* R0 G0 B0 R1 */\
"movq %%mm"red", %%mm7\n\t" \ "movd %%mm2, 4(%1) \n" /* G1 B1 */\
"por %%mm6, %%mm3\n\t" \ "psrlq $32, %%mm3 \n"\
"movq %%mm"blue", %%mm6\n\t" \ "psrlq $16, %%mm2 \n"\
"movq %%mm2, %%mm5\n\t" \ "movd %%mm3, 6(%1) \n" /* R2 G2 B2 R3 */\
"punpckhbw %%mm4, %%mm7\n\t" \ "movd %%mm2, 10(%1) \n" /* G3 B3 */\
"punpckhbw %%mm5, %%mm6\n\t" \ "psrlq $16, %%mm2 \n"\
"movq %%mm6, %%mm5\n\t" \ "movd %%mm5, 12(%1) \n" /* R4 G4 B4 R5 */\
"punpcklwd %%mm7, %%mm6\n\t" \ "movd %%mm2, 16(%1) \n" /* G5 B5 */\
"psrlq $16, %%mm5\n\t" \ "psrlq $32, %%mm5 \n"\
"psllq $56, %%mm5\n\t" \ "movd %%mm2, 20(%1) \n" /* -- -- G7 B7 */\
"por %%mm5, %%mm3\n\t" \ "movd %%mm5, 18(%1) \n" /* R6 G6 B6 R7 */\
"psllq $32, %%mm6\n\t" \
"por %%mm6, %%mm3\n\t" \ #endif
MOVNTQ " %%mm3, 8(%1)\n\t" \
\
/* generate third packed RGB octet */ \
"movq %%mm"red", %%mm7\n\t" \
"movq %%mm2, %%mm5\n\t" \
"movq %%mm2, %%mm3\n\t" \
"movq %%mm"blue", %%mm6\n\t" \
"punpckhbw %%mm"red", %%mm3\n\t" \
"punpckhbw %%mm4, %%mm7\n\t" \
"psllq $32, %%mm3\n\t" \
"punpckhbw %%mm5, %%mm6\n\t" \
"psrlq $48, %%mm3\n\t" \
"punpckhwd %%mm7, %%mm6\n\t" \
"movq %%mm6, %%mm7\n\t" \
"psrlq $32, %%mm6\n\t" \
"psllq $32, %%mm7\n\t" \
"psllq $40, %%mm6\n\t" \
"psrlq $16, %%mm7\n\t" \
"por %%mm6, %%mm3\n\t" \
"por %%mm7, %%mm3\n\t" \
MOVNTQ " %%mm3, 16(%1)\n\t" \
static inline int RENAME(yuv420_rgb24)(SwsContext *c, const uint8_t *src[], static inline int RENAME(yuv420_rgb24)(SwsContext *c, const uint8_t *src[],
int srcStride[], int srcStride[],
...@@ -387,6 +382,7 @@ static inline int RENAME(yuv420_rgb32)(SwsContext *c, const uint8_t *src[], ...@@ -387,6 +382,7 @@ static inline int RENAME(yuv420_rgb32)(SwsContext *c, const uint8_t *src[],
YUV2RGB_INITIAL_LOAD YUV2RGB_INITIAL_LOAD
YUV2RGB YUV2RGB
RGB_PACK_INTERLEAVE
SET_EMPTY_ALPHA SET_EMPTY_ALPHA
RGB_PACK32(REG_RED, REG_GREEN, REG_BLUE, REG_ALPHA) RGB_PACK32(REG_RED, REG_GREEN, REG_BLUE, REG_ALPHA)
...@@ -408,6 +404,7 @@ static inline int RENAME(yuva420_rgb32)(SwsContext *c, const uint8_t *src[], ...@@ -408,6 +404,7 @@ static inline int RENAME(yuva420_rgb32)(SwsContext *c, const uint8_t *src[],
const uint8_t *pa = src[3] + y * srcStride[3]; const uint8_t *pa = src[3] + y * srcStride[3];
YUV2RGB_INITIAL_LOAD YUV2RGB_INITIAL_LOAD
YUV2RGB YUV2RGB
RGB_PACK_INTERLEAVE
LOAD_ALPHA LOAD_ALPHA
RGB_PACK32(REG_RED, REG_GREEN, REG_BLUE, REG_ALPHA) RGB_PACK32(REG_RED, REG_GREEN, REG_BLUE, REG_ALPHA)
...@@ -428,6 +425,7 @@ static inline int RENAME(yuv420_bgr32)(SwsContext *c, const uint8_t *src[], ...@@ -428,6 +425,7 @@ static inline int RENAME(yuv420_bgr32)(SwsContext *c, const uint8_t *src[],
YUV2RGB_INITIAL_LOAD YUV2RGB_INITIAL_LOAD
YUV2RGB YUV2RGB
RGB_PACK_INTERLEAVE
SET_EMPTY_ALPHA SET_EMPTY_ALPHA
RGB_PACK32(REG_BLUE, REG_GREEN, REG_RED, REG_ALPHA) RGB_PACK32(REG_BLUE, REG_GREEN, REG_RED, REG_ALPHA)
...@@ -449,6 +447,7 @@ static inline int RENAME(yuva420_bgr32)(SwsContext *c, const uint8_t *src[], ...@@ -449,6 +447,7 @@ static inline int RENAME(yuva420_bgr32)(SwsContext *c, const uint8_t *src[],
const uint8_t *pa = src[3] + y * srcStride[3]; const uint8_t *pa = src[3] + y * srcStride[3];
YUV2RGB_INITIAL_LOAD YUV2RGB_INITIAL_LOAD
YUV2RGB YUV2RGB
RGB_PACK_INTERLEAVE
LOAD_ALPHA LOAD_ALPHA
RGB_PACK32(REG_BLUE, REG_GREEN, REG_RED, REG_ALPHA) RGB_PACK32(REG_BLUE, REG_GREEN, REG_RED, REG_ALPHA)
......
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