Commit 44a1e51a authored by michael's avatar michael

Move dummy picture allocation code from mpeg1/2 to mpegvideo.

This fixes a infinite loop on a b frame.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@20672 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent ee733e43
...@@ -2434,25 +2434,6 @@ static int decode_chunks(AVCodecContext *avctx, ...@@ -2434,25 +2434,6 @@ static int decode_chunks(AVCodecContext *avctx,
return -1; 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) { if (avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) {
s->slice_count++; s->slice_count++;
break; break;
......
...@@ -894,7 +894,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ...@@ -894,7 +894,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
} }
} }
} }
alloc:
if(!s->encoding){ if(!s->encoding){
/* release non reference frames */ /* release non reference frames */
for(i=0; i<MAX_PICTURE_COUNT; i++){ for(i=0; i<MAX_PICTURE_COUNT; i++){
...@@ -946,14 +946,26 @@ alloc: ...@@ -946,14 +946,26 @@ alloc:
s->current_picture_ptr ? s->current_picture_ptr->data[0] : NULL, s->current_picture_ptr ? s->current_picture_ptr->data[0] : NULL,
s->pict_type, s->dropable);*/ s->pict_type, s->dropable);*/
if(s->last_picture_ptr) ff_copy_picture(&s->last_picture, s->last_picture_ptr); if(s->codec_id != CODEC_ID_H264){
if(s->next_picture_ptr) ff_copy_picture(&s->next_picture, s->next_picture_ptr); if((s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && s->pict_type!=FF_I_TYPE){
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"); 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 /* Allocate a dummy frame */
goto alloc; 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);
assert(s->pict_type == FF_I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0])); assert(s->pict_type == FF_I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0]));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment