[FFmpeg-cvslog] r20653 - trunk/libavcodec/mpeg12.c

michael subversion
Sun Nov 29 04:05:11 CET 2009


Author: michael
Date: Sun Nov 29 04:05:11 2009
New Revision: 20653

Log:
Restructure dummy frame allocation.
New code also allocates a dummy frame for an p field after an i field,
previously that could segfault due to reading from NULL+x.

Modified:
   trunk/libavcodec/mpeg12.c

Modified: trunk/libavcodec/mpeg12.c
==============================================================================
--- trunk/libavcodec/mpeg12.c	Sun Nov 29 03:46:49 2009	(r20652)
+++ trunk/libavcodec/mpeg12.c	Sun Nov 29 04:05:11 2009	(r20653)
@@ -2371,14 +2371,8 @@ static int decode_chunks(AVCodecContext 
                 if(s2->last_picture_ptr==NULL){
                 /* Skip B-frames if we do not have reference frames and gop is not closed */
                     if(s2->pict_type==FF_B_TYPE){
-                        int i;
                         if(!s2->closed_gop)
                             break;
-                        /* Allocate a dummy frame */
-                        i= ff_find_unused_picture(s2, 0);
-                        s2->last_picture_ptr= &s2->picture[i];
-                        if(ff_alloc_picture(s2, s2->last_picture_ptr, 0) < 0)
-                            return -1;
                     }
                 }
                 if(s2->next_picture_ptr==NULL){
@@ -2416,6 +2410,25 @@ static int decode_chunks(AVCodecContext 
                     return -1;
                 }
 
+                if(s2->last_picture_ptr==NULL && s2->pict_type!=FF_I_TYPE){
+                    int i;
+                    /* Allocate a dummy frame */
+                    i= ff_find_unused_picture(s2, 0);
+                    s2->last_picture_ptr= &s2->picture[i];
+                    if(ff_alloc_picture(s2, s2->last_picture_ptr, 0) < 0)
+                        return -1;
+                    s2->last_picture= *s2->last_picture_ptr;
+                }
+                if(s2->next_picture_ptr==NULL && s2->pict_type==FF_B_TYPE){
+                    int i;
+                    /* Allocate a dummy frame */
+                    i= ff_find_unused_picture(s2, 0);
+                    s2->next_picture_ptr= &s2->picture[i];
+                    if(ff_alloc_picture(s2, s2->next_picture_ptr, 0) < 0)
+                        return -1;
+                    s2->next_picture= *s2->next_picture_ptr;
+                }
+
                 if (avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) {
                     s->slice_count++;
                     break;



More information about the ffmpeg-cvslog mailing list