mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
asfenc: simplify writing of comment header.
Patch by Anton Khirnov wyskas gmail com Originally committed as revision 22058 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
e4ea625ab0
commit
a677078e14
@ -265,7 +265,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
|
||||
{
|
||||
ASFContext *asf = s->priv_data;
|
||||
ByteIOContext *pb = s->pb;
|
||||
AVMetadataTag *title, *author, *copyright, *comment;
|
||||
AVMetadataTag *tags[5];
|
||||
int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
|
||||
int has_title;
|
||||
int metadata_count;
|
||||
@ -274,13 +274,14 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
|
||||
int bit_rate;
|
||||
int64_t duration;
|
||||
|
||||
title = av_metadata_get(s->metadata, "title" , NULL, 0);
|
||||
author = av_metadata_get(s->metadata, "author" , NULL, 0);
|
||||
copyright = av_metadata_get(s->metadata, "copyright", NULL, 0);
|
||||
comment = av_metadata_get(s->metadata, "comment" , NULL, 0);
|
||||
tags[0] = av_metadata_get(s->metadata, "title" , NULL, 0);
|
||||
tags[1] = av_metadata_get(s->metadata, "author" , NULL, 0);
|
||||
tags[2] = av_metadata_get(s->metadata, "copyright", NULL, 0);
|
||||
tags[3] = av_metadata_get(s->metadata, "comment" , NULL, 0);
|
||||
tags[4] = av_metadata_get(s->metadata, "rating" , NULL, 0);
|
||||
|
||||
duration = asf->duration + PREROLL_TIME * 10000;
|
||||
has_title = title || author || copyright || comment;
|
||||
has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
|
||||
metadata_count = s->metadata ? s->metadata->count : 0;
|
||||
|
||||
bit_rate = 0;
|
||||
@ -329,15 +330,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
|
||||
/* title and other infos */
|
||||
if (has_title) {
|
||||
hpos = put_header(pb, &ff_asf_comment_header);
|
||||
put_le16(pb, title ? 2 * (strlen(title->value ) + 1) : 0);
|
||||
put_le16(pb, author ? 2 * (strlen(author->value ) + 1) : 0);
|
||||
put_le16(pb, copyright ? 2 * (strlen(copyright->value) + 1) : 0);
|
||||
put_le16(pb, comment ? 2 * (strlen(comment->value ) + 1) : 0);
|
||||
put_le16(pb, 0);
|
||||
if (title ) put_str16_nolen(pb, title->value );
|
||||
if (author ) put_str16_nolen(pb, author->value );
|
||||
if (copyright) put_str16_nolen(pb, copyright->value);
|
||||
if (comment ) put_str16_nolen(pb, comment->value );
|
||||
for (n = 0; n < FF_ARRAY_ELEMS(tags); n++)
|
||||
put_le16(pb, tags[n] ? 2*(strlen(tags[n]->value) + 1) : 0);
|
||||
for (n = 0; n < FF_ARRAY_ELEMS(tags); n++)
|
||||
if (tags[n])
|
||||
put_str16_nolen(pb, tags[n]->value);
|
||||
end_header(pb, hpos);
|
||||
}
|
||||
if (metadata_count) {
|
||||
|
Loading…
Reference in New Issue
Block a user