]> granicus.if.org Git - taglib/commitdiff
Fixed ID3v1-style genre to string conversion in MP4 files
authorLukáš Lalinský <lalinsky@gmail.com>
Thu, 29 Oct 2009 15:53:20 +0000 (15:53 +0000)
committerLukáš Lalinský <lalinsky@gmail.com>
Thu, 29 Oct 2009 15:53:20 +0000 (15:53 +0000)
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1042312 283d02a7-25f6-0310-bc7c-ecb5cbfe19da

NEWS
taglib/mp4/mp4tag.cpp
tests/data/gnre.m4a [new file with mode: 0644]
tests/test_mp4.cpp

diff --git a/NEWS b/NEWS
index 437af6e13746560df4e58d54a1f626963658d702..8531d17eda61b2f0aeb506286c98a86dc208cc19 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ TagLib 1.6.1
  * Fixed a failing test on ppc64.
  * Support for binary 'covr' atom in MP4 files. TagLib 1.6 treated them
    as text atoms, which corrupted them in some cases.
+ * Fixed ID3v1-style genre to string conversion in MP4 files.
 
 TagLib 1.6
 ==========
index df74811d019d8ae407f11cdd188a19cc08ce2884..2f4008622618c6c9f714fcf62cf631ac8febf739 100644 (file)
@@ -143,8 +143,8 @@ MP4::Tag::parseGnre(MP4::Atom *atom, TagLib::File *file)
   ByteVectorList data = parseData(atom, file);
   if(data.size()) {
     int idx = (int)data[0].toShort();
-    if(!d->items.contains("\251gen")) {
-      d->items.insert("\251gen", StringList(ID3v1::genre(idx)));
+    if(!d->items.contains("\251gen") && idx > 0) {
+      d->items.insert("\251gen", StringList(ID3v1::genre(idx - 1)));
     }
   }
 }
diff --git a/tests/data/gnre.m4a b/tests/data/gnre.m4a
new file mode 100644 (file)
index 0000000..f925ea9
Binary files /dev/null and b/tests/data/gnre.m4a differ
index 8bb6282508360a8b026c596d1a5617d039bc7d71..ad1195dfb6988fcdaa187ca63cf10528afd8dc20 100644 (file)
@@ -19,6 +19,7 @@ class TestMP4 : public CppUnit::TestFixture
   CPPUNIT_TEST(testUpdateStco);
   CPPUNIT_TEST(testSaveExisingWhenIlstIsLast);
   CPPUNIT_TEST(test64BitAtom);
+  CPPUNIT_TEST(testGnre);
   CPPUNIT_TEST(testCovrRead);
   CPPUNIT_TEST(testCovrWrite);
   CPPUNIT_TEST_SUITE_END();
@@ -147,6 +148,12 @@ public:
     deleteFile(filename);
   }
 
+  void testGnre()
+  {
+    MP4::File *f = new MP4::File("data/gnre.m4a");
+    CPPUNIT_ASSERT_EQUAL(TagLib::String("Ska"), f->tag()->genre());
+  }
+
   void testCovrRead()
   {
     MP4::File *f = new MP4::File("data/has-tags.m4a");