summaryrefslogtreecommitdiff
path: root/libavformat/asfenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2010-02-25 16:50:26 +0000
committerBenoit Fouet <benoit.fouet@free.fr>2010-02-25 16:50:26 +0000
commita677078e147a74c17f2ded84e0fd6b795a3d610d (patch)
treedf676d9c9c128a58014e3b21e1c7fa3de0a1fdfd /libavformat/asfenc.c
parente4ea625ab03c766945a16e30d689fcaabb2416b7 (diff)
downloadffmpeg-a677078e147a74c17f2ded84e0fd6b795a3d610d.tar.gz
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
Diffstat (limited to 'libavformat/asfenc.c')
-rw-r--r--libavformat/asfenc.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 5f584a288c..58571ca042 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -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) {