[FFmpeg-cvslog] r22058 - trunk/libavformat/asfenc.c

benoit subversion
Thu Feb 25 17:50:26 CET 2010


Author: benoit
Date: Thu Feb 25 17:50:26 2010
New Revision: 22058

Log:
asfenc: simplify writing of comment header.
Patch by Anton Khirnov wyskas gmail com

Modified:
   trunk/libavformat/asfenc.c

Modified: trunk/libavformat/asfenc.c
==============================================================================
--- trunk/libavformat/asfenc.c	Thu Feb 25 17:38:23 2010	(r22057)
+++ trunk/libavformat/asfenc.c	Thu Feb 25 17:50:26 2010	(r22058)
@@ -265,7 +265,7 @@ static int asf_write_header1(AVFormatCon
 {
     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(AVFormatCon
     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(AVFormatCon
     /* 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) {



More information about the ffmpeg-cvslog mailing list