[Mplayer-cvslog] CVS: main cinepak.c,1.5,1.6
Mike Melanson
melanson at mplayer.dev.hu
Thu Feb 28 06:20:26 CET 2002
Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv7360
Modified Files:
cinepak.c
Log Message:
These changes may fix the Cinepak color issue on PPC when decoding to
BGR32 or YUY2 output data; then again, they may not. The changes have yet
to be fully tested. At the very least, the Cinepak decoder still works on
x86.
Index: cinepak.c
===================================================================
RCS file: /cvsroot/mplayer/main/cinepak.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- cinepak.c 28 Feb 2002 01:12:24 -0000 1.5
+++ cinepak.c 28 Feb 2002 05:20:24 -0000 1.6
@@ -95,37 +95,55 @@
}
}
-//#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;
+int row_inc = stride - 8;
- 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);
+ *frm++ = cb->y0;
+ *frm++ = cb->u;
+ *frm++ = cb->y0;
+ *frm++ = cb->v;
+ *frm++ = cb->y1;
+ *frm++ = cb->u;
+ *frm++ = cb->y1;
+ *frm++ = cb->v;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb->y0;
+ *frm++ = cb->u;
+ *frm++ = cb->y0;
+ *frm++ = cb->v;
+ *frm++ = cb->y1;
+ *frm++ = cb->u;
+ *frm++ = cb->y1;
+ *frm++ = cb->v;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb->y2;
+ *frm++ = cb->u;
+ *frm++ = cb->y2;
+ *frm++ = cb->v;
+ *frm++ = cb->y3;
+ *frm++ = cb->u;
+ *frm++ = cb->y3;
+ *frm++ = cb->v;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb->y2;
+ *frm++ = cb->u;
+ *frm++ = cb->y2;
+ *frm++ = cb->v;
+ *frm++ = cb->y3;
+ *frm++ = cb->u;
+ *frm++ = cb->y3;
+ *frm++ = cb->v;
}
@@ -133,24 +151,52 @@
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);
+ int row_inc = stride - 8;
+ *frm++ = cb0->y0;
+ *frm++ = cb0->u;
+ *frm++ = cb0->y1;
+ *frm++ = cb0->v;
+ *frm++ = cb1->y0;
+ *frm++ = cb1->u;
+ *frm++ = cb1->y1;
+ *frm++ = cb1->v;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb0->y2;
+ *frm++ = cb0->u;
+ *frm++ = cb0->y3;
+ *frm++ = cb0->v;
+ *frm++ = cb1->y2;
+ *frm++ = cb1->u;
+ *frm++ = cb1->y3;
+ *frm++ = cb1->v;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb2->y0;
+ *frm++ = cb2->u;
+ *frm++ = cb2->y1;
+ *frm++ = cb2->v;
+ *frm++ = cb3->y0;
+ *frm++ = cb3->u;
+ *frm++ = cb3->y1;
+ *frm++ = cb3->v;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb2->y2;
+ *frm++ = cb2->u;
+ *frm++ = cb2->y3;
+ *frm++ = cb2->v;
+ *frm++ = cb3->y2;
+ *frm++ = cb3->u;
+ *frm++ = cb3->y3;
+ *frm++ = cb3->v;
}
@@ -185,10 +231,20 @@
uvg = -((c->u+1) >> 1) - c->v;
uvb = c->u << 1;
- c->rgb0 = (uiclp[c->y0 + uvr] << 16) | (uiclp[c->y0 + uvg] << 8) | uiclp[c->y0 + uvb];
- c->rgb1 = (uiclp[c->y1 + uvr] << 16) | (uiclp[c->y1 + uvg] << 8) | uiclp[c->y1 + uvb];
- c->rgb2 = (uiclp[c->y2 + uvr] << 16) | (uiclp[c->y2 + uvg] << 8) | uiclp[c->y2 + uvb];
- c->rgb3 = (uiclp[c->y3 + uvr] << 16) | (uiclp[c->y3 + uvg] << 8) | uiclp[c->y3 + uvb];
+ c->r[0] = uiclp[c->y0 + uvr];
+ c->r[1] = uiclp[c->y1 + uvr];
+ c->r[2] = uiclp[c->y2 + uvr];
+ c->r[3] = uiclp[c->y3 + uvr];
+
+ c->g[0] = uiclp[c->y0 + uvg];
+ c->g[1] = uiclp[c->y1 + uvg];
+ c->g[2] = uiclp[c->y2 + uvg];
+ c->g[3] = uiclp[c->y3 + uvg];
+
+ c->b[0] = uiclp[c->y0 + uvb];
+ c->b[1] = uiclp[c->y1 + uvb];
+ c->b[2] = uiclp[c->y2 + uvb];
+ c->b[3] = uiclp[c->y3 + uvb];
}
}
@@ -196,20 +252,84 @@
/* ------------------------------------------------------------------------ */
inline void cvid_v1_32(unsigned char *frm, unsigned char *end, int stride, cvid_codebook *cb)
{
-unsigned long *vptr = (unsigned long *)frm, rgb;
-int row_inc = stride/4;
+int row_inc = stride - 16;
- vptr[0] = rgb = cb->rgb0; vptr[1] = rgb;
- vptr[2] = rgb = cb->rgb1; vptr[3] = rgb;
- vptr += row_inc; if(vptr > (unsigned long *)end) return;
- vptr[0] = rgb = cb->rgb0; vptr[1] = rgb;
- vptr[2] = rgb = cb->rgb1; vptr[3] = rgb;
- vptr += row_inc; if(vptr > (unsigned long *)end) return;
- vptr[0] = rgb = cb->rgb2; vptr[1] = rgb;
- vptr[2] = rgb = cb->rgb3; vptr[3] = rgb;
- vptr += row_inc; if(vptr > (unsigned long *)end) return;
- vptr[0] = rgb = cb->rgb2; vptr[1] = rgb;
- vptr[2] = rgb = cb->rgb3; vptr[3] = rgb;
+ *frm++ = cb->b[0];
+ *frm++ = cb->g[0];
+ *frm++ = cb->r[0];
+ frm++;
+ *frm++ = cb->b[0];
+ *frm++ = cb->g[0];
+ *frm++ = cb->r[0];
+ frm++;
+ *frm++ = cb->b[1];
+ *frm++ = cb->g[1];
+ *frm++ = cb->r[1];
+ frm++;
+ *frm++ = cb->b[1];
+ *frm++ = cb->g[1];
+ *frm++ = cb->r[1];
+ frm++;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb->b[0];
+ *frm++ = cb->g[0];
+ *frm++ = cb->r[0];
+ frm++;
+ *frm++ = cb->b[0];
+ *frm++ = cb->g[0];
+ *frm++ = cb->r[0];
+ frm++;
+ *frm++ = cb->b[1];
+ *frm++ = cb->g[1];
+ *frm++ = cb->r[1];
+ frm++;
+ *frm++ = cb->b[1];
+ *frm++ = cb->g[1];
+ *frm++ = cb->r[1];
+ frm++;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb->b[2];
+ *frm++ = cb->g[2];
+ *frm++ = cb->r[2];
+ frm++;
+ *frm++ = cb->b[2];
+ *frm++ = cb->g[2];
+ *frm++ = cb->r[2];
+ frm++;
+ *frm++ = cb->b[3];
+ *frm++ = cb->g[3];
+ *frm++ = cb->r[3];
+ frm++;
+ *frm++ = cb->b[3];
+ *frm++ = cb->g[3];
+ *frm++ = cb->r[3];
+ frm++;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb->b[2];
+ *frm++ = cb->g[2];
+ *frm++ = cb->r[2];
+ frm++;
+ *frm++ = cb->b[2];
+ *frm++ = cb->g[2];
+ *frm++ = cb->r[2];
+ frm++;
+ *frm++ = cb->b[3];
+ *frm++ = cb->g[3];
+ *frm++ = cb->r[3];
+ frm++;
+ *frm++ = cb->b[3];
+ *frm++ = cb->g[3];
+ *frm++ = cb->r[3];
+ frm++;
}
@@ -217,28 +337,84 @@
inline void cvid_v4_32(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;
+int row_inc = stride - 16;
- vptr[0] = cb0->rgb0;
- vptr[1] = cb0->rgb1;
- vptr[2] = cb1->rgb0;
- vptr[3] = cb1->rgb1;
- vptr += row_inc; if(vptr > (unsigned long *)end) return;
- vptr[0] = cb0->rgb2;
- vptr[1] = cb0->rgb3;
- vptr[2] = cb1->rgb2;
- vptr[3] = cb1->rgb3;
- vptr += row_inc; if(vptr > (unsigned long *)end) return;
- vptr[0] = cb2->rgb0;
- vptr[1] = cb2->rgb1;
- vptr[2] = cb3->rgb0;
- vptr[3] = cb3->rgb1;
- vptr += row_inc; if(vptr > (unsigned long *)end) return;
- vptr[0] = cb2->rgb2;
- vptr[1] = cb2->rgb3;
- vptr[2] = cb3->rgb2;
- vptr[3] = cb3->rgb3;
+ *frm++ = cb0->b[0];
+ *frm++ = cb0->g[0];
+ *frm++ = cb0->r[0];
+ frm++;
+ *frm++ = cb0->b[1];
+ *frm++ = cb0->g[1];
+ *frm++ = cb0->r[1];
+ frm++;
+ *frm++ = cb1->b[0];
+ *frm++ = cb1->g[0];
+ *frm++ = cb1->r[0];
+ frm++;
+ *frm++ = cb1->b[1];
+ *frm++ = cb1->g[1];
+ *frm++ = cb1->r[1];
+ frm++;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb0->b[2];
+ *frm++ = cb0->g[2];
+ *frm++ = cb0->r[2];
+ frm++;
+ *frm++ = cb0->b[3];
+ *frm++ = cb0->g[3];
+ *frm++ = cb0->r[3];
+ frm++;
+ *frm++ = cb1->b[2];
+ *frm++ = cb1->g[2];
+ *frm++ = cb1->r[2];
+ frm++;
+ *frm++ = cb1->b[3];
+ *frm++ = cb1->g[3];
+ *frm++ = cb1->r[3];
+ frm++;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb2->b[0];
+ *frm++ = cb2->g[0];
+ *frm++ = cb2->r[0];
+ frm++;
+ *frm++ = cb2->b[1];
+ *frm++ = cb2->g[1];
+ *frm++ = cb2->r[1];
+ frm++;
+ *frm++ = cb3->b[0];
+ *frm++ = cb3->g[0];
+ *frm++ = cb3->r[0];
+ frm++;
+ *frm++ = cb3->b[1];
+ *frm++ = cb3->g[1];
+ *frm++ = cb3->r[1];
+ frm++;
+ frm += row_inc;
+ if (frm > end)
+ return;
+
+ *frm++ = cb2->b[2];
+ *frm++ = cb2->g[2];
+ *frm++ = cb2->r[2];
+ frm++;
+ *frm++ = cb2->b[3];
+ *frm++ = cb2->g[3];
+ *frm++ = cb2->r[3];
+ frm++;
+ *frm++ = cb3->b[2];
+ *frm++ = cb3->g[2];
+ *frm++ = cb3->r[2];
+ frm++;
+ *frm++ = cb3->b[3];
+ *frm++ = cb3->g[3];
+ *frm++ = cb3->r[3];
+ frm++;
}
More information about the MPlayer-cvslog
mailing list