Mercurial > libavcodec.hg
changeset 10606:9ea5f2f1874f libavcodec
Move dummy picture allocation code from mpeg1/2 to mpegvideo.
This fixes a infinite loop on a b frame.
author | michael |
---|---|
date | Mon, 30 Nov 2009 21:22:01 +0000 |
parents | 2c2827f792a1 |
children | 6e672d7eb297 |
files | mpeg12.c mpegvideo.c |
diffstat | 2 files changed, 19 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/mpeg12.c Mon Nov 30 19:15:19 2009 +0000 +++ b/mpeg12.c Mon Nov 30 21:22:01 2009 +0000 @@ -2434,25 +2434,6 @@ 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;
--- a/mpegvideo.c Mon Nov 30 19:15:19 2009 +0000 +++ b/mpegvideo.c Mon Nov 30 21:22:01 2009 +0000 @@ -894,7 +894,7 @@ } } } -alloc: + if(!s->encoding){ /* release non reference frames */ for(i=0; i<MAX_PICTURE_COUNT; i++){ @@ -946,15 +946,27 @@ 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){