MMX(2) accelerated yuv420->rgb24 routine, trivial as essentially as it just

swaps R and B inputs for the existing yuv420->bgr24 routine.

Originally committed as revision 30254 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
release/0.6
Zuxy Meng 15 years ago
parent 75dd693840
commit 23b0072ad7
  1. 6
      libswscale/x86/yuv2rgb_mmx.c
  2. 210
      libswscale/x86/yuv2rgb_template.c

@ -72,7 +72,8 @@ SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
if (HAVE_7REGS) return yuva420_bgr32_MMX2;
break;
} else return yuv420_bgr32_MMX2;
case PIX_FMT_BGR24: return yuv420_rgb24_MMX2;
case PIX_FMT_RGB24: return yuv420_rgb24_MMX2;
case PIX_FMT_BGR24: return yuv420_bgr24_MMX2;
case PIX_FMT_RGB565: return yuv420_rgb16_MMX2;
case PIX_FMT_RGB555: return yuv420_rgb15_MMX2;
}
@ -89,7 +90,8 @@ SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
if (HAVE_7REGS) return yuva420_bgr32_MMX;
break;
} else return yuv420_bgr32_MMX;
case PIX_FMT_BGR24: return yuv420_rgb24_MMX;
case PIX_FMT_RGB24: return yuv420_rgb24_MMX;
case PIX_FMT_BGR24: return yuv420_bgr24_MMX;
case PIX_FMT_RGB565: return yuv420_rgb16_MMX;
case PIX_FMT_RGB555: return yuv420_rgb15_MMX;
}

