diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2007-07-10 14:37:33 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2007-07-10 14:37:33 +0000 |
commit | 7da31a80b7790267db27a9da052683285ecb3ac3 (patch) | |
tree | 4ef3b1e573b0a707d8ebb56c0b27914b4a430864 /libavcodec/mpegvideo_enc.c | |
parent | 153696a663a04586f4662c10f8dee2bd741345b8 (diff) | |
download | ffmpeg-7da31a80b7790267db27a9da052683285ecb3ac3.tar.gz |
Split ff_set_mpeg4_time() and move the non mpeg4 specific part
into mpegvideo_enc.c.
Originally committed as revision 9577 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpegvideo_enc.c')
-rw-r--r-- | libavcodec/mpegvideo_enc.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 4f933a6997..f7d6896940 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2671,6 +2671,21 @@ static int estimate_qp(MpegEncContext *s, int dry_run){ return 0; } +/* must be called before writing the header */ +static void set_frame_distances(MpegEncContext * s){ + assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE); + s->time= s->current_picture_ptr->pts*s->avctx->time_base.num; + + if(s->pict_type==B_TYPE){ + s->pb_time= s->pp_time - (s->last_non_b_time - s->time); + assert(s->pb_time > 0 && s->pb_time < s->pp_time); + }else{ + s->pp_time= s->time - s->last_non_b_time; + s->last_non_b_time= s->time; + assert(s->picture_number==0 || s->pp_time > 0); + } +} + static int encode_picture(MpegEncContext *s, int picture_number) { int i; @@ -2685,7 +2700,9 @@ static int encode_picture(MpegEncContext *s, int picture_number) /* we need to initialize some time vars before we can encode b-frames */ // RAL: Condition added for MPEG1VIDEO if (s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->h263_msmpeg4)) - ff_set_mpeg4_time(s, s->picture_number); //FIXME rename and use has_b_frames or similar + set_frame_distances(s); + if(ENABLE_MPEG4_ENCODER && s->codec_id == CODEC_ID_MPEG4) + ff_set_mpeg4_time(s); s->me.scene_change_score=0; |