Skip to content

Commit

Permalink
Consistent rounding when calculating the MP4 audio length.
Browse files Browse the repository at this point in the history
  • Loading branch information
TsudaKageyu committed Nov 19, 2015
1 parent f310b18 commit 1cc3e4c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion taglib/mp4/mp4properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ MP4::Properties::read(File *file, Atoms *atoms)
length = data.toUInt(24U);
}
if(unit > 0 && length > 0)
d->length = static_cast<int>(length * 1000.0 / unit);
d->length = static_cast<int>(length * 1000.0 / unit + 0.5);

MP4::Atom *atom = trak->find("mdia", "minf", "stbl", "stsd");
if(!atom) {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mp4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TestMP4 : public CppUnit::TestFixture
CPPUNIT_ASSERT(f.audioProperties());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL(3707, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(3708, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
Expand Down

0 comments on commit 1cc3e4c

Please sign in to comment.