diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-12-29 22:25:08 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-12-29 22:25:08 +0000 |
commit | 1031fabd14205e1ad2aeb8839f23c20dbcf4fdbe (patch) | |
tree | 5e2f396ddfa284598b0da6eda0c5eb68e5a4f747 /libavcodec | |
parent | 622eb8367b9e8f6d04829051dcec274029f97a80 (diff) | |
download | ffmpeg-1031fabd14205e1ad2aeb8839f23c20dbcf4fdbe.tar.gz |
picture number fixes
Originally committed as revision 2634 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mpegvideo.c | 22 | ||||
-rw-r--r-- | libavcodec/mpegvideo.h | 5 | ||||
-rw-r--r-- | libavcodec/ratecontrol.c | 2 |
3 files changed, 11 insertions, 18 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index e04b14d10d..dae3cd4f82 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -427,6 +427,7 @@ int MPV_common_init(MpegEncContext *s) if (!s->encoding) s->progressive_sequence= 1; s->progressive_frame= 1; + s->coded_picture_number = 0; y_size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); c_size = (s->mb_width + 2) * (s->mb_height + 2); @@ -975,6 +976,7 @@ int MPV_encode_init(AVCodecContext *avctx) return -1; s->picture_number = 0; + s->input_picture_number = 0; s->picture_in_gop_number = 0; s->fake_picture_number = 0; /* motion detector init */ @@ -1153,8 +1155,7 @@ alloc: pic->reference= s->pict_type != B_TYPE ? 3 : 0; - if(s->current_picture_ptr) //FIXME broken, we need a coded_picture_number in MpegEncContext - pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1; + pic->coded_picture_number= s->coded_picture_number++; if( alloc_picture(s, (Picture*)pic, 0) < 0) return -1; @@ -1644,9 +1645,7 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){ } copy_picture_attributes(pic, pic_arg); - if(s->input_picture[encoding_delay]) - pic->display_picture_number= s->input_picture[encoding_delay]->display_picture_number + 1; - + pic->display_picture_number= s->input_picture_number++; } /* shift buffer entries */ @@ -1660,10 +1659,6 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){ static void select_input_picture(MpegEncContext *s){ int i; - int coded_pic_num=0; - - if(s->reordered_input_picture[0]) - coded_pic_num= s->reordered_input_picture[0]->coded_picture_number + 1; for(i=1; i<MAX_PICTURE_COUNT; i++) s->reordered_input_picture[i-1]= s->reordered_input_picture[i]; @@ -1674,7 +1669,7 @@ static void select_input_picture(MpegEncContext *s){ if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){ s->reordered_input_picture[0]= s->input_picture[0]; s->reordered_input_picture[0]->pict_type= I_TYPE; - s->reordered_input_picture[0]->coded_picture_number= coded_pic_num; + s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; }else{ int b_frames; @@ -1735,12 +1730,11 @@ static void select_input_picture(MpegEncContext *s){ s->reordered_input_picture[0]->pict_type= I_TYPE; else s->reordered_input_picture[0]->pict_type= P_TYPE; - s->reordered_input_picture[0]->coded_picture_number= coded_pic_num; + s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; for(i=0; i<b_frames; i++){ - coded_pic_num++; s->reordered_input_picture[i+1]= s->input_picture[i]; s->reordered_input_picture[i+1]->pict_type= B_TYPE; - s->reordered_input_picture[i+1]->coded_picture_number= coded_pic_num; + s->reordered_input_picture[i+1]->coded_picture_number= s->coded_picture_number++; } } } @@ -1839,8 +1833,6 @@ int MPV_encode_picture(AVCodecContext *avctx, } } - s->input_picture_number++; - flush_put_bits(&s->pb); s->frame_bits = (pbBufPtr(&s->pb) - s->pb.buf) * 8; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 4fe388ec40..39461f7e32 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -260,8 +260,9 @@ typedef struct MpegEncContext { /* sequence parameters */ int context_initialized; - int input_picture_number; - int picture_number; + int input_picture_number; ///< used to set pic->display_picture_number, shouldnt be used for/by anything else + int coded_picture_number; ///< used to set pic->coded_picture_number, shouldnt be used for/by anything else + int picture_number; //FIXME remove, unclear definition int picture_in_gop_number; ///< 0-> first pic in gop, ... int b_frames_since_non_b; ///< used for encoding, relative to not yet reordered input int mb_width, mb_height; ///< number of MBs horizontally & vertically diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 6247315b1d..955290e44b 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -39,7 +39,7 @@ static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_f void ff_write_pass1_stats(MpegEncContext *s){ sprintf(s->avctx->stats_out, "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d;\n", - s->picture_number, s->input_picture_number - s->max_b_frames, s->pict_type, + s->current_picture_ptr->display_picture_number, s->current_picture_ptr->coded_picture_number, s->pict_type, s->current_picture.quality, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits, s->f_code, s->b_code, s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count); } |