]> granicus.if.org Git - taglib/commitdiff
Consistent rounding when calculating the MP4 audio length.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Thu, 19 Nov 2015 09:24:20 +0000 (18:24 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Thu, 19 Nov 2015 09:24:20 +0000 (18:24 +0900)
taglib/mp4/mp4properties.cpp
tests/test_mp4.cpp

index 0ac77342c9144dfdd74bad47a941af09767b335f..ba8215475eebc3986f2e27848535a339023389b8 100644 (file)
@@ -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) {
index c110a61229f2b56399ac5c1086377ea90778ac09..58dbae42325225aceb8d0d670dc7b33477f5ac29 100644 (file)
@@ -40,7 +40,7 @@ public:
     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());