[FFmpeg-devel] [PATCHv2 4/5] vorbis: append data from tags together

Ben Boeckel mathstuf at gmail.com
Sat Oct 26 04:18:07 CEST 2013


Currently, if there are multiple 'performer' tags, the last one is the
only one which appears. Instead, join them with a semicolon.

Signed-off-by: Ben Boeckel <mathstuf at gmail.com>
---
 libavformat/oggparsevorbis.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 36ad738..c421074 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -113,22 +113,24 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
         v++;
 
         if (tl && vl) {
-            char *tt, *ct;
+            char *tt, *ct, *vt;
 
             tt = av_malloc(tl + 1);
-            ct = av_malloc(vl + 1);
+            ct = av_malloc(vl + 2);
             if (!tt || !ct) {
                 av_freep(&tt);
                 av_freep(&ct);
                 return AVERROR(ENOMEM);
             }
+            ct[0] = ';';
+            vt = ct + 1;
 
             for (j = 0; j < tl; j++)
                 tt[j] = av_toupper(t[j]);
             tt[tl] = 0;
 
-            memcpy(ct, v, vl);
-            ct[vl] = 0;
+            memcpy(vt, v, vl);
+            vt[vl] = 0;
 
             /* The format in which the pictures are stored is the FLAC format.
              * Xiph says: "The binary FLAC picture structure is base64 encoded
@@ -146,7 +148,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
                     av_freep(&ct);
                     continue;
                 }
-                if ((ret = av_base64_decode(pict, ct, vl)) > 0)
+                if ((ret = av_base64_decode(pict, vt, vl)) > 0)
                     ret = ff_flac_parse_picture(as, pict, ret);
                 av_freep(&tt);
                 av_freep(&ct);
@@ -155,10 +157,17 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
                     av_log(as, AV_LOG_WARNING, "Failed to parse cover art block.\n");
                     continue;
                 }
-            } else if (!ogm_chapter(as, tt, ct))
-                av_dict_set(m, tt, ct,
+            } else if (!ogm_chapter(as, tt, vt)) {
+                int extra_flags = 0;
+                if (m && av_dict_get(*m, tt, NULL, 0)) {
+                    extra_flags = AV_DICT_APPEND;
+                    --vt;
+                }
+                av_dict_set(m, tt, vt,
                             AV_DICT_DONT_STRDUP_KEY |
-                            AV_DICT_DONT_STRDUP_VAL);
+                            extra_flags);
+                av_freep(&ct);
+            }
         }
     }
 
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list