# HG changeset patch # User michael # Date 1077674750 0 # Node ID 7ae26b6e197f86e23402b24abe5ae3d38f4c03b4 # Parent bc8f5e1635b93de4bf166a5a5f246e05598cc01f set AVFrame.pts based upon framerate if its 0 detect & warn if the user prvides pts only for some frames, and try to guess the missing ones diff -r bc8f5e1635b9 -r 7ae26b6e197f h263.c --- a/h263.c Mon Feb 23 21:18:29 2004 +0000 +++ b/h263.c Wed Feb 25 02:05:50 2004 +0000 @@ -2156,10 +2156,9 @@ void ff_set_mpeg4_time(MpegEncContext * s, int picture_number){ int time_div, time_mod; - if(s->current_picture_ptr->pts) - s->time= (s->current_picture_ptr->pts*s->time_increment_resolution + 500*1000)/(1000*1000); - else - s->time= av_rescale(picture_number*(int64_t)s->avctx->frame_rate_base, s->time_increment_resolution, s->avctx->frame_rate); + assert(s->current_picture_ptr->pts); + s->time= (s->current_picture_ptr->pts*s->time_increment_resolution + 500*1000)/(1000*1000); + time_div= s->time/s->time_increment_resolution; time_mod= s->time%s->time_increment_resolution; diff -r bc8f5e1635b9 -r 7ae26b6e197f mpegvideo.c --- a/mpegvideo.c Mon Feb 23 21:18:29 2004 +0000 +++ b/mpegvideo.c Wed Feb 25 02:05:50 2004 +0000 @@ -1850,8 +1850,18 @@ copy_picture_attributes(pic, pic_arg); pic->display_picture_number= s->input_picture_number++; + if(pic->pts){ + s->user_specified_pts= pic->pts; + }else{ + if(s->user_specified_pts){ + pic->pts= s->user_specified_pts + 1000ULL*1000ULL*s->avctx->frame_rate_base / s->avctx->frame_rate; + av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=0 trying to guess (%Ld)\n", pic->pts); + }else{ + pic->pts= av_rescale(pic->display_picture_number*(int64_t)s->avctx->frame_rate_base, 1000*1000, s->avctx->frame_rate); + } + } } - + /* shift buffer entries */ for(i=1; iencoding_delay+1*/; i++) s->input_picture[i-1]= s->input_picture[i]; diff -r bc8f5e1635b9 -r 7ae26b6e197f mpegvideo.h --- a/mpegvideo.h Mon Feb 23 21:18:29 2004 +0000 +++ b/mpegvideo.h Wed Feb 25 02:05:50 2004 +0000 @@ -275,6 +275,7 @@ 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 + int64_t user_specified_pts;///< last non zero pts from AVFrame which was passed into avcodec_encode_video() int mb_width, mb_height; ///< number of MBs horizontally & vertically int mb_stride; ///< mb_width+1 used for some arrays to allow simple addressng of left & top MBs withoutt sig11 int b8_stride; ///< 2*mb_width+1 used for some 8x8 block arrays to allow simple addressng