Mercurial > libavcodec.hg
diff mpegvideo.c @ 1168:5af9aeadbdc3 libavcodec
H264 decoder & demuxer
author | michaelni |
---|---|
date | Fri, 04 Apr 2003 14:42:28 +0000 |
parents | f0c39139426d |
children | 86d5a33eaec8 |
line wrap: on
line diff
--- a/mpegvideo.c Fri Apr 04 13:45:45 2003 +0000 +++ b/mpegvideo.c Fri Apr 04 14:42:28 2003 +0000 @@ -227,7 +227,9 @@ * The pixels are allocated/set by calling get_buffer() if shared=0 */ static int alloc_picture(MpegEncContext *s, Picture *pic, int shared){ - + const int big_mb_num= (s->mb_width+1)*(s->mb_height+1); + int i; + if(shared){ assert(pic->data[0]); assert(pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED); @@ -268,9 +270,17 @@ CHECKED_ALLOCZ(pic->mbskip_table , s->mb_num * sizeof(uint8_t)+1) //the +1 is for the slice end check CHECKED_ALLOCZ(pic->qscale_table , s->mb_num * sizeof(uint8_t)) + if(s->out_format == FMT_H264){ + CHECKED_ALLOCZ(pic->mb_type_base , big_mb_num * sizeof(uint16_t)) + pic->mb_type= pic->mb_type_base + s->mb_width+2; + for(i=0; i<2; i++){ + CHECKED_ALLOCZ(pic->motion_val[i], 2 * 16 * s->mb_num * sizeof(uint16_t)) + CHECKED_ALLOCZ(pic->ref_index[i] , 4 * s->mb_num * sizeof(uint8_t)) + } + } pic->qstride= s->mb_width; } - + //it might be nicer if the application would keep track of these but it would require a API change memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1); s->prev_pict_types[0]= s->pict_type; @@ -298,7 +308,13 @@ av_freep(&pic->mb_cmp_score); av_freep(&pic->mbskip_table); av_freep(&pic->qscale_table); - + av_freep(&pic->mb_type_base); + pic->mb_type= NULL; + for(i=0; i<2; i++){ + av_freep(&pic->motion_val[i]); + av_freep(&pic->ref_index[i]); + } + if(pic->type == FF_BUFFER_TYPE_INTERNAL){ for(i=0; i<4; i++){ av_freep(&pic->base[i]); @@ -855,7 +871,7 @@ } }else{ for(i=0; i<MAX_PICTURE_COUNT; i++){ - if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) break; + if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) break; //FIXME } for(i=0; i<MAX_PICTURE_COUNT; i++){ if(s->picture[i].data[0]==NULL) break; @@ -873,7 +889,9 @@ AVFrame *pic; s->mb_skiped = 0; - + + assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264); + /* mark&release old frames */ if (s->pict_type != B_TYPE && s->last_picture_ptr) { avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr); @@ -895,7 +913,7 @@ i= find_unused_picture(s, 0); pic= (AVFrame*)&s->picture[i]; - pic->reference= s->pict_type != B_TYPE; + pic->reference= s->pict_type != B_TYPE ? 3 : 0; if(s->current_picture_ptr) pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1; @@ -905,11 +923,12 @@ s->current_picture_ptr= &s->picture[i]; } + s->current_picture= *s->current_picture_ptr; + if(s->out_format != FMT_H264){ if (s->pict_type != B_TYPE) { s->last_picture_ptr= s->next_picture_ptr; s->next_picture_ptr= s->current_picture_ptr; } - s->current_picture= *s->current_picture_ptr; if(s->last_picture_ptr) s->last_picture= *s->last_picture_ptr; if(s->next_picture_ptr) s->next_picture= *s->next_picture_ptr; if(s->new_picture_ptr ) s->new_picture = *s->new_picture_ptr; @@ -931,6 +950,7 @@ assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference goto alloc; } + } s->hurry_up= s->avctx->hurry_up; s->error_resilience= avctx->error_resilience; @@ -1059,7 +1079,7 @@ i= find_unused_picture(s, 1); pic= (AVFrame*)&s->picture[i]; - pic->reference= 1; + pic->reference= 3; for(i=0; i<4; i++){ pic->data[i]= pic_arg->data[i]; @@ -1070,7 +1090,7 @@ i= find_unused_picture(s, 0); pic= (AVFrame*)&s->picture[i]; - pic->reference= 1; + pic->reference= 3; alloc_picture(s, (Picture*)pic, 0); for(i=0; i<4; i++){ @@ -1215,7 +1235,7 @@ } if(s->reordered_input_picture[0]){ - s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE; + s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE ? 3 : 0; s->new_picture= *s->reordered_input_picture[0]; @@ -3944,6 +3964,8 @@ case P_TYPE: return 'P'; case B_TYPE: return 'B'; case S_TYPE: return 'S'; + case SI_TYPE:return 'i'; + case SP_TYPE:return 'p'; default: return '?'; } }