aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/id3v2.c
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2015-05-07 23:56:37 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-06-18 19:15:49 +0200
commitd4007d176313f6fe08c4fd2e484495f55e280c2a (patch)
treedab9f46dae400a61482c6fce3f761b067e772cd4 /libavformat/id3v2.c
parent622f1468c92cb399e824894aa456d5590da6cc56 (diff)
downloadffmpeg-d4007d176313f6fe08c4fd2e484495f55e280c2a.tar.gz
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@gmx.at>
Diffstat (limited to 'libavformat/id3v2.c')
-rw-r--r--libavformat/id3v2.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 52d85312e4..6eec60e896 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: