[FFmpeg-cvslog] avformat/id3v2: parse ID3 Private frames as extra metadata

Anssi Hannula git at videolan.org
Tue Dec 31 02:30:04 CET 2013


ffmpeg | branch: master | Anssi Hannula <anssi.hannula at iki.fi> | Mon Dec 30 10:09:17 2013 +0200| [53765ae33b8b0baaebd1914b165bb26fb6122176] | committer: Anssi Hannula

avformat/id3v2: parse ID3 Private frames as extra metadata

They are used in HLS.

Signed-off-by: Anssi Hannula <anssi.hannula at iki.fi>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=53765ae33b8b0baaebd1914b165bb26fb6122176
---

 libavformat/id3v2.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 libavformat/id3v2.h |    6 ++++++
 2 files changed, 52 insertions(+)

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 3eb368e..54c85d1 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -570,6 +570,51 @@ end:
     av_free(dst);
 }
 
+static void free_priv(void *obj)
+{
+    ID3v2ExtraMetaPRIV *priv = obj;
+    av_freep(&priv->owner);
+    av_freep(&priv->data);
+    av_freep(&priv);
+}
+
+static void read_priv(AVFormatContext *s, AVIOContext *pb, int taglen,
+                      char *tag, ID3v2ExtraMeta **extra_meta, int isv34)
+{
+    ID3v2ExtraMeta *meta;
+    ID3v2ExtraMetaPRIV *priv;
+
+    meta = av_mallocz(sizeof(*meta));
+    priv = av_mallocz(sizeof(*priv));
+
+    if (!meta || !priv)
+        goto fail;
+
+    if (decode_str(s, pb, ID3v2_ENCODING_ISO8859, &priv->owner, &taglen) < 0)
+        goto fail;
+
+    priv->data = av_malloc(taglen);
+    if (!priv->data)
+        goto fail;
+
+    priv->datasize = taglen;
+
+    if (avio_read(pb, priv->data, priv->datasize) != priv->datasize)
+        goto fail;
+
+    meta->tag   = "PRIV";
+    meta->data  = priv;
+    meta->next  = *extra_meta;
+    *extra_meta = meta;
+
+    return;
+
+fail:
+    if (priv)
+        free_priv(priv);
+    av_freep(&meta);
+}
+
 typedef struct ID3v2EMFunc {
     const char *tag3;
     const char *tag4;
@@ -582,6 +627,7 @@ static const ID3v2EMFunc id3v2_extra_meta_funcs[] = {
     { "GEO", "GEOB", read_geobtag, free_geobtag },
     { "PIC", "APIC", read_apic,    free_apic    },
     { "CHAP","CHAP", read_chapter, NULL         },
+    { "PRIV","PRIV", read_priv,    free_priv    },
     { NULL }
 };
 
diff --git a/libavformat/id3v2.h b/libavformat/id3v2.h
index e893922..58970a1 100644
--- a/libavformat/id3v2.h
+++ b/libavformat/id3v2.h
@@ -73,6 +73,12 @@ typedef struct ID3v2ExtraMetaAPIC {
     enum AVCodecID id;
 } ID3v2ExtraMetaAPIC;
 
+typedef struct ID3v2ExtraMetaPRIV {
+    uint8_t *owner;
+    uint8_t *data;
+    uint32_t datasize;
+} ID3v2ExtraMetaPRIV;
+
 /**
  * Detect ID3v2 Header.
  * @param buf   must be ID3v2_HEADER_SIZE byte long



More information about the ffmpeg-cvslog mailing list