summaryrefslogtreecommitdiff
path: root/libavformat/avienc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-05-18 12:12:59 +0200
committerAnton Khirnov <anton@khirnov.net>2014-06-18 15:12:34 +0200
commit194be1f43ea391eb986732707435176e579265aa (patch)
tree2045d50660f7e045fde6cda7a2ed8213c24f5aab /libavformat/avienc.c
parentd754ed41727b1fcbab335b510248a9758a73320c (diff)
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).
Diffstat (limited to 'libavformat/avienc.c')
-rw-r--r--libavformat/avienc.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 87075d4b93..417a8e99d2 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);