]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Map MOV fourcc YUV2 correctly to PIX_FMT_YUYV422.
authorcehoyos <cehoyos@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Thu, 2 Apr 2009 12:15:04 +0000 (12:15 +0000)
committercehoyos <cehoyos@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Thu, 2 Apr 2009 12:15:04 +0000 (12:15 +0000)
Patch by Jai Menon

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@18316 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/raw.c
libavcodec/rawdec.c
libavcodec/rawenc.c
libavformat/isom.c

index 28d6b0129b48d25dd4223c6f2dbc85f9ef2190b3..c79c0125f71872049bb2b4011af59e83c1434e8f 100644 (file)
@@ -51,6 +51,7 @@ const PixelFormatTag ff_raw_pixelFormatTags[] = {
     /* 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 },
index db44f0c8b483e08d9a88087398edcd6c68a97bf6..963e148aa17d0d2e8cec8b784b0a6013bc78e44a 100644 (file)
@@ -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 @@ static int raw_decode(AVCodecContext *avctx,
         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;
 }
index 4e560333e157050ca94fc3373a72266273a732b8..82a543ad468874118fcad27d857827dac337214b 100644 (file)
@@ -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 av_cold int raw_init_encoder(AVCodecContext *avctx)
 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 = {
index b78d65e8fb381cf39dfecddf3752c18007b415e7..a4b89bdf07a520d79bb62ee251395d0bb185b028 100644 (file)
@@ -61,7 +61,7 @@ const AVCodecTag codec_movvideo_tags[] = {
 /*  { CODEC_ID_, MKTAG('I', 'V', '5', '0') }, *//* Indeo 5.0 */
 
     { CODEC_ID_RAWVIDEO, MKTAG('r', 'a', 'w', ' ') }, /* Uncompressed RGB */
-/*  { CODEC_ID_RAWVIDEO, MKTAG('Y', 'u', 'v', '2') }, *//* Uncompressed YUV422 */
+    { CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', '2') }, /* Uncompressed YUV422 */
     { CODEC_ID_RAWVIDEO, MKTAG('A', 'V', 'U', 'I') }, /* YUV with alpha-channel (AVID Uncompressed) */
     { CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') }, /* UNCOMPRESSED 8BIT 4:2:2 */