[FFmpeg-cvslog] mjpegdec: support AVRn interlaced

Michael Niedermayer git at videolan.org
Fri Aug 10 15:56:35 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Aug 10 15:47:07 2012 +0200| [d9d0c1ccc3df39fecbbbb6b600c18542741c5a51] | committer: Michael Niedermayer

mjpegdec: support AVRn interlaced

Fixes Ticket1527
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d9d0c1ccc3df39fecbbbb6b600c18542741c5a51
---

 libavcodec/mjpegdec.c |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 37e5fd6..4fb2f3e 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1209,9 +1209,6 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask,
     }else
         prev_shift = point_transform = 0;
 
-    for (i = 0; i < nb_components; i++)
-        s->last_dc[i] = 1024;
-
     if (nb_components > 1) {
         /* interleaved stream */
         s->mb_width  = (s->width  + s->h_max * block_size - 1) / (s->h_max * block_size);
@@ -1236,6 +1233,9 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask,
     /* mjpeg-b can have padding bytes between sos and image data, skip them */
     for (i = s->mjpb_skiptosod; i > 0; i--)
         skip_bits(&s->gb, 8);
+next_field:
+    for (i = 0; i < nb_components; i++)
+        s->last_dc[i] = 1024;
 
     if (s->lossless) {
         av_assert0(s->picture_ptr == &s->picture);
@@ -1266,6 +1266,19 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask,
                 return -1;
         }
     }
+    if(s->interlaced && get_bits_left(&s->gb) > 32 && show_bits(&s->gb, 8) == 0xFF) {
+        GetBitContext bak= s->gb;
+        align_get_bits(&bak);
+        if(show_bits(&bak, 16) == 0xFFD1) {
+            av_log(s->avctx, AV_LOG_DEBUG, "AVRn ingterlaced picture\n");
+            s->gb = bak;
+            skip_bits(&s->gb, 16);
+            s->bottom_field ^= 1;
+
+            goto next_field;
+        }
+    }
+
     emms_c();
     return 0;
  out_of_range:



More information about the ffmpeg-cvslog mailing list