Some aiff file use ID3 tag to store artist genre and etc. 64/169764/3 accepted/tizen/unified/20180212.062418 submit/tizen/20180209.055356
authoryujie.cheng <yujie.cheng@samsung.com>
Fri, 9 Feb 2018 02:23:37 +0000 (10:23 +0800)
committeryujie.cheng <yujie.cheng@samsung.com>
Fri, 9 Feb 2018 05:18:35 +0000 (13:18 +0800)
Change-Id: Iba8d0eb220b9da8ee9ca031245a5d60975137372

libavformat/aiffdec.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 3c45c61..0d6ec79
@@ -25,6 +25,7 @@
 #include "internal.h"
 #include "pcm.h"
 #include "aiff.h"
+#include "id3v2.h"
 
 #define AIFF                    0
 #define AIFF_C_VERSION1         0xA2805140
@@ -187,12 +188,13 @@ static int aiff_probe(AVProbeData *p)
 static int aiff_read_header(AVFormatContext *s)
 {
     int size, filesize;
-    int64_t offset = 0;
+    int64_t offset = 0, position;
     uint32_t tag;
     unsigned version = AIFF_C_VERSION1;
     AVIOContext *pb = s->pb;
     AVStream * st;
     AIFFInputContext *aiff = s->priv_data;
+    ID3v2ExtraMeta *id3v2_extra_meta = NULL;
 
     /* check FORM header */
     filesize = get_tag(pb, &tag);
@@ -229,6 +231,15 @@ static int aiff_read_header(AVFormatContext *s)
             if (offset > 0) // COMM is after SSND
                 goto got_sound;
             break;
+        case MKTAG('I', 'D', '3', ' '): /* Some aiff file use ID3 tag to store artist genre and etc. merge from ffmpeg */
+            position = avio_tell(pb);
+            ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
+            if (id3v2_extra_meta)
+                ff_id3v2_parse_apic(s, &id3v2_extra_meta);
+            ff_id3v2_free_extra_meta(&id3v2_extra_meta);
+            if (position + size > avio_tell(pb))
+                avio_skip(pb, position + size - avio_tell(pb));
+            break;
         case MKTAG('F', 'V', 'E', 'R'):     /* Version chunk */
             version = avio_rb32(pb);
             break;
@@ -249,9 +260,9 @@ static int aiff_read_header(AVFormatContext *s)
             offset = avio_rb32(pb);      /* Offset of sound data */
             avio_rb32(pb);               /* BlockSize... don't care */
             offset += avio_tell(pb);    /* Compute absolute data offset */
-            if (st->codecpar->block_align)    /* Assume COMM already parsed */
+            if (st->codecpar->block_align && !(pb->seekable & AVIO_SEEKABLE_NORMAL))    /* Assume COMM already parsed */
                 goto got_sound;
-            if (!pb->seekable) {
+            if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) {
                 av_log(s, AV_LOG_ERROR, "file is not seekable\n");
                 return -1;
             }