aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2011-04-16 16:19:10 -0700
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2011-04-16 16:19:10 -0700
commit0ba8485666f532f2dbab716f74e1be1189102c89 (patch)
tree5a2187399ac311227f70b0aec9cd4c4c8c9cfc9f /libavformat/movenc.c
parent1aeb88b77ddbd3802127a61bf8610e55b6c49a6f (diff)
downloadffmpeg-0ba8485666f532f2dbab716f74e1be1189102c89.tar.gz
In mov muxer, compute avg bitrate in esds
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 599c913b35..5bc356279a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -247,10 +247,20 @@ static void putDescr(AVIOContext *pb, int tag, unsigned int size)
avio_w8(pb, size & 0x7F);
}
+static unsigned compute_avg_bitrate(MOVTrack *track)
+{
+ uint64_t size = 0;
+ int i;
+ for (i = 0; i < track->entry; i++)
+ size += track->cluster[i].size;
+ return size * 8 * track->timescale / track->trackDuration;
+}
+
static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
{
int64_t pos = avio_tell(pb);
int decoderSpecificInfoLen = track->vosLen ? 5+track->vosLen : 0;
+ unsigned avg_bitrate;
avio_wb32(pb, 0); // size
ffio_wfourcc(pb, "esds");
@@ -282,11 +292,10 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
avio_w8(pb, track->enc->rc_buffer_size>>(3+16)); // Buffersize DB (24 bits)
avio_wb16(pb, (track->enc->rc_buffer_size>>3)&0xFFFF); // Buffersize DB
- avio_wb32(pb, FFMAX(track->enc->bit_rate, track->enc->rc_max_rate)); // maxbitrate (FIXME should be max rate in any 1 sec window)
- if(track->enc->rc_max_rate != track->enc->rc_min_rate || track->enc->rc_min_rate==0)
- avio_wb32(pb, 0); // vbr
- else
- avio_wb32(pb, track->enc->rc_max_rate); // avg bitrate
+ avg_bitrate = compute_avg_bitrate(track);
+ // maxbitrate (FIXME should be max rate in any 1 sec window)
+ avio_wb32(pb, FFMAX3(track->enc->bit_rate, track->enc->rc_max_rate, avg_bitrate));
+ avio_wb32(pb, avg_bitrate);
if (track->vosLen) {
// DecoderSpecific info descriptor