Browse code

Merge remote-tracking branch 'qatar/master'

* qatar/master:
crypto: Use av_freep instead of av_free
lavf: don't try to free private options if priv_data is NULL.
swscale: fix types of assembly arguments.
swscale: move two macros that are only used once into caller.
swscale: remove unused function.
options: Add missing braces around struct initializer.
mov: Remove leftover crufty debug statement with references to a local file.
dvbsubdec: Fix compilation of debug code.
Remove all uses of now deprecated metadata functions.
Move metadata API from lavf to lavu.

Conflicts:
doc/APIchanges
libavformat/aiffdec.c
libavformat/asfdec.c
libavformat/avformat.h
libavformat/avidec.c
libavformat/cafdec.c
libavformat/matroskaenc.c
libavformat/mov.c
libavformat/mp3enc.c
libavformat/wtv.c
libavutil/avutil.h
libavutil/internal.h
libswscale/swscale.c
libswscale/x86/swscale_template.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/06/09 11:47:19
Showing 65 changed files
... ...
@@ -50,6 +50,11 @@ API changes, most recent first:
50 50
 2011-05-XX - XXXXXX - lavfi 2.6.0 - avcodec.h
51 51
   Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h.
52 52
 
53
+2011-06-xx - xxxxxxx - lavu 51.5.0 - AVMetadata
54
+  Move AVMetadata from lavf to lavu and rename it to
55
+  AVDictionary -- new installed header dict.h.
56
+  All av_metadata_* functions renamed to av_dict_*.
57
+
53 58
 2011-06-07 - a6703fa - lavu 51.4.0 - av_get_bytes_per_sample()
54 59
   Add av_get_bytes_per_sample() in libavutil/samplefmt.h.
55 60
   Deprecate av_get_bits_per_sample_fmt().
... ...
@@ -39,6 +39,7 @@
39 39
 #include "libavutil/colorspace.h"
40 40
 #include "libavutil/fifo.h"
41 41
 #include "libavutil/intreadwrite.h"
42
+#include "libavutil/dict.h"
42 43
 #include "libavutil/pixdesc.h"
43 44
 #include "libavutil/avstring.h"
44 45
 #include "libavutil/libm.h"
... ...
@@ -199,7 +200,7 @@ static int64_t start_time = 0;
199 199
 static int64_t recording_timestamp = 0;
200 200
 static int64_t input_ts_offset = 0;
201 201
 static int file_overwrite = 0;
202
-static AVMetadata *metadata;
202
+static AVDictionary *metadata;
203 203
 static int do_benchmark = 0;
204 204
 static int do_hex_dump = 0;
205 205
 static int do_pkt_dump = 0;
... ...
@@ -1953,7 +1954,7 @@ static int copy_chapters(int infile, int outfile)
1953 1953
         out_ch->end       = FFMIN(rt, in_ch->end   - ts_off);
1954 1954
 
1955 1955
         if (metadata_chapters_autocopy)
1956
-            av_metadata_copy(&out_ch->metadata, in_ch->metadata, 0);
1956
+            av_dict_copy(&out_ch->metadata, in_ch->metadata, 0);
1957 1957
 
1958 1958
         os->nb_chapters++;
1959 1959
         os->chapters = av_realloc(os->chapters, sizeof(AVChapter)*os->nb_chapters);
... ...
@@ -2181,8 +2182,8 @@ static int transcode(AVFormatContext **output_files,
2181 2181
         icodec = ist->st->codec;
2182 2182
 
2183 2183
         if (metadata_streams_autocopy)
2184
-            av_metadata_copy(&ost->st->metadata, ist->st->metadata,
2185
-                             AV_METADATA_DONT_OVERWRITE);
2184
+            av_dict_copy(&ost->st->metadata, ist->st->metadata,
2185
+                         AV_DICT_DONT_OVERWRITE);
2186 2186
 
2187 2187
         ost->st->disposition = ist->st->disposition;
2188 2188
         codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
... ...
@@ -2419,7 +2420,7 @@ static int transcode(AVFormatContext **output_files,
2419 2419
     /* set meta data information from input file if required */
2420 2420
     for (i=0;i<nb_meta_data_maps;i++) {
2421 2421
         AVFormatContext *files[2];
2422
-        AVMetadata      **meta[2];
2422
+        AVDictionary    **meta[2];
2423 2423
         int j;
2424 2424
 
2425 2425
 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
... ...
@@ -2462,15 +2463,15 @@ static int transcode(AVFormatContext **output_files,
2462 2462
             }
2463 2463
         }
2464 2464
 
2465
-        av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE);
2465
+        av_dict_copy(meta[0], *meta[1], AV_DICT_DONT_OVERWRITE);
2466 2466
     }
2467 2467
 
2468 2468
     /* copy global metadata by default */
2469 2469
     if (metadata_global_autocopy) {
2470 2470
 
2471 2471
         for (i = 0; i < nb_output_files; i++)
2472
-            av_metadata_copy(&output_files[i]->metadata, input_files[0].ctx->metadata,
2473
-                             AV_METADATA_DONT_OVERWRITE);
2472
+            av_dict_copy(&output_files[i]->metadata, input_files[0].ctx->metadata,
2473
+                         AV_DICT_DONT_OVERWRITE);
2474 2474
     }
2475 2475
 
2476 2476
     /* copy chapters according to chapter maps */
... ...
@@ -2943,7 +2944,7 @@ static int opt_metadata(const char *opt, const char *arg)
2943 2943
     }
2944 2944
     *mid++= 0;
2945 2945
 
2946
-    av_metadata_set2(&metadata, arg, mid, 0);
2946
+    av_dict_set(&metadata, arg, mid, 0);
2947 2947
 
2948 2948
     return 0;
2949 2949
 }
... ...
@@ -3631,7 +3632,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx)
3631 3631
             parse_forced_key_frames(forced_key_frames, ost, video_enc);
3632 3632
     }
3633 3633
     if (video_language) {
3634
-        av_metadata_set2(&st->metadata, "language", video_language, 0);
3634
+        av_dict_set(&st->metadata, "language", video_language, 0);
3635 3635
         av_freep(&video_language);
3636 3636
     }
3637 3637
 
... ...
@@ -3711,7 +3712,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx)
3711 3711
     }
3712 3712
     audio_enc->time_base= (AVRational){1, audio_sample_rate};
3713 3713
     if (audio_language) {
3714
-        av_metadata_set2(&st->metadata, "language", audio_language, 0);
3714
+        av_dict_set(&st->metadata, "language", audio_language, 0);
3715 3715
         av_freep(&audio_language);
3716 3716
     }
3717 3717
 
... ...
@@ -3807,7 +3808,7 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx)
3807 3807
     }
3808 3808
 
3809 3809
     if (subtitle_language) {
3810
-        av_metadata_set2(&st->metadata, "language", subtitle_language, 0);
3810
+        av_dict_set(&st->metadata, "language", subtitle_language, 0);
3811 3811
         av_freep(&subtitle_language);
3812 3812
     }
3813 3813
 
... ...
@@ -3926,8 +3927,8 @@ static int opt_output_file(const char *opt, const char *filename)
3926 3926
 
3927 3927
         oc->timestamp = recording_timestamp;
3928 3928
 
3929
-        av_metadata_copy(&oc->metadata, metadata, 0);
3930
-        av_metadata_free(&metadata);
3929
+        av_dict_copy(&oc->metadata, metadata, 0);
3930
+        av_dict_free(&metadata);
3931 3931
     }
3932 3932
 
3933 3933
     output_files[nb_output_files++] = oc;
... ...
@@ -25,6 +25,7 @@
25 25
 #include "libavcodec/avcodec.h"
26 26
 #include "libavutil/opt.h"
27 27
 #include "libavutil/pixdesc.h"
28
+#include "libavutil/dict.h"
28 29
 #include "libavdevice/avdevice.h"
29 30
 #include "cmdutils.h"
30 31
 
... ...
@@ -160,7 +161,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
160 160
     AVCodecContext *dec_ctx;
161 161
     AVCodec *dec;
162 162
     char val_str[128];
163
-    AVMetadataTag *tag = NULL;
163
+    AVDictionaryEntry *tag = NULL;
164 164
     AVRational display_aspect_ratio;
165 165
 
166 166
     printf("[STREAM]\n");
... ...
@@ -226,7 +227,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
226 226
     if (stream->nb_frames)
227 227
         printf("nb_frames=%"PRId64"\n",    stream->nb_frames);
228 228
 
