[MPlayer-dev-eng] [PATCH] vd_ffmpeg: crash on changing colorspace and extradata handling

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Mar 23 11:40:12 CET 2006


Hi,
attached are to patches to vd_ffmpeg. The first one avoids a crash when
the colorspace changes during decoding (e.g. mf://*.jpg when the jpgs
use different chroma subsampling, like 00.jpg and 04.jpg in incoming).
This is done by properly reinitializing the vo in this case, so that the
get_buffer function returns large enough buffers.
The second patch passes extradata on as default, instead of having this
large list of all codecs that need it. This one may be more reason for
discussion (and testing) I guess.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpcodecs/vd_ffmpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_ffmpeg.c,v
retrieving revision 1.159
diff -u -r1.159 vd_ffmpeg.c
--- libmpcodecs/vd_ffmpeg.c	8 Feb 2006 23:22:29 -0000	1.159
+++ libmpcodecs/vd_ffmpeg.c	23 Mar 2006 09:41:43 -0000
@@ -58,6 +58,7 @@
 typedef struct {
     AVCodecContext *avctx;
     AVFrame *pic;
+    enum PixelFormat pix_fmt;
     float last_aspect;
     int do_slices;
     int do_dr1;
@@ -533,6 +519,7 @@
     if (// aspect != ctx->last_aspect ||
 	width != sh->disp_w  ||
 	height != sh->disp_h ||
+	pix_fmt != ctx->pix_fmt ||
 	!ctx->vo_inited)
     {
 	mp_msg(MSGT_DECVIDEO, MSGL_V, "[ffmpeg] aspect_ratio: %f\n", aspect);
-------------- next part --------------
Index: libmpcodecs/vd_ffmpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_ffmpeg.c,v
retrieving revision 1.159
diff -u -r1.159 vd_ffmpeg.c
--- libmpcodecs/vd_ffmpeg.c	8 Feb 2006 23:22:29 -0000	1.159
+++ libmpcodecs/vd_ffmpeg.c	23 Mar 2006 09:41:43 -0000
@@ -337,6 +338,7 @@
 	}
 #endif
     }
+    else
     if(   sh->format == mmioFOURCC('R', 'V', '1', '0')
        || sh->format == mmioFOURCC('R', 'V', '1', '3')
        || sh->format == mmioFOURCC('R', 'V', '2', '0')
@@ -361,25 +363,15 @@
 
 //        printf("%X %X %d %d\n", extrahdr[0], extrahdr[1]);
     }
-    if (sh->bih && (sh->bih->biSize != sizeof(BITMAPINFOHEADER)) &&
-	(sh->format == mmioFOURCC('M','4','S','2') ||
-	 sh->format == mmioFOURCC('M','P','4','S') ||
-	 sh->format == mmioFOURCC('H','F','Y','U') ||
-	 sh->format == mmioFOURCC('F','F','V','H') ||
-	 sh->format == mmioFOURCC('W','M','V','2') ||
-	 sh->format == mmioFOURCC('W','M','V','3') ||
-	 sh->format == mmioFOURCC('A','S','V','1') ||
-	 sh->format == mmioFOURCC('A','S','V','2') ||
-	 sh->format == mmioFOURCC('V','S','S','H') ||
-	 sh->format == mmioFOURCC('M','S','Z','H') ||
-	 sh->format == mmioFOURCC('Z','L','I','B') ||
-	 sh->format == mmioFOURCC('M','P','4','V') ||
-	 sh->format == mmioFOURCC('F','L','I','C') ||
-	 sh->format == mmioFOURCC('S','N','O','W') ||
-	 sh->format == mmioFOURCC('a','v','c','1') ||
-	 sh->format == mmioFOURCC('L','O','C','O') ||
-	 sh->format == mmioFOURCC('t','h','e','o')
-         ))
+    else
+    if (sh->ImageDesc &&
+	 sh->format == mmioFOURCC('S','V','Q','3')){
+	avctx->extradata_size = (*(int*)sh->ImageDesc) - sizeof(int);
+	avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+	memcpy(avctx->extradata, ((int*)sh->ImageDesc)+1, avctx->extradata_size);
+    }
+    else
+    if (sh->bih && (sh->bih->biSize != sizeof(BITMAPINFOHEADER)))
     {
 	avctx->extradata_size = sh->bih->biSize-sizeof(BITMAPINFOHEADER);
 	avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
@@ -400,12 +392,6 @@
                    min(sh->bih->biClrUsed * 4, AVPALETTE_SIZE));
 	}
 #endif
-    if (sh->ImageDesc &&
-	 sh->format == mmioFOURCC('S','V','Q','3')){
-	avctx->extradata_size = (*(int*)sh->ImageDesc) - sizeof(int);
-	avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
-	memcpy(avctx->extradata, ((int*)sh->ImageDesc)+1, avctx->extradata_size);
-    }
     
     if(sh->bih)
 	avctx->bits_per_sample= sh->bih->biBitCount;


More information about the MPlayer-dev-eng mailing list