From f32b503f56d3de43d5cc885f0365b1064a1b3ac6 Mon Sep 17 00:00:00 2001 From: Ryan Francesconi <2917795+ryanfrancesconi@users.noreply.github.com> Date: Sat, 4 Apr 2026 07:34:37 -0700 Subject: [PATCH] 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. --- taglib/mp4/mp4properties.cpp | 2 +- taglib/mpeg/mpegheader.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index df83d641..c932ed0d 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -224,7 +224,7 @@ MP4::Properties::read(File *file, const Atoms *atoms) pos += 10; if(const unsigned int bitrateValue = data.toUInt(pos); bitrateValue != 0 || d->length <= 0) { - d->bitrate = static_cast((bitrateValue + 500) / 1000.0 + 0.5); + d->bitrate = static_cast(bitrateValue / 1000.0 + 0.5); } else { d->bitrate = static_cast( diff --git a/taglib/mpeg/mpegheader.cpp b/taglib/mpeg/mpegheader.cpp index c20b89d3..084a3486 100644 --- a/taglib/mpeg/mpegheader.cpp +++ b/taglib/mpeg/mpegheader.cpp @@ -239,7 +239,7 @@ void MPEG::Header::parse(File *file, offset_t offset, bool checkLength) (static_cast(frameLengthData[0]) << 3) | (static_cast(frameLengthData[1]) >> 5); - d->bitrate = static_cast(d->frameLength * d->sampleRate / 1024.0 + 0.5) * 8 / 1024; + d->bitrate = static_cast(d->frameLength * d->sampleRate / 1024.0 + 0.5) * 8 / 1000; } } else {