summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormelanson <melanson@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-03-26 05:03:10 +0000
committermelanson <melanson@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-03-26 05:03:10 +0000
commit3f5ad4c82b639b3524df447c08be7685d2ca290a (patch)
tree9d4579a9a0bae5c2bdb7a677aa7b23ad40e574de
parent18f583efc750aedeee3a7a64fcd299c6e8ea69c7 (diff)
downloadmpv-3f5ad4c82b639b3524df447c08be7685d2ca290a.tar.bz2
mpv-3f5ad4c82b639b3524df447c08be7685d2ca290a.tar.xz
added YUY2 output to the widely used (heh) CYUV decoder because it seemed
like a good idea...isn't YUY2 better supported that UYVY? git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5352 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--cyuv.c78
-rw-r--r--etc/codecs.conf1
-rw-r--r--libmpcodecs/vd_cyuv.c5
3 files changed, 68 insertions, 16 deletions
diff --git a/cyuv.c b/cyuv.c
index 86d597af7d..3a14ca01d7 100644
--- a/cyuv.c
+++ b/cyuv.c
@@ -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 @@ char *delta_y_tbl, *delta_c_tbl, *ptr;
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 --git a/etc/codecs.conf b/etc/codecs.conf
index f4aa787f19..ad8e7903cc 100644
--- a/etc/codecs.conf
+++ b/etc/codecs.conf
@@ -343,6 +343,7 @@ videocodec cyuv
status working
fourcc cyuv,CYUV
driver cyuv
+ out YUY2
out UYVY
videocodec qtsmc
diff --git a/libmpcodecs/vd_cyuv.c b/libmpcodecs/vd_cyuv.c
index 9e936b0715..b9500a63a2 100644
--- a/libmpcodecs/vd_cyuv.c
+++ b/libmpcodecs/vd_cyuv.c
@@ -39,7 +39,7 @@ void decode_cyuv(
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 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
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;
}