Revision fe01dd8d libavformat/mp3enc.c

View differences:

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