diff postproc/rgb2rgb_template.c @ 11068:f33f908ae085

uyvy output support in swscaler
author alex
date Thu, 09 Oct 2003 22:25:53 +0000
parents a32fb6812221
children 3254b413ef1c
line wrap: on
line diff
--- a/postproc/rgb2rgb_template.c	Thu Oct 09 22:24:07 2003 +0000
+++ b/postproc/rgb2rgb_template.c	Thu Oct 09 22:25:53 2003 +0000
@@ -1568,6 +1568,64 @@
 	RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);
 }
 
+static inline void RENAME(yuvPlanartouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
+	unsigned int width, unsigned int height,
+	int lumStride, int chromStride, int dstStride, int vertLumPerChroma)
+{
+	unsigned y;
+	const unsigned chromWidth= width>>1;
+	for(y=0; y<height; y++)
+	{
+#if __WORDSIZE >= 64
+		int i;
+		uint64_t *ldst = (uint64_t *) dst;
+		const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
+		for(i = 0; i < chromWidth; i += 2){
+			uint64_t k, l;
+			k = uc[0] + (yc[0] << 8) +
+			    (vc[0] << 16) + (yc[1] << 24);
+			l = uc[1] + (yc[2] << 8) +
+			    (vc[1] << 16) + (yc[3] << 24);
+			*ldst++ = k + (l << 32);
+			yc += 4;
+			uc += 2;
+			vc += 2;
+		}
+
+#else
+		int i, *idst = (int32_t *) dst;
+		const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
+		for(i = 0; i < chromWidth; i++){
+			*idst++ = uc[0] + (yc[0] << 8) +
+			    (vc[0] << 16) + (yc[1] << 24);
+			yc += 2;
+			uc++;
+			vc++;
+		}
+#endif
+		if((y&(vertLumPerChroma-1))==(vertLumPerChroma-1) )
+		{
+			usrc += chromStride;
+			vsrc += chromStride;
+		}
+		ysrc += lumStride;
+		dst += dstStride;
+	}
+}
+
+/**
+ *
+ * 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)
+ */
+static inline void RENAME(yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
+	unsigned int width, unsigned int height,
+	int lumStride, int chromStride, int dstStride)
+{
+	//FIXME interpolate chroma
+	RENAME(yuvPlanartouyvy)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);
+}
+
 /**
  *
  * width should be a multiple of 16