WavPack: A bit more accurate calculation of the stream length.

This commit is contained in:
Tsuda Kageyu 2015-05-26 14:54:20 +09:00
parent 22f250eaa4
commit 8f6af3f020
3 changed files with 30 additions and 2 deletions

View File

@ -272,8 +272,19 @@ void WavPack::File::read(bool readProperties, Properties::ReadStyle /* propertie
// Look for WavPack audio properties
if(readProperties)
d->properties = new Properties(this, length() - d->APESize);
if(readProperties) {
long streamLength;
if(d->hasAPE)
streamLength = d->APELocation;
else if(d->hasID3v1)
streamLength = d->ID3v1Location;
else
streamLength = length();
d->properties = new Properties(this, streamLength);
}
}
long WavPack::File::findAPE()

BIN
tests/data/tagged.wv Normal file

Binary file not shown.

View File

@ -14,6 +14,7 @@ class TestWavPack : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE(TestWavPack);
CPPUNIT_TEST(testNoLengthProperties);
CPPUNIT_TEST(testMultiChannelProperties);
CPPUNIT_TEST(testTaggedProperties);
CPPUNIT_TEST(testFuzzedFile);
CPPUNIT_TEST_SUITE_END();
@ -51,6 +52,22 @@ public:
CPPUNIT_ASSERT_EQUAL(1031, f.audioProperties()->version());
}
void testTaggedProperties()
{
WavPack::File f(TEST_FILE_PATH_C("tagged.wv"));
CPPUNIT_ASSERT(f.audioProperties());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL(3550, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(172, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(16, f.audioProperties()->bitsPerSample());
CPPUNIT_ASSERT_EQUAL(false, f.audioProperties()->isLossless());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT_EQUAL(156556U, f.audioProperties()->sampleFrames());
CPPUNIT_ASSERT_EQUAL(1031, f.audioProperties()->version());
}
void testFuzzedFile()
{
WavPack::File f(TEST_FILE_PATH_C("infloop.wv"));