comparison mpegvideo.c @ 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 ce2cf9e32b09
children a47f207fe4b5
comparison
equal deleted inserted replaced
10605:2c2827f792a1 10606:9ea5f2f1874f
892 } 892 }
893 } 893 }
894 } 894 }
895 } 895 }
896 } 896 }
897 alloc: 897
898 if(!s->encoding){ 898 if(!s->encoding){
899 /* release non reference frames */ 899 /* release non reference frames */
900 for(i=0; i<MAX_PICTURE_COUNT; i++){ 900 for(i=0; i<MAX_PICTURE_COUNT; i++){
901 if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){ 901 if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
902 free_frame_buffer(s, &s->picture[i]); 902 free_frame_buffer(s, &s->picture[i]);
944 s->last_picture_ptr ? s->last_picture_ptr->data[0] : NULL, 944 s->last_picture_ptr ? s->last_picture_ptr->data[0] : NULL,
945 s->next_picture_ptr ? s->next_picture_ptr->data[0] : NULL, 945 s->next_picture_ptr ? s->next_picture_ptr->data[0] : NULL,
946 s->current_picture_ptr ? s->current_picture_ptr->data[0] : NULL, 946 s->current_picture_ptr ? s->current_picture_ptr->data[0] : NULL,
947 s->pict_type, s->dropable);*/ 947 s->pict_type, s->dropable);*/
948 948
949 if(s->codec_id != CODEC_ID_H264){
950 if((s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && s->pict_type!=FF_I_TYPE){
951 av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
952 /* Allocate a dummy frame */
953 i= ff_find_unused_picture(s, 0);
954 s->last_picture_ptr= &s->picture[i];
955 if(ff_alloc_picture(s, s->last_picture_ptr, 0) < 0)
956 return -1;
957 }
958 if((s->next_picture_ptr==NULL || s->next_picture_ptr->data[0]==NULL) && s->pict_type==FF_B_TYPE){
959 /* Allocate a dummy frame */
960 i= ff_find_unused_picture(s, 0);
961 s->next_picture_ptr= &s->picture[i];
962 if(ff_alloc_picture(s, s->next_picture_ptr, 0) < 0)
963 return -1;
964 }
965 }
966
949 if(s->last_picture_ptr) ff_copy_picture(&s->last_picture, s->last_picture_ptr); 967 if(s->last_picture_ptr) ff_copy_picture(&s->last_picture, s->last_picture_ptr);
950 if(s->next_picture_ptr) ff_copy_picture(&s->next_picture, s->next_picture_ptr); 968 if(s->next_picture_ptr) ff_copy_picture(&s->next_picture, s->next_picture_ptr);
951
952 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){
953 av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
954 assert(s->pict_type != FF_B_TYPE); //these should have been dropped if we don't have a reference
955 goto alloc;
956 }
957 969
958 assert(s->pict_type == FF_I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0])); 970 assert(s->pict_type == FF_I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0]));
959 971
960 if(s->picture_structure!=PICT_FRAME && s->out_format != FMT_H264){ 972 if(s->picture_structure!=PICT_FRAME && s->out_format != FMT_H264){
961 int i; 973 int i;