[FFmpeg-cvslog] id3v2: strip trailing spaces from APIC tag

wm4 git at videolan.org
Thu Jun 18 19:16:36 CEST 2015


ffmpeg | branch: master | wm4 <nfxjfg at googlemail.com> | Thu May  7 23:56:37 2015 +0200| [d4007d176313f6fe08c4fd2e484495f55e280c2a] | committer: Michael Niedermayer

id3v2: strip trailing spaces from APIC tag

The APIC description must be unique, and some ID3v2 tag writers add
spaces to write several APIC entries with the same description. The
trailing spaces simply serve as a way to disambiguate the description.
Do this so that API users do not have to special-case mp3 to fix this
cosmetic issue.

Requested-by: wm4
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/id3v2.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 52d8531..6eec60e 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -535,6 +535,13 @@ static void free_apic(void *obj)
     av_freep(&apic);
 }
 
+static void rstrip_spaces(char *buf)
+{
+    size_t len = strlen(buf);
+    while (len > 0 && buf[len - 1] == ' ')
+        buf[--len] = 0;
+}
+
 static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen,
                       const char *tag, ID3v2ExtraMeta **extra_meta,
                       int isv34)
@@ -608,6 +615,10 @@ static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen,
     new_extra->next = *extra_meta;
     *extra_meta     = new_extra;
 
+    // The description must be unique, and some ID3v2 tag writers add spaces
+    // to write several APIC entries with the same description.
+    rstrip_spaces(apic->description);
+
     return;
 
 fail:



More information about the ffmpeg-cvslog mailing list