]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/metadata.c
Split (picture|seq) parameter set decoding out of h264.c.
[ffmpeg] / libavformat / metadata.c
index 0ed3cf709a487f169ed6e4585ad2e029adf60fe3..080ebcde886ce4244ea58deed10cb90f889c0f0e 100644 (file)
@@ -46,7 +46,7 @@ av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int f
     return NULL;
 }
 
-int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
+int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags)
 {
     AVMetadata *m= *pm;
     AVMetadataTag *tag= av_metadata_get(m, key, NULL, AV_METADATA_MATCH_CASE);
@@ -66,7 +66,13 @@ int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
             return AVERROR(ENOMEM);
     }
     if(value){
+        if(flags & AV_METADATA_DONT_STRDUP_KEY){
+            m->elems[m->count].key  = key;
+        }else
         m->elems[m->count].key  = av_strdup(key  );
+        if(flags & AV_METADATA_DONT_STRDUP_VAL){
+            m->elems[m->count].value= value;
+        }else
         m->elems[m->count].value= av_strdup(value);
         m->count++;
     }
@@ -78,6 +84,13 @@ int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
     return 0;
 }
 
+#if LIBAVFORMAT_VERSION_MAJOR == 52
+int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
+{
+    return av_metadata_set2(pm, key, value, 0);
+}
+#endif
+
 void av_metadata_free(AVMetadata **pm)
 {
     AVMetadata *m= *pm;
@@ -97,28 +110,26 @@ static void metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
 {
     /* TODO: use binary search to look up the two conversion tables
        if the tables are getting big enough that it would matter speed wise */
-    const AVMetadataConv *s_conv1 = s_conv, *d_conv1 = d_conv, *sc, *dc;
+    const AVMetadataConv *sc, *dc;
     AVMetadataTag *mtag = NULL;
     AVMetadata *dst = NULL;
-    const char *key, *key2;
+    const char *key;
 
     while((mtag=av_metadata_get(*pm, "", mtag, AV_METADATA_IGNORE_SUFFIX))) {
-        key = key2 = mtag->key;
+        key = mtag->key;
         if (s_conv != d_conv) {
-            if (!s_conv)
-                s_conv1 = (const AVMetadataConv[2]){{key,key}};
-            for (sc=s_conv1; sc->native; sc++)
-                if (!strcasecmp(key, sc->native)) {
-                    key2 = sc->generic;
-                    break;
-                }
-            if (!d_conv)
-                d_conv1 = (const AVMetadataConv[2]){{key2,key2}};
-            for (dc=d_conv1; dc->native; dc++)
-                if (!strcasecmp(key2, dc->generic)) {
-                    key = dc->native;
-                    break;
-                }
+            if (s_conv)
+                for (sc=s_conv; sc->native; sc++)
+                    if (!strcasecmp(key, sc->native)) {
+                        key = sc->generic;
+                        break;
+                    }
+            if (d_conv)
+                for (dc=d_conv; dc->native; dc++)
+                    if (!strcasecmp(key, dc->generic)) {
+                        key = dc->native;
+                        break;
+                    }
         }
         av_metadata_set(&dst, key, mtag->value);
     }