]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/rawdec.c
correctly interleave audio and video according to specs
[ffmpeg] / libavcodec / rawdec.c
index 6039f132320b49be8176522e186573cea90d8e19..db44f0c8b483e08d9a88087398edcd6c68a97bf6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Raw Video Decoder
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file rawdec.c
+ * @file libavcodec/rawdec.c
  * Raw Video Decoder
  */
 
@@ -30,6 +30,7 @@
 typedef struct RawVideoContext {
     unsigned char * buffer;  /* block of memory for holding one frame */
     int             length;  /* number of bytes in buffer */
+    int flip;
     AVFrame pic;             ///< AVCodecContext.coded_frame
 } RawVideoContext;
 
@@ -40,7 +41,7 @@ static const PixelFormatTag pixelFormatBpsAVI[] = {
     { PIX_FMT_RGB555, 16 },
     { PIX_FMT_BGR24,  24 },
     { PIX_FMT_RGB32,  32 },
-    { -1, 0 },
+    { PIX_FMT_NONE, 0 },
 };
 
 static const PixelFormatTag pixelFormatBpsMOV[] = {
@@ -51,10 +52,10 @@ static const PixelFormatTag pixelFormatBpsMOV[] = {
     { PIX_FMT_BGR555,   16 },
     { PIX_FMT_RGB24,    24 },
     { PIX_FMT_BGR32_1,  32 },
-    { -1, 0 },
+    { PIX_FMT_NONE, 0 },
 };
 
-static int findPixelFormat(const PixelFormatTag *tags, unsigned int fourcc)
+static enum PixelFormat findPixelFormat(const PixelFormatTag *tags, unsigned int fourcc)
 {
     while (tags->pix_fmt >= 0) {
         if (tags->fourcc == fourcc)
@@ -85,14 +86,15 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
     if (!context->buffer)
         return -1;
 
+    if(avctx->extradata_size >= 9 && !memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9))
+        context->flip=1;
+
     return 0;
 }
 
 static void flip(AVCodecContext *avctx, AVPicture * picture){
-    if(!avctx->codec_tag && avctx->bits_per_coded_sample && picture->linesize[2]==0){
-        picture->data[0] += picture->linesize[0] * (avctx->height-1);
-        picture->linesize[0] *= -1;
-    }
+    picture->data[0] += picture->linesize[0] * (avctx->height-1);
+    picture->linesize[0] *= -1;
 }
 
 static int raw_decode(AVCodecContext *avctx,
@@ -131,7 +133,8 @@ static int raw_decode(AVCodecContext *avctx,
         avctx->palctrl->palette_changed = 0;
     }
 
-    flip(avctx, picture);
+    if(context->flip)
+        flip(avctx, picture);
 
     if (avctx->codec_tag == MKTAG('Y', 'V', '1', '2'))
     {