changeset 9335:c7396480f8e3 libavcodec

Map MOV fourcc YUV2 correctly to PIX_FMT_YUYV422. Patch by Jai Menon
author cehoyos
date Thu, 02 Apr 2009 12:15:04 +0000
parents 44f117042212
children 62940d73e9fe
files raw.c rawdec.c rawenc.c
diffstat 3 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/raw.c	Thu Apr 02 08:53:34 2009 +0000
+++ b/raw.c	Thu Apr 02 12:15:04 2009 +0000
@@ -51,6 +51,7 @@
     /* quicktime */
     { PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') },
     { PIX_FMT_UYVY422, MKTAG('A', 'V', 'U', 'I') }, /* FIXME merge both fields */
+    { PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', '2') },
     { PIX_FMT_PAL8,    MKTAG('W', 'R', 'A', 'W') },
 
     { PIX_FMT_NONE, 0 },
--- a/rawdec.c	Thu Apr 02 08:53:34 2009 +0000
+++ b/rawdec.c	Thu Apr 02 12:15:04 2009 +0000
@@ -26,6 +26,7 @@
 
 #include "avcodec.h"
 #include "raw.h"
+#include "libavutil/intreadwrite.h"
 
 typedef struct RawVideoContext {
     unsigned char * buffer;  /* block of memory for holding one frame */
@@ -144,6 +145,17 @@
         picture->data[2] = tmp;
     }
 
+    if(avctx->codec_tag == AV_RL32("yuv2") &&
+       avctx->pix_fmt   == PIX_FMT_YUYV422) {
+        int x, y;
+        uint8_t *line = picture->data[0];
+        for(y = 0; y < avctx->height; y++) {
+            for(x = 0; x < avctx->width; x++)
+                line[2*x + 1] ^= 0x80;
+            line += picture->linesize[0];
+        }
+    }
+
     *data_size = sizeof(AVPicture);
     return buf_size;
 }
--- a/rawenc.c	Thu Apr 02 08:53:34 2009 +0000
+++ b/rawenc.c	Thu Apr 02 12:15:04 2009 +0000
@@ -26,6 +26,7 @@
 
 #include "avcodec.h"
 #include "raw.h"
+#include "libavutil/intreadwrite.h"
 
 static av_cold int raw_init_encoder(AVCodecContext *avctx)
 {
@@ -40,8 +41,16 @@
 static int raw_encode(AVCodecContext *avctx,
                             unsigned char *frame, int buf_size, void *data)
 {
-    return avpicture_layout((AVPicture *)data, avctx->pix_fmt, avctx->width,
+    int ret = avpicture_layout((AVPicture *)data, avctx->pix_fmt, avctx->width,
                                                avctx->height, frame, buf_size);
+
+    if(avctx->codec_tag == AV_RL32("yuv2") && ret > 0 &&
+       avctx->pix_fmt   == PIX_FMT_YUYV422) {
+        int x;
+        for(x = 1; x < avctx->height*avctx->width*2; x += 2)
+            frame[x] ^= 0x80;
+    }
+    return ret;
 }
 
 AVCodec rawvideo_encoder = {