$OpenBSD: patch-taglib_mp4_mp4tag_cpp,v 1.2 2012/11/12 11:12:03 dcoppa Exp $

Correctly parse covr atoms with type 0
(upstream git commit 3a5aeb457324f9dcac2c0051e94b0d748af63f65)

Fix a bug in updating MP4 tags
(upstream git commit a9df3e48f7b59bc27e115e5b0ad057a642b6fac3)

--- taglib/mp4/mp4tag.cpp.orig	Thu Sep  6 20:03:15 2012
+++ taglib/mp4/mp4tag.cpp	Mon Nov 12 10:53:31 2012
@@ -283,10 +283,13 @@ MP4::Tag::parseCovr(MP4::Atom *atom, TagLib::File *fil
       debug("MP4: Unexpected atom \"" + name + "\", expecting \"data\"");
       break;
     }
-    if(flags == TypeJPEG || flags == TypePNG || flags == TypeBMP || flags == TypeGIF) {
+    if(flags == TypeJPEG || flags == TypePNG || flags == TypeBMP || flags == TypeGIF || flags == TypeImplicit) {
       value.append(MP4::CoverArt(MP4::CoverArt::Format(flags),
                                  data.mid(pos + 16, length - 16)));
     }
+    else {
+      debug("MP4: Unknown covr format " + String::number(flags));
+    }
     pos += length;
   }
   if(value.size() > 0)
@@ -570,7 +573,7 @@ MP4::Tag::updateOffsets(long delta, long offset)
         atom->offset += delta;
       }
       d->file->seek(atom->offset + 9);
-      ByteVector data = d->file->readBlock(atom->offset - 9);
+      ByteVector data = d->file->readBlock(atom->length - 9);
       unsigned int flags = (ByteVector(1, '\0') + data.mid(0, 3)).toUInt();
       if(flags & 1) {
         long long o = data.mid(7, 8).toLongLong();
