changeset 3646:3f25f07f4e92

Cinepak YUY2 support
author arpi
date Fri, 21 Dec 2001 17:49:31 +0000
parents 7e4ace9675b4
children 6ed77f4d208e
files cinepak.c dec_video.c etc/codecs.conf
diffstat 3 files changed, 91 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cinepak.c	Fri Dec 21 17:38:55 2001 +0000
+++ b/cinepak.c	Fri Dec 21 17:49:31 2001 +0000
@@ -52,6 +52,88 @@
 
 
 /* ---------------------------------------------------------------------- */
+static inline void read_codebook_yuy2(cvid_codebook *c, int mode)
+{
+
+	if(mode)		/* black and white */
+		{
+		c->y0 = get_byte();
+		c->y1 = get_byte();
+		c->y2 = get_byte();
+		c->y3 = get_byte();
+		c->u = c->v = 128;
+		}
+	else			/* colour */
+		{
+		c->y0 = get_byte();  /* luma */
+		c->y1 = get_byte();
+		c->y2 = get_byte();
+		c->y3 = get_byte();
+		c->u = 128+get_byte(); /* chroma */
+		c->v = 128+get_byte();
+		}
+}
+
+//#define PACK_YUV(cb,y0,y1,u,v) ((cb->y0<<24)|(((unsigned char)cb->u)<<16)|(cb->y1<<8)|(((unsigned char)cb->v)))
+#define PACK_YUV(cb,y0,y1,u,v) ((((unsigned char)cb->v)<<24)|(cb->y1<<16)|(((unsigned char)cb->u)<<8)|(cb->y0))
+
+#define TO_YUY2_U0(cb) PACK_YUV(cb,y0,y0,u,v)
+#define TO_YUY2_U1(cb) PACK_YUV(cb,y1,y1,u,v)
+#define TO_YUY2_L0(cb) PACK_YUV(cb,y2,y2,u,v)
+#define TO_YUY2_L1(cb) PACK_YUV(cb,y3,y3,u,v)
+
+#define TO_YUY2_U(cb) PACK_YUV(cb,y0,y1,u,v)
+#define TO_YUY2_L(cb) PACK_YUV(cb,y2,y3,u,v)
+
+/* ------------------------------------------------------------------------ */
+inline void cvid_v1_yuy2(unsigned char *frm, unsigned char *end, int stride, cvid_codebook *cb)
+{
+unsigned long *vptr = (unsigned long *)frm, rgb;
+int row_inc = stride/4;
+
+	vptr[0] = TO_YUY2_U0(cb);
+	vptr[1] = TO_YUY2_U1(cb);
+	vptr += row_inc; if(vptr > (unsigned long *)end) return;
+
+	vptr[0] = TO_YUY2_U0(cb);
+	vptr[1] = TO_YUY2_U1(cb);
+	vptr += row_inc; if(vptr > (unsigned long *)end) return;
+
+	vptr[0] = TO_YUY2_L0(cb);
+	vptr[1] = TO_YUY2_L1(cb);
+	vptr += row_inc; if(vptr > (unsigned long *)end) return;
+
+	vptr[0] = TO_YUY2_L0(cb);
+	vptr[1] = TO_YUY2_L1(cb);
+}
+
+
+/* ------------------------------------------------------------------------ */
+inline void cvid_v4_yuy2(unsigned char *frm, unsigned char *end, int stride, cvid_codebook *cb0,
+	cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3)
+{
+unsigned long *vptr = (unsigned long *)frm;
+int row_inc = stride/4;
+
+	vptr[0] = TO_YUY2_U(cb0);
+	vptr[1] = TO_YUY2_U(cb1);
+	vptr += row_inc; if(vptr > (unsigned long *)end) return;
+
+	vptr[0] = TO_YUY2_L(cb0);
+	vptr[1] = TO_YUY2_L(cb1);
+	vptr += row_inc; if(vptr > (unsigned long *)end) return;
+
+	vptr[0] = TO_YUY2_U(cb2);
+	vptr[1] = TO_YUY2_U(cb3);
+	vptr += row_inc; if(vptr > (unsigned long *)end) return;
+
+	vptr[0] = TO_YUY2_L(cb2);
+	vptr[1] = TO_YUY2_L(cb3);
+
+}
+
+
+/* ---------------------------------------------------------------------- */
 static inline void read_codebook_32(cvid_codebook *c, int mode)
 {
 int uvr, uvg, uvb;
@@ -139,6 +221,7 @@
 }
 
 
+
 /* ---------------------------------------------------------------------- */
 static inline void read_codebook_24(cvid_codebook *c, int mode)
 {
@@ -294,6 +377,12 @@
 
 	switch(bit_per_pixel)
 		{
+		case 16:
+			bpp = 2;
+			read_codebook = read_codebook_yuy2;
+			cvid_v1 = cvid_v1_yuy2;
+			cvid_v4 = cvid_v4_yuy2;
+			break;
 		case 24:
 			bpp = 3;
 			read_codebook = read_codebook_24;
--- a/dec_video.c	Fri Dec 21 17:38:55 2001 +0000
+++ b/dec_video.c	Fri Dec 21 17:49:31 2001 +0000
@@ -564,7 +564,7 @@
 switch(sh_video->codec->driver){
  case VFM_CINEPAK:
    decode_cinepak(sh_video->context, start, in_size, sh_video->our_out_buffer,
-      sh_video->disp_w, sh_video->disp_h, out_fmt&255);
+      sh_video->disp_w, sh_video->disp_h, (out_fmt==IMGFMT_YUY2)?16:(out_fmt&255));
    blit_frame = 3;
    break;
 #ifdef USE_XANIM
--- a/etc/codecs.conf	Fri Dec 21 17:38:55 2001 +0000
+++ b/etc/codecs.conf	Fri Dec 21 17:49:31 2001 +0000
@@ -266,6 +266,7 @@
   status working
   fourcc cvid,CVID
   driver cinepak
+  out YUY2
   out BGR32,BGR24
 
 videocodec msrle