Skip to content

Commit f32b503

Browse files
Fix bitrate calculation unit errors in ADTS and MP4 ESDS parsers (#1330)
mpegheader.cpp: ADTS bitrate divided by 1024 (binary kilo) instead of 1000 (decimal kilo), causing ~2.4% underreporting for all AAC streams. mp4properties.cpp: ESDS averageBitrate double-rounded via both +500 and +0.5 before int cast, causing standard bitrates (128000, 192000, etc.) to read 1 kbps too high.
1 parent d6a2134 commit f32b503

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

taglib/mp4/mp4properties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ MP4::Properties::read(File *file, const Atoms *atoms)
224224
pos += 10;
225225
if(const unsigned int bitrateValue = data.toUInt(pos);
226226
bitrateValue != 0 || d->length <= 0) {
227-
d->bitrate = static_cast<int>((bitrateValue + 500) / 1000.0 + 0.5);
227+
d->bitrate = static_cast<int>(bitrateValue / 1000.0 + 0.5);
228228
}
229229
else {
230230
d->bitrate = static_cast<int>(

taglib/mpeg/mpegheader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void MPEG::Header::parse(File *file, offset_t offset, bool checkLength)
239239
(static_cast<unsigned char>(frameLengthData[0]) << 3) |
240240
(static_cast<unsigned char>(frameLengthData[1]) >> 5);
241241

242-
d->bitrate = static_cast<int>(d->frameLength * d->sampleRate / 1024.0 + 0.5) * 8 / 1024;
242+
d->bitrate = static_cast<int>(d->frameLength * d->sampleRate / 1024.0 + 0.5) * 8 / 1000;
243243
}
244244
}
245245
else {

0 commit comments

Comments
 (0)