@ -295,6 +295,106 @@ static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStr
YUV2RGB_OPERANDS
}
#if HAVE_MMX2
#define RGB_PLANAR2PACKED24(red, blue)\
"movq "MANGLE(ff_M24A)", %%mm4 \n\t"\
"movq "MANGLE(ff_M24C)", %%mm7 \n\t"\
"pshufw $0x50, %%mm"blue", %%mm5 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */\
"pshufw $0x50, %%mm2, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */\
"pshufw $0x00, %%mm"red", %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */\
\
"pand %%mm4, %%mm5 \n\t" /* B2 B1 B0 */\
"pand %%mm4, %%mm3 \n\t" /* G2 G1 G0 */\
"pand %%mm7, %%mm6 \n\t" /* R1 R0 */\
\
"psllq $8, %%mm3 \n\t" /* G2 G1 G0 */\
"por %%mm5, %%mm6 \n\t"\
"por %%mm3, %%mm6 \n\t"\
MOVNTQ" %%mm6, (%1) \n\t"\
\
"psrlq $8, %%mm2 \n\t" /* 00 G7 G6 G5 G4 G3 G2 G1 */\
"pshufw $0xA5, %%mm"blue", %%mm5\n\t" /* B5 B4 B5 B4 B3 B2 B3 B2 */\
"pshufw $0x55, %%mm2, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */\
"pshufw $0xA5, %%mm"red", %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */\
\
"pand "MANGLE(ff_M24B)", %%mm5 \n\t" /* B5 B4 B3 */\
"pand %%mm7, %%mm3 \n\t" /* G4 G3 */\
"pand %%mm4, %%mm6 \n\t" /* R4 R3 R2 */\
\
"por %%mm5, %%mm3 \n\t" /* B5 G4 B4 G3 B3 */\
"por %%mm3, %%mm6 \n\t"\
MOVNTQ" %%mm6, 8(%1) \n\t"\
\
"pshufw $0xFF, %%mm"blue", %%mm5\n\t" /* B7 B6 B7 B6 B7 B6 B6 B7 */\
"pshufw $0xFA, %%mm2, %%mm3 \n\t" /* 00 G7 00 G7 G6 G5 G6 G5 */\
"pshufw $0xFA, %%mm"red", %%mm6 \n\t" /* R7 R6 R7 R6 R5 R4 R5 R4 */\
"movd 4 (%2, %0), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */\
\
"pand %%mm7, %%mm5 \n\t" /* B7 B6 */\
"pand %%mm4, %%mm3 \n\t" /* G7 G6 G5 */\
"pand "MANGLE(ff_M24B)", %%mm6 \n\t" /* R7 R6 R5 */\
"movd 4 (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */\
\
"por %%mm5, %%mm3 \n\t"\
"por %%mm3, %%mm6 \n\t"\
MOVNTQ" %%mm6, 16(%1) \n\t"\
"movq 8 (%5, %0, 2), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */\
"pxor %%mm4, %%mm4 \n\t"
#else
#define RGB_PLANAR2PACKED24(red, blue)\
"pxor %%mm4, %%mm4 \n\t"\
"movq %%mm"blue", %%mm5\n\t" /* B */\
"movq %%mm"red", %%mm6 \n\t" /* R */\
"punpcklbw %%mm2, %%mm"blue"\n\t" /* GBGBGBGB 0 */\
"punpcklbw %%mm4, %%mm"red" \n\t" /* 0R0R0R0R 0 */\
"punpckhbw %%mm2, %%mm5 \n\t" /* GBGBGBGB 2 */\
"punpckhbw %%mm4, %%mm6 \n\t" /* 0R0R0R0R 2 */\
"movq %%mm"blue", %%mm7\n\t" /* GBGBGBGB 0 */\
"movq %%mm5, %%mm3 \n\t" /* GBGBGBGB 2 */\
"punpcklwd %%mm"red", %%mm7 \n\t" /* 0RGB0RGB 0 */\
"punpckhwd %%mm"red", %%mm"blue"\n\t" /* 0RGB0RGB 1 */\
"punpcklwd %%mm6, %%mm5 \n\t" /* 0RGB0RGB 2 */\
"punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\
\
"movq %%mm7, %%mm2 \n\t" /* 0RGB0RGB 0 */\
"movq %%mm"blue", %%mm6\n\t" /* 0RGB0RGB 1 */\
"movq %%mm5, %%mm"red" \n\t" /* 0RGB0RGB 2 */\
"movq %%mm3, %%mm4 \n\t" /* 0RGB0RGB 3 */\
\
"psllq $40, %%mm7 \n\t" /* RGB00000 0 */\
"psllq $40, %%mm"blue"\n\t" /* RGB00000 1 */\
"psllq $40, %%mm5 \n\t" /* RGB00000 2 */\
"psllq $40, %%mm3 \n\t" /* RGB00000 3 */\
\
"punpckhdq %%mm2, %%mm7 \n\t" /* 0RGBRGB0 0 */\
"punpckhdq %%mm6, %%mm"blue"\n\t" /* 0RGBRGB0 1 */\
"punpckhdq %%mm"red", %%mm5 \n\t" /* 0RGBRGB0 2 */\
"punpckhdq %%mm4, %%mm3 \n\t" /* 0RGBRGB0 3 */\
\
"psrlq $8, %%mm7 \n\t" /* 00RGBRGB 0 */\
"movq %%mm"blue", %%mm6\n\t" /* 0RGBRGB0 1 */\
"psllq $40, %%mm"blue"\n\t" /* GB000000 1 */\
"por %%mm"blue", %%mm7\n\t" /* GBRGBRGB 0 */\
MOVNTQ" %%mm7, (%1) \n\t"\
\
"psrlq $24, %%mm6 \n\t" /* 0000RGBR 1 */\
"movq %%mm5, %%mm"red" \n\t" /* 0RGBRGB0 2 */\
"psllq $24, %%mm5 \n\t" /* BRGB0000 2 */\
"por %%mm5, %%mm6 \n\t" /* BRGBRGBR 1 */\
MOVNTQ" %%mm6, 8(%1) \n\t"\
\
"movq 8 (%5, %0, 2), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */\
\
"psrlq $40, %%mm"red" \n\t" /* 000000RG 2 */\
"psllq $8, %%mm3 \n\t" /* RGBRGB00 3 */\
"por %%mm3, %%mm"red" \n\t" /* RGBRGBRG 2 */\
MOVNTQ" %%mm"red", 16(%1)\n\t"\
\
"movd 4 (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */\
"movd 4 (%2, %0), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */\
"pxor %%mm4, %%mm4 \n\t"
#endif
static inline int RENAME(yuv420_rgb24)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
@ -306,106 +406,24 @@ static inline int RENAME(yuv420_rgb24)(SwsContext *c, uint8_t* src[], int srcStr
YUV2RGB_INIT
YUV2RGB
/* mm0=B, %%mm2=G, %%mm1=R */
#if HAVE_MMX2
"movq "MANGLE(ff_M24A)", %%mm4 \n\t"
"movq "MANGLE(ff_M24C)", %%mm7 \n\t"
"pshufw $0x50, %%mm0, %%mm5 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */
"pshufw $0x50, %%mm2, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */
"pshufw $0x00, %%mm1, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */
"pand %%mm4, %%mm5 \n\t" /* B2 B1 B0 */
"pand %%mm4, %%mm3 \n\t" /* G2 G1 G0 */
"pand %%mm7, %%mm6 \n\t" /* R1 R0 */
"psllq $8, %%mm3 \n\t" /* G2 G1 G0 */
"por %%mm5, %%mm6 \n\t"
"por %%mm3, %%mm6 \n\t"
MOVNTQ" %%mm6, (%1) \n\t"
"psrlq $8, %%mm2 \n\t" /* 00 G7 G6 G5 G4 G3 G2 G1 */
"pshufw $0xA5, %%mm0, %%mm5 \n\t" /* B5 B4 B5 B4 B3 B2 B3 B2 */
"pshufw $0x55, %%mm2, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */
"pshufw $0xA5, %%mm1, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */
"pand "MANGLE(ff_M24B)", %%mm5 \n\t" /* B5 B4 B3 */
"pand %%mm7, %%mm3 \n\t" /* G4 G3 */
"pand %%mm4, %%mm6 \n\t" /* R4 R3 R2 */
"por %%mm5, %%mm3 \n\t" /* B5 G4 B4 G3 B3 */
"por %%mm3, %%mm6 \n\t"
MOVNTQ" %%mm6, 8(%1) \n\t"
"pshufw $0xFF, %%mm0, %%mm5 \n\t" /* B7 B6 B7 B6 B7 B6 B6 B7 */
"pshufw $0xFA, %%mm2, %%mm3 \n\t" /* 00 G7 00 G7 G6 G5 G6 G5 */
"pshufw $0xFA, %%mm1, %%mm6 \n\t" /* R7 R6 R7 R6 R5 R4 R5 R4 */
"movd 4 (%2, %0), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
"pand %%mm7, %%mm5 \n\t" /* B7 B6 */
"pand %%mm4, %%mm3 \n\t" /* G7 G6 G5 */
"pand "MANGLE(ff_M24B)", %%mm6 \n\t" /* R7 R6 R5 */
"movd 4 (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
\
"por %%mm5, %%mm3 \n\t"
"por %%mm3, %%mm6 \n\t"
MOVNTQ" %%mm6, 16(%1) \n\t"
"movq 8 (%5, %0, 2), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
"pxor %%mm4, %%mm4 \n\t"
RGB_PLANAR2PACKED24("0", "1")
#else
"pxor %%mm4, %%mm4 \n\t"
"movq %%mm0, %%mm5 \n\t" /* B */
"movq %%mm1, %%mm6 \n\t" /* R */
"punpcklbw %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */
"punpcklbw %%mm4, %%mm1 \n\t" /* 0R0R0R0R 0 */
"punpckhbw %%mm2, %%mm5 \n\t" /* GBGBGBGB 2 */
"punpckhbw %%mm4, %%mm6 \n\t" /* 0R0R0R0R 2 */
"movq %%mm0, %%mm7 \n\t" /* GBGBGBGB 0 */
"movq %%mm5, %%mm3 \n\t" /* GBGBGBGB 2 */
"punpcklwd %%mm1, %%mm7 \n\t" /* 0RGB0RGB 0 */
"punpckhwd %%mm1, %%mm0 \n\t" /* 0RGB0RGB 1 */
"punpcklwd %%mm6, %%mm5 \n\t" /* 0RGB0RGB 2 */
"punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */
"movq %%mm7, %%mm2 \n\t" /* 0RGB0RGB 0 */
"movq %%mm0, %%mm6 \n\t" /* 0RGB0RGB 1 */
"movq %%mm5, %%mm1 \n\t" /* 0RGB0RGB 2 */
"movq %%mm3, %%mm4 \n\t" /* 0RGB0RGB 3 */
"psllq $40, %%mm7 \n\t" /* RGB00000 0 */
"psllq $40, %%mm0 \n\t" /* RGB00000 1 */
"psllq $40, %%mm5 \n\t" /* RGB00000 2 */
"psllq $40, %%mm3 \n\t" /* RGB00000 3 */
"punpckhdq %%mm2, %%mm7 \n\t" /* 0RGBRGB0 0 */
"punpckhdq %%mm6, %%mm0 \n\t" /* 0RGBRGB0 1 */
"punpckhdq %%mm1, %%mm5 \n\t" /* 0RGBRGB0 2 */
"punpckhdq %%mm4, %%mm3 \n\t" /* 0RGBRGB0 3 */
"psrlq $8, %%mm7 \n\t" /* 00RGBRGB 0 */
"movq %%mm0, %%mm6 \n\t" /* 0RGBRGB0 1 */
"psllq $40, %%mm0 \n\t" /* GB000000 1 */
"por %%mm0, %%mm7 \n\t" /* GBRGBRGB 0 */
MOVNTQ" %%mm7, (%1) \n\t"
"movd 4 (%2, %0), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
"psrlq $24, %%mm6 \n\t" /* 0000RGBR 1 */
"movq %%mm5, %%mm1 \n\t" /* 0RGBRGB0 2 */
"psllq $24, %%mm5 \n\t" /* BRGB0000 2 */
"por %%mm5, %%mm6 \n\t" /* BRGBRGBR 1 */
MOVNTQ" %%mm6, 8(%1) \n\t"
YUV2RGB_ENDLOOP(3)
YUV2RGB_OPERANDS
}
"movq 8 (%5, %0, 2), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
static inline int RENAME(yuv420_bgr24)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
int y, h_size;
"psrlq $40, %%mm1 \n\t" /* 000000RG 2 */
"psllq $8, %%mm3 \n\t" /* RGBRGB00 3 */
"por %%mm3, %%mm1 \n\t" /* RGBRGBRG 2 */
MOVNTQ" %%mm1, 16(%1) \n\t"
YUV422_UNSHIFT
YUV2RGB_LOOP(3)
"movd 4 (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
"pxor %%mm4, %%mm4 \n\t"
#endif
YUV2RGB_INIT
YUV2RGB
/* mm0=B, %%mm2=G, %%mm1=R */
RGB_PLANAR2PACKED24("1", "0")
YUV2RGB_ENDLOOP(3)
YUV2RGB_OPERANDS

Loading…
Cancel
Save