[FFmpeg-devel] [PATCH 1/3] lavf/id3v2 read COMM tag
Matthieu Bouron
matthieu.bouron at gmail.com
Sun Jul 1 11:16:41 CEST 2012
---
libavformat/id3v2.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 216d4a2..cb88858 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -505,6 +505,42 @@ fail:
avio_seek(pb, end, SEEK_SET);
}
+static void read_comm(AVFormatContext *s, AVIOContext *pb, int taglen, char *tag, ID3v2ExtraMeta **extra_meta)
+{
+ uint8_t* dst = NULL;
+ int64_t end = avio_tell(pb) + taglen;
+ uint8_t encoding;
+
+ if (taglen <= 4)
+ goto fail;
+
+ encoding = avio_r8(pb);
+ taglen--;
+
+ // Read lang
+ avio_rb24(pb);
+ taglen -= 3;
+
+ // Read short description
+ if (decode_str(s, pb, encoding, &dst, &taglen) < 0) {
+ av_log(s, AV_LOG_ERROR, "Error reading short description in COMM frame\n");
+ goto fail;
+ }
+ av_freep(&dst);
+
+ // Read full description
+ if (decode_str(s, pb, encoding, &dst, &taglen) < 0) {
+ av_log(s, AV_LOG_ERROR, "Error reading description in COMM frame\n");
+ goto fail;
+ }
+
+ av_dict_set(&s->metadata, "comment", dst, 0);
+ av_freep(&dst);
+
+fail:
+ avio_seek(pb, end, SEEK_SET);
+}
+
typedef struct ID3v2EMFunc {
const char *tag3;
const char *tag4;
@@ -515,6 +551,7 @@ typedef struct ID3v2EMFunc {
static const ID3v2EMFunc id3v2_extra_meta_funcs[] = {
{ "GEO", "GEOB", read_geobtag, free_geobtag },
{ "PIC", "APIC", read_apic, free_apic },
+ { "COM", "COMM", read_comm, NULL },
{ NULL }
};
--
1.7.11
More information about the ffmpeg-devel
mailing list