From 194be1f43ea391eb986732707435176e579265aa Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 18 May 2014 12:12:59 +0200 Subject: lavf: switch to AVStream.time_base as the hint for the muxer timebase Previously, AVStream.codec.time_base was used for that purpose, which was quite confusing for the callers. This change also opens the path for removing AVStream.codec. The change in the lavf-mkv test is due to the native timebase (1/1000) being used instead of the default one (1/90000), so the packets are now sent to the crc muxer in the same order in which they are demuxed (previously some of them got reordered because of inexact timestamp conversion). --- libavformat/avienc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'libavformat/avienc.c') diff --git a/libavformat/avienc.c b/libavformat/avienc.c index 87075d4..417a8e9 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -144,6 +144,7 @@ static int avi_write_header(AVFormatContext *s) AVIOContext *pb = s->pb; int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale; AVCodecContext *video_enc; + AVStream *video_st = NULL; int64_t list1, list2, strh, strf; AVDictionaryEntry *t = NULL; @@ -172,15 +173,18 @@ static int avi_write_header(AVFormatContext *s) for (n = 0; n < s->nb_streams; n++) { AVCodecContext *codec = s->streams[n]->codec; bitrate += codec->bit_rate; - if (codec->codec_type == AVMEDIA_TYPE_VIDEO) + if (codec->codec_type == AVMEDIA_TYPE_VIDEO) { video_enc = codec; + video_st = s->streams[n]; + } } nb_frames = 0; - if (video_enc) - avio_wl32(pb, (uint32_t) (INT64_C(1000000) * video_enc->time_base.num / - video_enc->time_base.den)); + // TODO: should be avg_frame_rate + if (video_st) + avio_wl32(pb, (uint32_t) (INT64_C(1000000) * video_st->time_base.num / + video_st->time_base.den)); else avio_wl32(pb, 0); avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */ @@ -337,7 +341,8 @@ static int avi_write_header(AVFormatContext *s) avio_wl32(pb, 0); // video format = unknown avio_wl32(pb, 0); // video standard = unknown - avio_wl32(pb, lrintf(1.0 / av_q2d(enc->time_base))); + // TODO: should be avg_frame_rate + avio_wl32(pb, lrintf(1.0 / av_q2d(st->time_base))); avio_wl32(pb, enc->width); avio_wl32(pb, enc->height); avio_wl16(pb, den); -- cgit v1.1