changeset 2375:24d3a50d1b8b libavcodec

raw rgb flip fix
author michael
date Tue, 30 Nov 2004 21:50:16 +0000
parents b36811e1386a
children ed9bb4a45afa
files raw.c
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/raw.c	Sun Nov 28 19:19:39 2004 +0000
+++ b/raw.c	Tue Nov 30 21:50:16 2004 +0000
@@ -106,6 +106,13 @@
     return 0;
 }
 
+static void flip(AVCodecContext *avctx, AVPicture * picture){
+    if(!avctx->codec_tag && avctx->bits_per_sample && picture->linesize[1]==0){
+        picture->data[0] += picture->linesize[0] * (avctx->height-1);
+        picture->linesize[0] *= -1;
+    }
+}
+
 static int raw_decode(AVCodecContext *avctx,
 			    void *data, int *data_size,
 			    uint8_t *buf, int buf_size)
@@ -118,6 +125,7 @@
     /* Early out without copy if packet size == frame size */
     if (buf_size == context->length  &&  context->p == context->buffer) {
         avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height);
+        flip(avctx, picture);        
         *data_size = sizeof(AVPicture);
         return buf_size;
     }
@@ -132,6 +140,7 @@
     memcpy(context->p, buf, bytesNeeded);
     context->p = context->buffer;
     avpicture_fill(picture, context->buffer, avctx->pix_fmt, avctx->width, avctx->height);
+    flip(avctx, picture);        
     *data_size = sizeof(AVPicture);
     return bytesNeeded;
 }