# HG changeset patch # User melanson # Date 1017118990 0 # Node ID eea0213d64c8d5f65196cb83c39c33997ff275d9 # Parent d59e27f2f5be29269c15576d4397538ce7c2d1a9 added YUY2 output to the widely used (heh) CYUV decoder because it seemed like a good idea...isn't YUY2 better supported that UYVY? diff -r d59e27f2f5be -r eea0213d64c8 cyuv.c --- a/cyuv.c Tue Mar 26 04:41:43 2002 +0000 +++ b/cyuv.c Tue Mar 26 05:03:10 2002 +0000 @@ -21,6 +21,8 @@ #include #include +#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; + } } } diff -r d59e27f2f5be -r eea0213d64c8 etc/codecs.conf --- a/etc/codecs.conf Tue Mar 26 04:41:43 2002 +0000 +++ b/etc/codecs.conf Tue Mar 26 05:03:10 2002 +0000 @@ -343,6 +343,7 @@ status working fourcc cyuv,CYUV driver cyuv + out YUY2 out UYVY videocodec qtsmc diff -r d59e27f2f5be -r eea0213d64c8 libmpcodecs/vd_cyuv.c --- a/libmpcodecs/vd_cyuv.c Tue Mar 26 04:41:43 2002 +0000 +++ b/libmpcodecs/vd_cyuv.c Tue Mar 26 05:03:10 2002 +0000 @@ -39,7 +39,7 @@ unsigned char *frame, int width, int height, - int bit_per_pixel); + int format); // decode a frame static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ @@ -50,7 +50,8 @@ sh->disp_w, sh->disp_h); if(!mpi) return NULL; - decode_cyuv(data, len, mpi->planes[0], sh->disp_w, sh->disp_h, 0); + decode_cyuv(data, len, mpi->planes[0], sh->disp_w, sh->disp_h, + sh->codec->outfmt[sh->outfmtidx]); return mpi; }