1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

In mov muxer, compute avg bitrate in esds

This commit is contained in:
Baptiste Coudurier 2011-04-16 16:19:10 -07:00
parent 1aeb88b77d
commit 0ba8485666
4 changed files with 17 additions and 8 deletions

View File

@ -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

View File

@ -1,3 +1,3 @@
439684b82ccc1fdd24a23392c238ae53 *./tests/data/lavf/lavf.mov
a901cd05609080e8f5c09ca5da7290f0 *./tests/data/lavf/lavf.mov
357681 ./tests/data/lavf/lavf.mov
./tests/data/lavf/lavf.mov CRC=0x2f6a9b26

View File

@ -1,4 +1,4 @@
080e75117f8142001b096cd977ba287e *./tests/data/vsynth1/odivx.mp4
d2405fd9e350854a161f48bc63f49253 *./tests/data/vsynth1/odivx.mp4
540156 ./tests/data/vsynth1/odivx.mp4
8828a375448dc5c2215163ba70656f89 *./tests/data/mpeg4.vsynth1.out.yuv
stddev: 7.97 PSNR: 30.10 MAXDIFF: 105 bytes: 7603200/ 7603200

View File

@ -1,4 +1,4 @@
8ffbe8ce43fe126b12cf9621717d641b *./tests/data/vsynth2/odivx.mp4
2e3bf184668d4807ae6df0bdceba487b *./tests/data/vsynth2/odivx.mp4
119809 ./tests/data/vsynth2/odivx.mp4
90a3577850239083a9042bef33c50e85 *./tests/data/mpeg4.vsynth2.out.yuv
stddev: 5.34 PSNR: 33.57 MAXDIFF: 83 bytes: 7603200/ 7603200