summaryrefslogtreecommitdiffstats
path: root/postproc/rgb2rgb_template.c
diff options
context:
space:
mode:
Diffstat (limited to 'postproc/rgb2rgb_template.c')
-rw-r--r--postproc/rgb2rgb_template.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/postproc/rgb2rgb_template.c b/postproc/rgb2rgb_template.c
index 015e7f2d56..b6c26a11ee 100644
--- a/postproc/rgb2rgb_template.c
+++ b/postproc/rgb2rgb_template.c
@@ -1295,6 +1295,95 @@ static inline void RENAME(yvu9toyv12)(const uint8_t *ysrc, const uint8_t *usrc,
/* XXX: implement upscaling for U,V */
}
+static inline void RENAME(planar2x)(const uint8_t *src, uint8_t *dst, int srcWidth, int srcHeight, int srcStride, int dstStride)
+{
+ int x,y;
+
+ // first line
+ for(x=0; x<srcWidth; x++){
+ dst[2*x+0]=
+ dst[2*x+1]= src[x];
+ }
+ dst+= dstStride;
+
+ for(y=1; y<srcHeight; y++){
+#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
+ const int mmxSize= srcWidth;
+ asm volatile(
+ "movl %4, %%eax \n\t"
+ "1: \n\t"
+ "movq (%0, %%eax), %%mm0 \n\t"
+ "movq (%1, %%eax), %%mm1 \n\t"
+ "movq 1(%0, %%eax), %%mm2 \n\t"
+ "movq 1(%1, %%eax), %%mm3 \n\t"
+ "movq %%mm0, %%mm4 \n\t"
+ "movq %%mm1, %%mm5 \n\t"
+ PAVGB" %%mm3, %%mm0 \n\t"
+ PAVGB" %%mm3, %%mm0 \n\t"
+ PAVGB" %%mm4, %%mm3 \n\t"
+ PAVGB" %%mm4, %%mm3 \n\t"
+ PAVGB" %%mm2, %%mm1 \n\t"
+ PAVGB" %%mm2, %%mm1 \n\t"
+ PAVGB" %%mm5, %%mm2 \n\t"
+ PAVGB" %%mm5, %%mm2 \n\t"
+ "movq %%mm3, %%mm4 \n\t"
+ "movq %%mm2, %%mm5 \n\t"
+ "punpcklbw %%mm1, %%mm3 \n\t"
+ "punpckhbw %%mm1, %%mm4 \n\t"
+ "punpcklbw %%mm0, %%mm2 \n\t"
+ "punpckhbw %%mm0, %%mm5 \n\t"
+#if 1
+ MOVNTQ" %%mm3, (%2, %%eax, 2) \n\t"
+ MOVNTQ" %%mm4, 8(%2, %%eax, 2) \n\t"
+ MOVNTQ" %%mm2, (%3, %%eax, 2) \n\t"
+ MOVNTQ" %%mm5, 8(%3, %%eax, 2) \n\t"
+#else
+ "movq %%mm3, (%2, %%eax, 2) \n\t"
+ "movq %%mm4, 8(%2, %%eax, 2) \n\t"
+ "movq %%mm2, (%3, %%eax, 2) \n\t"
+ "movq %%mm5, 8(%3, %%eax, 2) \n\t"
+#endif
+ "addl $8, %%eax \n\t"
+ " js 1b \n\t"
+ :: "r" (src + mmxSize-1), "r" (src + srcStride + mmxSize-1),
+ "r" (dst + mmxSize*2), "r" (dst + dstStride + mmxSize*2),
+ "g" (-mmxSize)
+ : "%eax"
+
+ );
+ dst[0]=
+ dst[dstStride]= src[0];
+#else
+ dst[0]=
+ dst[dstStride]= src[0];
+
+ for(x=0; x<srcWidth-1; x++){
+ dst[2*x +1]= (3*src[x+0] + src[x+srcStride+1])>>2;
+ dst[2*x+dstStride+2]= ( src[x+0] + 3*src[x+srcStride+1])>>2;
+ dst[2*x+dstStride+1]= ( src[x+1] + 3*src[x+srcStride ])>>2;
+ dst[2*x +2]= (3*src[x+1] + src[x+srcStride ])>>2;
+ }
+#endif
+ dst[srcWidth*2 -1]=
+ dst[srcWidth*2 -1 + dstStride]= src[srcWidth-1];
+
+ dst+=dstStride*2;
+ src+=srcStride;
+ }
+ src-=srcStride;
+
+ // last line
+ for(x=0; x<srcWidth; x++){
+ dst[2*x+0]=
+ dst[2*x+1]= src[x];
+ }
+#ifdef HAVE_MMX
+asm volatile( EMMS" \n\t"
+ SFENCE" \n\t"
+ :::"memory");
+#endif
+}
+
/**
*
* height should be a multiple of 2 and width should be a multiple of 16 (if this is a