mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Merge pull request #577 from TsudaKageyu/frameoffset
Fix MPEG::File::firstFrameOffset() and lastFrameOffset(). (#190)
This commit is contained in:
commit
a06d55ae6f
@ -433,7 +433,7 @@ long MPEG::File::firstFrameOffset()
|
||||
{
|
||||
long position = 0;
|
||||
|
||||
if(ID3v2Tag()) {
|
||||
if(hasID3v2Tag()) {
|
||||
position = d->ID3v2Location + ID3v2Tag()->header()->completeTagSize();
|
||||
|
||||
// Skip duplicate ID3v2 tags.
|
||||
@ -456,7 +456,7 @@ long MPEG::File::firstFrameOffset()
|
||||
|
||||
long MPEG::File::lastFrameOffset()
|
||||
{
|
||||
return previousFrameOffset(ID3v1Tag() ? d->ID3v1Location - 1 : length());
|
||||
return previousFrameOffset(hasID3v1Tag() ? d->ID3v1Location - 1 : length());
|
||||
}
|
||||
|
||||
bool MPEG::File::hasID3v1Tag() const
|
||||
|
BIN
tests/data/ape-id3v1.mp3
Normal file
BIN
tests/data/ape-id3v1.mp3
Normal file
Binary file not shown.
BIN
tests/data/ape-id3v2.mp3
Normal file
BIN
tests/data/ape-id3v2.mp3
Normal file
Binary file not shown.
BIN
tests/data/ape.mp3
Normal file
BIN
tests/data/ape.mp3
Normal file
Binary file not shown.
@ -18,6 +18,7 @@ class TestMPEG : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testSaveID3v23);
|
||||
CPPUNIT_TEST(testDuplicateID3v2);
|
||||
CPPUNIT_TEST(testFuzzedFile);
|
||||
CPPUNIT_TEST(testFrameOffset);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -111,6 +112,28 @@ public:
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
}
|
||||
|
||||
void testFrameOffset()
|
||||
{
|
||||
{
|
||||
MPEG::File f(TEST_FILE_PATH_C("ape.mp3"));
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
CPPUNIT_ASSERT_EQUAL((long)0x0000, f.firstFrameOffset());
|
||||
CPPUNIT_ASSERT_EQUAL((long)0x1FD6, f.lastFrameOffset());
|
||||
}
|
||||
{
|
||||
MPEG::File f(TEST_FILE_PATH_C("ape-id3v1.mp3"));
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
CPPUNIT_ASSERT_EQUAL((long)0x0000, f.firstFrameOffset());
|
||||
CPPUNIT_ASSERT_EQUAL((long)0x1FD6, f.lastFrameOffset());
|
||||
}
|
||||
{
|
||||
MPEG::File f(TEST_FILE_PATH_C("ape-id3v2.mp3"));
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
CPPUNIT_ASSERT_EQUAL((long)0x041A, f.firstFrameOffset());
|
||||
CPPUNIT_ASSERT_EQUAL((long)0x23F0, f.lastFrameOffset());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestMPEG);
|
||||
|
Loading…
Reference in New Issue
Block a user