229
-    while ((tag = av_metadata_get(stream->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
229
+    while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
230 230
         printf("TAG:%s=%s\n", tag->key, tag->value);
231 231
 
232 232
     printf("[/STREAM]\n");
... ...
@@ -234,7 +235,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
234 234
 
235 235
 static void show_format(AVFormatContext *fmt_ctx)
236 236
 {
237
-    AVMetadataTag *tag = NULL;
237
+    AVDictionaryEntry *tag = NULL;
238 238
     char val_str[128];
239 239
 
240 240
     printf("[FORMAT]\n");
... ...
@@ -252,7 +253,7 @@ static void show_format(AVFormatContext *fmt_ctx)
252 252
     printf("bit_rate=%s\n",         value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate,
253 253
                                                  unit_bit_per_second_str));
254 254
 
255
-    while ((tag = av_metadata_get(fmt_ctx->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
255
+    while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
256 256
         printf("TAG:%s=%s\n", tag->key, tag->value);
257 257
 
258 258
     printf("[/FORMAT]\n");
... ...
@@ -36,6 +36,7 @@
36 36
 #include "libavformat/avio_internal.h"
37 37
 #include "libavutil/avstring.h"
38 38
 #include "libavutil/lfg.h"
39
+#include "libavutil/dict.h"
39 40
 #include "libavutil/random_seed.h"
40 41
 #include "libavutil/parseutils.h"
41 42
 #include "libavutil/opt.h"
... ...
@@ -854,7 +855,7 @@ static void close_connection(HTTPContext *c)
854 854
         ctx = c->rtp_ctx[i];
855 855
         if (ctx) {
856 856
             av_write_trailer(ctx);
857
-            av_metadata_free(&ctx->metadata);
857
+            av_dict_free(&ctx->metadata);
858 858
             av_free(ctx->streams[0]);
859 859
             av_free(ctx);
860 860
         }
... ...
@@ -2224,10 +2225,10 @@ static int http_prepare_data(HTTPContext *c)
2224 2224
     switch(c->state) {
2225 2225
     case HTTPSTATE_SEND_DATA_HEADER:
2226 2226
         memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx));
2227
-        av_metadata_set2(&c->fmt_ctx.metadata, "author"   , c->stream->author   , 0);
2228
-        av_metadata_set2(&c->fmt_ctx.metadata, "comment"  , c->stream->comment  , 0);
2229
-        av_metadata_set2(&c->fmt_ctx.metadata, "copyright", c->stream->copyright, 0);
2230
-        av_metadata_set2(&c->fmt_ctx.metadata, "title"    , c->stream->title    , 0);
2227
+        av_dict_set(&c->fmt_ctx.metadata, "author"   , c->stream->author   , 0);
2228
+        av_dict_set(&c->fmt_ctx.metadata, "comment"  , c->stream->comment  , 0);
2229
+        av_dict_set(&c->fmt_ctx.metadata, "copyright", c->stream->copyright, 0);
2230
+        av_dict_set(&c->fmt_ctx.metadata, "title"    , c->stream->title    , 0);
2231 2231
 
2232 2232
         c->fmt_ctx.streams = av_mallocz(sizeof(AVStream *) * c->stream->nb_streams);
2233 2233
 
... ...
@@ -2272,7 +2273,7 @@ static int http_prepare_data(HTTPContext *c)
2272 2272
             http_log("Error writing output header\n");
2273 2273
             return -1;
2274 2274
         }
2275
-        av_metadata_free(&c->fmt_ctx.metadata);
2275
+        av_dict_free(&c->fmt_ctx.metadata);
2276 2276
 
2277 2277
         len = avio_close_dyn_buf(c->fmt_ctx.pb, &c->pb_buffer);
2278 2278
         c->buffer_ptr = c->pb_buffer;
... ...
@@ -2927,8 +2928,8 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
2927 2927
     if (avc == NULL) {
2928 2928
         return -1;
2929 2929
     }
2930
-    av_metadata_set2(&avc->metadata, "title",
2931
-                     stream->title[0] ? stream->title : "No Title", 0);
2930
+    av_dict_set(&avc->metadata, "title",
2931
+               stream->title[0] ? stream->title : "No Title", 0);
2932 2932
     avc->nb_streams = stream->nb_streams;
2933 2933
     if (stream->is_multicast) {
2934 2934
         snprintf(avc->filename, 1024, "rtp://%s:%d?multicast=1?ttl=%d",
... ...
@@ -2954,7 +2955,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
2954 2954
 
2955 2955
  sdp_done:
2956 2956
     av_free(avc->streams);
2957
-    av_metadata_free(&avc->metadata);
2957
+    av_dict_free(&avc->metadata);
2958 2958
     av_free(avc);
2959 2959
     av_free(avs);
2960 2960
 
... ...
@@ -35,6 +35,7 @@
35 35
 
36 36
 #ifdef DEBUG
37 37
 #undef fprintf
38
+#undef perror
38 39
 #if 0
39 40
 static void png_save(const char *filename, uint8_t *bitmap, int w, int h,
40 41
                      uint32_t *rgba_palette)
... ...
@@ -49,7 +50,7 @@ static void png_save(const char *filename, uint8_t *bitmap, int w, int h,
49 49
     f = fopen(fname, "w");
50 50
     if (!f) {
51 51
         perror(fname);
52
-        exit(1);
52
+        return;
53 53
     }
54 54
     fprintf(f, "P6\n"
55 55
             "%d %d\n"
... ...
@@ -71,7 +72,7 @@ static void png_save(const char *filename, uint8_t *bitmap, int w, int h,
71 71
     f = fopen(fname2, "w");
72 72
     if (!f) {
73 73
         perror(fname2);
74
-        exit(1);
74
+        return;
75 75
     }
76 76
     fprintf(f, "P5\n"
77 77
             "%d %d\n"
... ...
@@ -105,7 +106,7 @@ static void png_save2(const char *filename, uint32_t *bitmap, int w, int h)
105 105
     f = fopen(fname, "w");
106 106
     if (!f) {
107 107
         perror(fname);
108
-        exit(1);
108
+        return;
109 109
     }
110 110
     fprintf(f, "P6\n"
111 111
             "%d %d\n"
... ...
@@ -127,7 +128,7 @@ static void png_save2(const char *filename, uint32_t *bitmap, int w, int h)
127 127
     f = fopen(fname2, "w");
128 128
     if (!f) {
129 129
         perror(fname2);
130
-        exit(1);
130
+        return;
131 131
     }
132 132
     fprintf(f, "P5\n"
133 133
             "%d %d\n"
... ...
@@ -20,6 +20,7 @@
20 20
  */
21 21
 
22 22
 #include "libavutil/intfloat_readwrite.h"
23
+#include "libavutil/dict.h"
23 24
 #include "avformat.h"
24 25
 #include "pcm.h"
25 26
 #include "aiff.h"
... ...
@@ -21,6 +21,7 @@
21 21
  */
22 22
 
23 23
 #include "libavutil/intreadwrite.h"
24
+#include "libavutil/dict.h"
24 25
 #include "avformat.h"
25 26
 #include "apetag.h"
26 27
 
... ...
@@ -57,7 +58,7 @@ static int ape_tag_read_field(AVFormatContext *s)
57 57
         return AVERROR(ENOMEM);
58 58
     avio_read(pb, value, size);
59 59
     value[size] = 0;
60
-    av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
60
+    av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL);
61 61
     return 0;
62 62
 }
63 63
 
... ...
@@ -28,6 +28,7 @@
28 28
 #include "libavutil/avstring.h"
29 29
 #include "libavutil/intreadwrite.h"
30 30
 #include "libavutil/opt.h"
31
+#include "libavutil/dict.h"
31 32
 #include "avformat.h"
32 33
 #include "internal.h"
33 34
 #include <unistd.h>
... ...
@@ -505,7 +506,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap)
505 505
             }
506 506
             avcodec_copy_context(st->codec, v->ctx->streams[j]->codec);
507 507
             if (v->bandwidth)
508
-                av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str,
508
+                av_dict_set(&st->metadata, "variant_bitrate", bitrate_str,
509 509
                                  0);
510 510
         }
511 511
         stream_offset += v->ctx->nb_streams;
... ...
@@ -24,6 +24,7 @@
24 24
 #include "libavutil/bswap.h"
25 25
 #include "libavutil/common.h"
26 26
 #include "libavutil/avstring.h"
27
+#include "libavutil/dict.h"
27 28
 #include "libavcodec/mpegaudio.h"
28 29
 #include "avformat.h"
29 30
 #include "avio_internal.h"
... ...
@@ -172,7 +173,8 @@ static void get_tag(AVFormatContext *s, const char *key, int type, int len)
172 172
         av_log(s, AV_LOG_DEBUG, "Unsupported value type %d in tag %s.\n", type, key);
173 173
         goto finish;
174 174
     }
175
-    av_metadata_set2(&s->metadata, key, value, 0);
175
+    if (*value)
176
+        av_dict_set(&s->metadata, key, value, 0);
176 177
 finish:
177 178
     av_freep(&value);
178 179
     avio_seek(s->pb, off + len, SEEK_SET);
... ...
@@ -681,7 +683,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
681 681
                     const char primary_tag[3] = { rfc1766[0], rfc1766[1], '\0' }; // ignore country code if any
682 682
                     const char *iso6392 = av_convert_lang_to(primary_tag, AV_LANG_ISO639_2_BIBL);
683 683
                     if (iso6392)
684
-                        av_metadata_set2(&st->metadata, "language", iso6392, 0);
684
+                        av_dict_set(&st->metadata, "language", iso6392, 0);
685 685
                 }
686 686
             }
687 687
         }
... ...
@@ -19,10 +19,10 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 #include "avformat.h"
22
-#include "metadata.h"
23 22
 #include "riff.h"
24 23
 #include "asf.h"
25 24
 #include "avio_internal.h"
25
+#include "libavutil/dict.h"
26 26
 
27 27
 #undef NDEBUG
28 28
 #include <assert.h>
... ...
@@ -296,7 +296,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
296 296
 {
297 297
     ASFContext *asf = s->priv_data;
298 298
     AVIOContext *pb = s->pb;
299
-    AVMetadataTag *tags[5];
299
+    AVDictionaryEntry *tags[5];
300 300
     int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
301 301
     int has_title;
302 302
     int metadata_count;
... ...
@@ -307,11 +307,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
307 307
 
308 308
     ff_metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL);
309 309
 
310
-    tags[0] = av_metadata_get(s->metadata, "title"    , NULL, 0);
311
-    tags[1] = av_metadata_get(s->metadata, "author"   , NULL, 0);
312
-    tags[2] = av_metadata_get(s->metadata, "copyright", NULL, 0);
313
-    tags[3] = av_metadata_get(s->metadata, "comment"  , NULL, 0);
314
-    tags[4] = av_metadata_get(s->metadata, "rating"   , NULL, 0);
310
+    tags[0] = av_dict_get(s->metadata, "title"    , NULL, 0);
311
+    tags[1] = av_dict_get(s->metadata, "author"   , NULL, 0);
312
+    tags[2] = av_dict_get(s->metadata, "copyright", NULL, 0);
313
+    tags[3] = av_dict_get(s->metadata, "comment"  , NULL, 0);
314
+    tags[4] = av_dict_get(s->metadata, "rating"   , NULL, 0);
315 315
 
316 316
     duration = asf->duration + PREROLL_TIME * 10000;
317 317
     has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
... ...
@@ -381,10 +381,10 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
381 381
         end_header(pb, hpos);
382 382
     }
383 383
     if (metadata_count) {
384
-        AVMetadataTag *tag = NULL;
384
+        AVDictionaryEntry *tag = NULL;
385 385
         hpos = put_header(pb, &ff_asf_extended_content_header);
386 386
         avio_wl16(pb, metadata_count);
387
-        while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
387
+        while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
388 388
             put_str16(pb, tag->key);
389 389
             avio_wl16(pb, 0);
390 390
             put_str16(pb, tag->value);
... ...
@@ -40,6 +40,7 @@ const char *avformat_license(void);
40 40
 #include <time.h>
41 41
 #include <stdio.h>  /* FILE */
42 42
 #include "libavcodec/avcodec.h"
43
+#include "libavutil/dict.h"
43 44
 
44 45
 #include "avio.h"
45 46
 #include "libavformat/version.h"
... ...
@@ -106,21 +107,24 @@ struct AVFormatContext;
106 106
  * variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of
107 107
  */
108 108
 
109
-#define AV_METADATA_MATCH_CASE      1
110
-#define AV_METADATA_IGNORE_SUFFIX   2
111
-#define AV_METADATA_DONT_STRDUP_KEY 4
112
-#define AV_METADATA_DONT_STRDUP_VAL 8
113
-#define AV_METADATA_DONT_OVERWRITE 16   ///< Don't overwrite existing tags.
109
+#if FF_API_OLD_METADATA2
110
+/**
111
+ * @defgroup old_metadata Old metadata API
112
+ * The following functions are deprecated, use
113
+ * their equivalents from libavutil/dict.h instead.
114
+ * @{
115
+ */
114 116
 
115
-typedef struct {
116
-    char *key;
117
-    char *value;
118
-}AVMetadataTag;
117
+#define AV_METADATA_MATCH_CASE      AV_DICT_MATCH_CASE
118
+#define AV_METADATA_IGNORE_SUFFIX   AV_DICT_IGNORE_SUFFIX
119
+#define AV_METADATA_DONT_STRDUP_KEY AV_DICT_DONT_STRDUP_KEY
120
+#define AV_METADATA_DONT_STRDUP_VAL AV_DICT_DONT_STRDUP_VAL
121
+#define AV_METADATA_DONT_OVERWRITE  AV_DICT_DONT_OVERWRITE
122
+
123
+typedef attribute_deprecated AVDictionary AVMetadata;
124
+typedef attribute_deprecated AVDictionaryEntry  AVMetadataTag;
119 125
 
120
-typedef struct AVMetadata AVMetadata;
121
-#if FF_API_OLD_METADATA2
122 126
 typedef struct AVMetadataConv AVMetadataConv;
123
-#endif
124 127
 
125 128
 /**
126 129
  * Get a metadata element with matching key.
... ...
@@ -130,8 +134,8 @@ typedef struct AVMetadataConv AVMetadataConv;
130 130
  * @param flags Allows case as well as suffix-insensitive comparisons.
131 131
  * @return Found tag or NULL, changing key or value leads to undefined behavior.
132 132
  */
133
-AVMetadataTag *
134
-av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags);
133
+attribute_deprecated AVDictionaryEntry *
134
+av_metadata_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
135 135
 
136 136
 /**
137 137
  * Set the given tag in *pm, overwriting an existing tag.
... ...
@@ -143,30 +147,32 @@ av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int f
143 143
  *        Passing a NULL value will cause an existing tag to be deleted.
144 144
  * @return >= 0 on success otherwise an error code <0
145 145
  */
146
-int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags);
146
+attribute_deprecated int av_metadata_set2(AVDictionary **pm, const char *key, const char *value, int flags);
147 147
 
148
-#if FF_API_OLD_METADATA2
149 148
 /**
150 149
  * This function is provided for compatibility reason and currently does nothing.
151 150
  */
152 151
 attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
153 152
                                                                         const AVMetadataConv *s_conv);
154
-#endif
155 153
 
156 154
 /**
157
- * Copy metadata from one AVMetadata struct into another.
158
- * @param dst pointer to a pointer to a AVMetadata struct. If *dst is NULL,
155
+ * Copy metadata from one AVDictionary struct into another.
156
+ * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
159 157
  *            this function will allocate a struct for you and put it in *dst
160
- * @param src pointer to source AVMetadata struct
158
+ * @param src pointer to source AVDictionary struct
161 159
  * @param flags flags to use when setting metadata in *dst
162
- * @note metadata is read using the AV_METADATA_IGNORE_SUFFIX flag
160
+ * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
163 161
  */
164
-void av_metadata_copy(AVMetadata **dst, AVMetadata *src, int flags);
162
+attribute_deprecated void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags);
165 163
 
166 164
 /**
167
- * Free all the memory allocated for an AVMetadata struct.
165
+ * Free all the memory allocated for an AVDictionary struct.
168 166
  */
169
-void av_metadata_free(AVMetadata **m);
167
+attribute_deprecated void av_metadata_free(AVDictionary **m);
168
+/**
169
+ * @}
170
+ */
171
+#endif
170 172
 
171 173
 
172 174
 /* packet functions */
... ...
@@ -563,7 +569,7 @@ typedef struct AVStream {
563 563
      */
564 564
     AVRational sample_aspect_ratio;
565 565
 
566
-    AVMetadata *metadata;
566
+    AVDictionary *metadata;
567 567
 
568 568
     /* Intended mostly for av_read_frame() support. Not supposed to be used by */
569 569
     /* external applications; try to use something else if at all possible.    */
... ...
@@ -644,7 +650,7 @@ typedef struct AVProgram {
644 644
     enum AVDiscard discard;        ///< selects which program to discard and which to feed to the caller
645 645
     unsigned int   *stream_index;
646 646
     unsigned int   nb_stream_indexes;
647
-    AVMetadata *metadata;
647
+    AVDictionary *metadata;
648 648
 
649 649
     int program_num;
650 650
     int pmt_pid;
... ...
@@ -658,7 +664,7 @@ typedef struct AVChapter {
658 658
     int id;                 ///< unique ID to identify the chapter
659 659
     AVRational time_base;   ///< time base in which the start/end timestamps are specified
660 660
     int64_t start, end;     ///< chapter start/end time in time_base units
661
-    AVMetadata *metadata;
661
+    AVDictionary *metadata;
662 662
 } AVChapter;
663 663
 
664 664
 /**
... ...
@@ -824,7 +830,7 @@ typedef struct AVFormatContext {
824 824
 
825 825
     struct AVPacketList *packet_buffer_end;
826 826
 
827
-    AVMetadata *metadata;
827
+    AVDictionary *metadata;
828 828
 
829 829
     /**
830 830
      * Remaining size available for raw_packet_buffer, in bytes.
... ...
@@ -26,6 +26,7 @@
26 26
 #include "libavutil/intreadwrite.h"
27 27
 #include "libavutil/bswap.h"
28 28
 #include "libavutil/opt.h"
29
+#include "libavutil/dict.h"
29 30
 #include "avformat.h"
30 31
 #include "avi.h"
31 32
 #include "dv.h"
... ...
@@ -280,8 +281,8 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t
280 280
 
281 281
     AV_WL32(key, tag);
282 282
 
283
-    return av_metadata_set2(st ? &st->metadata : &s->metadata, key, value,
284
-                            AV_METADATA_DONT_STRDUP_VAL);
283
+    return av_dict_set(st ? &st->metadata : &s->metadata, key, value,
284
+                            AV_DICT_DONT_STRDUP_VAL);
285 285
 }
286 286
 
287 287
 static void avi_read_info(AVFormatContext *s, uint64_t end)
... ...
@@ -296,7 +297,7 @@ static void avi_read_info(AVFormatContext *s, uint64_t end)
296 296
 static const char months[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
297 297
                                     "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
298 298
 
299
-static void avi_metadata_creation_time(AVMetadata **metadata, char *date)
299
+static void avi_metadata_creation_time(AVDictionary **metadata, char *date)
300 300
 {
301 301
     char month[4], time[9], buffer[64];
302 302
     int i, day, year;
... ...
@@ -307,11 +308,11 @@ static void avi_metadata_creation_time(AVMetadata **metadata, char *date)
307 307
             if (!strcasecmp(month, months[i])) {
308 308
                 snprintf(buffer, sizeof(buffer), "%.4d-%.2d-%.2d %s",
309 309
                          year, i+1, day, time);
310
-                av_metadata_set2(metadata, "creation_time", buffer, 0);
310
+                av_dict_set(metadata, "creation_time", buffer, 0);
311 311
             }
312 312
     } else if (date[4] == '/' && date[7] == '/') {
313 313
         date[4] = date[7] = '-';
314
-        av_metadata_set2(metadata, "creation_time", date, 0);
314
+        av_dict_set(metadata, "creation_time", date, 0);
315 315
     }
316 316
 }
317 317
 
... ...
@@ -339,7 +340,7 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
339 339
                     break;
340 340
                 }
341 341
                 if (name)
342
-                    av_metadata_set2(&s->metadata, name, buffer, 0);
342
+                    av_dict_set(&s->metadata, name, buffer, 0);
343 343
                 avio_skip(s->pb, size);
344 344
             }
345 345
             break;
... ...
@@ -795,7 +796,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt) {
795 795
         ret = avio_get_str16le(pb, desc_len, desc, sizeof(desc));
796 796
         avio_skip(pb, desc_len - ret);
797 797
         if (*desc)
798
-            av_metadata_set2(&st->metadata, "title", desc, 0);
798
+            av_dict_set(&st->metadata, "title", desc, 0);
799 799
 
800 800
         avio_rl16(pb);   /* flags? */
801 801
         avio_rl32(pb);   /* data size */
... ...
@@ -23,6 +23,7 @@
23 23
 #include "avio_internal.h"
24 24
 #include "riff.h"
25 25
 #include "libavutil/intreadwrite.h"
26
+#include "libavutil/dict.h"
26 27
 
27 28
 /*
28 29
  * TODO:
... ...
@@ -157,7 +158,7 @@ static int avi_write_header(AVFormatContext *s)
157 157
     int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
158 158
     AVCodecContext *stream, *video_enc;
159 159
     int64_t list1, list2, strh, strf;
160
-    AVMetadataTag *t = NULL;
160
+    AVDictionaryEntry *t = NULL;
161 161
 
162 162
     if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
163 163
         av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n",
... ...
@@ -297,7 +298,7 @@ static int avi_write_header(AVFormatContext *s)
297 297
             return -1;
298 298
         }
299 299
         ff_end_tag(pb, strf);
300
-        if ((t = av_metadata_get(s->streams[i]->metadata, "title", NULL, 0))) {
300
+        if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) {
301 301
             avi_write_info_tag(s->pb, "strn", t->value);
302 302
             t = NULL;
303 303
         }
... ...
@@ -379,7 +380,7 @@ static int avi_write_header(AVFormatContext *s)
379 379
     ffio_wfourcc(pb, "INFO");
380 380
     ff_metadata_conv(&s->metadata, ff_avi_metadata_conv, NULL);
381 381
     for (i = 0; *ff_avi_tags[i]; i++) {
382
-        if ((t = av_metadata_get(s->metadata, ff_avi_tags[i], NULL, AV_METADATA_MATCH_CASE)))
382
+        if ((t = av_dict_get(s->metadata, ff_avi_tags[i], NULL, AV_DICT_MATCH_CASE)))
383 383
             avi_write_info_tag(s->pb, t->key, t->value);
384 384
     }
385 385
     ff_end_tag(pb, list2);
... ...
@@ -29,6 +29,7 @@
29 29
 #include "riff.h"
30 30
 #include "isom.h"
31 31
 #include "libavutil/intreadwrite.h"
32
+#include "libavutil/dict.h"
32 33
 #include "caf.h"
33 34
 
34 35
 typedef struct {
... ...
@@ -187,7 +188,7 @@ static void read_info_chunk(AVFormatContext *s, int64_t size)
187 187
         char value[1024];
188 188
         get_strz(pb, key, sizeof(key));
189 189
         get_strz(pb, value, sizeof(value));
190
-        av_metadata_set2(&s->metadata, key, value, 0);
190
+        av_dict_set(&s->metadata, key, value, 0);
191 191
     }
192 192
 }
193 193
 
... ...
@@ -22,6 +22,7 @@
22 22
 #include "avformat.h"
23 23
 #include "ffmeta.h"
24 24
 #include "internal.h"
25
+#include "libavutil/dict.h"
25 26
 
26 27
 static int probe(AVProbeData *p)
27 28
 {
... ...
@@ -93,7 +94,7 @@ static uint8_t *unescape(uint8_t *buf, int size)
93 93
     return ret;
94 94
 }
95 95
 
96
-static int read_tag(uint8_t *line, AVMetadata **m)
96
+static int read_tag(uint8_t *line, AVDictionary **m)
97 97
 {
98 98
     uint8_t *key, *value, *p = line;
99 99
 
... ...
@@ -117,13 +118,13 @@ static int read_tag(uint8_t *line, AVMetadata **m)
117 117
         return AVERROR(ENOMEM);
118 118
     }
119 119
 
120
-    av_metadata_set2(m, key, value, AV_METADATA_DONT_STRDUP_KEY | AV_METADATA_DONT_STRDUP_VAL);
120
+    av_dict_set(m, key, value, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
121 121
     return 0;
122 122
 }
123 123
 
124 124
 static int read_header(AVFormatContext *s, AVFormatParameters *ap)
125 125
 {
126
-    AVMetadata **m = &s->metadata;
126
+    AVDictionary **m = &s->metadata;
127 127
     uint8_t line[1024];
128 128
 
129 129
     while(!url_feof(s->pb)) {
... ...
@@ -23,6 +23,7 @@
23 23
 
24 24
 #include "avformat.h"
25 25
 #include "ffmeta.h"
26
+#include "libavutil/dict.h"
26 27
 
27 28
 
28 29
 static void write_escape_str(AVIOContext *s, const uint8_t *str)
... ...
@@ -37,10 +38,10 @@ static void write_escape_str(AVIOContext *s, const uint8_t *str)
37 37
     }
38 38
 }
39 39
 
40
-static void write_tags(AVIOContext *s, AVMetadata *m)
40
+static void write_tags(AVIOContext *s, AVDictionary *m)
41 41
 {
42
-    AVMetadataTag *t = NULL;
43
-    while ((t = av_metadata_get(m, "", t, AV_METADATA_IGNORE_SUFFIX))) {
42
+    AVDictionaryEntry *t = NULL;
43
+    while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) {
44 44
         write_escape_str(s, t->key);
45 45
         avio_w8(s, '=');
46 46
         write_escape_str(s, t->value);
... ...
@@ -22,7 +22,6 @@
22 22
 #include "libavcodec/flac.h"
23 23
 #include "avformat.h"
24 24
 #include "flacenc.h"
25
-#include "metadata.h"
26 25
 #include "vorbiscomment.h"
27 26
 #include "libavcodec/bytestream.h"
28 27
 
... ...
@@ -39,7 +38,7 @@ static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_byte
39 39
     return 0;
40 40
 }
41 41
 
42
-static int flac_write_block_comment(AVIOContext *pb, AVMetadata **m,
42
+static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
43 43
                                     int last_block, int bitexact)
44 44
 {
45 45
     const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
... ...
@@ -25,6 +25,7 @@
25 25
  */
26 26
 
27 27
 #include "libavutil/avstring.h"
28
+#include "libavutil/dict.h"
28 29
 #include "libavcodec/bytestream.h"
29 30
 #include "libavcodec/mpeg4audio.h"
30 31
 #include "avformat.h"
... ...
@@ -259,17 +260,17 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
259 259
 
260 260
         if(amf_type == AMF_DATA_TYPE_BOOL) {
261 261
             av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val));
262
-            av_metadata_set2(&s->metadata, key, str_val, 0);
262
+            av_dict_set(&s->metadata, key, str_val, 0);
263 263
         } else if(amf_type == AMF_DATA_TYPE_NUMBER) {
264 264
             snprintf(str_val, sizeof(str_val), "%.f", num_val);
265
-            av_metadata_set2(&s->metadata, key, str_val, 0);
265
+            av_dict_set(&s->metadata, key, str_val, 0);
266 266
             if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
267 267
             else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0))
