[FFmpeg-devel] [PATCH] libavformat: Add format context parameter to ff_id3v2_read_dict

Lukas Stabe lukas at stabe.de
Tue Sep 26 09:49:44 EEST 2017


The format context (when not NULL) is used to store chapter information,
which was not previously supported by ff_id3v2_read_dict.

This fixes https://trac.ffmpeg.org/ticket/6558
---
 libavformat/hls.c   | 2 +-
 libavformat/id3v2.c | 4 ++--
 libavformat/id3v2.h | 6 ++++--
 libavformat/utils.c | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 0995345bbf..f37bfa4e4f 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -909,7 +909,7 @@ static void parse_id3(AVFormatContext *s, AVIOContext *pb,
     static const char id3_priv_owner_ts[] = "com.apple.streaming.transportStreamTimestamp";
     ID3v2ExtraMeta *meta;
 
-    ff_id3v2_read_dict(pb, metadata, ID3v2_DEFAULT_MAGIC, extra_meta);
+    ff_id3v2_read_dict(NULL, pb, metadata, ID3v2_DEFAULT_MAGIC, extra_meta);
     for (meta = *extra_meta; meta; meta = meta->next) {
         if (!strcmp(meta->tag, "PRIV")) {
             ID3v2ExtraMetaPRIV *priv = meta->data;
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 05346350ad..2327d93379 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -1097,10 +1097,10 @@ static void id3v2_read_internal(AVIOContext *pb, AVDictionary **metadata,
     merge_date(metadata);
 }
 
-void ff_id3v2_read_dict(AVIOContext *pb, AVDictionary **metadata,
+void ff_id3v2_read_dict(AVFormatContext *s, AVIOContext *pb, AVDictionary **metadata,
                         const char *magic, ID3v2ExtraMeta **extra_meta)
 {
-    id3v2_read_internal(pb, metadata, NULL, magic, extra_meta, 0);
+    id3v2_read_internal(pb, metadata, s, magic, extra_meta, 0);
 }
 
 void ff_id3v2_read(AVFormatContext *s, const char *magic,
diff --git a/libavformat/id3v2.h b/libavformat/id3v2.h
index 9d7bf1c03c..d8768e955a 100644
--- a/libavformat/id3v2.h
+++ b/libavformat/id3v2.h
@@ -97,13 +97,15 @@ int ff_id3v2_tag_len(const uint8_t *buf);
 /**
  * Read an ID3v2 tag into specified dictionary and retrieve supported extra metadata.
  *
- * Chapters are not currently read by this variant.
+ * Chapters are not currently only read by this variant when s is not NULL.
  *
  * @param metadata Parsed metadata is stored here
  * @param extra_meta If not NULL, extra metadata is parsed into a list of
  * ID3v2ExtraMeta structs and *extra_meta points to the head of the list
+ * @param s If not NULL, chapter information is stored in the provided context
  */
-void ff_id3v2_read_dict(AVIOContext *pb, AVDictionary **metadata, const char *magic, ID3v2ExtraMeta **extra_meta);
+void ff_id3v2_read_dict(AVFormatContext *s, AVIOContext *pb, AVDictionary **metadata,
+                        const char *magic, ID3v2ExtraMeta **extra_meta);
 
 /**
  * Read an ID3v2 tag, including supported extra metadata and chapters.
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7abca632b5..079a8211d2 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -588,7 +588,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
 
     /* e.g. AVFMT_NOFILE formats will not have a AVIOContext */
     if (s->pb)
-        ff_id3v2_read_dict(s->pb, &s->internal->id3v2_meta, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
+        ff_id3v2_read_dict(s, s->pb, &s->internal->id3v2_meta, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
 
 
     if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
-- 
2.14.1



More information about the ffmpeg-devel mailing list