[FFmpeg-devel] [PATCH 4/4] Use an AVMetadata struct for storing metadata, simplify.

Stefano Sabatini stefano.sabatini-lala
Sat Apr 24 15:34:17 CEST 2010


---
 ffmpeg.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 36eefe1..c45d8a4 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -172,8 +172,7 @@ static int64_t start_time = 0;
 static int64_t rec_timestamp = 0;
 static int64_t input_ts_offset = 0;
 static int file_overwrite = 0;
-static int metadata_count;
-static AVMetadataTag *metadata;
+static AVMetadata *metadata;
 static int do_benchmark = 0;
 static int do_hex_dump = 0;
 static int do_pkt_dump = 0;
@@ -2711,11 +2710,7 @@ static int opt_metadata(const char *opt, const char *arg)
         av_exit(1);
     }
     *mid++= 0;
-
-    metadata_count++;
-    metadata= av_realloc(metadata, sizeof(*metadata)*metadata_count);
-    metadata[metadata_count-1].key  = av_strdup(arg);
-    metadata[metadata_count-1].value= av_strdup(mid);
+    av_metadata_set2(&metadata, arg, mid, 0);
 
     return 0;
 }
@@ -3451,6 +3446,7 @@ static void opt_output_file(const char *filename)
     int input_has_video, input_has_audio, input_has_subtitle;
     AVFormatParameters params, *ap = ¶ms;
     AVOutputFormat *file_oformat;
+    AVMetadataTag *tag = NULL;
 
     if (!strcmp(filename, "-"))
         filename = "pipe:";
@@ -3532,10 +3528,9 @@ static void opt_output_file(const char *filename)
 
         oc->timestamp = rec_timestamp;
 
-        for(; metadata_count>0; metadata_count--){
-            av_metadata_set2(&oc->metadata, metadata[metadata_count-1].key,
-                                            metadata[metadata_count-1].value, 0);
-        }
+        while ((tag = av_metadata_get(oc->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
+            av_metadata_set2(&oc->metadata, tag->key, tag->value, 0);
+
         av_metadata_conv(oc, oc->oformat->metadata_conv, NULL);
     }
 
-- 
1.7.0




More information about the ffmpeg-devel mailing list