summaryrefslogtreecommitdiff
path: root/libavformat/mp3enc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-01-21 19:54:34 +0000
committerJanne Grunau <janne-ffmpeg@jannau.net>2011-01-22 02:06:10 +0100
commitcb6bc57681b2ec5232e64db176f41fb2517de146 (patch)
treeda1e2226bc122eeff749b3a4fa57029d50ad134f /libavformat/mp3enc.c
parent8c3caf7fb1be2eb6eb4683b1a0383cba5c25ee19 (diff)
id3v2: split tables for various ID3v2 versions
This is needed for upcoming ID3v2.3 muxing support. Signed-off-by: Janne Grunau <janne-ffmpeg@jannau.net>
Diffstat (limited to 'libavformat/mp3enc.c')
-rw-r--r--libavformat/mp3enc.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index db180d66e8..f55e12319c 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -148,6 +148,20 @@ AVOutputFormat mp2_muxer = {
#endif
#if CONFIG_MP3_MUXER
+static int id3v2_check_write_tag(AVFormatContext *s, AVMetadataTag *t, const char table[][4])
+{
+ uint32_t tag;
+ int i;
+
+ if (t->key[0] != 'T' || strlen(t->key) != 4)
+ return -1;
+ tag = AV_RB32(t->key);
+ for (i = 0; *table[i]; i++)
+ if (tag == AV_RB32(table[i]))
+ return id3v2_put_ttag(s, t->value, NULL, tag, ID3v2_ENCODING_UTF8);
+ return -1;
+}
+
/**
* Write an ID3v2.4 header at beginning of stream
*/
@@ -166,29 +180,25 @@ static int mp3_write_header(struct AVFormatContext *s)
size_pos = url_ftell(s->pb);
put_be32(s->pb, 0);
- ff_metadata_conv(&s->metadata, ff_id3v2_metadata_conv, NULL);
+ ff_metadata_conv(&s->metadata, ff_id3v2_34_metadata_conv, NULL);
+ ff_metadata_conv(&s->metadata, ff_id3v2_4_metadata_conv, NULL);
while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
- uint32_t tag = 0;
int ret;
- if (t->key[0] == 'T' && strlen(t->key) == 4) {
- int i;
- for (i = 0; *ff_id3v2_tags[i]; i++)
- if (AV_RB32(t->key) == AV_RB32(ff_id3v2_tags[i])) {
- tag = AV_RB32(t->key);
- if ((ret = id3v2_put_ttag(s, t->value, NULL, tag, ID3v2_ENCODING_UTF8)) < 0)
- return ret;
- totlen += ret;
- break;
- }
+ if ((ret = id3v2_check_write_tag(s, t, ff_id3v2_tags)) > 0) {
+ totlen += ret;
+ continue;
}
-
- if (!tag) { /* unknown tag, write as TXXX frame */
- tag = MKBETAG('T', 'X', 'X', 'X');
- if ((ret = id3v2_put_ttag(s, t->key, t->value, tag, ID3v2_ENCODING_UTF8)) < 0)
- return ret;
+ if ((ret = id3v2_check_write_tag(s, t, ff_id3v2_4_tags)) > 0) {
totlen += ret;
+ continue;
}
+
+ /* unknown tag, write as TXXX frame */
+ if ((ret = id3v2_put_ttag(s, t->key, t->value, MKBETAG('T', 'X', 'X', 'X'),
+ ID3v2_ENCODING_UTF8)) < 0)
+ return ret;
+ totlen += ret;
}
cur_pos = url_ftell(s->pb);