Commit a8aa1629 authored by ramiro's avatar ramiro

Add support for nv12/nv21 input.

git-svn-id: file:///var/local/repositories/mplayer/trunk/libswscale@29974 b3059339-0415-0410-9bf9-f77b7e298cf2
parent 1922450b
...@@ -135,6 +135,8 @@ const char * swscale_license(void) ...@@ -135,6 +135,8 @@ const char * swscale_license(void)
|| (x)==PIX_FMT_GRAY8 \ || (x)==PIX_FMT_GRAY8 \
|| (x)==PIX_FMT_YUV410P \ || (x)==PIX_FMT_YUV410P \
|| (x)==PIX_FMT_YUV440P \ || (x)==PIX_FMT_YUV440P \
|| (x)==PIX_FMT_NV12 \
|| (x)==PIX_FMT_NV21 \
|| (x)==PIX_FMT_GRAY16BE \ || (x)==PIX_FMT_GRAY16BE \
|| (x)==PIX_FMT_GRAY16LE \ || (x)==PIX_FMT_GRAY16LE \
|| (x)==PIX_FMT_YUV444P \ || (x)==PIX_FMT_YUV444P \
......
...@@ -1784,6 +1784,54 @@ static inline void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *s ...@@ -1784,6 +1784,54 @@ static inline void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *s
#endif #endif
} }
static inline void RENAME(nvXXtoUV)(uint8_t *dst1, uint8_t *dst2,
const uint8_t *src, long width)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",2), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"psrlw $8, %%mm2 \n\t"
"psrlw $8, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
"movq %%mm0, (%2, %%"REG_a") \n\t"
"movq %%mm2, (%3, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst1+width), "r" (dst2+width)
: "%"REG_a
);
#else
int i;
for (i = 0; i < width; i++) {
dst1[i] = src[2*i+0];
dst2[i] = src[2*i+1];
}
#endif
}
static inline void nv12ToUV(uint8_t *dstU, uint8_t *dstV,
const uint8_t *src1, const uint8_t *src2,
long width, uint32_t *unused)
{
RENAME(nvXXtoUV)(dstU, dstV, src1, width);
}
static inline void nv21ToUV(uint8_t *dstU, uint8_t *dstV,
const uint8_t *src1, const uint8_t *src2,
long width, uint32_t *unused)
{
RENAME(nvXXtoUV)(dstV, dstU, src1, width);
}
#if COMPILE_TEMPLATE_MMX #if COMPILE_TEMPLATE_MMX
static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, long width, enum PixelFormat srcFormat) static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, long width, enum PixelFormat srcFormat)
{ {
...@@ -2914,6 +2962,8 @@ static void RENAME(sws_init_swScale)(SwsContext *c) ...@@ -2914,6 +2962,8 @@ static void RENAME(sws_init_swScale)(SwsContext *c)
switch(srcFormat) { switch(srcFormat) {
case PIX_FMT_YUYV422 : c->hcscale_internal = RENAME(yuy2ToUV); break; case PIX_FMT_YUYV422 : c->hcscale_internal = RENAME(yuy2ToUV); break;
case PIX_FMT_UYVY422 : c->hcscale_internal = RENAME(uyvyToUV); break; case PIX_FMT_UYVY422 : c->hcscale_internal = RENAME(uyvyToUV); break;
case PIX_FMT_NV12 : c->hcscale_internal = nv12ToUV; break;
case PIX_FMT_NV21 : c->hcscale_internal = nv21ToUV; break;
case PIX_FMT_RGB8 : case PIX_FMT_RGB8 :
case PIX_FMT_BGR8 : case PIX_FMT_BGR8 :
case PIX_FMT_PAL8 : case PIX_FMT_PAL8 :
......
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