[Mplayer-cvslog] CVS: main cyuv.c,1.1,1.2
Mike Melanson
melanson at mplayer.dev.hu
Tue Mar 26 06:03:12 CET 2002
Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv8283
Modified Files:
cyuv.c
Log Message:
added YUY2 output to the widely used (heh) CYUV decoder because it seemed
like a good idea...isn't YUY2 better supported that UYVY?
Index: cyuv.c
===================================================================
RCS file: /cvsroot/mplayer/main/cyuv.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cyuv.c 4 Jan 2002 05:56:52 -0000 1.1
+++ cyuv.c 26 Mar 2002 05:03:09 -0000 1.2
@@ -21,6 +21,8 @@
#include <sys/types.h>
#include <unistd.h>
+#include "loader/wine/avifmt.h" // for mmioFOURCC macro
+
/* ------------------------------------------------------------------------
* This function decodes a buffer containing a CYUV encoded frame.
*
@@ -29,9 +31,9 @@
* frame - the output frame buffer (UYVY format)
* width - the width of the output frame
* height - the height of the output frame
- * bit_per_pixel - ignored for now: may be used later for conversions.
+ * format - the requested output format
*/
-void decode_cyuv(unsigned char *buf, int size, unsigned char *frame, int width, int height, int bit_per_pixel)
+void decode_cyuv(unsigned char *buf, int size, unsigned char *frame, int width, int height, int format)
{
int i, xpos, ypos, cur_Y = 0, cur_U = 0, cur_V = 0;
char *delta_y_tbl, *delta_c_tbl, *ptr;
@@ -48,38 +50,86 @@
cur_U = *(ptr++);
cur_Y = (cur_U & 0x0f) << 4;
cur_U = cur_U & 0xf0;
- *frame++ = cur_U;
- *frame++ = cur_Y;
+ if (format == mmioFOURCC('Y','U','Y','2'))
+ {
+ *frame++ = cur_Y;
+ *frame++ = cur_U;
+ }
+ else
+ {
+ *frame++ = cur_U;
+ *frame++ = cur_Y;
+ }
cur_V = *(ptr++);
cur_Y = (cur_Y + delta_y_tbl[cur_V & 0x0f]) & 0xff;
cur_V = cur_V & 0xf0;
- *frame++ = cur_V;
- *frame++ = cur_Y;
+ if (format == mmioFOURCC('Y','U','Y','2'))
+ {
+ *frame++ = cur_Y;
+ *frame++ = cur_V;
+ }
+ else
+ {
+ *frame++ = cur_V;
+ *frame++ = cur_Y;
+ }
}
else /* subsequent pixels in scanline */
{
i = *(ptr++);
cur_U = (cur_U + delta_c_tbl[i >> 4]) & 0xff;
cur_Y = (cur_Y + delta_y_tbl[i & 0x0f]) & 0xff;
- *frame++ = cur_U;
- *frame++ = cur_Y;
+ if (format == mmioFOURCC('Y','U','Y','2'))
+ {
+ *frame++ = cur_Y;
+ *frame++ = cur_U;
+ }
+ else
+ {
+ *frame++ = cur_U;
+ *frame++ = cur_Y;
+ }
i = *(ptr++);
cur_V = (cur_V + delta_c_tbl[i >> 4]) & 0xff;
cur_Y = (cur_Y + delta_y_tbl[i & 0x0f]) & 0xff;
- *frame++ = cur_V;
- *frame++ = cur_Y;
+ if (format == mmioFOURCC('Y','U','Y','2'))
+ {
+ *frame++ = cur_Y;
+ *frame++ = cur_V;
+ }
+ else
+ {
+ *frame++ = cur_V;
+ *frame++ = cur_Y;
+ }
}
i = *(ptr++);
cur_Y = (cur_Y + delta_y_tbl[i & 0x0f]) & 0xff;
- *frame++ = cur_U;
- *frame++ = cur_Y;
+ if (format == mmioFOURCC('Y','U','Y','2'))
+ {
+ *frame++ = cur_Y;
+ *frame++ = cur_U;
+ }
+ else
+ {
+ *frame++ = cur_U;
+ *frame++ = cur_Y;
+ }
cur_Y = (cur_Y + delta_y_tbl[i >> 4]) & 0xff;
- *frame++ = cur_V;
- *frame++ = cur_Y;
+ if (format == mmioFOURCC('Y','U','Y','2'))
+ {
+ *frame++ = cur_Y;
+ *frame++ = cur_V;
+ }
+ else
+ {
+ *frame++ = cur_V;
+ *frame++ = cur_Y;
+ }
}
}
More information about the MPlayer-cvslog
mailing list