[FFmpeg-devel] [PATCH] JPEG interlaced error resilience

Reimar Döffinger Reimar.Doeffinger
Sun Aug 2 10:04:39 CEST 2009


Hello,
currently when FFmpeg encounters a broken interlaced JPEG where only the
second part is available, it decodes nothing at all.
This patch changes the behaviour to make it still decode the second half
(e.g. the odd lines).
Currently the only real source of such broken JPEGs is the MJPEG parser which
incorrectly splits all interlaced JPEGs into two packets.
While with ffplay this makes the output of e.g. issue 1276, that is only
by chance an is not fixed by this patch.
Index: libavcodec/mjpegdec.c
===================================================================
--- libavcodec/mjpegdec.c	(revision 19557)
+++ libavcodec/mjpegdec.c	(working copy)
@@ -281,8 +281,11 @@
         s->first_picture = 0;
     }
 
-    if(s->interlaced && (s->bottom_field == !s->interlace_polarity))
+    if(s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
+        if (s->got_picture) // just second part of interlaced JPEG
         return 0;
+        av_log(s->avctx, AV_LOG_WARNING, "Interlaced JPEG starting with second field\n");
+    }
 
     /* XXX: not complete test ! */
     pix_fmt_id = (s->h_count[0] << 28) | (s->v_count[0] << 24) |




More information about the ffmpeg-devel mailing list