268 268
                 vcodec->bit_rate = num_val * 1024.0;
269 269
             else if(!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0))
270 270
                 acodec->bit_rate = num_val * 1024.0;
271 271
         } else if (amf_type == AMF_DATA_TYPE_STRING)
272
-            av_metadata_set2(&s->metadata, key, str_val, 0);
272
+            av_dict_set(&s->metadata, key, str_val, 0);
273 273
     }
274 274
 
275 275
     return 0;
... ...
@@ -25,6 +25,7 @@
25 25
 #include "internal.h"
26 26
 #include "avc.h"
27 27
 #include "metadata.h"
28
+#include "libavutil/dict.h"
28 29
 
29 30
 #undef NDEBUG
30 31
 #include <assert.h>
... ...
@@ -179,7 +180,7 @@ static int flv_write_header(AVFormatContext *s)
179 179
     int i;
180 180
     double framerate = 0.0;
181 181
     int metadata_size_pos, data_size;
182
-    AVMetadataTag *tag = NULL;
182
+    AVDictionaryEntry *tag = NULL;
183 183
 
184 184
     for(i=0; i<s->nb_streams; i++){
185 185
         AVCodecContext *enc = s->streams[i]->codec;
... ...
@@ -276,7 +277,7 @@ static int flv_write_header(AVFormatContext *s)
276 276
         put_amf_double(pb, audio_enc->codec_tag);
277 277
     }
278 278
 
279
-    while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
279
+    while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
280 280
         put_amf_string(pb, tag->key);
281 281
         avio_w8(pb, AMF_DATA_TYPE_STRING);
282 282
         put_amf_string(pb, tag->value);
... ...
@@ -21,6 +21,7 @@
21 21
 
22 22
 #include "id3v1.h"
23 23
 #include "libavcodec/avcodec.h"
24
+#include "libavutil/dict.h"
24 25
 
