diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2009-11-29 06:05:11 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2009-11-29 06:05:11 +0300 |
commit | d9b99556bfa9388d3d61b92dd22853e05a1ea428 (patch) | |
tree | e27bd0fa0e441c2a7777fac9b3dca619d94f87e5 /libavcodec/mpeg12.c | |
parent | 729ef3ba6205d99de29a3f279890759af414bcb8 (diff) |
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.
Originally committed as revision 20653 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpeg12.c')
-rw-r--r-- | libavcodec/mpeg12.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 196930c463..7e2d1ba9d2 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -2371,14 +2371,8 @@ static int decode_chunks(AVCodecContext *avctx, 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 *avctx, 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; |