diff options
author | Urs Fleisch <ufleisch@users.sourceforge.net> | 2020-12-27 10:17:34 +0100 |
---|---|---|
committer | Urs Fleisch <ufleisch@users.sourceforge.net> | 2020-12-27 10:17:34 +0100 |
commit | 563fbaf82aa363940394ea1f91ec1c758f2e0621 (patch) | |
tree | 61d7ec9726dd02369b2c9f84ddeaf3a87aa7b24f /taglib/mp4 | |
parent | 3d71ea1ad263e399952810a442522efc7f36ef62 (diff) |
Handle the case when MP4 file header has zero bitrate
This incorporates [6ca536b5] (mp4 properties: handle the case when
mp4 file header has zero bitrate) from PR #899 with a more accurate
bitrate calculation and a unit test.
Diffstat (limited to 'taglib/mp4')
-rw-r--r-- | taglib/mp4/mp4properties.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index a577ac3e..6c6976fa 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -234,7 +234,14 @@ MP4::Properties::read(File *file, Atoms *atoms) pos += 3; } pos += 10; - d->bitrate = static_cast<int>((data.toUInt(pos) + 500) / 1000.0 + 0.5); + const unsigned int bitrateValue = data.toUInt(pos); + if(bitrateValue != 0 || d->length <= 0) { + d->bitrate = static_cast<int>((bitrateValue + 500) / 1000.0 + 0.5); + } + else { + d->bitrate = static_cast<int>( + (calculateMdatLength(atoms->atoms) * 8) / d->length); + } } } } |