summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2009-11-30 21:22:01 +0000
committerMichael Niedermayer <michaelni@gmx.at>2009-11-30 21:22:01 +0000
commitd52b4abe8b7d58b1680b5ae5fccfcbd50ad98ef0 (patch)
tree1ed07c4099960d1748974a0bed144c8cbae22baf /libavcodec/mpegvideo.c
parentfd1ef13bb4ac13f330178b4c2d67a62d3aaf46d9 (diff)
Move dummy picture allocation code from mpeg1/2 to mpegvideo.
This fixes a infinite loop on a b frame. Originally committed as revision 20672 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r--libavcodec/mpegvideo.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index e62428db58..65f900eb9c 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -894,7 +894,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
}
}
}
-alloc:
+
if(!s->encoding){
/* release non reference frames */
for(i=0; i<MAX_PICTURE_COUNT; i++){
@@ -946,15 +946,27 @@ alloc:
s->current_picture_ptr ? s->current_picture_ptr->data[0] : NULL,
s->pict_type, s->dropable);*/
+ if(s->codec_id != CODEC_ID_H264){
+ if((s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && s->pict_type!=FF_I_TYPE){
+ av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
+ /* Allocate a dummy frame */
+ i= ff_find_unused_picture(s, 0);
+ s->last_picture_ptr= &s->picture[i];
+ if(ff_alloc_picture(s, s->last_picture_ptr, 0) < 0)
+ return -1;
+ }
+ if((s->next_picture_ptr==NULL || s->next_picture_ptr->data[0]==NULL) && s->pict_type==FF_B_TYPE){
+ /* Allocate a dummy frame */
+ i= ff_find_unused_picture(s, 0);
+ s->next_picture_ptr= &s->picture[i];
+ if(ff_alloc_picture(s, s->next_picture_ptr, 0) < 0)
+ return -1;
+ }
+ }
+
if(s->last_picture_ptr) ff_copy_picture(&s->last_picture, s->last_picture_ptr);
if(s->next_picture_ptr) ff_copy_picture(&s->next_picture, s->next_picture_ptr);
- if(s->pict_type != FF_I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && !s->dropable && s->codec_id != CODEC_ID_H264){
- av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
- assert(s->pict_type != FF_B_TYPE); //these should have been dropped if we don't have a reference
- goto alloc;
- }
-
assert(s->pict_type == FF_I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0]));
if(s->picture_structure!=PICT_FRAME && s->out_format != FMT_H264){