[Ffmpeg-devel] [PATCH] mjpeg decoder, mplayer mf://*.jpg

Reimar Döffinger Reimar.Doeffinger
Tue Jul 19 13:36:34 CEST 2005


Hi,
using
mplayer -fps 1 mf://*.jpg
on the files from http://www.mplayerhq.hu/MPlayer/incoming/mf_jpeg_prob
does not work.
The attached patch fixes it, though i have no idea if it is correct for
all MJPEG files (I guess it could be made dependant on the IJPG fourcc
if necessary).
It resets the restart_count to 0 at the beginning of every frame. I
think that restart_interval should probably be reset as well, but it was
at least not necessary for these samples.
I added the memset to the decode_init function since I find it very
irritating that currently
mjpeg_decode_end(avctx);
mjpeg_decode_init(avctx);
does not reset all the state - actually it even leads to a crash, since
e.g. s->qscale_table is freed, but not set to 0, so you get a double free.

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavcodec/mjpeg.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mjpeg.c,v
retrieving revision 1.111
diff -u -r1.111 mjpeg.c
--- libavcodec/mjpeg.c	17 Jul 2005 12:56:56 -0000	1.111
+++ libavcodec/mjpeg.c	19 Jul 2005 11:33:41 -0000
@@ -882,6 +882,7 @@
 {
     MJpegDecodeContext *s = avctx->priv_data;
     MpegEncContext s2;
+    memset(s, 0, sizeof(MJpegDecodeContext));
 
     s->avctx = avctx;
 
@@ -1822,6 +1823,8 @@
     int start_code;
     AVFrame *picture = data;
 
+    s->restart_interval = 0;
+    s->restart_count = 0;
     buf_ptr = buf;
     buf_end = buf + buf_size;
     while (buf_ptr < buf_end) {



More information about the ffmpeg-devel mailing list