25 26
 const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + 1] = {
26 27
       [0] = "Blues",
... ...
@@ -191,7 +192,7 @@ static void get_string(AVFormatContext *s, const char *key,
191 191
     *q = '\0';
192 192
 
193 193
     if (*str)
194
-        av_metadata_set2(&s->metadata, key, str, 0);
194
+        av_dict_set(&s->metadata, key, str, 0);
195 195
 }
196 196
 
197 197
 /**
... ...
@@ -215,11 +216,11 @@ static int parse_tag(AVFormatContext *s, const uint8_t *buf)
215 215
     get_string(s, "comment", buf + 97, 30);
216 216
     if (buf[125] == 0 && buf[126] != 0) {
217 217
         snprintf(str, sizeof(str), "%d", buf[126]);
218
-        av_metadata_set2(&s->metadata, "track", str, 0);
218
+        av_dict_set(&s->metadata, "track", str, 0);
219 219
     }
220 220
     genre = buf[127];
221 221
     if (genre <= ID3v1_GENRE_MAX)
222
-        av_metadata_set2(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0);
222
+        av_dict_set(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0);
223 223
     return 0;
224 224
 }
225 225
 
... ...
@@ -30,7 +30,7 @@
30 30
 #include "id3v1.h"
31 31
 #include "libavutil/avstring.h"
32 32
 #include "libavutil/intreadwrite.h"
33
-#include "metadata.h"
33
+#include "libavutil/dict.h"
34 34
 #include "avio_internal.h"
35 35
 
36 36
 int ff_id3v2_match(const uint8_t *buf, const char * magic)
... ...
@@ -140,7 +140,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha
140 140
         val = dst;
141 141
 
142 142
     if (val)
143
-        av_metadata_set2(&s->metadata, key, val, AV_METADATA_DONT_OVERWRITE);
143
+        av_dict_set(&s->metadata, key, val, AV_DICT_DONT_OVERWRITE);
144 144
 }
145 145
 
146 146
 static int is_number(const char *str)
... ...
@@ -149,44 +149,44 @@ static int is_number(const char *str)
149 149
     return !*str;
150 150
 }
151 151
 
152
-static AVMetadataTag* get_date_tag(AVMetadata *m, const char *tag)
152
+static AVDictionaryEntry* get_date_tag(AVDictionary *m, const char *tag)
153 153
 {
154
-    AVMetadataTag *t;
155
-    if ((t = av_metadata_get(m, tag, NULL, AV_METADATA_MATCH_CASE)) &&
154
+    AVDictionaryEntry *t;
155
+    if ((t = av_dict_get(m, tag, NULL, AV_DICT_MATCH_CASE)) &&
156 156
         strlen(t->value) == 4 && is_number(t->value))
157 157
         return t;
158 158
     return NULL;
159 159
 }
160 160
 
161
-static void merge_date(AVMetadata **m)
161
+static void merge_date(AVDictionary **m)
162 162
 {
163
-    AVMetadataTag *t;
163
+    AVDictionaryEntry *t;
164 164
     char date[17] = {0};      // YYYY-MM-DD hh:mm
165 165
 
166 166
     if (!(t = get_date_tag(*m, "TYER")) &&
167 167
         !(t = get_date_tag(*m, "TYE")))
168 168
         return;
169 169
     av_strlcpy(date, t->value, 5);
170
-    av_metadata_set2(m, "TYER", NULL, 0);
171
-    av_metadata_set2(m, "TYE",  NULL, 0);
170
+    av_dict_set(m, "TYER", NULL, 0);
171
+    av_dict_set(m, "TYE",  NULL, 0);
172 172
 
173 173
     if (!(t = get_date_tag(*m, "TDAT")) &&
174 174
         !(t = get_date_tag(*m, "TDA")))
175 175
         goto finish;
176 176
     snprintf(date + 4, sizeof(date) - 4, "-%.2s-%.2s", t->value + 2, t->value);
177
-    av_metadata_set2(m, "TDAT", NULL, 0);
178
-    av_metadata_set2(m, "TDA",  NULL, 0);
177
+    av_dict_set(m, "TDAT", NULL, 0);
178
+    av_dict_set(m, "TDA",  NULL, 0);
179 179
 
180 180
     if (!(t = get_date_tag(*m, "TIME")) &&
181 181
         !(t = get_date_tag(*m, "TIM")))
182 182
         goto finish;
183 183
     snprintf(date + 10, sizeof(date) - 10, " %.2s:%.2s", t->value, t->value + 2);
184
-    av_metadata_set2(m, "TIME", NULL, 0);
185
-    av_metadata_set2(m, "TIM",  NULL, 0);
184
+    av_dict_set(m, "TIME", NULL, 0);
185
+    av_dict_set(m, "TIM",  NULL, 0);
186 186
 
187 187
 finish:
188 188
     if (date[0])
189
-        av_metadata_set2(m, "date", date, 0);
189
+        av_dict_set(m, "date", date, 0);
190 190
 }
191 191
 
192 192
 static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
... ...
@@ -30,6 +30,7 @@
30 30
 
31 31
 #include "libavcodec/bytestream.h"
32 32
 #include "libavutil/intreadwrite.h"
33
+#include "libavutil/dict.h"
33 34
 #include "avformat.h"
34 35
 
35 36
 #define ID_8SVX       MKTAG('8','S','V','X')
... ...
@@ -109,7 +110,7 @@ static int get_metadata(AVFormatContext *s,
109 109
         return AVERROR(EIO);
110 110
     }
111 111
     buf[data_size] = 0;
112
-    av_metadata_set2(&s->metadata, tag, buf, AV_METADATA_DONT_STRDUP_VAL);
112
+    av_dict_set(&s->metadata, tag, buf, AV_DICT_DONT_STRDUP_VAL);
113 113
     return 0;
114 114
 }
115 115
 
... ...
@@ -42,6 +42,7 @@
42 42
 #include "libavutil/intreadwrite.h"
43 43
 #include "libavutil/avstring.h"
44 44
 #include "libavutil/lzo.h"
45
+#include "libavutil/dict.h"
45 46
 #if CONFIG_ZLIB
46 47
 #include <zlib.h>
47 48
 #endif
... ...
@@ -1073,7 +1074,7 @@ static void matroska_merge_packets(AVPacket *out, AVPacket *in)
1073 1073
 }
1074 1074
 
1075 1075
 static void matroska_convert_tag(AVFormatContext *s, EbmlList *list,
1076
-                                 AVMetadata **metadata, char *prefix)
1076
+                                 AVDictionary **metadata, char *prefix)
1077 1077
 {
1078 1078
     MatroskaTag *tags = list->elem;
1079 1079
     char key[1024];
... ...
@@ -1089,14 +1090,14 @@ static void matroska_convert_tag(AVFormatContext *s, EbmlList *list,
1089 1089
         if (prefix)  snprintf(key, sizeof(key), "%s/%s", prefix, tags[i].name);
1090 1090
         else         av_strlcpy(key, tags[i].name, sizeof(key));
1091 1091
         if (tags[i].def || !lang) {
1092
-        av_metadata_set2(metadata, key, tags[i].string, 0);
1092
+        av_dict_set(metadata, key, tags[i].string, 0);
1093 1093
         if (tags[i].sub.nb_elem)
1094 1094
             matroska_convert_tag(s, &tags[i].sub, metadata, key);
1095 1095
         }
1096 1096
         if (lang) {
1097 1097
             av_strlcat(key, "-", sizeof(key));
1098 1098
             av_strlcat(key, lang, sizeof(key));
1099
-            av_metadata_set2(metadata, key, tags[i].string, 0);
1099
+            av_dict_set(metadata, key, tags[i].string, 0);
1100 1100
             if (tags[i].sub.nb_elem)
1101 1101
                 matroska_convert_tag(s, &tags[i].sub, metadata, key);
1102 1102
         }
... ...
@@ -1269,7 +1270,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
1269 1269
     if (matroska->duration)
1270 1270
         matroska->ctx->duration = matroska->duration * matroska->time_scale
1271 1271
                                   * 1000 / AV_TIME_BASE;
1272
-    av_metadata_set2(&s->metadata, "title", matroska->title, 0);
1272
+    av_dict_set(&s->metadata, "title", matroska->title, 0);
1273 1273
 
1274 1274
     tracks = matroska->tracks.elem;
1275 1275
     for (i=0; i < matroska->tracks.nb_elem; i++) {
... ...
@@ -1467,8 +1468,8 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
1467 1467
         st->codec->codec_id = codec_id;
1468 1468
         st->start_time = 0;
1469 1469
         if (strcmp(track->language, "und"))
1470
-            av_metadata_set2(&st->metadata, "language", track->language, 0);
1471
-        av_metadata_set2(&st->metadata, "title", track->name, 0);
1470
+            av_dict_set(&st->metadata, "language", track->language, 0);
1471
+        av_dict_set(&st->metadata, "title", track->name, 0);
1472 1472
 
1473 1473
         if (track->flag_default)
1474 1474
             st->disposition |= AV_DISPOSITION_DEFAULT;
... ...
@@ -1550,7 +1551,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
1550 1550
             AVStream *st = av_new_stream(s, 0);
1551 1551
             if (st == NULL)
1552 1552
                 break;
1553
-            av_metadata_set2(&st->metadata, "filename",attachements[j].filename, 0);
1553
+            av_dict_set(&st->metadata, "filename",attachements[j].filename, 0);
1554 1554
             st->codec->codec_id = CODEC_ID_NONE;
1555 1555
             st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
1556 1556
             st->codec->extradata  = av_malloc(attachements[j].bin.size);
... ...
@@ -1578,7 +1579,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
1578 1578
             ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000},
1579 1579
                            chapters[i].start, chapters[i].end,
1580 1580
                            chapters[i].title);
1581
-            av_metadata_set2(&chapters[i].chapter->metadata,
1581
+            av_dict_set(&chapters[i].chapter->metadata,
1582 1582
                              "title", chapters[i].title, 0);
1583 1583
             max_start = chapters[i].start;
1584 1584
         }
... ...
@@ -30,6 +30,7 @@
30 30
 #include "libavutil/intreadwrite.h"
31 31
 #include "libavutil/random_seed.h"
32 32
 #include "libavutil/lfg.h"
33
+#include "libavutil/dict.h"
33 34
 #include "libavcodec/xiph.h"
34 35
 #include "libavcodec/mpeg4audio.h"
35 36
 #include <strings.h>
... ...
@@ -523,7 +524,7 @@ static int mkv_write_tracks(AVFormatContext *s)
523 523
         int bit_depth = av_get_bits_per_sample(codec->codec_id);
524 524
         int sample_rate = codec->sample_rate;
525 525
         int output_sample_rate = 0;
526
-        AVMetadataTag *tag;
526
+        AVDictionaryEntry *tag;
527 527
 
528 528
         if (!bit_depth)
529 529
             bit_depth = av_get_bits_per_sample_fmt(codec->sample_fmt);
... ...
@@ -536,9 +537,9 @@ static int mkv_write_tracks(AVFormatContext *s)
536 536
         put_ebml_uint (pb, MATROSKA_ID_TRACKUID        , i + 1);
537 537
         put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0);    // no lacing (yet)
538 538
 
539
-        if ((tag = av_metadata_get(st->metadata, "title", NULL, 0)))
539
+        if ((tag = av_dict_get(st->metadata, "title", NULL, 0)))
540 540
             put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value);
541
-        tag = av_metadata_get(st->metadata, "language", NULL, 0);
541
+        tag = av_dict_get(st->metadata, "language", NULL, 0);
542 542
         put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag ? tag->value:"und");
543 543
 
544 544
         if (st->disposition)
... ...
@@ -587,8 +588,8 @@ static int mkv_write_tracks(AVFormatContext *s)
587 587
                 put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width);
588 588
                 put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, codec->height);
589 589
 
590
-                if ((tag = av_metadata_get(st->metadata, "stereo_mode", NULL, 0)) ||
591
-                    (tag = av_metadata_get( s->metadata, "stereo_mode", NULL, 0))) {
590
+                if ((tag = av_dict_get(st->metadata, "stereo_mode", NULL, 0)) ||
591
+                    (tag = av_dict_get( s->metadata, "stereo_mode", NULL, 0))) {
592 592
                     // save stereo mode flag
593 593
                     uint64_t st_mode = MATROSKA_VIDEO_STEREO_MODE_COUNT;
594 594
 
... ...
@@ -677,7 +678,7 @@ static int mkv_write_chapters(AVFormatContext *s)
677 677
     for (i = 0; i < s->nb_chapters; i++) {
678 678
         ebml_master chapteratom, chapterdisplay;
679 679
         AVChapter *c     = s->chapters[i];
680
-        AVMetadataTag *t = NULL;
680
+        AVDictionaryEntry *t = NULL;
681 681
 
682 682
         chapteratom = start_ebml_master(pb, MATROSKA_ID_CHAPTERATOM, 0);
683 683
         put_ebml_uint(pb, MATROSKA_ID_CHAPTERUID, c->id);
... ...
@@ -687,7 +688,7 @@ static int mkv_write_chapters(AVFormatContext *s)
687 687
                       av_rescale_q(c->end,   c->time_base, scale));
688 688
         put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGHIDDEN , 0);
689 689
         put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGENABLED, 1);
690
-        if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
690
+        if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
691 691
             chapterdisplay = start_ebml_master(pb, MATROSKA_ID_CHAPTERDISPLAY, 0);
692 692
             put_ebml_string(pb, MATROSKA_ID_CHAPSTRING, t->value);
693 693
             put_ebml_string(pb, MATROSKA_ID_CHAPLANG  , "und");
... ...
@@ -700,7 +701,7 @@ static int mkv_write_chapters(AVFormatContext *s)
700 700
     return 0;
701 701
 }
702 702
 
703
-static void mkv_write_simpletag(AVIOContext *pb, AVMetadataTag *t)
703
+static void mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t)
704 704
 {
705 705
     uint8_t *key = av_strdup(t->key);
706 706
     uint8_t *p   = key;
... ...
@@ -730,12 +731,12 @@ static void mkv_write_simpletag(AVIOContext *pb, AVMetadataTag *t)
730 730
     av_freep(&key);
731 731
 }
732 732
 
733
-static int mkv_write_tag(AVFormatContext *s, AVMetadata *m, unsigned int elementid,
733
+static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int elementid,
734 734
                          unsigned int uid, ebml_master *tags)
735 735
 {
736 736
     MatroskaMuxContext *mkv = s->priv_data;
737 737
     ebml_master tag, targets;
738
-    AVMetadataTag *t = NULL;
738
+    AVDictionaryEntry *t = NULL;
739 739
     int ret;
740 740
 
741 741
     if (!tags->pos) {
... ...
@@ -751,7 +752,7 @@ static int mkv_write_tag(AVFormatContext *s, AVMetadata *m, unsigned int element
751 751
         put_ebml_uint(s->pb, elementid, uid);
752 752
     end_ebml_master(s->pb, targets);
753 753
 
754
-    while ((t = av_metadata_get(m, "", t, AV_METADATA_IGNORE_SUFFIX)))
754
+    while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX)))
755 755
         if (strcasecmp(t->key, "title") && strcasecmp(t->key, "stereo_mode"))
756 756
             mkv_write_simpletag(s->pb, t);
757 757
 
... ...
@@ -766,7 +767,7 @@ static int mkv_write_tags(AVFormatContext *s)
766 766
 
767 767
     ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL);
768 768
 
769
-    if (av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX)) {
769
+    if (av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
770 770
         ret = mkv_write_tag(s, s->metadata, 0, 0, &tags);
771 771
         if (ret < 0) return ret;
772 772
     }
... ...
@@ -774,7 +775,7 @@ static int mkv_write_tags(AVFormatContext *s)
774 774
     for (i = 0; i < s->nb_streams; i++) {
775 775
         AVStream *st = s->streams[i];
776 776
 
777
-        if (!av_metadata_get(st->metadata, "", 0, AV_METADATA_IGNORE_SUFFIX))
777
+        if (!av_dict_get(st->metadata, "", 0, AV_DICT_IGNORE_SUFFIX))
778 778
             continue;
779 779
 
780 780
         ret = mkv_write_tag(s, st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID, i + 1, &tags);
... ...
@@ -784,7 +785,7 @@ static int mkv_write_tags(AVFormatContext *s)
784 784
     for (i = 0; i < s->nb_chapters; i++) {
785 785
         AVChapter *ch = s->chapters[i];
786 786
 
787
-        if (!av_metadata_get(ch->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
787
+        if (!av_dict_get(ch->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
788 788
             continue;
789 789
 
790 790
         ret = mkv_write_tag(s, ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID, ch->id, &tags);
... ...
@@ -801,7 +802,7 @@ static int mkv_write_header(AVFormatContext *s)
801 801
     MatroskaMuxContext *mkv = s->priv_data;
802 802
     AVIOContext *pb = s->pb;
803 803
     ebml_master ebml_header, segment_info;
804
-    AVMetadataTag *tag;
804
+    AVDictionaryEntry *tag;
805 805
     int ret, i;
806 806
 
807 807
     if (!strcmp(s->oformat->name, "webm")) mkv->mode = MODE_WEBM;
... ...
@@ -838,7 +839,7 @@ static int mkv_write_header(AVFormatContext *s)
838 838
 
839 839
     segment_info = start_ebml_master(pb, MATROSKA_ID_INFO, 0);
840 840
     put_ebml_uint(pb, MATROSKA_ID_TIMECODESCALE, 1000000);
841
-    if ((tag = av_metadata_get(s->metadata, "title", NULL, 0)))
841
+    if ((tag = av_dict_get(s->metadata, "title", NULL, 0)))
842 842
         put_ebml_string(pb, MATROSKA_ID_TITLE, tag->value);
843 843
     if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
844 844
         uint32_t segment_uid[4];
... ...
@@ -21,107 +21,51 @@
21 21
 #include <strings.h>
22 22
 #include "avformat.h"
23 23
 #include "metadata.h"
24
+#include "libavutil/dict.h"
24 25
 
25
-AVMetadataTag *
26
-av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags)
26
+#if FF_API_OLD_METADATA2
27
+AVDictionaryEntry *
28
+av_metadata_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
27 29
 {
28
-    unsigned int i, j;
29
-
30
-    if(!m)
31
-        return NULL;
32
-
33
-    if(prev) i= prev - m->elems + 1;
34
-    else     i= 0;
35
-
36
-    for(; i<m->count; i++){
37
-        const char *s= m->elems[i].key;
38
-        if(flags & AV_METADATA_MATCH_CASE) for(j=0;         s[j]  ==         key[j]  && key[j]; j++);
39
-        else                               for(j=0; toupper(s[j]) == toupper(key[j]) && key[j]; j++);
40
-        if(key[j])
41
-            continue;
42
-        if(s[j] && !(flags & AV_METADATA_IGNORE_SUFFIX))
43
-            continue;
44
-        return &m->elems[i];
45
-    }
46
-    return NULL;
30
+    return av_dict_get(m, key, prev, flags);
47 31
 }
48 32
 
49
-int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags)
33
+int av_metadata_set2(AVDictionary **pm, const char *key, const char *value, int flags)
50 34
 {
51
-    AVMetadata *m= *pm;
52
-    AVMetadataTag *tag= av_metadata_get(m, key, NULL, flags);
53
-
54
-    if(!m)
55
-        m=*pm= av_mallocz(sizeof(*m));
56
-
57
-    if(tag){
58
-        if (flags & AV_METADATA_DONT_OVERWRITE)
59
-            return 0;
60
-        av_free(tag->value);
61
-        av_free(tag->key);
62
-        *tag= m->elems[--m->count];
63
-    }else{
64
-        AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
65
-        if(tmp){
66
-            m->elems= tmp;
67
-        }else
68
-            return AVERROR(ENOMEM);
69
-    }
70
-    if(value){
71
-        if(flags & AV_METADATA_DONT_STRDUP_KEY){
72
-            m->elems[m->count].key  = key;
73
-        }else
74
-        m->elems[m->count].key  = av_strdup(key  );
75
-        if(flags & AV_METADATA_DONT_STRDUP_VAL){
76
-            m->elems[m->count].value= value;
77
-        }else
78
-        m->elems[m->count].value= av_strdup(value);
79
-        m->count++;
80
-    }
81
-    if(!m->count) {
82
-        av_free(m->elems);
83
-        av_freep(pm);
84
-    }
85
-
86
-    return 0;
35
+    return av_dict_set(pm, key, value, flags);
87 36
 }
88 37
 
89
-#if FF_API_OLD_METADATA2
90 38
 void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv,
91 39
                                             const AVMetadataConv *s_conv)
92 40
 {
93 41
     return;
94 42
 }
95
-#endif
96 43
 
97
-void av_metadata_free(AVMetadata **pm)
44
+void av_metadata_free(AVDictionary **pm)
98 45
 {
99
-    AVMetadata *m= *pm;
46
+    av_dict_free(pm);
47
+}
100 48
 
101
-    if(m){
102
-        while(m->count--){
103
-            av_free(m->elems[m->count].key);
104
-            av_free(m->elems[m->count].value);
105
-        }
106
-        av_free(m->elems);
107
-    }
108
-    av_freep(pm);
49
+void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags)
50
+{
51
+    av_dict_copy(dst, src, flags);
109 52
 }
53
+#endif
110 54
 
111
-void ff_metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
55
+void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
112 56
                                        const AVMetadataConv *s_conv)
113 57
 {
114 58
     /* TODO: use binary search to look up the two conversion tables
115 59
        if the tables are getting big enough that it would matter speed wise */
116 60
     const AVMetadataConv *sc, *dc;
117
-    AVMetadataTag *mtag = NULL;
118
-    AVMetadata *dst = NULL;
61
+    AVDictionaryEntry *mtag = NULL;
62
+    AVDictionary *dst = NULL;
119 63
     const char *key;
120 64
 
121 65
     if (d_conv == s_conv)
122 66
         return;
123 67
 
124
-    while((mtag=av_metadata_get(*pm, "", mtag, AV_METADATA_IGNORE_SUFFIX))) {
68
+    while ((mtag = av_dict_get(*pm, "", mtag, AV_DICT_IGNORE_SUFFIX))) {
125 69
         key = mtag->key;
126 70
         if (s_conv)
127 71
             for (sc=s_conv; sc->native; sc++)
... ...
@@ -135,9 +79,9 @@ void ff_metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
135 135
                     key = dc->native;
136 136
                     break;
137 137
                 }
138
-        av_metadata_set2(&dst, key, mtag->value, 0);
138
+        av_dict_set(&dst, key, mtag->value, 0);
139 139
     }
140
-    av_metadata_free(pm);
140
+    av_dict_free(pm);
141 141
     *pm = dst;
142 142
 }
143 143
 
... ...
@@ -154,10 +98,3 @@ void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
154 154
         ff_metadata_conv(&ctx->programs[i]->metadata, d_conv, s_conv);
155 155
 }
156 156
 
157
-void av_metadata_copy(AVMetadata **dst, AVMetadata *src, int flags)
158
-{
159
-    AVMetadataTag *t = NULL;
160
-
161
-    while ((t = av_metadata_get(src, "", t, AV_METADATA_IGNORE_SUFFIX)))
162
-        av_metadata_set2(dst, t->key, t->value, flags);
163
-}
... ...
@@ -29,11 +29,7 @@
29 29
 
30 30
 
31 31
 #include "avformat.h"
32
-
33
-struct AVMetadata{
34
-    int count;
35
-    AVMetadataTag *elems;
36
-};
32
+#include "libavutil/dict.h"
37 33
 
38 34
 struct AVMetadataConv{
39 35
     const char *native;
... ...
@@ -43,7 +39,7 @@ struct AVMetadataConv{
43 43
 typedef struct AVMetadataConv AVMetadataConv;
44 44
 #endif
45 45
 
46
-void ff_metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
46
+void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
47 47
                                        const AVMetadataConv *s_conv);
48 48
 void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
49 49
                                                 const AVMetadataConv *s_conv);
... ...
@@ -27,6 +27,7 @@
27 27
 
28 28
 #include "libavutil/intreadwrite.h"
29 29
 #include "libavutil/avstring.h"
30
+#include "libavutil/dict.h"
30 31
 #include "avformat.h"
31 32
 #include "avio_internal.h"
32 33
 #include "riff.h"
... ...
@@ -84,7 +85,7 @@ static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, uns
84 84
 
85 85
     avio_rb16(pb); // unknown
86 86
     snprintf(buf, sizeof(buf), "%d", avio_rb16(pb));
87
-    av_metadata_set2(&c->fc->metadata, type, buf, 0);
87
+    av_dict_set(&c->fc->metadata, type, buf, 0);
88 88
 
89 89
     avio_rb16(pb); // total tracks/discs
90 90
 
... ...
@@ -208,10 +209,10 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
208 208
             avio_read(pb, str, str_size);
209 209
             str[str_size] = 0;
210 210
         }
211
-        av_metadata_set2(&c->fc->metadata, key, str, 0);
211
+        av_dict_set(&c->fc->metadata, key, str, 0);
212 212
         if (*language && strcmp(language, "und")) {
213 213
             snprintf(key2, sizeof(key2), "%s-%s", key, language);
214
-            av_metadata_set2(&c->fc->metadata, key2, str, 0);
214
+            av_dict_set(&c->fc->metadata, key2, str, 0);
215 215
         }
216 216
     }
217 217
     av_dlog(c->fc, "lang \"%3s\" ", language);
... ...
@@ -557,10 +558,10 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
557 557
     if (strcmp(type, "qt  "))
558 558
         c->isom = 1;
559 559
     av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type);
560
-    av_metadata_set2(&c->fc->metadata, "major_brand", type, 0);
560
+    av_dict_set(&c->fc->metadata, "major_brand", type, 0);
561 561
     minor_ver = avio_rb32(pb); /* minor version */
