Revision fe01dd8d

View differences:

libavformat/id3v2.c
273 273
            url_fseek(s->pb, off, SEEK_SET);
274 274
        }
275 275
    } while (found_header);
276
    ff_metadata_conv(&s->metadata, NULL, ff_id3v2_metadata_conv);
276
    ff_metadata_conv(&s->metadata, NULL, ff_id3v2_34_metadata_conv);
277
    ff_metadata_conv(&s->metadata, NULL, ff_id3v2_2_metadata_conv);
278
    ff_metadata_conv(&s->metadata, NULL, ff_id3v2_4_metadata_conv);
277 279
}
278 280

  
279
const AVMetadataConv ff_id3v2_metadata_conv[] = {
281
const AVMetadataConv ff_id3v2_34_metadata_conv[] = {
280 282
    { "TALB", "album"},
281
    { "TAL",  "album"},
282 283
    { "TCOM", "composer"},
283 284
    { "TCON", "genre"},
284
    { "TCO",  "genre"},
285 285
    { "TCOP", "copyright"},
286
    { "TDRL", "date"},
287
    { "TDRC", "date"},
288
    { "TDEN", "creation_time"},
289 286
    { "TENC", "encoded_by"},
290
    { "TEN",  "encoded_by"},
291 287
    { "TIT2", "title"},
292
    { "TT2",  "title"},
293 288
    { "TLAN", "language"},
294 289
    { "TPE1", "artist"},
295
    { "TP1",  "artist"},
296 290
    { "TPE2", "album_artist"},
297
    { "TP2",  "album_artist"},
298 291
    { "TPE3", "performer"},
299
    { "TP3",  "performer"},
300 292
    { "TPOS", "disc"},
301 293
    { "TPUB", "publisher"},
302 294
    { "TRCK", "track"},
303
    { "TRK",  "track"},
295
    { "TSSE", "encoder"},
296
    { 0 }
297
};
298

  
299
const AVMetadataConv ff_id3v2_4_metadata_conv[] = {
300
    { "TDRL", "date"},
301
    { "TDRC", "date"},
302
    { "TDEN", "creation_time"},
304 303
    { "TSOA", "album-sort"},
305 304
    { "TSOP", "artist-sort"},
306 305
    { "TSOT", "title-sort"},
307
    { "TSSE", "encoder"},
308 306
    { 0 }
309 307
};
310 308

  
309
const AVMetadataConv ff_id3v2_2_metadata_conv[] = {
310
    { "TAL",  "album"},
311
    { "TCO",  "genre"},
312
    { "TT2",  "title"},
313
    { "TEN",  "encoded_by"},
314
    { "TP1",  "artist"},
315
    { "TP2",  "album_artist"},
316
    { "TP3",  "performer"},
317
    { "TRK",  "track"},
318
    { 0 }
319
};
320

  
321

  
311 322
const char ff_id3v2_tags[][4] = {
312
   "TALB", "TBPM", "TCOM", "TCON", "TCOP", "TDEN", "TDLY", "TDOR", "TDRC",
313
   "TDRL", "TDTG", "TENC", "TEXT", "TFLT", "TIPL", "TIT1", "TIT2", "TIT3",
314
   "TKEY", "TLAN", "TLEN", "TMCL", "TMED", "TMOO", "TOAL", "TOFN", "TOLY",
315
   "TOPE", "TOWN", "TPE1", "TPE2", "TPE3", "TPE4", "TPOS", "TPRO", "TPUB",
316
   "TRCK", "TRSN", "TRSO", "TSOA", "TSOP", "TSOT", "TSRC", "TSSE", "TSST",
323
   "TALB", "TBPM", "TCOM", "TCON", "TCOP", "TDLY", "TENC", "TEXT",
324
   "TFLT", "TIT1", "TIT2", "TIT3", "TKEY", "TLAN", "TLEN", "TMED",
325
   "TOAL", "TOFN", "TOLY", "TOPE", "TOWN", "TPE1", "TPE2", "TPE3",
326
   "TPE4", "TPOS", "TPUB", "TRCK", "TRSN", "TRSO", "TSRC", "TSSE",
327
   { 0 },
328
};
329

  
330
const char ff_id3v2_4_tags[][4] = {
331
   "TDEN", "TDOR", "TDRC", "TDRL", "TDTG", "TIPL", "TMCL", "TMOO",
332
   "TPRO", "TSOA", "TSOP", "TSOT", "TSST",
333
   { 0 },
334
};
335

  
336
const char ff_id3v2_3_tags[][4] = {
337
   "TDAT", "TIME", "TORY", "TRDA", "TSIZ", "TYER",
317 338
   { 0 },
318 339
};
libavformat/id3v2.h
65 65
 */
66 66
void ff_id3v2_read(AVFormatContext *s, const char *magic);
67 67

  
68
extern const AVMetadataConv ff_id3v2_metadata_conv[];
68
extern const AVMetadataConv ff_id3v2_34_metadata_conv[];
69
extern const AVMetadataConv ff_id3v2_4_metadata_conv[];
70
extern const AVMetadataConv ff_id3v2_2_metadata_conv[];
69 71

  
70 72
/**
71
 * A list of ID3v2.4 text information frames.
73
 * A list of text information frames allowed in both ID3 v2.3 and v2.4
72 74
 * http://www.id3.org/id3v2.4.0-frames
75
 * http://www.id3.org/id3v2.4.0-changes
73 76
 */
74 77
extern const char ff_id3v2_tags[][4];
75 78

  
79
/**
80
 * ID3v2.4-only text information frames.
81
 */
82
extern const char ff_id3v2_4_tags[][4];
83

  
84
/**
85
 * ID3v2.3-only text information frames.
86
 */
87
extern const char ff_id3v2_3_tags[][4];
88

  
76 89
#endif /* AVFORMAT_ID3V2_H */
libavformat/mp3enc.c
148 148
#endif
149 149

  
150 150
#if CONFIG_MP3_MUXER
151
static int id3v2_check_write_tag(AVFormatContext *s, AVMetadataTag *t, const char table[][4])
152
{
153
    uint32_t tag;
154
    int i;
155

  
156
    if (t->key[0] != 'T' || strlen(t->key) != 4)
157
        return -1;
158
    tag = AV_RB32(t->key);
159
    for (i = 0; *table[i]; i++)
160
        if (tag == AV_RB32(table[i]))
161
            return id3v2_put_ttag(s, t->value, NULL, tag, ID3v2_ENCODING_UTF8);
162
    return -1;
163
}
164

  
151 165
/**
152 166
 * Write an ID3v2.4 header at beginning of stream
153 167
 */
......
166 180
    size_pos = url_ftell(s->pb);
167 181
    put_be32(s->pb, 0);
168 182

  
169
    ff_metadata_conv(&s->metadata, ff_id3v2_metadata_conv, NULL);
183
    ff_metadata_conv(&s->metadata, ff_id3v2_34_metadata_conv, NULL);
184
    ff_metadata_conv(&s->metadata, ff_id3v2_4_metadata_conv, NULL);
170 185
    while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
171
        uint32_t tag = 0;
172 186
        int ret;
173 187

  
174
        if (t->key[0] == 'T' && strlen(t->key) == 4) {
175
            int i;
176
            for (i = 0; *ff_id3v2_tags[i]; i++)
177
                if (AV_RB32(t->key) == AV_RB32(ff_id3v2_tags[i])) {
178
                    tag = AV_RB32(t->key);
179
                    if ((ret = id3v2_put_ttag(s, t->value, NULL, tag, ID3v2_ENCODING_UTF8)) < 0)
180
                        return ret;
181
                    totlen += ret;
182
                    break;
183
                }
188
        if ((ret = id3v2_check_write_tag(s, t, ff_id3v2_tags)) > 0) {
189
            totlen += ret;
190
            continue;
184 191
        }
185

  
186
        if (!tag) { /* unknown tag, write as TXXX frame */
187
            tag = MKBETAG('T', 'X', 'X', 'X');
188
            if ((ret = id3v2_put_ttag(s, t->key, t->value, tag, ID3v2_ENCODING_UTF8)) < 0)
189
                return ret;
192
        if ((ret = id3v2_check_write_tag(s, t, ff_id3v2_4_tags)) > 0) {
190 193
            totlen += ret;
194
            continue;
191 195
        }
196

  
197
        /* unknown tag, write as TXXX frame */
198
        if ((ret = id3v2_put_ttag(s, t->key, t->value, MKBETAG('T', 'X', 'X', 'X'),
199
                                  ID3v2_ENCODING_UTF8)) < 0)
200
            return ret;
201
        totlen += ret;
192 202
    }
193 203

  
194 204
    cur_pos = url_ftell(s->pb);

Also available in: Unified diff