[MPlayer-cvslog] r34397 - trunk/libmpcodecs/vd_ffmpeg.c

reimar subversion at mplayerhq.hu
Mon Dec 5 19:08:30 CET 2011


Author: reimar
Date: Mon Dec  5 19:08:29 2011
New Revision: 34397

Log:
Discard frames where the size does not match the AVCodecContext width/height.

This avoids possible crashes on video size changes. The problem
is that we reinitialize the vo on get_buffer but due to codec
delay libavcodec might still return frames with the old size
afterwards, which the vo might no longer be able to handle.
Ideally libavcodec should not show this behaviour, since it
requires that any application using DR1 can handle frames of
different sizes simultaneously - which seems a bit extreme.

Modified:
   trunk/libmpcodecs/vd_ffmpeg.c

Modified: trunk/libmpcodecs/vd_ffmpeg.c
==============================================================================
--- trunk/libmpcodecs/vd_ffmpeg.c	Mon Dec  5 12:38:15 2011	(r34396)
+++ trunk/libmpcodecs/vd_ffmpeg.c	Mon Dec  5 19:08:29 2011	(r34397)
@@ -897,12 +897,18 @@ static mp_image_t *decode(sh_video_t *sh
 
     if(!mpi)
     mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE,
-        avctx->width, avctx->height);
+        pic->width, pic->height);
     if(!mpi){        // temporary!
         mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_MPCODECS_CouldntAllocateImageForCodec);
         return NULL;
     }
 
+    if (mpi->w != pic->width || mpi->h != pic->height ||
+        pic->width != avctx->width || pic->height != avctx->height) {
+        mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Dropping frame with size not matching configured size\n");
+        return NULL;
+    }
+
     if(!dr1){
         mpi->planes[0]=pic->data[0];
         mpi->planes[1]=pic->data[1];


More information about the MPlayer-cvslog mailing list