562 562
     snprintf(minor_ver_str, sizeof(minor_ver_str), "%d", minor_ver);
563
-    av_metadata_set2(&c->fc->metadata, "minor_version", minor_ver_str, 0);
563
+    av_dict_set(&c->fc->metadata, "minor_version", minor_ver_str, 0);
564 564
 
565 565
     comp_brand_size = atom.size - 8;
566 566
     if (comp_brand_size < 0)
... ...
@@ -570,7 +571,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
570 570
         return AVERROR(ENOMEM);
571 571
     avio_read(pb, comp_brands_str, comp_brand_size);
572 572
     comp_brands_str[comp_brand_size] = 0;
573
-    av_metadata_set2(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
573
+    av_dict_set(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
574 574
     av_freep(&comp_brands_str);
575 575
 
576 576
     return 0;
... ...
@@ -594,7 +595,7 @@ static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
594 594
     return mov_read_default(c, pb, atom);
595 595
 }
596 596
 
597
-static void mov_metadata_creation_time(AVMetadata **metadata, time_t time)
597
+static void mov_metadata_creation_time(AVDictionary **metadata, time_t time)
598 598
 {
599 599
     char buffer[32];
600 600
     if (time) {
... ...
@@ -603,7 +604,7 @@ static void mov_metadata_creation_time(AVMetadata **metadata, time_t time)
603 603
         ptm = gmtime(&time);
604 604
         if (!ptm) return;
605 605
         strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm);
606
-        av_metadata_set2(metadata, "creation_time", buffer, 0);
606
+        av_dict_set(metadata, "creation_time", buffer, 0);
607 607
     }
608 608
 }
609 609
 
... ...
@@ -640,7 +641,7 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
640 640
 
641 641
     lang = avio_rb16(pb); /* language */
642 642
     if (ff_mov_lang_to_iso639(lang, language))
643
-        av_metadata_set2(&st->metadata, "language", language, 0);
643
+        av_dict_set(&st->metadata, "language", language, 0);
644 644
     avio_rb16(pb); /* quality */
645 645
 
646 646
     return 0;
... ...
@@ -2147,9 +2148,6 @@ static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
2147 2147
         goto free_and_return;
2148 2148
     atom.type = MKTAG('m','o','o','v');
2149 2149
     atom.size = moov_len;
2150
-#ifdef DEBUG
2151
-//    { int fd = open("/tmp/uncompheader.mov", O_WRONLY | O_CREAT); write(fd, moov_data, moov_len); close(fd); }
2152
-#endif
2153 2150
     ret = mov_read_default(c, &ctx, atom);
2154 2151
 free_and_return:
2155 2152
     av_free(moov_data);
... ...
@@ -33,6 +33,7 @@
33 33
 #include "internal.h"
34 34
 #include "libavutil/avstring.h"
35 35
 #include "libavutil/opt.h"
36
+#include "libavutil/dict.h"
36 37
 
37 38
 #undef NDEBUG
38 39
 #include <assert.h>
... ...
@@ -1534,15 +1535,15 @@ static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb,
1534 1534
                                      int long_style)
