Commit 31410dbc authored by michael's avatar michael

yuy2toyv12 fixed and speedup


git-svn-id: file:///var/local/repositories/mplayer/trunk/postproc@2725 b3059339-0415-0410-9bf9-f77b7e298cf2
parent 34cc9aa4
...@@ -291,7 +291,8 @@ void palette8torgb15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, cons ...@@ -291,7 +291,8 @@ void palette8torgb15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, cons
} }
/** /**
* *
* width must be a multiple of 16 for the MMX version * height should be a multiple of 2 and width should be a multiple of 16 (if this is a
* problem for anyone then tell me, and ill fix it)
*/ */
void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
int width, int height, int lumStride, int chromStride, int dstStride) int width, int height, int lumStride, int chromStride, int dstStride)
...@@ -359,8 +360,18 @@ asm( EMMS" \n\t" ...@@ -359,8 +360,18 @@ asm( EMMS" \n\t"
#endif #endif
} }
void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, unsigned num_pixels) /**
*
* height should be a multiple of 2 and width should be a multiple of 16 (if this is a
* problem for anyone then tell me, and ill fix it)
*/
void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
int width, int height, int lumStride, int chromStride, int srcStride)
{ {
int y;
const int chromWidth= width>>1;
for(y=0; y<height; y+=2)
{
#ifdef HAVE_MMX #ifdef HAVE_MMX
asm volatile( asm volatile(
"xorl %%eax, %%eax \n\t" "xorl %%eax, %%eax \n\t"
...@@ -409,20 +420,56 @@ void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, ...@@ -409,20 +420,56 @@ void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
"addl $8, %%eax \n\t" "addl $8, %%eax \n\t"
"cmpl %4, %%eax \n\t" "cmpl %4, %%eax \n\t"
" jb 1b \n\t" " jb 1b \n\t"
EMMS" \n\t"
SFENCE "1: \n\t"
::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "r" (num_pixels>>1) PREFETCH" 64(%0, %%eax, 4) \n\t"
"movq (%0, %%eax, 4), %%mm0 \n\t" // YUYV YUYV(0)
"movq 8(%0, %%eax, 4), %%mm1 \n\t" // YUYV YUYV(4)
"movq 16(%0, %%eax, 4), %%mm2 \n\t" // YUYV YUYV(8)
"movq 24(%0, %%eax, 4), %%mm3 \n\t" // YUYV YUYV(12)
"pand %%mm7, %%mm0 \n\t" // Y0Y0 Y0Y0(0)
"pand %%mm7, %%mm1 \n\t" // Y0Y0 Y0Y0(4)
"pand %%mm7, %%mm2 \n\t" // Y0Y0 Y0Y0(8)
"pand %%mm7, %%mm3 \n\t" // Y0Y0 Y0Y0(12)
"packuswb %%mm1, %%mm0 \n\t" // YYYY YYYY(0)
"packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(8)
MOVNTQ" %%mm0, (%1, %%eax, 2) \n\t"
MOVNTQ" %%mm2, 8(%1, %%eax, 2) \n\t"
"addl $8, %%eax \n\t"
"cmpl %5, %%eax \n\t"
" jb 1b \n\t"
::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "r" (chromWidth), "m"(width)
: "memory", "%eax" : "memory", "%eax"
); );
#else #else
int i; int i;
num_pixels>>=1; for(i=0; i<chromWidth; i++)
for(i=0; i<num_pixels; i++)
{ {
ydst[2*i+0] = src[4*i+0]; ydst[2*i+0] = src[4*i+0];
udst[i] = src[4*i+1]; udst[i] = src[4*i+1];
ydst[2*i+1] = src[4*i+2]; ydst[2*i+1] = src[4*i+2];
vdst[i] = src[4*i+3]; vdst[i] = src[4*i+3];
} }
ydst += lumStride;
src += srcStride;
for(i=0; i<chromWidth; i++)
{
ydst[2*i+0] = src[4*i+0];
ydst[2*i+1] = src[4*i+2];
}
#endif
udst += chromStride;
vdst += chromStride;
ydst += lumStride;
src += srcStride;
}
#ifdef HAVE_MMX
asm( EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
#endif #endif
} }
...@@ -23,6 +23,7 @@ extern void palette8torgb24(const uint8_t *src, uint8_t *dst, unsigned num_pixel ...@@ -23,6 +23,7 @@ extern void palette8torgb24(const uint8_t *src, uint8_t *dst, unsigned num_pixel
extern void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, extern void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
int width, int height, int lumStride, int chromStride, int dstStride); int width, int height, int lumStride, int chromStride, int dstStride);
extern void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, unsigned num_pixels); extern void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
int width, int height, int lumStride, int chromStride, int srcStride);
#endif #endif
...@@ -291,7 +291,8 @@ void palette8torgb15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, cons ...@@ -291,7 +291,8 @@ void palette8torgb15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, cons
} }
/** /**
* *
* width must be a multiple of 16 for the MMX version * height should be a multiple of 2 and width should be a multiple of 16 (if this is a
* problem for anyone then tell me, and ill fix it)
*/ */
void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
int width, int height, int lumStride, int chromStride, int dstStride) int width, int height, int lumStride, int chromStride, int dstStride)
...@@ -359,8 +360,18 @@ asm( EMMS" \n\t" ...@@ -359,8 +360,18 @@ asm( EMMS" \n\t"
#endif #endif
} }
void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, unsigned num_pixels) /**
*
* height should be a multiple of 2 and width should be a multiple of 16 (if this is a
* problem for anyone then tell me, and ill fix it)
*/
void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
int width, int height, int lumStride, int chromStride, int srcStride)
{ {
int y;
const int chromWidth= width>>1;
for(y=0; y<height; y+=2)
{
#ifdef HAVE_MMX #ifdef HAVE_MMX
asm volatile( asm volatile(
"xorl %%eax, %%eax \n\t" "xorl %%eax, %%eax \n\t"
...@@ -409,20 +420,56 @@ void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, ...@@ -409,20 +420,56 @@ void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
"addl $8, %%eax \n\t" "addl $8, %%eax \n\t"
"cmpl %4, %%eax \n\t" "cmpl %4, %%eax \n\t"
" jb 1b \n\t" " jb 1b \n\t"
EMMS" \n\t"
SFENCE "1: \n\t"
::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "r" (num_pixels>>1) PREFETCH" 64(%0, %%eax, 4) \n\t"
"movq (%0, %%eax, 4), %%mm0 \n\t" // YUYV YUYV(0)
"movq 8(%0, %%eax, 4), %%mm1 \n\t" // YUYV YUYV(4)
"movq 16(%0, %%eax, 4), %%mm2 \n\t" // YUYV YUYV(8)
"movq 24(%0, %%eax, 4), %%mm3 \n\t" // YUYV YUYV(12)
"pand %%mm7, %%mm0 \n\t" // Y0Y0 Y0Y0(0)
"pand %%mm7, %%mm1 \n\t" // Y0Y0 Y0Y0(4)
"pand %%mm7, %%mm2 \n\t" // Y0Y0 Y0Y0(8)
"pand %%mm7, %%mm3 \n\t" // Y0Y0 Y0Y0(12)
"packuswb %%mm1, %%mm0 \n\t" // YYYY YYYY(0)
"packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(8)
MOVNTQ" %%mm0, (%1, %%eax, 2) \n\t"
MOVNTQ" %%mm2, 8(%1, %%eax, 2) \n\t"
"addl $8, %%eax \n\t"
"cmpl %5, %%eax \n\t"
" jb 1b \n\t"
::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "r" (chromWidth), "m"(width)
: "memory", "%eax" : "memory", "%eax"
); );
#else #else
int i; int i;
num_pixels>>=1; for(i=0; i<chromWidth; i++)
for(i=0; i<num_pixels; i++)
{ {
ydst[2*i+0] = src[4*i+0]; ydst[2*i+0] = src[4*i+0];
udst[i] = src[4*i+1]; udst[i] = src[4*i+1];
ydst[2*i+1] = src[4*i+2]; ydst[2*i+1] = src[4*i+2];
vdst[i] = src[4*i+3]; vdst[i] = src[4*i+3];
} }
ydst += lumStride;
src += srcStride;
for(i=0; i<chromWidth; i++)
{
ydst[2*i+0] = src[4*i+0];
ydst[2*i+1] = src[4*i+2];
}
#endif
udst += chromStride;
vdst += chromStride;
ydst += lumStride;
src += srcStride;
}
#ifdef HAVE_MMX
asm( EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
#endif #endif
} }
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