Revision a677078e libavformat/asfenc.c

View differences:

libavformat/asfenc.c
265 265
{
266 266
    ASFContext *asf = s->priv_data;
267 267
    ByteIOContext *pb = s->pb;
268
    AVMetadataTag *title, *author, *copyright, *comment;
268
    AVMetadataTag *tags[5];
269 269
    int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
270 270
    int has_title;
271 271
    int metadata_count;
......
274 274
    int bit_rate;
275 275
    int64_t duration;
276 276

  
277
    title     = av_metadata_get(s->metadata, "title"    , NULL, 0);
278
    author    = av_metadata_get(s->metadata, "author"   , NULL, 0);
279
    copyright = av_metadata_get(s->metadata, "copyright", NULL, 0);
280
    comment   = av_metadata_get(s->metadata, "comment"  , NULL, 0);
277
    tags[0] = av_metadata_get(s->metadata, "title"    , NULL, 0);
278
    tags[1] = av_metadata_get(s->metadata, "author"   , NULL, 0);
279
    tags[2] = av_metadata_get(s->metadata, "copyright", NULL, 0);
280
    tags[3] = av_metadata_get(s->metadata, "comment"  , NULL, 0);
281
    tags[4] = av_metadata_get(s->metadata, "rating"   , NULL, 0);
281 282

  
282 283
    duration = asf->duration + PREROLL_TIME * 10000;
283
    has_title = title || author || copyright || comment;
284
    has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
284 285
    metadata_count = s->metadata ? s->metadata->count : 0;
285 286

  
286 287
    bit_rate = 0;
......
329 330
    /* title and other infos */
330 331
    if (has_title) {
331 332
        hpos = put_header(pb, &ff_asf_comment_header);
332
        put_le16(pb, title     ? 2 * (strlen(title->value    ) + 1) : 0);
333
        put_le16(pb, author    ? 2 * (strlen(author->value   ) + 1) : 0);
334
        put_le16(pb, copyright ? 2 * (strlen(copyright->value) + 1) : 0);
335
        put_le16(pb, comment   ? 2 * (strlen(comment->value  ) + 1) : 0);
336
        put_le16(pb, 0);
337
        if (title    ) put_str16_nolen(pb, title->value    );
338
        if (author   ) put_str16_nolen(pb, author->value   );
339
        if (copyright) put_str16_nolen(pb, copyright->value);
340
        if (comment  ) put_str16_nolen(pb, comment->value  );
333
        for (n = 0; n < FF_ARRAY_ELEMS(tags); n++)
334
            put_le16(pb, tags[n] ? 2*(strlen(tags[n]->value) + 1) : 0);
335
        for (n = 0; n < FF_ARRAY_ELEMS(tags); n++)
336
            if (tags[n])
337
                put_str16_nolen(pb, tags[n]->value);
341 338
        end_header(pb, hpos);
342 339
    }
343 340
    if (metadata_count) {

Also available in: Unified diff