Revision 04d2540c libavformat/avidec.c

View differences:

libavformat/avidec.c
227 227
    }
228 228
}
229 229

  
230
static int avi_read_tag(AVFormatContext *s, AVStream *st, const char *key, unsigned int size)
230
static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t size)
231 231
{
232 232
    ByteIOContext *pb = s->pb;
233
    char *value;
233
    char key[5] = {0}, *value;
234 234

  
235 235
    size += (size & 1);
236 236

  
......
242 242
    get_buffer(pb, value, size);
243 243
    value[size]=0;
244 244

  
245
    AV_WL32(key, tag);
246

  
245 247
    if(st)
246 248
        return av_metadata_set2(&st->metadata, key, value,
247 249
                                    AV_METADATA_DONT_STRDUP_VAL);
......
250 252
                                  AV_METADATA_DONT_STRDUP_VAL);
251 253
}
252 254

  
255
static void avi_read_info(AVFormatContext *s, uint64_t end)
256
{
257
    while (url_ftell(s->pb) < end) {
258
        uint32_t tag  = get_le32(s->pb);
259
        uint32_t size = get_le32(s->pb);
260
        avi_read_tag(s, NULL, tag, size);
261
    }
262
}
263

  
253 264
static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
254 265
{
255 266
    AVIContext *avi = s->priv_data;
......
301 312
                dprintf(NULL, "movi end=%"PRIx64"\n", avi->movi_end);
302 313
                goto end_of_header;
303 314
            }
315
            else if (tag1 == MKTAG('I', 'N', 'F', 'O'))
316
                avi_read_info(s, list_end);
317

  
304 318
            break;
305 319
        case MKTAG('d', 'm', 'l', 'h'):
306 320
            avi->is_odml = 1;
......
606 620
            }
607 621
            url_fseek(pb, size, SEEK_CUR);
608 622
            break;
609
        case MKTAG('I', 'N', 'A', 'M'):
610
            avi_read_tag(s, NULL, "Title", size);
611
            break;
612
        case MKTAG('I', 'A', 'R', 'T'):
613
            avi_read_tag(s, NULL, "Artist", size);
614
            break;
615
        case MKTAG('I', 'C', 'O', 'P'):
616
            avi_read_tag(s, NULL, "Copyright", size);
617
            break;
618
        case MKTAG('I', 'C', 'M', 'T'):
619
            avi_read_tag(s, NULL, "Comment", size);
620
            break;
621
        case MKTAG('I', 'G', 'N', 'R'):
622
            avi_read_tag(s, NULL, "Genre", size);
623
            break;
624
        case MKTAG('I', 'P', 'R', 'D'):
625
            avi_read_tag(s, NULL, "Album", size);
626
            break;
627
        case MKTAG('I', 'P', 'R', 'T'):
628
            avi_read_tag(s, NULL, "Track", size);
629
            break;
630 623
        case MKTAG('s', 't', 'r', 'n'):
631 624
            if(s->nb_streams){
632
                avi_read_tag(s, s->streams[s->nb_streams-1], "Title", size);
625
                avi_read_tag(s, s->streams[s->nb_streams-1], tag, size);
633 626
                break;
634 627
            }
635 628
        default:
......
1190 1183
    avi_read_packet,
1191 1184
    avi_read_close,
1192 1185
    avi_read_seek,
1186
    .metadata_conv = ff_avi_metadata_conv,
1193 1187
};

Also available in: Unified diff