changeset 10438:710e226783f0 libavcodec

Flip (M)JPEG frames encoded by Intel JPEG library. Fixes issues 1464 and 1468.
author cehoyos
date Mon, 19 Oct 2009 15:41:28 +0000
parents 00bd0c4c1489
children b4b55a3d65c9
files mjpegdec.c mjpegdec.h
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mjpegdec.c	Mon Oct 19 15:14:00 2009 +0000
+++ b/mjpegdec.c	Mon Oct 19 15:41:28 2009 +0000
@@ -105,6 +105,8 @@
             av_log(avctx, AV_LOG_DEBUG, "mjpeg bottom field first\n");
         }
     }
+    if (avctx->codec->id == CODEC_ID_AMV)
+        s->flipped = 1;
 
     return 0;
 }
@@ -773,7 +775,7 @@
         data[c] = s->picture.data[c];
         linesize[c]=s->linesize[c];
         s->coefs_finished[c] |= 1;
-        if(s->avctx->codec->id==CODEC_ID_AMV) {
+        if(s->flipped) {
             //picture should be flipped upside-down for this codec
             assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE));
             data[c] += (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 ));
@@ -1176,6 +1178,9 @@
             else if(!strcmp(cbuf, "CS=ITU601")){
                 s->cs_itu601= 1;
             }
+            else if(len > 20 && !strncmp(cbuf, "Intel(R) JPEG Library", 21)){
+                s->flipped = 1;
+            }
 
             av_free(cbuf);
         }
--- a/mjpegdec.h	Mon Oct 19 15:14:00 2009 +0000
+++ b/mjpegdec.h	Mon Oct 19 15:41:28 2009 +0000
@@ -101,6 +101,7 @@
     int mjpb_skiptosod;
 
     int cur_scan; /* current scan, used by JPEG-LS */
+    int flipped; /* true if picture is flipped */
 } MJpegDecodeContext;
 
 int ff_mjpeg_decode_init(AVCodecContext *avctx);