1535 1535
 {
1536 1536
     int l, lang = 0, len, len2;
1537
-    AVMetadataTag *t, *t2 = NULL;
1537
+    AVDictionaryEntry *t, *t2 = NULL;
1538 1538
     char tag2[16];
1539 1539
 
1540
-    if (!(t = av_metadata_get(s->metadata, tag, NULL, 0)))
1540
+    if (!(t = av_dict_get(s->metadata, tag, NULL, 0)))
1541 1541
         return 0;
1542 1542
 
1543 1543
     len = strlen(t->key);
1544 1544
     snprintf(tag2, sizeof(tag2), "%s-", tag);
1545
-    while ((t2 = av_metadata_get(s->metadata, tag2, t2, AV_METADATA_IGNORE_SUFFIX))) {
1545
+    while ((t2 = av_dict_get(s->metadata, tag2, t2, AV_DICT_IGNORE_SUFFIX))) {
1546 1546
         len2 = strlen(t2->key);
1547 1547
         if (len2 == len+4 && !strcmp(t->value, t2->value)
1548 1548
             && (l=ff_mov_iso639_to_lang(&t2->key[len2-3], 1)) >= 0) {
... ...
@@ -1557,7 +1558,7 @@ static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb,
1557 1557
 static int mov_write_trkn_tag(AVIOContext *pb, MOVMuxContext *mov,
1558 1558
                               AVFormatContext *s)
1559 1559
 {
1560
-    AVMetadataTag *t = av_metadata_get(s->metadata, "track", NULL, 0);
1560
+    AVDictionaryEntry *t = av_dict_get(s->metadata, "track", NULL, 0);
1561 1561
     int size = 0, track = t ? atoi(t->value) : 0;
1562 1562
     if (track) {
1563 1563
         avio_wb32(pb, 32); /* size */
... ...
@@ -1649,7 +1650,7 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s,
1649 1649
                                   const char *tag, const char *str)
1650 1650
 {
1651 1651
     int64_t pos = avio_tell(pb);
1652
-    AVMetadataTag *t = av_metadata_get(s->metadata, str, NULL, 0);
1652
+    AVDictionaryEntry *t = av_dict_get(s->metadata, str, NULL, 0);
1653 1653
     if (!t || !utf8len(t->value))
1654 1654
         return 0;
1655 1655
     avio_wb32(pb, 0);   /* size */
... ...
@@ -1661,7 +1662,7 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s,
1661 1661
         avio_wb16(pb, language_code("eng")); /* language */
1662 1662
         avio_write(pb, t->value, strlen(t->value)+1); /* UTF8 string value */
1663 1663
         if (!strcmp(tag, "albm") &&
1664
-            (t = av_metadata_get(s->metadata, "track", NULL, 0)))
1664
+            (t = av_dict_get(s->metadata, "track", NULL, 0)))
1665 1665
             avio_w8(pb, atoi(t->value));
1666 1666
     }
1667 1667
     return updateSize(pb, pos);
... ...
@@ -1680,10 +1681,10 @@ static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s)
1680 1680
 
1681 1681
     for (i = 0; i < nb_chapters; i++) {
1682 1682
         AVChapter *c = s->chapters[i];
1683
-        AVMetadataTag *t;
1683
+        AVDictionaryEntry *t;
1684 1684
         avio_wb64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000}));
1685 1685
 
1686
-        if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
1686
+        if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
1687 1687
             int len = FFMIN(strlen(t->value), 255);
1688 1688
             avio_w8(pb, len);
1689 1689
             avio_write(pb, t->value, len);
... ...
@@ -1761,7 +1762,7 @@ static void mov_write_psp_udta_tag(AVIOContext *pb,
1761 1761
 
1762 1762
 static int mov_write_uuidusmt_tag(AVIOContext *pb, AVFormatContext *s)
1763 1763
 {
1764
-    AVMetadataTag *title = av_metadata_get(s->metadata, "title", NULL, 0);
1764
+    AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0);
1765 1765
     int64_t pos, pos2;
1766 1766
 
1767 1767
     if (title) {
... ...
@@ -2115,13 +2116,13 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
2115 2115
 
2116 2116
     for (i = 0; i < s->nb_chapters; i++) {
2117 2117
         AVChapter *c = s->chapters[i];
2118
-        AVMetadataTag *t;
2118
+        AVDictionaryEntry *t;
2119 2119
 
2120 2120
         int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
2121 2121
         pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
2122 2122
         pkt.duration = end - pkt.dts;
2123 2123
 
2124
-        if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
2124
+        if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
2125 2125
             len = strlen(t->value);
2126 2126
             pkt.size = len+2;
2127 2127
             pkt.data = av_malloc(pkt.size);
... ...
@@ -2195,7 +2196,7 @@ static int mov_write_header(AVFormatContext *s)
2195 2195
     for(i=0; i<s->nb_streams; i++){
2196 2196
         AVStream *st= s->streams[i];
2197 2197
         MOVTrack *track= &mov->tracks[i];
2198
-        AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0);
2198
+        AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
2199 2199
 
2200 2200
         track->enc = st->codec;
2201 2201
         track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV);
... ...
@@ -21,6 +21,7 @@
21 21
 
22 22
 #include "libavutil/avstring.h"
23 23
 #include "libavutil/intreadwrite.h"
24
+#include "libavutil/dict.h"
24 25
 #include "avformat.h"
25 26
 #include "id3v2.h"
26 27
 #include "id3v1.h"
... ...
@@ -149,7 +150,7 @@ static int mp3_read_header(AVFormatContext *s,
149 149
 
150 150
     off = avio_tell(s->pb);
151 151
 
152
-    if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
152
+    if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
153 153
         ff_id3v1_read(s);
154 154
 
155 155
     if (mp3_parse_vbr_tags(s, st, off) < 0)
... ...
@@ -31,19 +31,20 @@
31 31
 #include "libavcodec/mpegaudiodata.h"
32 32
 #include "libavcodec/mpegaudiodecheader.h"
33 33
 #include "libavformat/avio_internal.h"
34
+#include "libavutil/dict.h"
34 35
 
35 36
 static int id3v1_set_string(AVFormatContext *s, const char *key,
36 37
                             uint8_t *buf, int buf_size)
37 38
 {
38
-    AVMetadataTag *tag;
39
-    if ((tag = av_metadata_get(s->metadata, key, NULL, 0)))
39
+    AVDictionaryEntry *tag;
40
+    if ((tag = av_dict_get(s->metadata, key, NULL, 0)))
40 41
         av_strlcpy(buf, tag->value, buf_size);
41 42
     return !!tag;
42 43
 }
43 44
 
44 45
 static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
45 46
 {
46
-    AVMetadataTag *tag;
47
+    AVDictionaryEntry *tag;
47 48
     int i, count = 0;
48 49
 
49 50
     memset(buf, 0, ID3v1_TAG_SIZE); /* fail safe */
... ...
@@ -55,13 +56,13 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
55 55
     count += id3v1_set_string(s, "TALB",    buf + 63, 30);       //album
56 56
     count += id3v1_set_string(s, "TDRL",    buf + 93,  4);       //date
57 57
     count += id3v1_set_string(s, "comment", buf + 97, 30);
58
-    if ((tag = av_metadata_get(s->metadata, "TRCK", NULL, 0))) { //track
58
+    if ((tag = av_dict_get(s->metadata, "TRCK", NULL, 0))) { //track
59 59
         buf[125] = 0;
60 60
         buf[126] = atoi(tag->value);
61 61
         count++;
62 62
     }
63 63
     buf[127] = 0xFF; /* default to unknown genre */
64
-    if ((tag = av_metadata_get(s->metadata, "TCON", NULL, 0))) { //genre
64
+    if ((tag = av_dict_get(s->metadata, "TCON", NULL, 0))) { //genre
65 65
         for(i = 0; i <= ID3v1_GENRE_MAX; i++) {
66 66
             if (!strcasecmp(tag->value, ff_id3v1_genre_str[i])) {
67 67
                 buf[127] = i;
... ...
@@ -186,7 +187,7 @@ static const AVClass mp3_muxer_class = {
186 186
     .version        = LIBAVUTIL_VERSION_INT,
187 187
 };
188 188
 
189
-static int id3v2_check_write_tag(AVFormatContext *s, AVMetadataTag *t, const char table[][4],
189
+static int id3v2_check_write_tag(AVFormatContext *s, AVDictionaryEntry *t, const char table[][4],
190 190
                                  enum ID3v2Encoding enc)
191 191
 {
192 192
     uint32_t tag;
... ...
@@ -345,7 +346,7 @@ static void mp3_fix_xing(AVFormatContext *s)
345 345
 static int mp3_write_header(struct AVFormatContext *s)
346 346
 {
347 347
     MP3Context  *mp3 = s->priv_data;
348
-    AVMetadataTag *t = NULL;
348
+    AVDictionaryEntry *t = NULL;
349 349
     int totlen = 0, enc = mp3->id3v2_version == 3 ? ID3v2_ENCODING_UTF16BOM :
350 350
                                                     ID3v2_ENCODING_UTF8;
351 351
     int64_t size_pos, cur_pos;
... ...
@@ -362,7 +363,7 @@ static int mp3_write_header(struct AVFormatContext *s)
362 362
     if (mp3->id3v2_version == 4)
363 363
         ff_metadata_conv(&s->metadata, ff_id3v2_4_metadata_conv, NULL);
364 364
 
365
-    while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
365
+    while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
366 366
         int ret;
367 367
 
368 368
         if ((ret = id3v2_check_write_tag(s, t, ff_id3v2_tags, enc)) > 0) {
... ...
@@ -23,6 +23,7 @@
23 23
 #include "avformat.h"
24 24
 #include "apetag.h"
25 25
 #include "id3v1.h"
26
+#include "libavutil/dict.h"
26 27
 
27 28
 #define MPC_FRAMESIZE  1152
28 29
 #define DELAY_FRAMES   32
... ...
@@ -96,7 +97,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap)
96 96
     if (s->pb->seekable) {
97 97
         int64_t pos = avio_tell(s->pb);
98 98
         ff_ape_parse_tag(s);
99
-        if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
99
+        if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
100 100
             ff_id3v1_read(s);
101 101
         avio_seek(s->pb, pos, SEEK_SET);
102 102
     }
... ...
@@ -26,6 +26,7 @@
26 26
 #include "libavutil/crc.h"
27 27
 #include "libavutil/intreadwrite.h"
28 28
 #include "libavutil/log.h"
29
+#include "libavutil/dict.h"
29 30
 #include "libavutil/opt.h"
30 31
 #include "libavcodec/bytestream.h"
31 32
 #include "avformat.h"
... ...
@@ -950,7 +951,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
950 950
         language[1] = get8(pp, desc_end);
951 951
         language[2] = get8(pp, desc_end);
952 952
         language[3] = 0;
953
-        av_metadata_set2(&st->metadata, "language", language, 0);
953
+        av_dict_set(&st->metadata, "language", language, 0);
954 954
         break;
955 955
     case 0x59: /* subtitling descriptor */
956 956
         language[0] = get8(pp, desc_end);
... ...
@@ -979,7 +980,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
979 979
             }
980 980
         }
981 981
         *pp += 4;
982
-        av_metadata_set2(&st->metadata, "language", language, 0);
982
+        av_dict_set(&st->metadata, "language", language, 0);
983 983
         break;
984 984
     case 0x0a: /* ISO 639 language descriptor */
985 985
         for (i = 0; i + 4 <= desc_len; i += 4) {
... ...
@@ -995,7 +996,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
995 995
         }
996 996
         if (i) {
997 997
             language[i - 1] = 0;
998
-            av_metadata_set2(&st->metadata, "language", language, 0);
998
+            av_dict_set(&st->metadata, "language", language, 0);
999 999
         }
1000 1000
         break;
1001 1001
     case 0x05: /* registration descriptor */
... ...
@@ -1248,8 +1249,8 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
1248 1248
                 if (name) {
1249 1249
                     AVProgram *program = av_new_program(ts->stream, sid);
1250 1250
                     if(program) {
1251
-                        av_metadata_set2(&program->metadata, "service_name", name, 0);
1252
-                        av_metadata_set2(&program->metadata, "service_provider", provider_name, 0);
1251
+                        av_dict_set(&program->metadata, "service_name", name, 0);
1252
+                        av_dict_set(&program->metadata, "service_provider", provider_name, 0);
1253 1253
                     }
1254 1254
                 }
1255 1255
                 av_free(name);
... ...
@@ -21,6 +21,7 @@
21 21
 
22 22
 #include "libavutil/bswap.h"
23 23
 #include "libavutil/crc.h"
24
+#include "libavutil/dict.h"
24 25
 #include "libavutil/opt.h"
25 26
 #include "libavcodec/mpegvideo.h"
26 27
 #include "avformat.h"
... ...
@@ -244,7 +245,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
244 244
     for(i = 0; i < s->nb_streams; i++) {
245 245
         AVStream *st = s->streams[i];
246 246
         MpegTSWriteStream *ts_st = st->priv_data;
247
-        AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0);
247
+        AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
248 248
         switch(st->codec->codec_id) {
249 249
         case CODEC_ID_MPEG1VIDEO:
250 250
         case CODEC_ID_MPEG2VIDEO:
... ...
@@ -443,7 +444,7 @@ static int mpegts_write_header(AVFormatContext *s)
443 443
     MpegTSWriteStream *ts_st;
444 444
     MpegTSService *service;
445 445
     AVStream *st, *pcr_st = NULL;
446
-    AVMetadataTag *title, *provider;
446
+    AVDictionaryEntry *title, *provider;
447 447
     int i, j;
448 448
     const char *service_name;
449 449
     const char *provider_name;
... ...
@@ -452,11 +453,11 @@ static int mpegts_write_header(AVFormatContext *s)
452 452
     ts->tsid = ts->transport_stream_id;
453 453
     ts->onid = ts->original_network_id;
454 454
     /* allocate a single DVB service */
455
-    title = av_metadata_get(s->metadata, "service_name", NULL, 0);
455
+    title = av_dict_get(s->metadata, "service_name", NULL, 0);
456 456
     if (!title)
457
-        title = av_metadata_get(s->metadata, "title", NULL, 0);
457
+        title = av_dict_get(s->metadata, "title", NULL, 0);
458 458
     service_name = title ? title->value : DEFAULT_SERVICE_NAME;
459
-    provider = av_metadata_get(s->metadata, "service_provider", NULL, 0);
459
+    provider = av_dict_get(s->metadata, "service_provider", NULL, 0);
460 460
     provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
461 461
     service = mpegts_add_service(ts, ts->service_id, provider_name, service_name);
462 462
     service->pmt.write_packet = section_write_packet;
... ...
@@ -20,6 +20,7 @@
20 20
  */
21 21
 #include "avformat.h"
22 22
 #include "riff.h"
23
+#include "libavutil/dict.h"
23 24
 
24 25
 //#define DEBUG
25 26
 //#define DEBUG_DUMP_INDEX // XXX dumbdriving-271.nsv breaks with it commented!!
... ...
@@ -328,7 +329,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
328 328
                 break;
329 329
             *p++ = '\0';
330 330
             av_dlog(s, "NSV NSVf INFO: %s='%s'\n", token, value);
331
-            av_metadata_set2(&s->metadata, token, value, 0);
331
+            av_dict_set(&s->metadata, token, value, 0);
332 332
         }
333 333
         av_free(strings);
334 334
     }
... ...
@@ -23,6 +23,7 @@
23 23
 #include <strings.h>
24 24
 #include "libavutil/avstring.h"
25 25
 #include "libavutil/bswap.h"
26
+#include "libavutil/dict.h"
26 27
 #include "libavutil/tree.h"
27 28
 #include "avio_internal.h"
28 29
 #include "nut.h"
... ...
@@ -401,7 +402,7 @@ static int decode_info_header(NUTContext *nut){
401 401
     const char *type;
402 402
     AVChapter *chapter= NULL;
403 403
     AVStream *st= NULL;
404
-    AVMetadata **metadata = NULL;
404
+    AVDictionary **metadata = NULL;
405 405
 
406 406
     end= get_packetheader(nut, bc, 1, INFO_STARTCODE);
407 407
     end += avio_tell(bc);
... ...
@@ -459,7 +460,7 @@ static int decode_info_header(NUTContext *nut){
459 459
             }
460 460
             if(metadata && strcasecmp(name,"Uses")
461 461
                && strcasecmp(name,"Depends") && strcasecmp(name,"Replaces"))
462
-                av_metadata_set2(metadata, name, str_value, 0);
462
+                av_dict_set(metadata, name, str_value, 0);
463 463
         }
464 464
     }
465 465
 
... ...
@@ -21,6 +21,7 @@
21 21
 
22 22
 #include "libavutil/intreadwrite.h"
23 23
 #include "libavutil/tree.h"
24
+#include "libavutil/dict.h"
24 25
 #include "libavcodec/mpegaudiodata.h"
25 26
 #include "nut.h"
26 27
 #include "internal.h"
... ...
@@ -432,7 +433,7 @@ static int add_info(AVIOContext *bc, const char *type, const char *value){
432 432
 
433 433
 static int write_globalinfo(NUTContext *nut, AVIOContext *bc){
434 434
     AVFormatContext *s= nut->avf;
435
-    AVMetadataTag *t = NULL;
435
+    AVDictionaryEntry *t = NULL;
436 436
     AVIOContext *dyn_bc;
437 437
     uint8_t *dyn_buf=NULL;
438 438
     int count=0, dyn_size;
... ...
@@ -440,7 +441,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext *bc){
440 440
     if(ret < 0)
441 441
         return ret;
442 442
 
443
-    while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
443
+    while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
444 444
         count += add_info(dyn_bc, t->key, t->value);
445 445
 
446 446
     ff_put_v(bc, 0); //stream_if_plus1
... ...
@@ -491,7 +492,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id)
491 491
 {
492 492
     AVIOContext *dyn_bc;
493 493
     uint8_t *dyn_buf = NULL;
494
-    AVMetadataTag *t = NULL;
494
+    AVDictionaryEntry *t = NULL;
495 495
     AVChapter *ch    = nut->avf->chapters[id];
496 496
     int ret, dyn_size, count = 0;
497 497
 
... ...
@@ -504,7 +505,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id)
504 504
     put_tt(nut, nut->chapter[id].time_base, bc, ch->start); // chapter_start
505 505
     ff_put_v(bc, ch->end - ch->start);                      // chapter_len
506 506
 
507
-    while ((t = av_metadata_get(ch->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
507
+    while ((t = av_dict_get(ch->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
508 508
         count += add_info(dyn_bc, t->key, t->value);
509 509
 
510 510
     ff_put_v(bc, count);
... ...
@@ -112,7 +112,7 @@ extern const struct ogg_codec ff_speex_codec;
112 112
 extern const struct ogg_codec ff_theora_codec;
113 113
 extern const struct ogg_codec ff_vorbis_codec;
114 114
 
115
-int ff_vorbis_comment(AVFormatContext *ms, AVMetadata **m, const uint8_t *buf, int size);
115
+int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, const uint8_t *buf, int size);
116 116
 
117 117
 static inline int
118 118
 ogg_find_stream (struct ogg * ogg, int serial)
... ...
@@ -241,7 +241,7 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
241 241
 }
242 242
 
243 243
 static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
244
-                                        int *header_len, AVMetadata **m, int framing_bit)
244
+                                        int *header_len, AVDictionary **m, int framing_bit)
245 245
 {
246 246
     const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
247 247
     int size;
... ...
@@ -267,7 +267,7 @@ static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
267 267
 
268 268
 static int ogg_build_flac_headers(AVCodecContext *avctx,
269 269
                                   OGGStreamContext *oggstream, int bitexact,
270
-                                  AVMetadata **m)
270
+                                  AVDictionary **m)
271 271
 {
272 272
     enum FLACExtradataFormat format;
273 273
     uint8_t *streaminfo;
... ...
@@ -307,7 +307,7 @@ static int ogg_build_flac_headers(AVCodecContext *avctx,
307 307
 
308 308
 static int ogg_build_speex_headers(AVCodecContext *avctx,
309 309
                                    OGGStreamContext *oggstream, int bitexact,
310
-                                   AVMetadata **m)
310
+                                   AVDictionary **m)
311 311
 {
312 312
     uint8_t *p;
313 313
 
... ...
@@ -25,6 +25,7 @@
25 25
 #include <stdlib.h>
26 26
 #include "libavutil/avstring.h"
27 27
 #include "libavutil/bswap.h"
28
+#include "libavutil/dict.h"
28 29
 #include "libavcodec/get_bits.h"
29 30
 #include "libavcodec/bytestream.h"
30 31
 #include "avformat.h"
... ...
@@ -57,8 +58,8 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
57 57
         if (!chapter)
58 58
             return 0;
59 59
 
60
-        av_metadata_set2(&chapter->metadata, "title", val,
61
-                         AV_METADATA_DONT_STRDUP_VAL);
60
+        av_dict_set(&chapter->metadata, "title", val,
61
+                         AV_DICT_DONT_STRDUP_VAL);
62 62
     } else
63 63
         return 0;
64 64
 
... ...
@@ -67,7 +68,7 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
67 67
 }
68 68
 
69 69
 int
70
-ff_vorbis_comment(AVFormatContext * as, AVMetadata **m, const uint8_t *buf, int size)
70
+ff_vorbis_comment(AVFormatContext * as, AVDictionary **m, const uint8_t *buf, int size)
71 71
 {
72 72
     const uint8_t *p = buf;
73 73
     const uint8_t *end = buf + size;
... ...
@@ -127,9 +128,9 @@ ff_vorbis_comment(AVFormatContext * as, AVMetadata **m, const uint8_t *buf, int
127 127
             ct[vl] = 0;
128 128
 
129 129
             if (!ogm_chapter(as, tt, ct))
130
-                av_metadata_set2(m, tt, ct,
131
-                                   AV_METADATA_DONT_STRDUP_KEY |
132
-                                   AV_METADATA_DONT_STRDUP_VAL);
130
+                av_dict_set(m, tt, ct,
131
+                                   AV_DICT_DONT_STRDUP_KEY |
132
+                                   AV_DICT_DONT_STRDUP_VAL);
133 133
         }
134 134
     }
135 135
 
... ...
@@ -62,7 +62,7 @@ static const AVOption options[]={
62 62
 {"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"},
63 63
 {"ts", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"},
64 64
 {"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E|D},
65
-{"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), FF_OPT_TYPE_INT, -1, -1, INT_MAX-1, D},
65
+{"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), FF_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D},
66 66
 {NULL},
67 67
 };
68 68
 
... ...
@@ -22,6 +22,7 @@
22 22
 //#define DEBUG
23 23
 
24 24
 #include "libavutil/intreadwrite.h"
25
+#include "libavutil/dict.h"
25 26
 #include "avformat.h"
26 27
 
27 28
 typedef struct {
... ...
@@ -98,7 +99,7 @@ static int r3d_read_red1(AVFormatContext *s)
98 98
 
99 99
     avio_read(s->pb, filename, 257);
100 100
     filename[sizeof(filename)-1] = 0;
101
-    av_metadata_set2(&st->metadata, "filename", filename, 0);
101
+    av_dict_set(&st->metadata, "filename", filename, 0);
102 102
 
103 103
     av_dlog(s, "filename %s\n", filename);
104 104
     av_dlog(s, "resolution %dx%d\n", st->codec->width, st->codec->height);
... ...
@@ -21,6 +21,7 @@
21 21
 
22 22
 #include "libavutil/avstring.h"
23 23
 #include "libavutil/intreadwrite.h"
24
+#include "libavutil/dict.h"
24 25
 #include "avformat.h"
25 26
 #include "riff.h"
26 27
 #include "rm.h"
... ...
@@ -104,7 +105,7 @@ static void rm_read_metadata(AVFormatContext *s, int wide)
104 104
     for (i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
105 105
         int len = wide ? avio_rb16(s->pb) : avio_r8(s->pb);
106 106
         get_strl(s->pb, buf, sizeof(buf), len);
107
-        av_metadata_set2(&s->metadata, ff_rm_metadata[i], buf, 0);
107
+        av_dict_set(&s->metadata, ff_rm_metadata[i], buf, 0);
108 108
     }
109 109
 }
110 110
 
... ...
@@ -21,6 +21,7 @@
21 21
 #include "avformat.h"
22 22
 #include "avio_internal.h"
23 23
 #include "rm.h"
24
+#include "libavutil/dict.h"
24 25
 
25 26
 typedef struct {
26 27
     int nb_packets;
... ...
@@ -71,7 +72,7 @@ static int rv10_write_header(AVFormatContext *ctx,
71 71
     const char *desc, *mimetype;
72 72
     int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i;
73 73
     int bit_rate, v, duration, flags, data_pos;
74
-    AVMetadataTag *tag;
74
+    AVDictionaryEntry *tag;
75 75
 
76 76
     start_ptr = s->buf_ptr;
77 77
 
... ...
@@ -127,13 +128,13 @@ static int rv10_write_header(AVFormatContext *ctx,
127 127
     ffio_wfourcc(s,"CONT");
128 128
     size =  4 * 2 + 10;
129 129
     for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
130
-        tag = av_metadata_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
130
+        tag = av_dict_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
131 131
         if(tag) size += strlen(tag->value);
132 132
     }
133 133
     avio_wb32(s,size);
134 134
     avio_wb16(s,0);
135 135
     for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
136
-        tag = av_metadata_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
136
+        tag = av_dict_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
137 137
         put_str(s, tag ? tag->value : "");
138 138
     }
139 139
 
... ...
@@ -20,6 +20,7 @@
20 20
  */
21 21
 
22 22
 #include "libavutil/avstring.h"
23
+#include "libavutil/dict.h"
23 24
 #include "avformat.h"
24 25
 #include <stdlib.h>
25 26
 
... ...
@@ -131,11 +132,11 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap)
131 131
     // for the text in a few cases; samples needed.)
132 132
     error |= read_line(pb, line, sizeof(line));      // ARMovie
133 133
     error |= read_line(pb, line, sizeof(line));      // movie name
134
-    av_metadata_set2(&s->metadata, "title"    , line, 0);
134
+    av_dict_set(&s->metadata, "title"    , line, 0);
135 135
     error |= read_line(pb, line, sizeof(line));      // date/copyright
136
-    av_metadata_set2(&s->metadata, "copyright", line, 0);
136
+    av_dict_set(&s->metadata, "copyright", line, 0);
137 137
     error |= read_line(pb, line, sizeof(line));      // author and other
138
-    av_metadata_set2(&s->metadata, "author"   , line, 0);
138
+    av_dict_set(&s->metadata, "author"   , line, 0);
139 139
 
140 140
     // video headers
141 141
     vst = av_new_stream(s, 0);
... ...
@@ -113,7 +113,7 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
113 113
         ret = av_open_input_stream(&rt->asf_ctx, &pb, "", &ff_asf_demuxer, NULL);
114 114
         if (ret < 0)
115 115
             return ret;
116
-        av_metadata_copy(&s->metadata, rt->asf_ctx->metadata, 0);
116
+        av_dict_copy(&s->metadata, rt->asf_ctx->metadata, 0);
117 117
         rt->asf_pb_pos = avio_tell(&pb);
118 118
         av_free(buf);
119 119
         rt->asf_ctx->pb = NULL;
... ...
@@ -24,6 +24,7 @@
24 24
 #include "libavutil/intreadwrite.h"
25 25
 #include "libavutil/parseutils.h"
26 26
 #include "libavutil/random_seed.h"
27
+#include "libavutil/dict.h"
27 28
 #include "avformat.h"
28 29
 #include "avio_internal.h"
29 30
 
... ...
@@ -281,11 +282,11 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
281 281
         }
282 282
         break;
283 283
     case 's':
284
-        av_metadata_set2(&s->metadata, "title", p, 0);
284
+        av_dict_set(&s->metadata, "title", p, 0);
285 285
         break;
286 286
     case 'i':
287 287
         if (s->nb_streams == 0) {
288
-            av_metadata_set2(&s->metadata, "comment", p, 0);
288
+            av_dict_set(&s->metadata, "comment", p, 0);
289 289
             break;
290 290
         }
291 291
         break;
... ...
@@ -25,6 +25,7 @@
25 25
  */
26 26
 
27 27
 #include "libavutil/intreadwrite.h"
28
+#include "libavutil/dict.h"
28 29
 #include "avformat.h"
29 30
 #include "sauce.h"
30 31
 
... ...
@@ -44,7 +45,7 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g
44 44
 #define GET_SAUCE_META(name,size) \
45 45
     if (avio_read(pb, buf, size) == size && buf[0]) { \
46 46
         buf[size] = 0; \
47
-        av_metadata_set2(&avctx->metadata, name, buf, 0); \
47
+        av_dict_set(&avctx->metadata, name, buf, 0); \
48 48
     }
49 49
 
50 50
     GET_SAUCE_META("title",     35)
... ...
@@ -95,7 +96,7 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g
95 95
                 str[65*i + 64] = '\n';
96 96
             }
97 97
             str[65*i] = 0;
98
-            av_metadata_set2(&avctx->metadata, "comment", str, AV_METADATA_DONT_STRDUP_VAL);
98
+            av_dict_set(&avctx->metadata, "comment", str, AV_DICT_DONT_STRDUP_VAL);
99 99
         }
100 100
     }
101 101
 
... ...
@@ -21,6 +21,7 @@
21 21
 #include <string.h>
22 22
 #include "libavutil/avstring.h"
23 23
 #include "libavutil/base64.h"
24
+#include "libavutil/dict.h"
24 25
 #include "libavutil/parseutils.h"
25 26
 #include "libavcodec/xiph.h"
26 27
 #include "libavcodec/mpeg4audio.h"
... ...
@@ -550,7 +551,7 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des
550 550
 
551 551
 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
552 552
 {
553
-    AVMetadataTag *title = av_metadata_get(ac[0]->metadata, "title", NULL, 0);
553
+    AVDictionaryEntry *title = av_dict_get(ac[0]->metadata, "title", NULL, 0);
554 554
     struct sdp_session_level s;
555 555
     int i, j, port, ttl, is_multicast;
556 556
     char dst[32], dst_type[5];
... ...
@@ -30,6 +30,7 @@
30 30
  */
31 31
 
32 32
 #include "libavutil/intreadwrite.h"
33
+#include "libavutil/dict.h"
33 34
 #include "avformat.h"
34 35
 #include "pcm.h"
35 36
 #include "sox.h"
... ...
@@ -101,8 +102,8 @@ static int sox_read_header(AVFormatContext *s,
101 101
         }
102 102
         comment[comment_size] = 0;
103 103
 
104
-        av_metadata_set2(&s->metadata, "comment", comment,
105
-                               AV_METADATA_DONT_STRDUP_VAL);
104
+        av_dict_set(&s->metadata, "comment", comment,
105
+                               AV_DICT_DONT_STRDUP_VAL);
106 106
     }
107 107
 
108 108
     avio_skip(pb, header_size - SOX_FIXED_HDR - comment_size);
... ...
@@ -30,6 +30,7 @@
30 30
  */
31 31
 
32 32
 #include "libavutil/intreadwrite.h"
33
+#include "libavutil/dict.h"
33 34
 #include "avformat.h"
34 35
 #include "avio_internal.h"
35 36
 #include "sox.h"
... ...
@@ -43,10 +44,10 @@ static int sox_write_header(AVFormatContext *s)
43 43
     SoXContext *sox = s->priv_data;
44 44
     AVIOContext *pb = s->pb;
45 45
     AVCodecContext *enc = s->streams[0]->codec;
46
-    AVMetadataTag *comment;
46
+    AVDictionaryEntry *comment;
47 47
     size_t comment_len = 0, comment_size;
48 48
 
49
-    comment = av_metadata_get(s->metadata, "comment", NULL, 0);
49
+    comment = av_dict_get(s->metadata, "comment", NULL, 0);
50 50
     if (comment)
51 51
         comment_len = strlen(comment->value);
52 52
     comment_size = (comment_len + 7) & ~7;
... ...
@@ -22,6 +22,7 @@
22 22
 #include "libavcodec/get_bits.h"
23 23
 #include "avformat.h"
24 24
 #include "id3v1.h"
25
+#include "libavutil/dict.h"
25 26
 
26 27
 typedef struct {
27 28
     int totalframes, currentframe;
... ...
@@ -43,7 +44,7 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
43 43
     int i, channels, bps, samplerate, datalen, framelen;
44 44
     uint64_t framepos, start_offset;
45 45
 
46
-    if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
46
+    if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
47 47
         ff_id3v1_read(s);
48 48
 
49 49
     start_offset = avio_tell(s->pb);
... ...
@@ -27,6 +27,7 @@
27 27
 #include "libavutil/intreadwrite.h"
28 28
 #include "libavutil/avstring.h"
29 29
 #include "libavutil/log.h"
30
+#include "libavutil/dict.h"
30 31
 #include "libavutil/opt.h"
31 32
 #include "libavutil/parseutils.h"
32 33
 #include "avformat.h"
... ...
@@ -60,7 +61,7 @@ static int efi_read(AVFormatContext *avctx, uint64_t start_pos)
60 60
         return -1; \
61 61
     if (avio_read(pb, buf, size) == size) { \
62 62
         buf[len] = 0; \
63
-        av_metadata_set2(&avctx->metadata, name, buf, 0); \
63
+        av_dict_set(&avctx->metadata, name, buf, 0); \
64 64
     }
65 65
 
66 66
     GET_EFI_META("filename", 12)
... ...
@@ -27,6 +27,7 @@
27 27
 #include "libavcodec/internal.h"
28 28
 #include "libavcodec/raw.h"
29 29
 #include "libavutil/opt.h"
30
+#include "libavutil/dict.h"
30 31
 #include "metadata.h"
31 32
 #include "id3v2.h"
32 33
 #include "libavutil/avstring.h"
... ...
@@ -2593,7 +2594,7 @@ void avformat_free_context(AVFormatContext *s)
2593 2593
     AVStream *st;
2594 2594
 
2595 2595
     av_opt_free(s);
2596
-    if (s->iformat && s->iformat->priv_class)
2596
+    if (s->iformat && s->iformat->priv_class && s->priv_data)
2597 2597
         av_opt_free(s->priv_data);
2598 2598
 
2599 2599
     for(i=0;i<s->nb_streams;i++) {
... ...
@@ -2603,7 +2604,7 @@ void avformat_free_context(AVFormatContext *s)
2603 2603
             av_parser_close(st->parser);
2604 2604
             av_free_packet(&st->cur_pkt);
2605 2605
         }
2606
-        av_metadata_free(&st->metadata);
2606
+        av_dict_free(&st->metadata);
2607 2607
         av_free(st->index_entries);
2608 2608
         av_free(st->codec->extradata);
2609 2609
         av_free(st->codec->subtitle_header);
... ...
@@ -2613,18 +2614,18 @@ void avformat_free_context(AVFormatContext *s)
2613 2613
         av_free(st);
2614 2614
     }
2615 2615
     for(i=s->nb_programs-1; i>=0; i--) {
2616
-        av_metadata_free(&s->programs[i]->metadata);
2616
+        av_dict_free(&s->programs[i]->metadata);
2617 2617
         av_freep(&s->programs[i]->stream_index);
2618 2618
         av_freep(&s->programs[i]);
2619 2619
     }
2620 2620
     av_freep(&s->programs);
2621 2621
     av_freep(&s->priv_data);
2622 2622
     while(s->nb_chapters--) {
2623
-        av_metadata_free(&s->chapters[s->nb_chapters]->metadata);
2623
+        av_dict_free(&s->chapters[s->nb_chapters]->metadata);
2624 2624
         av_free(s->chapters[s->nb_chapters]);
2625 2625
     }
2626 2626
     av_freep(&s->chapters);
2627
-    av_metadata_free(&s->metadata);
2627
+    av_dict_free(&s->metadata);
2628 2628
     av_freep(&s->streams);
2629 2629
     av_free(s);
2630 2630
 }
... ...
@@ -2728,7 +2729,7 @@ AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int6
2728 2728
             return NULL;
2729 2729
         dynarray_add(&s->chapters, &s->nb_chapters, chapter);
2730 2730
     }
2731
-    av_metadata_set2(&chapter->metadata, "title", title, 0);
2731
+    av_dict_set(&chapter->metadata, "title", title, 0);
2732 2732
     chapter->id    = id;
2733 2733
     chapter->time_base= time_base;
2734 2734
     chapter->start = start;
... ...
@@ -2923,7 +2924,7 @@ int av_write_header(AVFormatContext *s)
2923 2923
 
2924 2924
     /* set muxer identification string */
2925 2925
     if (s->nb_streams && !(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
2926
-        av_metadata_set2(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
2926
+        av_dict_set(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
2927 2927
     }
2928 2928
 
2929 2929
     if(s->oformat->write_header){
... ...
@@ -3245,13 +3246,13 @@ static void print_fps(double d, const char *postfix){
3245 3245
     else                  av_log(NULL, AV_LOG_INFO, ", %1.0fk %s", d/1000, postfix);
3246 3246
 }
3247 3247
 
3248
-static void dump_metadata(void *ctx, AVMetadata *m, const char *indent)
3248
+static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
3249 3249
 {
3250
-    if(m && !(m->count == 1 && av_metadata_get(m, "language", NULL, 0))){
3251
-        AVMetadataTag *tag=NULL;
3250
+    if(m && !(m->count == 1 && av_dict_get(m, "language", NULL, 0))){
3251
+        AVDictionaryEntry *tag=NULL;
3252 3252
 
3253 3253
         av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
3254
-        while((tag=av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
3254
+        while((tag=av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
3255 3255
             if(strcmp("language", tag->key))
3256 3256
                 av_log(ctx, AV_LOG_INFO, "%s  %-16s: %s\n", indent, tag->key, tag->value);
3257 3257
         }
... ...
@@ -3265,7 +3266,7 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out
3265 3265
     int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
3266 3266
     AVStream *st = ic->streams[i];
3267 3267
     int g = av_gcd(st->time_base.num, st->time_base.den);
3268
-    AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL, 0);
3268
+    AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
3269 3269
     avcodec_string(buf, sizeof(buf), st->codec, is_output);
3270 3270
     av_log(NULL, AV_LOG_INFO, "    Stream #%d.%d", index, i);
3271 3271
     /* the pid is an important information, so we display it */
... ...
@@ -3389,7 +3390,7 @@ void av_dump_format(AVFormatContext *ic,
3389 3389
     if(ic->nb_programs) {
3390 3390
         int j, k, total = 0;
3391 3391
         for(j=0; j<ic->nb_programs; j++) {
3392
-            AVMetadataTag *name = av_metadata_get(ic->programs[j]->metadata,
3392
+            AVDictionaryEntry *name = av_dict_get(ic->programs[j]->metadata,
3393 3393
                                                   "name", NULL, 0);
3394 3394
             av_log(NULL, AV_LOG_INFO, "  Program %d %s\n", ic->programs[j]->id,
3395 3395
                    name ? name->value : "");
... ...
@@ -23,6 +23,7 @@
23 23
 #include "metadata.h"
24 24
 #include "vorbiscomment.h"
25 25
 #include "libavcodec/bytestream.h"
26
+#include "libavutil/dict.h"
26 27
 
27 28
 /**
28 29
  * VorbisComment metadata conversion mapping.
... ...
@@ -36,15 +37,15 @@ const AVMetadataConv ff_vorbiscomment_metadata_conv[] = {
36 36
     { 0 }
37 37
 };
38 38
 
39
-int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
39
+int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
40 40
                             unsigned *count)
41 41
 {
42 42
     int len = 8;
43 43
     len += strlen(vendor_string);
44 44
     *count = 0;
45 45
     if (m) {
46
-        AVMetadataTag *tag = NULL;
47
-        while ((tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
46
+        AVDictionaryEntry *tag = NULL;
47
+        while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
48 48
             len += 4 +strlen(tag->key) + 1 + strlen(tag->value);
49 49
             (*count)++;
50 50
         }
... ...
@@ -52,15 +53,15 @@ int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
52 52
     return len;
53 53
 }
54 54
 
55
-int ff_vorbiscomment_write(uint8_t **p, AVMetadata **m,
55
+int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
56 56
                            const char *vendor_string, const unsigned count)
57 57
 {
58 58
     bytestream_put_le32(p, strlen(vendor_string));
59 59
     bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
60 60
     if (*m) {
61
-        AVMetadataTag *tag = NULL;
61
+        AVDictionaryEntry *tag = NULL;
62 62
         bytestream_put_le32(p, count);
63
-        while ((tag = av_metadata_get(*m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
63
+        while ((tag = av_dict_get(*m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
64 64
             unsigned int len1 = strlen(tag->key);
65 65
             unsigned int len2 = strlen(tag->value);
66 66
             bytestream_put_le32(p, len1+1+len2);
... ...
@@ -35,13 +35,13 @@
35 35
  * @param count Pointer to store the number of tags in m because m->count is "not allowed"
36 36
  * @return The length in bytes.
37 37
  */
38
-int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
38
+int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
39 39
                             unsigned *count);
40 40
 
41 41
 /**
42 42
  * Writes a VorbisComment into a buffer. The buffer, p, must have enough
43 43
  * data to hold the whole VorbisComment. The minimum size required can be
44
- * obtained by passing the same AVMetadata and vendor_string to
44
+ * obtained by passing the same AVDictionary and vendor_string to
45 45
  * ff_vorbiscomment_length()
46 46
  *
47 47
  * @param p The buffer in which to write.
... ...
@@ -49,7 +49,7 @@ int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
49 49
  * @param vendor_string The vendor string to write.
50 50
  * @param count The number of tags in m because m->count is "not allowed"
51 51
  */
52
-int ff_vorbiscomment_write(uint8_t **p, AVMetadata **m,
52
+int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
53 53
                            const char *vendor_string, const unsigned count);
54 54
 
55 55
 extern const AVMetadataConv ff_vorbiscomment_metadata_conv[];
... ...
@@ -21,6 +21,7 @@
21 21
 
22 22
 #include "avformat.h"
23 23
 #include "libavutil/intreadwrite.h"
24
+#include "libavutil/dict.h"
24 25
 
25 26
 typedef struct VqfContext {
26 27
     int frame_bit_len;
... ...
@@ -56,7 +57,7 @@ static void add_metadata(AVFormatContext *s, const char *tag,
56 56
         return;
57 57
     avio_read(s->pb, buf, len);
58 58
     buf[len] = 0;
59
-    av_metadata_set2(&s->metadata, tag, buf, AV_METADATA_DONT_STRDUP_VAL);
59
+    av_dict_set(&s->metadata, tag, buf, AV_DICT_DONT_STRDUP_VAL);
60 60
 }
61 61
 
62 62
 static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap)
... ...
@@ -28,6 +28,7 @@
28 28
  */
29 29
 
30 30
 #include "libavutil/intreadwrite.h"
31
+#include "libavutil/dict.h"
31 32
 #include "avformat.h"
32 33
 
33 34
 #define FORM_TAG MKTAG('F', 'O', 'R', 'M')
... ...
@@ -130,8 +131,8 @@ static int wc3_read_header(AVFormatContext *s,
130 130
             if ((ret = avio_read(pb, buffer, size)) != size)
131 131
                 return AVERROR(EIO);
132 132
             buffer[size] = 0;
133
-            av_metadata_set2(&s->metadata, "title", buffer,
134
-                                   AV_METADATA_DONT_STRDUP_VAL);
133
+            av_dict_set(&s->metadata, "title", buffer,
134
+                                   AV_DICT_DONT_STRDUP_VAL);
135 135
             break;
136 136
 
137 137
         case SIZE_TAG:
... ...
@@ -21,6 +21,7 @@
21 21
 
22 22
 #include "libavutil/audioconvert.h"
23 23
 #include "libavutil/intreadwrite.h"
24
+#include "libavutil/dict.h"
24 25
 #include "avformat.h"
25 26
 #include "apetag.h"
26 27
 #include "id3v1.h"
... ...
@@ -226,7 +227,7 @@ static int wv_read_header(AVFormatContext *s,
226 226
     if(s->pb->seekable) {
227 227
         int64_t cur = avio_tell(s->pb);
228 228
         ff_ape_parse_tag(s);
229
-        if(!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
229
+        if(!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
230 230
             ff_id3v1_read(s);
231 231
         avio_seek(s->pb, cur, SEEK_SET);
232 232
     }
... ...
@@ -27,6 +27,7 @@ HEADERS = adler32.h                                                     \
27 27
           mathematics.h                                                 \
28 28
           md5.h                                                         \
29 29
           mem.h                                                         \
30
+          dict.h                                                        \
30 31
           opt.h                                                         \
31 32
           parseutils.h                                                  \
32 33
           pixdesc.h                                                     \
... ...
@@ -60,6 +61,7 @@ OBJS = adler32.o                                                        \
60 60
        mathematics.o                                                    \
61 61
        md5.o                                                            \
62 62
        mem.o                                                            \
63
+       dict.o                                                           \
63 64
        opt.o                                                            \
64 65
        parseutils.o                                                     \
65 66
        pixdesc.o                                                        \
... ...
@@ -40,7 +40,7 @@
40 40
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
41 41
 
42 42
 #define LIBAVUTIL_VERSION_MAJOR 51
43
-#define LIBAVUTIL_VERSION_MINOR  7
43
+#define LIBAVUTIL_VERSION_MINOR  8
44 44
 #define LIBAVUTIL_VERSION_MICRO  0
45 45
 
46 46
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
47 47
new file mode 100644
... ...
@@ -0,0 +1,110 @@
0
+/*
1
+ * copyright (c) 2009 Michael Niedermayer
2
+ *
3
+ * This file is part of Libav.
4
+ *
5
+ * Libav is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * Libav is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with Libav; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+#include <strings.h>
21
+#include "dict.h"
22
+#include "internal.h"
23
+#include "mem.h"
24
+
25
+AVDictionaryEntry *
26
+av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
27
+{
28
+    unsigned int i, j;
29
+
30
+    if(!m)
31
+        return NULL;
32
+
33
+    if(prev) i= prev - m->elems + 1;
34
+    else     i= 0;
35
+
36
+    for(; i<m->count; i++){
37
+        const char *s= m->elems[i].key;
38
+        if(flags & AV_DICT_MATCH_CASE) for(j=0;         s[j]  ==         key[j]  && key[j]; j++);
39
+        else                               for(j=0; toupper(s[j]) == toupper(key[j]) && key[j]; j++);
40
+        if(key[j])
41
+            continue;
42
+        if(s[j] && !(flags & AV_DICT_IGNORE_SUFFIX))
43
+            continue;
44
+        return &m->elems[i];
45
+    }
46
+    return NULL;
47
+}
48
+
49
+int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
50
+{
51
+    AVDictionary      *m = *pm;
52
+    AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
53
+
54
+    if(!m)
55
+        m = *pm = av_mallocz(sizeof(*m));
56
+
57
+    if(tag) {
58
+        if (flags & AV_DICT_DONT_OVERWRITE)
59
+            return 0;
60
+        av_free(tag->value);
61
+        av_free(tag->key);
62
+        *tag = m->elems[--m->count];
63
+    } else {
64
+        AVDictionaryEntry *tmp = av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
65
+        if(tmp) {
66
+            m->elems = tmp;
67
+        } else
68
+            return AVERROR(ENOMEM);
69
+    }
70
+    if (value) {
71
+        if (flags & AV_DICT_DONT_STRDUP_KEY) {
72
+            m->elems[m->count].key  = key;
73
+        } else
74
+        m->elems[m->count].key  = av_strdup(key  );
75
+        if (flags & AV_DICT_DONT_STRDUP_VAL) {
76
+            m->elems[m->count].value = value;
77
+        } else
78
+            m->elems[m->count].value = av_strdup(value);
79
+        m->count++;
80
+    }
81
+    if (!m->count) {
82
+        av_free(m->elems);
83
+        av_freep(pm);
84
+    }
85
+
86
+    return 0;
87
+}
88
+
89
+void av_dict_free(AVDictionary **pm)
90
+{
91
+    AVDictionary *m = *pm;
92
+
93
+    if (m) {
94
+        while(m->count--) {
95
+            av_free(m->elems[m->count].key);
96
+            av_free(m->elems[m->count].value);
97
+        }
98
+        av_free(m->elems);
99
+    }
100
+    av_freep(pm);
101
+}
102
+
103
+void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags)
104
+{
105
+    AVDictionaryEntry *t = NULL;
106
+
107
+    while ((t = av_dict_get(src, "", t, AV_DICT_IGNORE_SUFFIX)))
108
+        av_dict_set(dst, t->key, t->value, flags);
109
+}
0 110
new file mode 100644
... ...
@@ -0,0 +1,78 @@
0
+/*
1
+ *
2
+ * This file is part of Libav.
3
+ *
4
+ * Libav is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU Lesser General Public
6
+ * License as published by the Free Software Foundation; either
7
+ * version 2.1 of the License, or (at your option) any later version.
8
+ *
9
+ * Libav is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * Lesser General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Lesser General Public
15
+ * License along with Libav; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
+ */
18
+
19
+/**
20
+ * @file Public dictionary API.
21
+ */
22
+
23
+#ifndef AVUTIL_DICT_H
24
+#define AVUTIL_DICT_H
25
+
26
+#define AV_DICT_MATCH_CASE      1
27
+#define AV_DICT_IGNORE_SUFFIX   2
28
+#define AV_DICT_DONT_STRDUP_KEY 4
29
+#define AV_DICT_DONT_STRDUP_VAL 8
30
+#define AV_DICT_DONT_OVERWRITE 16   ///< Don't overwrite existing entries.
31
+
32
+typedef struct {
33
+    char *key;
34
+    char *value;
35
+} AVDictionaryEntry;
36
+
37
+typedef struct AVDictionary AVDictionary;
38
+
39
+/**
40
+ * Get a dictionary entry with matching key.
41
+ *
42
+ * @param prev Set to the previous matching element to find the next.
43
+ *             If set to NULL the first matching element is returned.
44
+ * @param flags Allows case as well as suffix-insensitive comparisons.
45
+ * @return Found entry or NULL, changing key or value leads to undefined behavior.
46
+ */
47
+AVDictionaryEntry *
48
+av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
49
+
50
+/**
51
+ * Set the given entry in *pm, overwriting an existing entry.
52
+ *
53
+ * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
54
+ * a dictionary struct is allocated and put in *pm.
55
+ * @param key entry key to add to *pm (will be av_strduped depending on flags)
56
+ * @param value entry value to add to *pm (will be av_strduped depending on flags).
57
+ *        Passing a NULL value will cause an existing tag to be deleted.
58
+ * @return >= 0 on success otherwise an error code <0
59
+ */
60
+int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
61
+
62
+/**
63
+ * Copy entries from one AVDictionary struct into another.
64
+ * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
65
+ *            this function will allocate a struct for you and put it in *dst
66
+ * @param src pointer to source AVDictionary struct
67
+ * @param flags flags to use when setting entries in *dst
68
+ * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
69
+ */
70
+void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags);
71
+
72
+/**
73
+ * Free all the memory allocated for an AVDictionary struct.
74
+ */
75
+void av_dict_free(AVDictionary **m);
76
+
77
+#endif // AVUTIL_DICT_H
... ...
@@ -38,6 +38,12 @@
38 38
 #include "attributes.h"
39 39
 #include "timer.h"
40 40
 #include "cpu.h"
41
+#include "dict.h"
42
+
43
+struct AVDictionary {
44
+    int count;
45
+    AVDictionaryEntry *elems;
46
+};
41 47
 
42 48
 #ifndef attribute_align_arg
43 49
 #if ARCH_X86_32 && AV_GCC_VERSION_AT_LEAST(4,2)
... ...
@@ -380,40 +380,14 @@ yuv2NBPS(10, LE, 0);
380 380
 yuv2NBPS(16, BE, 1);
381 381
 yuv2NBPS(16, LE, 0);
382 382
 
383
-static inline void yuv2yuvX16_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
384
-                                const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize,
385
-                                const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, int dstW, int chrDstW,
386
-                                enum PixelFormat dstFormat)
387
-{
388
-    if (isNBPS(dstFormat)) {
389
-        const int depth = av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1+1;
390
-        yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize,
391
-                              chrFilter, chrUSrc, chrVSrc, chrFilterSize,
392
-                              alpSrc,
393
-                              dest, uDest, vDest, aDest,
394
-                              dstW, chrDstW, isBE(dstFormat), depth);
395
-    } else {
396
-        if (isBE(dstFormat)) {
397
-            yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize,
398
-                                   chrFilter, chrUSrc, chrVSrc, chrFilterSize,
399
-                                   alpSrc,
400
-                                   dest, uDest, vDest, aDest,
401
-                                   dstW, chrDstW, 1, 16);
402
-        } else {
403
-            yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize,
404
-                                   chrFilter, chrUSrc, chrVSrc, chrFilterSize,
405
-                                   alpSrc,
406
-                                   dest, uDest, vDest, aDest,
407
-                                   dstW, chrDstW, 0, 16);
408
-        }
409
-    }
410
-}
411
-
412
-static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
413
-                               const int16_t *chrFilter, const int16_t **chrUSrc,
414
-                               const int16_t **chrVSrc, int chrFilterSize,
415
-                               const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, int dstW, int chrDstW,
416
-                               const uint8_t *lumDither, const uint8_t *chrDither)
383
+static inline void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter,
384
+                              const int16_t **lumSrc, int lumFilterSize,
385
+                              const int16_t *chrFilter, const int16_t **chrUSrc,
386
+                              const int16_t **chrVSrc,
387
+                              int chrFilterSize, const int16_t **alpSrc,
388
+                              uint8_t *dest, uint8_t *uDest, uint8_t *vDest,
389
+                              uint8_t *aDest, int dstW, int chrDstW,
390
+                              const uint8_t *lumDither, const uint8_t *chrDither)
417 391
 {
418 392
     //FIXME Optimize (just quickly written not optimized..)
419 393
     int i;
... ...
@@ -180,19 +180,6 @@ static inline void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter,
180 180
     YSCALEYUV2YV12X_ACCURATE(LUM_MMX_FILTER_OFFSET, dest, dstW, 0)
181 181
 }
182 182
 
183
-#define YSCALEYUV2YV121 \
184
-    "mov %2, %%"REG_a"                    \n\t"\
185
-    ".p2align               4             \n\t" /* FIXME Unroll? */\
186
-    "1:                                   \n\t"\
187
-    "movq  (%0, %%"REG_a", 2), %%mm0      \n\t"\
188
-    "movq 8(%0, %%"REG_a", 2), %%mm1      \n\t"\
189
-    "psraw                 $7, %%mm0      \n\t"\
190
-    "psraw                 $7, %%mm1      \n\t"\
191
-    "packuswb           %%mm1, %%mm0      \n\t"\
192
-    MOVNTQ(%%mm0, (%1, %%REGa))\
193
-    "add                   $8, %%"REG_a"  \n\t"\
194
-    "jnc                   1b             \n\t"
195
-
196 183
 static inline void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc,
197 184
                                     const int16_t *chrUSrc, const int16_t *chrVSrc,
198 185
                                     const int16_t *alpSrc,
... ...
@@ -208,32 +195,25 @@ static inline void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc,
208 208
     while (p--) {
209 209
         if (dst[p]) {
210 210
             __asm__ volatile(
211
-               YSCALEYUV2YV121
212
-               :: "r" (src[p]), "r" (dst[p] + counter[p]),
213
-                  "g" (-counter[p])
214
-               : "%"REG_a
211
+                "mov %2, %%"REG_a"                    \n\t"
212
+                ".p2align               4             \n\t" /* FIXME Unroll? */
213
+                "1:                                   \n\t"
214
+                "movq  (%0, %%"REG_a", 2), %%mm0      \n\t"
215
+                "movq 8(%0, %%"REG_a", 2), %%mm1      \n\t"
216
+                "psraw                 $7, %%mm0      \n\t"
217
+                "psraw                 $7, %%mm1      \n\t"
218
+                "packuswb           %%mm1, %%mm0      \n\t"
219
+                MOVNTQ(%%mm0, (%1, %%REGa))
220
+                "add                   $8, %%"REG_a"  \n\t"
221
+                "jnc                   1b             \n\t"
222
+                :: "r" (src[p]), "r" (dst[p] + counter[p]),
223
+                   "g" (-counter[p])
224
+                : "%"REG_a
215 225
             );
216 226
         }
217 227
     }
218 228
 }
219 229
 
220
-#define YSCALEYUV2YV121_ACCURATE \
221
-    "mov %2, %%"REG_a"                    \n\t"\
222
-    "movq               0(%3), %%mm6      \n\t"\
223
-    "movq               8(%3), %%mm7      \n\t"\
224
-    ".p2align                4            \n\t" /* FIXME Unroll? */\
225
-    "1:                                   \n\t"\
226
-    "movq  (%0, %%"REG_a", 2), %%mm0      \n\t"\
227
-    "movq 8(%0, %%"REG_a", 2), %%mm1      \n\t"\
228
-    "paddsw             %%mm6, %%mm0      \n\t"\
229
-    "paddsw             %%mm7, %%mm1      \n\t"\
230
-    "psraw                 $7, %%mm0      \n\t"\
231
-    "psraw                 $7, %%mm1      \n\t"\
232
-    "packuswb           %%mm1, %%mm0      \n\t"\
233
-    MOVNTQ(%%mm0, (%1, %%REGa))\
234
-    "add                   $8, %%"REG_a"  \n\t"\
235
-    "jnc                   1b             \n\t"
236
-
237 230
 static inline void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc,
238 231
                                        const int16_t *chrUSrc, const int16_t *chrVSrc,
239 232
                                        const int16_t *alpSrc,
... ...
@@ -251,7 +231,21 @@ static inline void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc,
251 251
             int i;
252 252
             for(i=0; i<8; i++) c->dither16[i] = i<2 ? lumDither[i] : chrDither[i];
253 253
             __asm__ volatile(
254
-                YSCALEYUV2YV121_ACCURATE
254
+                "mov %2, %%"REG_a"                    \n\t"
255
+                "movq               0(%3), %%mm6      \n\t"
256
+                "movq               8(%3), %%mm7      \n\t"
257
+                ".p2align                4            \n\t" /* FIXME Unroll? */
258
+                "1:                                   \n\t"
259
+                "movq  (%0, %%"REG_a", 2), %%mm0      \n\t"
260
+                "movq 8(%0, %%"REG_a", 2), %%mm1      \n\t"
261
+                "paddsw             %%mm6, %%mm0      \n\t"
262
+                "paddsw             %%mm7, %%mm1      \n\t"
263
+                "psraw                 $7, %%mm0      \n\t"
264
+                "psraw                 $7, %%mm1      \n\t"
265
+                "packuswb           %%mm1, %%mm0      \n\t"
266
+                MOVNTQ(%%mm0, (%1, %%REGa))
267
+                "add                   $8, %%"REG_a"  \n\t"
268
+                "jnc                   1b             \n\t"
255 269
                 :: "r" (src[p]), "r" (dst[p] + counter[p]),
256 270
                    "g" (-counter[p]), "r"(c->dither16)
257 271
                 : "%"REG_a
... ...
@@ -2218,7 +2212,7 @@ static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
2218 2218
                                         int dstWidth, const uint8_t *src, int srcW,
2219 2219
                                         int xInc)
2220 2220
 {
2221
-    int32_t *filterPos = c->hLumFilterPos;
2221
+    int16_t *filterPos = c->hLumFilterPos;
2222 2222
     int16_t *filter    = c->hLumFilter;
2223 2223
     void    *mmx2FilterCode= c->lumMmx2FilterCode;
2224 2224
     int i;
... ...
@@ -2290,7 +2284,7 @@ static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *d
2290 2290
                                         int dstWidth, const uint8_t *src1,
2291 2291
                                         const uint8_t *src2, int srcW, int xInc)
2292 2292
 {
2293
-    int32_t *filterPos = c->hChrFilterPos;
2293
+    int16_t *filterPos = c->hChrFilterPos;
2294 2294
     int16_t *filter    = c->hChrFilter;
2295 2295
     void    *mmx2FilterCode= c->chrMmx2FilterCode;
2296 2296
     int i;