History

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

Michael Niedermayer committed 15 years ago

Commit f9ecb842 parents 7b8ed83 a71bcd165 files · +558 −407Browse files

Unified · Split

65 files
  1. doc/APIchanges +5 −0
  2. ffmpeg.c +15 −14
  3. ffprobe.c +5 −4
  4. ffserver.c +10 −9
  5. libavcodec/dvbsubdec.c +5 −4
  6. libavformat/aiffdec.c +1 −0
  7. libavformat/apetag.c +2 −1
  8. libavformat/applehttp.c +2 −1
  9. libavformat/asfdec.c +4 −2
  10. libavformat/asfenc.c +9 −9
  11. libavformat/avformat.h +34 −28
  12. libavformat/avidec.c +8 −7
  13. libavformat/avienc.c +4 −3
  14. libavformat/cafdec.c +2 −1
  15. libavformat/ffmetadec.c +4 −3
  16. libavformat/ffmetaenc.c +4 −3
  17. libavformat/flacenc.c +1 −2
  18. libavformat/flvdec.c +4 −3
  19. libavformat/flvenc.c +3 −2
  20. libavformat/id3v1.c +4 −3
  21. libavformat/id3v2.c +14 −14
  22. libavformat/iff.c +2 −1
  23. libavformat/matroskadec.c +9 −8
  24. libavformat/matroskaenc.c +17 −16
  25. libavformat/metadata.c +20 −83
  26. libavformat/metadata.h +2 −6
  27. libavformat/mov.c +10 −12
  28. libavformat/movenc.c +13 −12
  29. libavformat/mp3dec.c +2 −1
  30. libavformat/mp3enc.c +9 −8
  31. libavformat/mpc.c +2 −1
  32. libavformat/mpegts.c +6 −5
  33. libavformat/mpegtsenc.c +6 −5
  34. libavformat/nsvdec.c +2 −1
  35. libavformat/nutdec.c +3 −2
  36. libavformat/nutenc.c +5 −4
  37. libavformat/oggdec.h +1 −1
  38. libavformat/oggenc.c +3 −3
  39. libavformat/oggparsevorbis.c +7 −6
  40. libavformat/options.c +1 −1
  41. libavformat/r3d.c +2 −1
  42. libavformat/rmdec.c +2 −1
  43. libavformat/rmenc.c +4 −3
  44. libavformat/rpl.c +4 −3
  45. libavformat/rtpdec_asf.c +1 −1
  46. libavformat/rtsp.c +3 −2
  47. libavformat/sauce.c +3 −2
  48. libavformat/sdp.c +2 −1
  49. libavformat/soxdec.c +3 −2
  50. libavformat/soxenc.c +3 −2
  51. libavformat/tta.c +2 −1
  52. libavformat/tty.c +2 −1
  53. libavformat/utils.c +14 −13
  54. libavformat/vorbiscomment.c +7 −6
  55. libavformat/vorbiscomment.h +3 −3
  56. libavformat/vqf.c +2 −1
  57. libavformat/wc3movie.c +3 −2
  58. libavformat/wv.c +2 −1
  59. libavutil/Makefile +2 −0
  60. libavutil/avutil.h +1 −1
  61. libavutil/dict.c +110 −0
  62. libavutil/dict.h +78 −0
  63. libavutil/internal.h +6 −0
  64. libswscale/swscale.c +8 −34
  65. libswscale/x86/swscale_template.c +31 −37
doc/APIchanges+5−0
@@ -50,6 +50,11 @@ API changes, most recent first: · 49 unmodified lines
5050 2011-05-XX - XXXXXX - lavfi 2.6.0 - avcodec.h
5151 Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h.
5252
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+
5358 2011-06-07 - a6703fa - lavu 51.4.0 - av_get_bytes_per_sample()
5459 Add av_get_bytes_per_sample() in libavutil/samplefmt.h.
5560 Deprecate av_get_bits_per_sample_fmt().
ffmpeg.c+15−14
@@ -39,6 +39,7 @@ · 38 unmodified lines
3939 #include "libavutil/colorspace.h"
4040 #include "libavutil/fifo.h"
4141 #include "libavutil/intreadwrite.h"
42+#include "libavutil/dict.h"
4243 #include "libavutil/pixdesc.h"
4344 #include "libavutil/avstring.h"
4445 #include "libavutil/libm.h"
@@ -199,7 +200,7 @@ static int64_t start_time = 0; · 154 unmodified lines
199200 static int64_t recording_timestamp = 0;
200201 static int64_t input_ts_offset = 0;
201202 static int file_overwrite = 0;
202−static AVMetadata *metadata;
203+static AVDictionary *metadata;
203204 static int do_benchmark = 0;
204205 static int do_hex_dump = 0;
205206 static int do_pkt_dump = 0;
@@ -1953,7 +1954,7 @@ static int copy_chapters(int infile, int outfile) · 1747 unmodified lines
19531954 out_ch->end = FFMIN(rt, in_ch->end - ts_off);
19541955
19551956 if (metadata_chapters_autocopy)
1956− av_metadata_copy(&out_ch->metadata, in_ch->metadata, 0);
1957+ av_dict_copy(&out_ch->metadata, in_ch->metadata, 0);
19571958
19581959 os->nb_chapters++;
19591960 os->chapters = av_realloc(os->chapters, sizeof(AVChapter)*os->nb_chapters);
@@ -2181,8 +2182,8 @@ static int transcode(AVFormatContext **output_files, · 221 unmodified lines
21812182 icodec = ist->st->codec;
21822183
21832184 if (metadata_streams_autocopy)
2184− av_metadata_copy(&ost->st->metadata, ist->st->metadata,
2185− AV_METADATA_DONT_OVERWRITE);
2185+ av_dict_copy(&ost->st->metadata, ist->st->metadata,
2186+ AV_DICT_DONT_OVERWRITE);
21862187
21872188 ost->st->disposition = ist->st->disposition;
21882189 codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
@@ -2419,7 +2420,7 @@ static int transcode(AVFormatContext **output_files, · 230 unmodified lines
24192420 /* set meta data information from input file if required */
24202421 for (i=0;i<nb_meta_data_maps;i++) {
24212422 AVFormatContext *files[2];
2422− AVMetadata **meta[2];
2423+ AVDictionary **meta[2];
24232424 int j;
24242425
24252426 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
@@ -2462,15 +2463,15 @@ static int transcode(AVFormatContext **output_files, · 36 unmodified lines
24622463 }
24632464 }
24642465
2465− av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE);
2466+ av_dict_copy(meta[0], *meta[1], AV_DICT_DONT_OVERWRITE);
24662467 }
24672468
24682469 /* copy global metadata by default */
24692470 if (metadata_global_autocopy) {
24702471
24712472 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);
2473+ av_dict_copy(&output_files[i]->metadata, input_files[0].ctx->metadata,
2474+ AV_DICT_DONT_OVERWRITE);
24742475 }
24752476
24762477 /* copy chapters according to chapter maps */
@@ -2943,7 +2944,7 @@ static int opt_metadata(const char *opt, const char *arg) · 466 unmodified lines
29432944 }
29442945 *mid++= 0;
29452946
2946− av_metadata_set2(&metadata, arg, mid, 0);
2947+ av_dict_set(&metadata, arg, mid, 0);
29472948
29482949 return 0;
29492950 }
@@ -3631,7 +3632,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) · 681 unmodified lines
36313632 parse_forced_key_frames(forced_key_frames, ost, video_enc);
36323633 }
36333634 if (video_language) {
3634− av_metadata_set2(&st->metadata, "language", video_language, 0);
3635+ av_dict_set(&st->metadata, "language", video_language, 0);
36353636 av_freep(&video_language);
36363637 }
36373638
@@ -3711,7 +3712,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) · 73 unmodified lines
37113712 }
37123713 audio_enc->time_base= (AVRational){1, audio_sample_rate};
37133714 if (audio_language) {
3714− av_metadata_set2(&st->metadata, "language", audio_language, 0);
3715+ av_dict_set(&st->metadata, "language", audio_language, 0);
37153716 av_freep(&audio_language);
37163717 }
37173718
@@ -3807,7 +3808,7 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx) · 89 unmodified lines
38073808 }
38083809
38093810 if (subtitle_language) {
3810− av_metadata_set2(&st->metadata, "language", subtitle_language, 0);
3811+ av_dict_set(&st->metadata, "language", subtitle_language, 0);
38113812 av_freep(&subtitle_language);
38123813 }
38133814
@@ -3926,8 +3927,8 @@ static int opt_output_file(const char *opt, const char *filename) · 112 unmodified lines
39263927
39273928 oc->timestamp = recording_timestamp;
39283929
3929− av_metadata_copy(&oc->metadata, metadata, 0);
3930− av_metadata_free(&metadata);
3930+ av_dict_copy(&oc->metadata, metadata, 0);
3931+ av_dict_free(&metadata);
39313932 }
39323933
39333934 output_files[nb_output_files++] = oc;
ffprobe.c+5−4
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include "libavcodec/avcodec.h"
2626 #include "libavutil/opt.h"
2727 #include "libavutil/pixdesc.h"
28+#include "libavutil/dict.h"
2829 #include "libavdevice/avdevice.h"
2930 #include "cmdutils.h"
3031
@@ -160,7 +161,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) · 129 unmodified lines
160161 AVCodecContext *dec_ctx;
161162 AVCodec *dec;
162163 char val_str[128];
163− AVMetadataTag *tag = NULL;
164+ AVDictionaryEntry *tag = NULL;
164165 AVRational display_aspect_ratio;
165166
166167 printf("[STREAM]\n");
@@ -226,7 +227,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) · 59 unmodified lines
226227 if (stream->nb_frames)
227228 printf("nb_frames=%"PRId64"\n", stream->nb_frames);
228229
229− while ((tag = av_metadata_get(stream->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
230+ while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
230231 printf("TAG:%s=%s\n", tag->key, tag->value);
231232
232233 printf("[/STREAM]\n");
@@ -234,7 +235,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) · 1 unmodified line
234235
235236 static void show_format(AVFormatContext *fmt_ctx)
236237 {
237− AVMetadataTag *tag = NULL;
238+ AVDictionaryEntry *tag = NULL;
238239 char val_str[128];
239240
240241 printf("[FORMAT]\n");
@@ -252,7 +253,7 @@ static void show_format(AVFormatContext *fmt_ctx) · 11 unmodified lines
252253 printf("bit_rate=%s\n", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate,
253254 unit_bit_per_second_str));
254255
255− while ((tag = av_metadata_get(fmt_ctx->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
256+ while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
256257 printf("TAG:%s=%s\n", tag->key, tag->value);
257258
258259 printf("[/FORMAT]\n");
ffserver.c+10−9
@@ -36,6 +36,7 @@ · 35 unmodified lines
3636 #include "libavformat/avio_internal.h"
3737 #include "libavutil/avstring.h"
3838 #include "libavutil/lfg.h"
39+#include "libavutil/dict.h"
3940 #include "libavutil/random_seed.h"
4041 #include "libavutil/parseutils.h"
4142 #include "libavutil/opt.h"
@@ -854,7 +855,7 @@ static void close_connection(HTTPContext *c) · 812 unmodified lines
854855 ctx = c->rtp_ctx[i];
855856 if (ctx) {
856857 av_write_trailer(ctx);
857− av_metadata_free(&ctx->metadata);
858+ av_dict_free(&ctx->metadata);
858859 av_free(ctx->streams[0]);
859860 av_free(ctx);
860861 }
@@ -2224,10 +2225,10 @@ static int http_prepare_data(HTTPContext *c) · 1363 unmodified lines
22242225 switch(c->state) {
22252226 case HTTPSTATE_SEND_DATA_HEADER:
22262227 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);
2228+ av_dict_set(&c->fmt_ctx.metadata, "author" , c->stream->author , 0);
2229+ av_dict_set(&c->fmt_ctx.metadata, "comment" , c->stream->comment , 0);
2230+ av_dict_set(&c->fmt_ctx.metadata, "copyright", c->stream->copyright, 0);
2231+ av_dict_set(&c->fmt_ctx.metadata, "title" , c->stream->title , 0);
22312232
22322233 c->fmt_ctx.streams = av_mallocz(sizeof(AVStream *) * c->stream->nb_streams);
22332234
@@ -2272,7 +2273,7 @@ static int http_prepare_data(HTTPContext *c) · 38 unmodified lines
22722273 http_log("Error writing output header\n");
22732274 return -1;
22742275 }
2275− av_metadata_free(&c->fmt_ctx.metadata);
2276+ av_dict_free(&c->fmt_ctx.metadata);
22762277
22772278 len = avio_close_dyn_buf(c->fmt_ctx.pb, &c->pb_buffer);
22782279 c->buffer_ptr = c->pb_buffer;
@@ -2927,8 +2928,8 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, · 648 unmodified lines
29272928 if (avc == NULL) {
29282929 return -1;
29292930 }
2930− av_metadata_set2(&avc->metadata, "title",
2931− stream->title[0] ? stream->title : "No Title", 0);
2931+ av_dict_set(&avc->metadata, "title",
2932+ stream->title[0] ? stream->title : "No Title", 0);
29322933 avc->nb_streams = stream->nb_streams;
29332934 if (stream->is_multicast) {
29342935 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, · 19 unmodified lines
29542955
29552956 sdp_done:
29562957 av_free(avc->streams);
2957− av_metadata_free(&avc->metadata);
2958+ av_dict_free(&avc->metadata);
29582959 av_free(avc);
29592960 av_free(avs);
29602961
libavcodec/dvbsubdec.c+5−4
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535
3636 #ifdef DEBUG
3737 #undef fprintf
38+#undef perror
3839 #if 0
3940 static void png_save(const char *filename, uint8_t *bitmap, int w, int h,
4041 uint32_t *rgba_palette)
@@ -49,7 +50,7 @@ static void png_save(const char *filename, uint8_t *bitmap, int w, int h, · 8 unmodified lines
4950 f = fopen(fname, "w");
5051 if (!f) {
5152 perror(fname);
52− exit(1);
53+ return;
5354 }
5455 fprintf(f, "P6\n"
5556 "%d %d\n"
@@ -71,7 +72,7 @@ static void png_save(const char *filename, uint8_t *bitmap, int w, int h, · 15 unmodified lines
7172 f = fopen(fname2, "w");
7273 if (!f) {
7374 perror(fname2);
74− exit(1);
75+ return;
7576 }
7677 fprintf(f, "P5\n"
7778 "%d %d\n"
@@ -105,7 +106,7 @@ static void png_save2(const char *filename, uint32_t *bitmap, int w, int h) · 27 unmodified lines
105106 f = fopen(fname, "w");
106107 if (!f) {
107108 perror(fname);
108− exit(1);
109+ return;
109110 }
110111 fprintf(f, "P6\n"
111112 "%d %d\n"
@@ -127,7 +128,7 @@ static void png_save2(const char *filename, uint32_t *bitmap, int w, int h) · 15 unmodified lines
127128 f = fopen(fname2, "w");
128129 if (!f) {
129130 perror(fname2);
130− exit(1);
131+ return;
131132 }
132133 fprintf(f, "P5\n"
133134 "%d %d\n"
libavformat/aiffdec.c+1−0
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 */
2121
2222 #include "libavutil/intfloat_readwrite.h"
23+#include "libavutil/dict.h"
2324 #include "avformat.h"
2425 #include "pcm.h"
2526 #include "aiff.h"
libavformat/apetag.c+2−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 */
2222
2323 #include "libavutil/intreadwrite.h"
24+#include "libavutil/dict.h"
2425 #include "avformat.h"
2526 #include "apetag.h"
2627
@@ -57,7 +58,7 @@ static int ape_tag_read_field(AVFormatContext *s) · 30 unmodified lines
5758 return AVERROR(ENOMEM);
5859 avio_read(pb, value, size);
5960 value[size] = 0;
60− av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
61+ av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL);
6162 return 0;
6263 }
6364
libavformat/applehttp.c+2−1
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include "libavutil/avstring.h"
2929 #include "libavutil/intreadwrite.h"
3030 #include "libavutil/opt.h"
31+#include "libavutil/dict.h"
3132 #include "avformat.h"
3233 #include "internal.h"
3334 #include <unistd.h>
@@ -505,7 +506,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) · 471 unmodified lines
505506 }
506507 avcodec_copy_context(st->codec, v->ctx->streams[j]->codec);
507508 if (v->bandwidth)
508− av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str,
509+ av_dict_set(&st->metadata, "variant_bitrate", bitrate_str,
509510 0);
510511 }
511512 stream_offset += v->ctx->nb_streams;
libavformat/asfdec.c+4−2
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include "libavutil/bswap.h"
2525 #include "libavutil/common.h"
2626 #include "libavutil/avstring.h"
27+#include "libavutil/dict.h"
2728 #include "libavcodec/mpegaudio.h"
2829 #include "avformat.h"
2930 #include "avio_internal.h"
@@ -172,7 +173,8 @@ static void get_tag(AVFormatContext *s, const char *key, int type, int len) · 142 unmodified lines
172173 av_log(s, AV_LOG_DEBUG, "Unsupported value type %d in tag %s.\n", type, key);
173174 goto finish;
174175 }
175− av_metadata_set2(&s->metadata, key, value, 0);
176+ if (*value)
177+ av_dict_set(&s->metadata, key, value, 0);
176178 finish:
177179 av_freep(&value);
178180 avio_seek(s->pb, off + len, SEEK_SET);
@@ -681,7 +683,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) · 502 unmodified lines
681683 const char primary_tag[3] = { rfc1766[0], rfc1766[1], '\0' }; // ignore country code if any
682684 const char *iso6392 = av_convert_lang_to(primary_tag, AV_LANG_ISO639_2_BIBL);
683685 if (iso6392)
684− av_metadata_set2(&st->metadata, "language", iso6392, 0);
686+ av_dict_set(&st->metadata, "language", iso6392, 0);
685687 }
686688 }
687689 }
libavformat/asfenc.c+9−9
@@ -19,10 +19,10 @@ · 18 unmodified lines
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
2121 #include "avformat.h"
22−#include "metadata.h"
2322 #include "riff.h"
2423 #include "asf.h"
2524 #include "avio_internal.h"
25+#include "libavutil/dict.h"
2626
2727 #undef NDEBUG
2828 #include <assert.h>
@@ -296,7 +296,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data · 267 unmodified lines
296296 {
297297 ASFContext *asf = s->priv_data;
298298 AVIOContext *pb = s->pb;
299− AVMetadataTag *tags[5];
299+ AVDictionaryEntry *tags[5];
300300 int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
301301 int has_title;
302302 int metadata_count;
@@ -307,11 +307,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data · 4 unmodified lines
307307
308308 ff_metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL);
309309
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);
315315
316316 duration = asf->duration + PREROLL_TIME * 10000;
317317 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 · 63 unmodified lines
381381 end_header(pb, hpos);
382382 }
383383 if (metadata_count) {
384− AVMetadataTag *tag = NULL;
384+ AVDictionaryEntry *tag = NULL;
385385 hpos = put_header(pb, &ff_asf_extended_content_header);
386386 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))) {
388388 put_str16(pb, tag->key);
389389 avio_wl16(pb, 0);
390390 put_str16(pb, tag->value);
libavformat/avformat.h+34−28
@@ -40,6 +40,7 @@ const char *avformat_license(void); · 39 unmodified lines
4040 #include <time.h>
4141 #include <stdio.h> /* FILE */
4242 #include "libavcodec/avcodec.h"
43+#include "libavutil/dict.h"
4344
4445 #include "avio.h"
4546 #include "libavformat/version.h"
@@ -106,21 +107,24 @@ struct AVFormatContext; · 60 unmodified lines
106107 * variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of
107108 */
108109
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.
110+#if FF_API_OLD_METADATA2
111+/**
112+ * @defgroup old_metadata Old metadata API
113+ * The following functions are deprecated, use
114+ * their equivalents from libavutil/dict.h instead.
115+ * @{
116+ */
114117
115−typedef struct {
116− char *key;
117− char *value;
118−}AVMetadataTag;
118+#define AV_METADATA_MATCH_CASE AV_DICT_MATCH_CASE
119+#define AV_METADATA_IGNORE_SUFFIX AV_DICT_IGNORE_SUFFIX
120+#define AV_METADATA_DONT_STRDUP_KEY AV_DICT_DONT_STRDUP_KEY
121+#define AV_METADATA_DONT_STRDUP_VAL AV_DICT_DONT_STRDUP_VAL
122+#define AV_METADATA_DONT_OVERWRITE AV_DICT_DONT_OVERWRITE
123+
124+typedef attribute_deprecated AVDictionary AVMetadata;
125+typedef attribute_deprecated AVDictionaryEntry AVMetadataTag;
119126
120−typedef struct AVMetadata AVMetadata;
121−#if FF_API_OLD_METADATA2
122127 typedef struct AVMetadataConv AVMetadataConv;
123−#endif
124128
125129 /**
126130 * Get a metadata element with matching key.
@@ -130,8 +134,8 @@ typedef struct AVMetadataConv AVMetadataConv; · 3 unmodified lines
130134 * @param flags Allows case as well as suffix-insensitive comparisons.
131135 * @return Found tag or NULL, changing key or value leads to undefined behavior.
132136 */
133−AVMetadataTag *
134−av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags);
137+attribute_deprecated AVDictionaryEntry *
138+av_metadata_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
135139
136140 /**
137141 * 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 · 5 unmodified lines
143147 * Passing a NULL value will cause an existing tag to be deleted.
144148 * @return >= 0 on success otherwise an error code <0
145149 */
146−int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags);
150+attribute_deprecated int av_metadata_set2(AVDictionary **pm, const char *key, const char *value, int flags);
147151
148−#if FF_API_OLD_METADATA2
149152 /**
150153 * This function is provided for compatibility reason and currently does nothing.
151154 */
152155 attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
153156 const AVMetadataConv *s_conv);
154−#endif
155157
156158 /**
157− * Copy metadata from one AVMetadata struct into another.
158− * @param dst pointer to a pointer to a AVMetadata struct. If *dst is NULL,
159+ * Copy metadata from one AVDictionary struct into another.
160+ * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
159161 * this function will allocate a struct for you and put it in *dst
160− * @param src pointer to source AVMetadata struct
162+ * @param src pointer to source AVDictionary struct
161163 * @param flags flags to use when setting metadata in *dst
162− * @note metadata is read using the AV_METADATA_IGNORE_SUFFIX flag
164+ * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
163165 */
164−void av_metadata_copy(AVMetadata **dst, AVMetadata *src, int flags);
166+attribute_deprecated void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags);
165167
166168 /**
167− * Free all the memory allocated for an AVMetadata struct.
169+ * Free all the memory allocated for an AVDictionary struct.
168170 */
169−void av_metadata_free(AVMetadata **m);
171+attribute_deprecated void av_metadata_free(AVDictionary **m);
172+/**
173+ * @}
174+ */
175+#endif
170176
171177
172178 /* packet functions */
@@ -563,7 +569,7 @@ typedef struct AVStream { · 390 unmodified lines
563569 */
564570 AVRational sample_aspect_ratio;
565571
566− AVMetadata *metadata;
572+ AVDictionary *metadata;
567573
568574 /* Intended mostly for av_read_frame() support. Not supposed to be used by */
569575 /* external applications; try to use something else if at all possible. */
@@ -644,7 +650,7 @@ typedef struct AVProgram { · 74 unmodified lines
644650 enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller
645651 unsigned int *stream_index;
646652 unsigned int nb_stream_indexes;
647− AVMetadata *metadata;
653+ AVDictionary *metadata;
648654
649655 int program_num;
650656 int pmt_pid;
@@ -658,7 +664,7 @@ typedef struct AVChapter { · 7 unmodified lines
658664 int id; ///< unique ID to identify the chapter
659665 AVRational time_base; ///< time base in which the start/end timestamps are specified
660666 int64_t start, end; ///< chapter start/end time in time_base units
661− AVMetadata *metadata;
667+ AVDictionary *metadata;
662668 } AVChapter;
663669
664670 /**
@@ -824,7 +830,7 @@ typedef struct AVFormatContext { · 159 unmodified lines
824830
825831 struct AVPacketList *packet_buffer_end;
826832
827− AVMetadata *metadata;
833+ AVDictionary *metadata;
828834
829835 /**
830836 * Remaining size available for raw_packet_buffer, in bytes.
libavformat/avidec.c+8−7
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include "libavutil/intreadwrite.h"
2727 #include "libavutil/bswap.h"
2828 #include "libavutil/opt.h"
29+#include "libavutil/dict.h"
2930 #include "avformat.h"
3031 #include "avi.h"
3132 #include "dv.h"
@@ -280,8 +281,8 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t · 248 unmodified lines
280281
281282 AV_WL32(key, tag);
282283
283− return av_metadata_set2(st ? &st->metadata : &s->metadata, key, value,
284− AV_METADATA_DONT_STRDUP_VAL);
284+ return av_dict_set(st ? &st->metadata : &s->metadata, key, value,
285+ AV_DICT_DONT_STRDUP_VAL);
285286 }
286287
287288 static void avi_read_info(AVFormatContext *s, uint64_t end)
@@ -296,7 +297,7 @@ static void avi_read_info(AVFormatContext *s, uint64_t end) · 8 unmodified lines
296297 static const char months[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
297298 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
298299
299−static void avi_metadata_creation_time(AVMetadata **metadata, char *date)
300+static void avi_metadata_creation_time(AVDictionary **metadata, char *date)
300301 {
301302 char month[4], time[9], buffer[64];
302303 int i, day, year;
@@ -307,11 +308,11 @@ static void avi_metadata_creation_time(AVMetadata **metadata, char *date) · 4 unmodified lines
307308 if (!strcasecmp(month, months[i])) {
308309 snprintf(buffer, sizeof(buffer), "%.4d-%.2d-%.2d %s",
309310 year, i+1, day, time);
310− av_metadata_set2(metadata, "creation_time", buffer, 0);
311+ av_dict_set(metadata, "creation_time", buffer, 0);
311312 }
312313 } else if (date[4] == '/' && date[7] == '/') {
313314 date[4] = date[7] = '-';
314− av_metadata_set2(metadata, "creation_time", date, 0);
315+ av_dict_set(metadata, "creation_time", date, 0);
315316 }
316317 }
317318
@@ -339,7 +340,7 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end) · 21 unmodified lines
339340 break;
340341 }
341342 if (name)
342− av_metadata_set2(&s->metadata, name, buffer, 0);
343+ av_dict_set(&s->metadata, name, buffer, 0);
343344 avio_skip(s->pb, size);
344345 }
345346 break;
@@ -795,7 +796,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt) { · 449 unmodified lines
795796 ret = avio_get_str16le(pb, desc_len, desc, sizeof(desc));
796797 avio_skip(pb, desc_len - ret);
797798 if (*desc)
798− av_metadata_set2(&st->metadata, "title", desc, 0);
799+ av_dict_set(&st->metadata, "title", desc, 0);
799800
800801 avio_rl16(pb); /* flags? */
801802 avio_rl32(pb); /* data size */
libavformat/avienc.c+4−3
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include "avio_internal.h"
2424 #include "riff.h"
2525 #include "libavutil/intreadwrite.h"
26+#include "libavutil/dict.h"
2627
2728 /*
2829 * TODO:
@@ -157,7 +158,7 @@ static int avi_write_header(AVFormatContext *s) · 128 unmodified lines
157158 int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
158159 AVCodecContext *stream, *video_enc;
159160 int64_t list1, list2, strh, strf;
160− AVMetadataTag *t = NULL;
161+ AVDictionaryEntry *t = NULL;
161162
162163 if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
163164 av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n",
@@ -297,7 +298,7 @@ static int avi_write_header(AVFormatContext *s) · 133 unmodified lines
297298 return -1;
298299 }
299300 ff_end_tag(pb, strf);
300− if ((t = av_metadata_get(s->streams[i]->metadata, "title", NULL, 0))) {
301+ if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) {
301302 avi_write_info_tag(s->pb, "strn", t->value);
302303 t = NULL;
303304 }
@@ -379,7 +380,7 @@ static int avi_write_header(AVFormatContext *s) · 75 unmodified lines
379380 ffio_wfourcc(pb, "INFO");
380381 ff_metadata_conv(&s->metadata, ff_avi_metadata_conv, NULL);
381382 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)))
383+ if ((t = av_dict_get(s->metadata, ff_avi_tags[i], NULL, AV_DICT_MATCH_CASE)))
383384 avi_write_info_tag(s->pb, t->key, t->value);
384385 }
385386 ff_end_tag(pb, list2);
libavformat/cafdec.c+2−1
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include "riff.h"
3030 #include "isom.h"
3131 #include "libavutil/intreadwrite.h"
32+#include "libavutil/dict.h"
3233 #include "caf.h"
3334
3435 typedef struct {
@@ -187,7 +188,7 @@ static void read_info_chunk(AVFormatContext *s, int64_t size) · 152 unmodified lines
187188 char value[1024];
188189 get_strz(pb, key, sizeof(key));
189190 get_strz(pb, value, sizeof(value));
190− av_metadata_set2(&s->metadata, key, value, 0);
191+ av_dict_set(&s->metadata, key, value, 0);
191192 }
192193 }
193194
libavformat/ffmetadec.c+4−3
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 #include "avformat.h"
2323 #include "ffmeta.h"
2424 #include "internal.h"
25+#include "libavutil/dict.h"
2526
2627 static int probe(AVProbeData *p)
2728 {
@@ -93,7 +94,7 @@ static uint8_t *unescape(uint8_t *buf, int size) · 65 unmodified lines
9394 return ret;
9495 }
9596
96−static int read_tag(uint8_t *line, AVMetadata **m)
97+static int read_tag(uint8_t *line, AVDictionary **m)
9798 {
9899 uint8_t *key, *value, *p = line;
99100
@@ -117,13 +118,13 @@ static int read_tag(uint8_t *line, AVMetadata **m) · 17 unmodified lines
117118 return AVERROR(ENOMEM);
118119 }
119120
120− av_metadata_set2(m, key, value, AV_METADATA_DONT_STRDUP_KEY | AV_METADATA_DONT_STRDUP_VAL);
121+ av_dict_set(m, key, value, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
121122 return 0;
122123 }
123124
124125 static int read_header(AVFormatContext *s, AVFormatParameters *ap)
125126 {
126− AVMetadata **m = &s->metadata;
127+ AVDictionary **m = &s->metadata;
127128 uint8_t line[1024];
128129
129130 while(!url_feof(s->pb)) {
libavformat/ffmetaenc.c+4−3
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323
2424 #include "avformat.h"
2525 #include "ffmeta.h"
26+#include "libavutil/dict.h"
2627
2728
2829 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) · 8 unmodified lines
3738 }
3839 }
3940
40−static void write_tags(AVIOContext *s, AVMetadata *m)
41+static void write_tags(AVIOContext *s, AVDictionary *m)
4142 {
42− AVMetadataTag *t = NULL;
43− while ((t = av_metadata_get(m, "", t, AV_METADATA_IGNORE_SUFFIX))) {
43+ AVDictionaryEntry *t = NULL;
44+ while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) {
4445 write_escape_str(s, t->key);
4546 avio_w8(s, '=');
4647 write_escape_str(s, t->value);
libavformat/flacenc.c+1−2
@@ -22,7 +22,6 @@ · 21 unmodified lines
2222 #include "libavcodec/flac.h"
2323 #include "avformat.h"
2424 #include "flacenc.h"
25−#include "metadata.h"
2625 #include "vorbiscomment.h"
2726 #include "libavcodec/bytestream.h"
2827
@@ -39,7 +38,7 @@ static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_byte · 10 unmodified lines
3938 return 0;
4039 }
4140
42−static int flac_write_block_comment(AVIOContext *pb, AVMetadata **m,
41+static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
4342 int last_block, int bitexact)
4443 {
4544 const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
libavformat/flvdec.c+4−3
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 */
2626
2727 #include "libavutil/avstring.h"
28+#include "libavutil/dict.h"
2829 #include "libavcodec/bytestream.h"
2930 #include "libavcodec/mpeg4audio.h"
3031 #include "avformat.h"
@@ -259,17 +260,17 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst · 228 unmodified lines
259260
260261 if(amf_type == AMF_DATA_TYPE_BOOL) {
261262 av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val));
262− av_metadata_set2(&s->metadata, key, str_val, 0);
263+ av_dict_set(&s->metadata, key, str_val, 0);
263264 } else if(amf_type == AMF_DATA_TYPE_NUMBER) {
264265 snprintf(str_val, sizeof(str_val), "%.f", num_val);
265− av_metadata_set2(&s->metadata, key, str_val, 0);
266+ av_dict_set(&s->metadata, key, str_val, 0);
266267 if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
267268 else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0))
268269 vcodec->bit_rate = num_val * 1024.0;
269270 else if(!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0))
270271 acodec->bit_rate = num_val * 1024.0;
271272 } else if (amf_type == AMF_DATA_TYPE_STRING)
272− av_metadata_set2(&s->metadata, key, str_val, 0);
273+ av_dict_set(&s->metadata, key, str_val, 0);
273274 }
274275
275276 return 0;
libavformat/flvenc.c+3−2
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include "internal.h"
2626 #include "avc.h"
2727 #include "metadata.h"
28+#include "libavutil/dict.h"
2829
2930 #undef NDEBUG
3031 #include <assert.h>
@@ -179,7 +180,7 @@ static int flv_write_header(AVFormatContext *s) · 148 unmodified lines
179180 int i;
180181 double framerate = 0.0;
181182 int metadata_size_pos, data_size;
182− AVMetadataTag *tag = NULL;
183+ AVDictionaryEntry *tag = NULL;
183184
184185 for(i=0; i<s->nb_streams; i++){
185186 AVCodecContext *enc = s->streams[i]->codec;
@@ -276,7 +277,7 @@ static int flv_write_header(AVFormatContext *s) · 90 unmodified lines
276277 put_amf_double(pb, audio_enc->codec_tag);
277278 }
278279
279− while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
280+ while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
280281 put_amf_string(pb, tag->key);
281282 avio_w8(pb, AMF_DATA_TYPE_STRING);
282283 put_amf_string(pb, tag->value);
libavformat/id3v1.c+4−3
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "id3v1.h"
2323 #include "libavcodec/avcodec.h"
24+#include "libavutil/dict.h"
2425
2526 const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + 1] = {
2627 [0] = "Blues",
@@ -191,7 +192,7 @@ static void get_string(AVFormatContext *s, const char *key, · 164 unmodified lines
191192 *q = '\0';
192193
193194 if (*str)
194− av_metadata_set2(&s->metadata, key, str, 0);
195+ av_dict_set(&s->metadata, key, str, 0);
195196 }
196197
197198 /**
@@ -215,11 +216,11 @@ static int parse_tag(AVFormatContext *s, const uint8_t *buf) · 17 unmodified lines
215216 get_string(s, "comment", buf + 97, 30);
216217 if (buf[125] == 0 && buf[126] != 0) {
217218 snprintf(str, sizeof(str), "%d", buf[126]);
218− av_metadata_set2(&s->metadata, "track", str, 0);
219+ av_dict_set(&s->metadata, "track", str, 0);
219220 }
220221 genre = buf[127];
221222 if (genre <= ID3v1_GENRE_MAX)
222− av_metadata_set2(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0);
223+ av_dict_set(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0);
223224 return 0;
224225 }
225226
libavformat/id3v2.c+14−14
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030 #include "id3v1.h"
3131 #include "libavutil/avstring.h"
3232 #include "libavutil/intreadwrite.h"
33−#include "metadata.h"
33+#include "libavutil/dict.h"
3434 #include "avio_internal.h"
3535
3636 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 · 103 unmodified lines
140140 val = dst;
141141
142142 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);
144144 }
145145
146146 static int is_number(const char *str)
@@ -149,44 +149,44 @@ static int is_number(const char *str) · 2 unmodified lines
149149 return !*str;
150150 }
151151
152−static AVMetadataTag* get_date_tag(AVMetadata *m, const char *tag)
152+static AVDictionaryEntry* get_date_tag(AVDictionary *m, const char *tag)
153153 {
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)) &&
156156 strlen(t->value) == 4 && is_number(t->value))
157157 return t;
158158 return NULL;
159159 }
160160
161−static void merge_date(AVMetadata **m)
161+static void merge_date(AVDictionary **m)
162162 {
163− AVMetadataTag *t;
163+ AVDictionaryEntry *t;
164164 char date[17] = {0}; // YYYY-MM-DD hh:mm
165165
166166 if (!(t = get_date_tag(*m, "TYER")) &&
167167 !(t = get_date_tag(*m, "TYE")))
168168 return;
169169 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);
172172
173173 if (!(t = get_date_tag(*m, "TDAT")) &&
174174 !(t = get_date_tag(*m, "TDA")))
175175 goto finish;
176176 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);
179179
180180 if (!(t = get_date_tag(*m, "TIME")) &&
181181 !(t = get_date_tag(*m, "TIM")))
182182 goto finish;
183183 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);
186186
187187 finish:
188188 if (date[0])
189− av_metadata_set2(m, "date", date, 0);
189+ av_dict_set(m, "date", date, 0);
190190 }
191191
192192 static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
libavformat/iff.c+2−1
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030
3131 #include "libavcodec/bytestream.h"
3232 #include "libavutil/intreadwrite.h"
33+#include "libavutil/dict.h"
3334 #include "avformat.h"
3435
3536 #define ID_8SVX MKTAG('8','S','V','X')
@@ -109,7 +110,7 @@ static int get_metadata(AVFormatContext *s, · 73 unmodified lines
109110 return AVERROR(EIO);
110111 }
111112 buf[data_size] = 0;
112− av_metadata_set2(&s->metadata, tag, buf, AV_METADATA_DONT_STRDUP_VAL);
113+ av_dict_set(&s->metadata, tag, buf, AV_DICT_DONT_STRDUP_VAL);
113114 return 0;
114115 }
115116
libavformat/matroskadec.c+9−8
@@ -42,6 +42,7 @@ · 41 unmodified lines
4242 #include "libavutil/intreadwrite.h"
4343 #include "libavutil/avstring.h"
4444 #include "libavutil/lzo.h"
45+#include "libavutil/dict.h"
4546 #if CONFIG_ZLIB
4647 #include <zlib.h>
4748 #endif
@@ -1073,7 +1074,7 @@ static void matroska_merge_packets(AVPacket *out, AVPacket *in) · 1025 unmodified lines
10731074 }
10741075
10751076 static void matroska_convert_tag(AVFormatContext *s, EbmlList *list,
1076− AVMetadata **metadata, char *prefix)
1077+ AVDictionary **metadata, char *prefix)
10771078 {
10781079 MatroskaTag *tags = list->elem;
10791080 char key[1024];
@@ -1089,14 +1090,14 @@ static void matroska_convert_tag(AVFormatContext *s, EbmlList *list, · 9 unmodified lines
10891090 if (prefix) snprintf(key, sizeof(key), "%s/%s", prefix, tags[i].name);
10901091 else av_strlcpy(key, tags[i].name, sizeof(key));
10911092 if (tags[i].def || !lang) {
1092− av_metadata_set2(metadata, key, tags[i].string, 0);
1093+ av_dict_set(metadata, key, tags[i].string, 0);
10931094 if (tags[i].sub.nb_elem)
10941095 matroska_convert_tag(s, &tags[i].sub, metadata, key);
10951096 }
10961097 if (lang) {
10971098 av_strlcat(key, "-", sizeof(key));
10981099 av_strlcat(key, lang, sizeof(key));
1099− av_metadata_set2(metadata, key, tags[i].string, 0);
1100+ av_dict_set(metadata, key, tags[i].string, 0);
11001101 if (tags[i].sub.nb_elem)
11011102 matroska_convert_tag(s, &tags[i].sub, metadata, key);
11021103 }
@@ -1269,7 +1270,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) · 166 unmodified lines
12691270 if (matroska->duration)
12701271 matroska->ctx->duration = matroska->duration * matroska->time_scale
12711272 * 1000 / AV_TIME_BASE;
1272− av_metadata_set2(&s->metadata, "title", matroska->title, 0);
1273+ av_dict_set(&s->metadata, "title", matroska->title, 0);
12731274
12741275 tracks = matroska->tracks.elem;
12751276 for (i=0; i < matroska->tracks.nb_elem; i++) {
@@ -1467,8 +1468,8 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) · 191 unmodified lines
14671468 st->codec->codec_id = codec_id;
14681469 st->start_time = 0;
14691470 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);
1471+ av_dict_set(&st->metadata, "language", track->language, 0);
1472+ av_dict_set(&st->metadata, "title", track->name, 0);
14721473
14731474 if (track->flag_default)
14741475 st->disposition |= AV_DISPOSITION_DEFAULT;
@@ -1550,7 +1551,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) · 75 unmodified lines
15501551 AVStream *st = av_new_stream(s, 0);
15511552 if (st == NULL)
15521553 break;
1553− av_metadata_set2(&st->metadata, "filename",attachements[j].filename, 0);
1554+ av_dict_set(&st->metadata, "filename",attachements[j].filename, 0);
15541555 st->codec->codec_id = CODEC_ID_NONE;
15551556 st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
15561557 st->codec->extradata = av_malloc(attachements[j].bin.size);
@@ -1578,7 +1579,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) · 21 unmodified lines
15781579 ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000},
15791580 chapters[i].start, chapters[i].end,
15801581 chapters[i].title);
1581− av_metadata_set2(&chapters[i].chapter->metadata,
1582+ av_dict_set(&chapters[i].chapter->metadata,
15821583 "title", chapters[i].title, 0);
15831584 max_start = chapters[i].start;
15841585 }
libavformat/matroskaenc.c+17−16
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030 #include "libavutil/intreadwrite.h"
3131 #include "libavutil/random_seed.h"
3232 #include "libavutil/lfg.h"
33+#include "libavutil/dict.h"
3334 #include "libavcodec/xiph.h"
3435 #include "libavcodec/mpeg4audio.h"
3536 #include <strings.h>
@@ -523,7 +524,7 @@ static int mkv_write_tracks(AVFormatContext *s) · 487 unmodified lines
523524 int bit_depth = av_get_bits_per_sample(codec->codec_id);
524525 int sample_rate = codec->sample_rate;
525526 int output_sample_rate = 0;
526− AVMetadataTag *tag;
527+ AVDictionaryEntry *tag;
527528
528529 if (!bit_depth)
529530 bit_depth = av_get_bits_per_sample_fmt(codec->sample_fmt);
@@ -536,9 +537,9 @@ static int mkv_write_tracks(AVFormatContext *s) · 6 unmodified lines
536537 put_ebml_uint (pb, MATROSKA_ID_TRACKUID , i + 1);
537538 put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0); // no lacing (yet)
538539
539− if ((tag = av_metadata_get(st->metadata, "title", NULL, 0)))
540+ if ((tag = av_dict_get(st->metadata, "title", NULL, 0)))
540541 put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value);
541− tag = av_metadata_get(st->metadata, "language", NULL, 0);
542+ tag = av_dict_get(st->metadata, "language", NULL, 0);
542543 put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag ? tag->value:"und");
543544
544545 if (st->disposition)
@@ -587,8 +588,8 @@ static int mkv_write_tracks(AVFormatContext *s) · 42 unmodified lines
587588 put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width);
588589 put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, codec->height);
589590
590− if ((tag = av_metadata_get(st->metadata, "stereo_mode", NULL, 0)) ||
591− (tag = av_metadata_get( s->metadata, "stereo_mode", NULL, 0))) {
591+ if ((tag = av_dict_get(st->metadata, "stereo_mode", NULL, 0)) ||
592+ (tag = av_dict_get( s->metadata, "stereo_mode", NULL, 0))) {
592593 // save stereo mode flag
593594 uint64_t st_mode = MATROSKA_VIDEO_STEREO_MODE_COUNT;
594595
@@ -677,7 +678,7 @@ static int mkv_write_chapters(AVFormatContext *s) · 82 unmodified lines
677678 for (i = 0; i < s->nb_chapters; i++) {
678679 ebml_master chapteratom, chapterdisplay;
679680 AVChapter *c = s->chapters[i];
680− AVMetadataTag *t = NULL;
681+ AVDictionaryEntry *t = NULL;
681682
682683 chapteratom = start_ebml_master(pb, MATROSKA_ID_CHAPTERATOM, 0);
683684 put_ebml_uint(pb, MATROSKA_ID_CHAPTERUID, c->id);
@@ -687,7 +688,7 @@ static int mkv_write_chapters(AVFormatContext *s) · 3 unmodified lines
687688 av_rescale_q(c->end, c->time_base, scale));
688689 put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGHIDDEN , 0);
689690 put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGENABLED, 1);
690− if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
691+ if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
691692 chapterdisplay = start_ebml_master(pb, MATROSKA_ID_CHAPTERDISPLAY, 0);
692693 put_ebml_string(pb, MATROSKA_ID_CHAPSTRING, t->value);
693694 put_ebml_string(pb, MATROSKA_ID_CHAPLANG , "und");
@@ -700,7 +701,7 @@ static int mkv_write_chapters(AVFormatContext *s) · 6 unmodified lines
700701 return 0;
701702 }
702703
703−static void mkv_write_simpletag(AVIOContext *pb, AVMetadataTag *t)
704+static void mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t)
704705 {
705706 uint8_t *key = av_strdup(t->key);
706707 uint8_t *p = key;
@@ -730,12 +731,12 @@ static void mkv_write_simpletag(AVIOContext *pb, AVMetadataTag *t) · 23 unmodified lines
730731 av_freep(&key);
731732 }
732733
733−static int mkv_write_tag(AVFormatContext *s, AVMetadata *m, unsigned int elementid,
734+static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int elementid,
734735 unsigned int uid, ebml_master *tags)
735736 {
736737 MatroskaMuxContext *mkv = s->priv_data;
737738 ebml_master tag, targets;
738− AVMetadataTag *t = NULL;
739+ AVDictionaryEntry *t = NULL;
739740 int ret;
740741
741742 if (!tags->pos) {
@@ -751,7 +752,7 @@ static int mkv_write_tag(AVFormatContext *s, AVMetadata *m, unsigned int element · 9 unmodified lines
751752 put_ebml_uint(s->pb, elementid, uid);
752753 end_ebml_master(s->pb, targets);
753754
754− while ((t = av_metadata_get(m, "", t, AV_METADATA_IGNORE_SUFFIX)))
755+ while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX)))
755756 if (strcasecmp(t->key, "title") && strcasecmp(t->key, "stereo_mode"))
756757 mkv_write_simpletag(s->pb, t);
757758
@@ -766,7 +767,7 @@ static int mkv_write_tags(AVFormatContext *s) · 8 unmodified lines
766767
767768 ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL);
768769
769− if (av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX)) {
770+ if (av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
770771 ret = mkv_write_tag(s, s->metadata, 0, 0, &tags);
771772 if (ret < 0) return ret;
772773 }
@@ -774,7 +775,7 @@ static int mkv_write_tags(AVFormatContext *s) · 1 unmodified line
774775 for (i = 0; i < s->nb_streams; i++) {
775776 AVStream *st = s->streams[i];
776777
777− if (!av_metadata_get(st->metadata, "", 0, AV_METADATA_IGNORE_SUFFIX))
778+ if (!av_dict_get(st->metadata, "", 0, AV_DICT_IGNORE_SUFFIX))
778779 continue;
779780
780781 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) · 3 unmodified lines
784785 for (i = 0; i < s->nb_chapters; i++) {
785786 AVChapter *ch = s->chapters[i];
786787
787− if (!av_metadata_get(ch->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
788+ if (!av_dict_get(ch->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
788789 continue;
789790
790791 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) · 10 unmodified lines
801802 MatroskaMuxContext *mkv = s->priv_data;
802803 AVIOContext *pb = s->pb;
803804 ebml_master ebml_header, segment_info;
804− AVMetadataTag *tag;
805+ AVDictionaryEntry *tag;
805806 int ret, i;
806807
807808 if (!strcmp(s->oformat->name, "webm")) mkv->mode = MODE_WEBM;
@@ -838,7 +839,7 @@ static int mkv_write_header(AVFormatContext *s) · 30 unmodified lines
838839
839840 segment_info = start_ebml_master(pb, MATROSKA_ID_INFO, 0);
840841 put_ebml_uint(pb, MATROSKA_ID_TIMECODESCALE, 1000000);
841− if ((tag = av_metadata_get(s->metadata, "title", NULL, 0)))
842+ if ((tag = av_dict_get(s->metadata, "title", NULL, 0)))
842843 put_ebml_string(pb, MATROSKA_ID_TITLE, tag->value);
843844 if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
844845 uint32_t segment_uid[4];
libavformat/metadata.c+20−83
@@ -21,107 +21,51 @@ · 20 unmodified lines
2121 #include <strings.h>
2222 #include "avformat.h"
2323 #include "metadata.h"
24+#include "libavutil/dict.h"
2425
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)
2729 {
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);
4731 }
4832
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)
5034 {
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);
8736 }
8837
89−#if FF_API_OLD_METADATA2
9038 void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv,
9139 const AVMetadataConv *s_conv)
9240 {
9341 return;
9442 }
95−#endif
9643
97−void av_metadata_free(AVMetadata **pm)
44+void av_metadata_free(AVDictionary **pm)
9845 {
99− AVMetadata *m= *pm;
46+ av_dict_free(pm);
47+}
10048
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);
10952 }
53+#endif
11054
111−void ff_metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
55+void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
11256 const AVMetadataConv *s_conv)
11357 {
11458 /* TODO: use binary search to look up the two conversion tables
11559 if the tables are getting big enough that it would matter speed wise */
11660 const AVMetadataConv *sc, *dc;
117− AVMetadataTag *mtag = NULL;
118− AVMetadata *dst = NULL;
61+ AVDictionaryEntry *mtag = NULL;
62+ AVDictionary *dst = NULL;
11963 const char *key;
12064
12165 if (d_conv == s_conv)
12266 return;
12367
124− while((mtag=av_metadata_get(*pm, "", mtag, AV_METADATA_IGNORE_SUFFIX))) {
68+ while ((mtag = av_dict_get(*pm, "", mtag, AV_DICT_IGNORE_SUFFIX))) {
12569 key = mtag->key;
12670 if (s_conv)
12771 for (sc=s_conv; sc->native; sc++)
@@ -135,9 +79,9 @@ void ff_metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv, · 7 unmodified lines
13579 key = dc->native;
13680 break;
13781 }
138− av_metadata_set2(&dst, key, mtag->value, 0);
82+ av_dict_set(&dst, key, mtag->value, 0);
13983 }
140− av_metadata_free(pm);
84+ av_dict_free(pm);
14185 *pm = dst;
14286 }
14387
@@ -154,10 +98,3 @@ void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv, · 10 unmodified lines
15498 ff_metadata_conv(&ctx->programs[i]->metadata, d_conv, s_conv);
15599 }
156100
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−}
libavformat/metadata.h+2−6
@@ -29,11 +29,7 @@ · 28 unmodified lines
2929
3030
3131 #include "avformat.h"
32−
33−struct AVMetadata{
34− int count;
35− AVMetadataTag *elems;
36−};
32+#include "libavutil/dict.h"
3733
3834 struct AVMetadataConv{
3935 const char *native;
@@ -43,7 +39,7 @@ struct AVMetadataConv{ · 3 unmodified lines
4339 typedef struct AVMetadataConv AVMetadataConv;
4440 #endif
4541
46−void ff_metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
42+void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
4743 const AVMetadataConv *s_conv);
4844 void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
4945 const AVMetadataConv *s_conv);
libavformat/mov.c+10−12
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727
2828 #include "libavutil/intreadwrite.h"
2929 #include "libavutil/avstring.h"
30+#include "libavutil/dict.h"
3031 #include "avformat.h"
3132 #include "avio_internal.h"
3233 #include "riff.h"
@@ -84,7 +85,7 @@ static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, uns · 51 unmodified lines
8485
8586 avio_rb16(pb); // unknown
8687 snprintf(buf, sizeof(buf), "%d", avio_rb16(pb));
87− av_metadata_set2(&c->fc->metadata, type, buf, 0);
88+ av_dict_set(&c->fc->metadata, type, buf, 0);
8889
8990 avio_rb16(pb); // total tracks/discs
9091
@@ -208,10 +209,10 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 117 unmodified lines
208209 avio_read(pb, str, str_size);
209210 str[str_size] = 0;
210211 }
211− av_metadata_set2(&c->fc->metadata, key, str, 0);
212+ av_dict_set(&c->fc->metadata, key, str, 0);
212213 if (*language && strcmp(language, "und")) {
213214 snprintf(key2, sizeof(key2), "%s-%s", key, language);
214− av_metadata_set2(&c->fc->metadata, key2, str, 0);
215+ av_dict_set(&c->fc->metadata, key2, str, 0);
215216 }
216217 }
217218 av_dlog(c->fc, "lang \"%3s\" ", language);
@@ -557,10 +558,10 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 339 unmodified lines
557558 if (strcmp(type, "qt "))
558559 c->isom = 1;
559560 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);
561+ av_dict_set(&c->fc->metadata, "major_brand", type, 0);
561562 minor_ver = avio_rb32(pb); /* minor version */
562563 snprintf(minor_ver_str, sizeof(minor_ver_str), "%d", minor_ver);
563− av_metadata_set2(&c->fc->metadata, "minor_version", minor_ver_str, 0);
564+ av_dict_set(&c->fc->metadata, "minor_version", minor_ver_str, 0);
564565
565566 comp_brand_size = atom.size - 8;
566567 if (comp_brand_size < 0)
@@ -570,7 +571,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 3 unmodified lines
570571 return AVERROR(ENOMEM);
571572 avio_read(pb, comp_brands_str, comp_brand_size);
572573 comp_brands_str[comp_brand_size] = 0;
573− av_metadata_set2(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
574+ av_dict_set(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
574575 av_freep(&comp_brands_str);
575576
576577 return 0;
@@ -594,7 +595,7 @@ static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 17 unmodified lines
594595 return mov_read_default(c, pb, atom);
595596 }
596597
597−static void mov_metadata_creation_time(AVMetadata **metadata, time_t time)
598+static void mov_metadata_creation_time(AVDictionary **metadata, time_t time)
598599 {
599600 char buffer[32];
600601 if (time) {
@@ -603,7 +604,7 @@ static void mov_metadata_creation_time(AVMetadata **metadata, time_t time) · 2 unmodified lines
603604 ptm = gmtime(&time);
604605 if (!ptm) return;
605606 strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm);
606− av_metadata_set2(metadata, "creation_time", buffer, 0);
607+ av_dict_set(metadata, "creation_time", buffer, 0);
607608 }
608609 }
609610
@@ -640,7 +641,7 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 30 unmodified lines
640641
641642 lang = avio_rb16(pb); /* language */
642643 if (ff_mov_lang_to_iso639(lang, language))
643− av_metadata_set2(&st->metadata, "language", language, 0);
644+ av_dict_set(&st->metadata, "language", language, 0);
644645 avio_rb16(pb); /* quality */
645646
646647 return 0;
@@ -2147,9 +2148,6 @@ static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 1500 unmodified lines
21472148 goto free_and_return;
21482149 atom.type = MKTAG('m','o','o','v');
21492150 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
21532151 ret = mov_read_default(c, &ctx, atom);
21542152 free_and_return:
21552153 av_free(moov_data);
libavformat/movenc.c+13−12
@@ -33,6 +33,7 @@ · 32 unmodified lines
3333 #include "internal.h"
3434 #include "libavutil/avstring.h"
3535 #include "libavutil/opt.h"
36+#include "libavutil/dict.h"
3637
3738 #undef NDEBUG
3839 #include <assert.h>
@@ -1534,15 +1535,15 @@ static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb, · 1495 unmodified lines
15341535 int long_style)
15351536 {
15361537 int l, lang = 0, len, len2;
1537− AVMetadataTag *t, *t2 = NULL;
1538+ AVDictionaryEntry *t, *t2 = NULL;
15381539 char tag2[16];
15391540
1540− if (!(t = av_metadata_get(s->metadata, tag, NULL, 0)))
1541+ if (!(t = av_dict_get(s->metadata, tag, NULL, 0)))
15411542 return 0;
15421543
15431544 len = strlen(t->key);
15441545 snprintf(tag2, sizeof(tag2), "%s-", tag);
1545− while ((t2 = av_metadata_get(s->metadata, tag2, t2, AV_METADATA_IGNORE_SUFFIX))) {
1546+ while ((t2 = av_dict_get(s->metadata, tag2, t2, AV_DICT_IGNORE_SUFFIX))) {
15461547 len2 = strlen(t2->key);
15471548 if (len2 == len+4 && !strcmp(t->value, t2->value)
15481549 && (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, · 8 unmodified lines
15571558 static int mov_write_trkn_tag(AVIOContext *pb, MOVMuxContext *mov,
15581559 AVFormatContext *s)
15591560 {
1560− AVMetadataTag *t = av_metadata_get(s->metadata, "track", NULL, 0);
1561+ AVDictionaryEntry *t = av_dict_get(s->metadata, "track", NULL, 0);
15611562 int size = 0, track = t ? atoi(t->value) : 0;
15621563 if (track) {
15631564 avio_wb32(pb, 32); /* size */
@@ -1649,7 +1650,7 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s, · 85 unmodified lines
16491650 const char *tag, const char *str)
16501651 {
16511652 int64_t pos = avio_tell(pb);
1652− AVMetadataTag *t = av_metadata_get(s->metadata, str, NULL, 0);
1653+ AVDictionaryEntry *t = av_dict_get(s->metadata, str, NULL, 0);
16531654 if (!t || !utf8len(t->value))
16541655 return 0;
16551656 avio_wb32(pb, 0); /* size */
@@ -1661,7 +1662,7 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s, · 5 unmodified lines
16611662 avio_wb16(pb, language_code("eng")); /* language */
16621663 avio_write(pb, t->value, strlen(t->value)+1); /* UTF8 string value */
16631664 if (!strcmp(tag, "albm") &&
1664− (t = av_metadata_get(s->metadata, "track", NULL, 0)))
1665+ (t = av_dict_get(s->metadata, "track", NULL, 0)))
16651666 avio_w8(pb, atoi(t->value));
16661667 }
16671668 return updateSize(pb, pos);
@@ -1680,10 +1681,10 @@ static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s) · 12 unmodified lines
16801681
16811682 for (i = 0; i < nb_chapters; i++) {
16821683 AVChapter *c = s->chapters[i];
1683− AVMetadataTag *t;
1684+ AVDictionaryEntry *t;
16841685 avio_wb64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000}));
16851686
1686− if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
1687+ if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
16871688 int len = FFMIN(strlen(t->value), 255);
16881689 avio_w8(pb, len);
16891690 avio_write(pb, t->value, len);
@@ -1761,7 +1762,7 @@ static void mov_write_psp_udta_tag(AVIOContext *pb, · 71 unmodified lines
17611762
17621763 static int mov_write_uuidusmt_tag(AVIOContext *pb, AVFormatContext *s)
17631764 {
1764− AVMetadataTag *title = av_metadata_get(s->metadata, "title", NULL, 0);
1765+ AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0);
17651766 int64_t pos, pos2;
17661767
17671768 if (title) {
@@ -2115,13 +2116,13 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum) · 347 unmodified lines
21152116
21162117 for (i = 0; i < s->nb_chapters; i++) {
21172118 AVChapter *c = s->chapters[i];
2118− AVMetadataTag *t;
2119+ AVDictionaryEntry *t;
21192120
21202121 int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
21212122 pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
21222123 pkt.duration = end - pkt.dts;
21232124
2124− if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
2125+ if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
21252126 len = strlen(t->value);
21262127 pkt.size = len+2;
21272128 pkt.data = av_malloc(pkt.size);
@@ -2195,7 +2196,7 @@ static int mov_write_header(AVFormatContext *s) · 67 unmodified lines
21952196 for(i=0; i<s->nb_streams; i++){
21962197 AVStream *st= s->streams[i];
21972198 MOVTrack *track= &mov->tracks[i];
2198− AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0);
2199+ AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
21992200
22002201 track->enc = st->codec;
22012202 track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV);
libavformat/mp3dec.c+2−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "libavutil/avstring.h"
2323 #include "libavutil/intreadwrite.h"
24+#include "libavutil/dict.h"
2425 #include "avformat.h"
2526 #include "id3v2.h"
2627 #include "id3v1.h"
@@ -149,7 +150,7 @@ static int mp3_read_header(AVFormatContext *s, · 122 unmodified lines
149150
150151 off = avio_tell(s->pb);
151152
152− if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
153+ if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
153154 ff_id3v1_read(s);
154155
155156 if (mp3_parse_vbr_tags(s, st, off) < 0)
libavformat/mp3enc.c+9−8
@@ -31,19 +31,20 @@ · 30 unmodified lines
3131 #include "libavcodec/mpegaudiodata.h"
3232 #include "libavcodec/mpegaudiodecheader.h"
3333 #include "libavformat/avio_internal.h"
34+#include "libavutil/dict.h"
3435
3536 static int id3v1_set_string(AVFormatContext *s, const char *key,
3637 uint8_t *buf, int buf_size)
3738 {
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)))
4041 av_strlcpy(buf, tag->value, buf_size);
4142 return !!tag;
4243 }
4344
4445 static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
4546 {
46− AVMetadataTag *tag;
47+ AVDictionaryEntry *tag;
4748 int i, count = 0;
4849
4950 memset(buf, 0, ID3v1_TAG_SIZE); /* fail safe */
@@ -55,13 +56,13 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf) · 5 unmodified lines
5556 count += id3v1_set_string(s, "TALB", buf + 63, 30); //album
5657 count += id3v1_set_string(s, "TDRL", buf + 93, 4); //date
5758 count += id3v1_set_string(s, "comment", buf + 97, 30);
58− if ((tag = av_metadata_get(s->metadata, "TRCK", NULL, 0))) { //track
59+ if ((tag = av_dict_get(s->metadata, "TRCK", NULL, 0))) { //track
5960 buf[125] = 0;
6061 buf[126] = atoi(tag->value);
6162 count++;
6263 }
6364 buf[127] = 0xFF; /* default to unknown genre */
64− if ((tag = av_metadata_get(s->metadata, "TCON", NULL, 0))) { //genre
65+ if ((tag = av_dict_get(s->metadata, "TCON", NULL, 0))) { //genre
6566 for(i = 0; i <= ID3v1_GENRE_MAX; i++) {
6667 if (!strcasecmp(tag->value, ff_id3v1_genre_str[i])) {
6768 buf[127] = i;
@@ -186,7 +187,7 @@ static const AVClass mp3_muxer_class = { · 118 unmodified lines
186187 .version = LIBAVUTIL_VERSION_INT,
187188 };
188189
189−static int id3v2_check_write_tag(AVFormatContext *s, AVMetadataTag *t, const char table[][4],
190+static int id3v2_check_write_tag(AVFormatContext *s, AVDictionaryEntry *t, const char table[][4],
190191 enum ID3v2Encoding enc)
191192 {
192193 uint32_t tag;
@@ -345,7 +346,7 @@ static void mp3_fix_xing(AVFormatContext *s) · 152 unmodified lines
345346 static int mp3_write_header(struct AVFormatContext *s)
346347 {
347348 MP3Context *mp3 = s->priv_data;
348− AVMetadataTag *t = NULL;
349+ AVDictionaryEntry *t = NULL;
349350 int totlen = 0, enc = mp3->id3v2_version == 3 ? ID3v2_ENCODING_UTF16BOM :
350351 ID3v2_ENCODING_UTF8;
351352 int64_t size_pos, cur_pos;
@@ -362,7 +363,7 @@ static int mp3_write_header(struct AVFormatContext *s) · 10 unmodified lines
362363 if (mp3->id3v2_version == 4)
363364 ff_metadata_conv(&s->metadata, ff_id3v2_4_metadata_conv, NULL);
364365
365− while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
366+ while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
366367 int ret;
367368
368369 if ((ret = id3v2_check_write_tag(s, t, ff_id3v2_tags, enc)) > 0) {
libavformat/mpc.c+2−1
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include "avformat.h"
2424 #include "apetag.h"
2525 #include "id3v1.h"
26+#include "libavutil/dict.h"
2627
2728 #define MPC_FRAMESIZE 1152
2829 #define DELAY_FRAMES 32
@@ -96,7 +97,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap) · 67 unmodified lines
9697 if (s->pb->seekable) {
9798 int64_t pos = avio_tell(s->pb);
9899 ff_ape_parse_tag(s);
99− if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
100+ if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
100101 ff_id3v1_read(s);
101102 avio_seek(s->pb, pos, SEEK_SET);
102103 }
libavformat/mpegts.c+6−5
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include "libavutil/crc.h"
2727 #include "libavutil/intreadwrite.h"
2828 #include "libavutil/log.h"
29+#include "libavutil/dict.h"
2930 #include "libavutil/opt.h"
3031 #include "libavcodec/bytestream.h"
3132 #include "avformat.h"
@@ -950,7 +951,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type · 918 unmodified lines
950951 language[1] = get8(pp, desc_end);
951952 language[2] = get8(pp, desc_end);
952953 language[3] = 0;
953− av_metadata_set2(&st->metadata, "language", language, 0);
954+ av_dict_set(&st->metadata, "language", language, 0);
954955 break;
955956 case 0x59: /* subtitling descriptor */
956957 language[0] = get8(pp, desc_end);
@@ -979,7 +980,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type · 22 unmodified lines
979980 }
980981 }
981982 *pp += 4;
982− av_metadata_set2(&st->metadata, "language", language, 0);
983+ av_dict_set(&st->metadata, "language", language, 0);
983984 break;
984985 case 0x0a: /* ISO 639 language descriptor */
985986 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 · 9 unmodified lines
995996 }
996997 if (i) {
997998 language[i - 1] = 0;
998− av_metadata_set2(&st->metadata, "language", language, 0);
999+ av_dict_set(&st->metadata, "language", language, 0);
9991000 }
10001001 break;
10011002 case 0x05: /* registration descriptor */
@@ -1248,8 +1249,8 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len · 246 unmodified lines
12481249 if (name) {
12491250 AVProgram *program = av_new_program(ts->stream, sid);
12501251 if(program) {
1251− av_metadata_set2(&program->metadata, "service_name", name, 0);
1252− av_metadata_set2(&program->metadata, "service_provider", provider_name, 0);
1252+ av_dict_set(&program->metadata, "service_name", name, 0);
1253+ av_dict_set(&program->metadata, "service_provider", provider_name, 0);
12531254 }
12541255 }
12551256 av_free(name);
libavformat/mpegtsenc.c+6−5
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "libavutil/bswap.h"
2323 #include "libavutil/crc.h"
24+#include "libavutil/dict.h"
2425 #include "libavutil/opt.h"
2526 #include "libavcodec/mpegvideo.h"
2627 #include "avformat.h"
@@ -244,7 +245,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) · 217 unmodified lines
244245 for(i = 0; i < s->nb_streams; i++) {
245246 AVStream *st = s->streams[i];
246247 MpegTSWriteStream *ts_st = st->priv_data;
247− AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0);
248+ AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
248249 switch(st->codec->codec_id) {
249250 case CODEC_ID_MPEG1VIDEO:
250251 case CODEC_ID_MPEG2VIDEO:
@@ -443,7 +444,7 @@ static int mpegts_write_header(AVFormatContext *s) · 192 unmodified lines
443444 MpegTSWriteStream *ts_st;
444445 MpegTSService *service;
445446 AVStream *st, *pcr_st = NULL;
446− AVMetadataTag *title, *provider;
447+ AVDictionaryEntry *title, *provider;
447448 int i, j;
448449 const char *service_name;
449450 const char *provider_name;
@@ -452,11 +453,11 @@ static int mpegts_write_header(AVFormatContext *s) · 2 unmodified lines
452453 ts->tsid = ts->transport_stream_id;
453454 ts->onid = ts->original_network_id;
454455 /* allocate a single DVB service */
455− title = av_metadata_get(s->metadata, "service_name", NULL, 0);
456+ title = av_dict_get(s->metadata, "service_name", NULL, 0);
456457 if (!title)
457− title = av_metadata_get(s->metadata, "title", NULL, 0);
458+ title = av_dict_get(s->metadata, "title", NULL, 0);
458459 service_name = title ? title->value : DEFAULT_SERVICE_NAME;
459− provider = av_metadata_get(s->metadata, "service_provider", NULL, 0);
460+ provider = av_dict_get(s->metadata, "service_provider", NULL, 0);
460461 provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
461462 service = mpegts_add_service(ts, ts->service_id, provider_name, service_name);
462463 service->pmt.write_packet = section_write_packet;
libavformat/nsvdec.c+2−1
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 */
2121 #include "avformat.h"
2222 #include "riff.h"
23+#include "libavutil/dict.h"
2324
2425 //#define DEBUG
2526 //#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) · 302 unmodified lines
328329 break;
329330 *p++ = '\0';
330331 av_dlog(s, "NSV NSVf INFO: %s='%s'\n", token, value);
331− av_metadata_set2(&s->metadata, token, value, 0);
332+ av_dict_set(&s->metadata, token, value, 0);
332333 }
333334 av_free(strings);
334335 }
libavformat/nutdec.c+3−2
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include <strings.h>
2424 #include "libavutil/avstring.h"
2525 #include "libavutil/bswap.h"
26+#include "libavutil/dict.h"
2627 #include "libavutil/tree.h"
2728 #include "avio_internal.h"
2829 #include "nut.h"
@@ -401,7 +402,7 @@ static int decode_info_header(NUTContext *nut){ · 372 unmodified lines
401402 const char *type;
402403 AVChapter *chapter= NULL;
403404 AVStream *st= NULL;
404− AVMetadata **metadata = NULL;
405+ AVDictionary **metadata = NULL;
405406
406407 end= get_packetheader(nut, bc, 1, INFO_STARTCODE);
407408 end += avio_tell(bc);
@@ -459,7 +460,7 @@ static int decode_info_header(NUTContext *nut){ · 51 unmodified lines
459460 }
460461 if(metadata && strcasecmp(name,"Uses")
461462 && strcasecmp(name,"Depends") && strcasecmp(name,"Replaces"))
462− av_metadata_set2(metadata, name, str_value, 0);
463+ av_dict_set(metadata, name, str_value, 0);
463464 }
464465 }
465466
libavformat/nutenc.c+5−4
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "libavutil/intreadwrite.h"
2323 #include "libavutil/tree.h"
24+#include "libavutil/dict.h"
2425 #include "libavcodec/mpegaudiodata.h"
2526 #include "nut.h"
2627 #include "internal.h"
@@ -432,7 +433,7 @@ static int add_info(AVIOContext *bc, const char *type, const char *value){ · 405 unmodified lines
432433
433434 static int write_globalinfo(NUTContext *nut, AVIOContext *bc){
434435 AVFormatContext *s= nut->avf;
435− AVMetadataTag *t = NULL;
436+ AVDictionaryEntry *t = NULL;
436437 AVIOContext *dyn_bc;
437438 uint8_t *dyn_buf=NULL;
438439 int count=0, dyn_size;
@@ -440,7 +441,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext *bc){ · 1 unmodified line
440441 if(ret < 0)
441442 return ret;
442443
443− while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
444+ while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
444445 count += add_info(dyn_bc, t->key, t->value);
445446
446447 ff_put_v(bc, 0); //stream_if_plus1
@@ -491,7 +492,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id) · 44 unmodified lines
491492 {
492493 AVIOContext *dyn_bc;
493494 uint8_t *dyn_buf = NULL;
494− AVMetadataTag *t = NULL;
495+ AVDictionaryEntry *t = NULL;
495496 AVChapter *ch = nut->avf->chapters[id];
496497 int ret, dyn_size, count = 0;
497498
@@ -504,7 +505,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id) · 6 unmodified lines
504505 put_tt(nut, nut->chapter[id].time_base, bc, ch->start); // chapter_start
505506 ff_put_v(bc, ch->end - ch->start); // chapter_len
506507
507− while ((t = av_metadata_get(ch->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
508+ while ((t = av_dict_get(ch->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
508509 count += add_info(dyn_bc, t->key, t->value);
509510
510511 ff_put_v(bc, count);
libavformat/oggdec.h+1−1
@@ -112,7 +112,7 @@ extern const struct ogg_codec ff_speex_codec; · 111 unmodified lines
112112 extern const struct ogg_codec ff_theora_codec;
113113 extern const struct ogg_codec ff_vorbis_codec;
114114
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);
116116
117117 static inline int
118118 ogg_find_stream (struct ogg * ogg, int serial)
libavformat/oggenc.c+3−3
@@ -241,7 +241,7 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st, · 240 unmodified lines
241241 }
242242
243243 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)
245245 {
246246 const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
247247 int size;
@@ -267,7 +267,7 @@ static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact, · 19 unmodified lines
267267
268268 static int ogg_build_flac_headers(AVCodecContext *avctx,
269269 OGGStreamContext *oggstream, int bitexact,
270− AVMetadata **m)
270+ AVDictionary **m)
271271 {
272272 enum FLACExtradataFormat format;
273273 uint8_t *streaminfo;
@@ -307,7 +307,7 @@ static int ogg_build_flac_headers(AVCodecContext *avctx, · 33 unmodified lines
307307
308308 static int ogg_build_speex_headers(AVCodecContext *avctx,
309309 OGGStreamContext *oggstream, int bitexact,
310− AVMetadata **m)
310+ AVDictionary **m)
311311 {
312312 uint8_t *p;
313313
libavformat/oggparsevorbis.c+7−6
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include <stdlib.h>
2626 #include "libavutil/avstring.h"
2727 #include "libavutil/bswap.h"
28+#include "libavutil/dict.h"
2829 #include "libavcodec/get_bits.h"
2930 #include "libavcodec/bytestream.h"
3031 #include "avformat.h"
@@ -57,8 +58,8 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val) · 26 unmodified lines
5758 if (!chapter)
5859 return 0;
5960
60− av_metadata_set2(&chapter->metadata, "title", val,
61− AV_METADATA_DONT_STRDUP_VAL);
61+ av_dict_set(&chapter->metadata, "title", val,
62+ AV_DICT_DONT_STRDUP_VAL);
6263 } else
6364 return 0;
6465
@@ -67,7 +68,7 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val) · 2 unmodified lines
6768 }
6869
6970 int
70−ff_vorbis_comment(AVFormatContext * as, AVMetadata **m, const uint8_t *buf, int size)
71+ff_vorbis_comment(AVFormatContext * as, AVDictionary **m, const uint8_t *buf, int size)
7172 {
7273 const uint8_t *p = buf;
7374 const uint8_t *end = buf + size;
@@ -127,9 +128,9 @@ ff_vorbis_comment(AVFormatContext * as, AVMetadata **m, const uint8_t *buf, int · 53 unmodified lines
127128 ct[vl] = 0;
128129
129130 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);
131+ av_dict_set(m, tt, ct,
132+ AV_DICT_DONT_STRDUP_KEY |
133+ AV_DICT_DONT_STRDUP_VAL);
133134 }
134135 }
135136
libavformat/options.c+1−1
@@ -62,7 +62,7 @@ static const AVOption options[]={ · 61 unmodified lines
6262 {"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"},
6363 {"ts", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"},
6464 {"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},
6666 {NULL},
6767 };
6868
libavformat/r3d.c+2−1
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 //#define DEBUG
2323
2424 #include "libavutil/intreadwrite.h"
25+#include "libavutil/dict.h"
2526 #include "avformat.h"
2627
2728 typedef struct {
@@ -98,7 +99,7 @@ static int r3d_read_red1(AVFormatContext *s) · 70 unmodified lines
9899
99100 avio_read(s->pb, filename, 257);
100101 filename[sizeof(filename)-1] = 0;
101− av_metadata_set2(&st->metadata, "filename", filename, 0);
102+ av_dict_set(&st->metadata, "filename", filename, 0);
102103
103104 av_dlog(s, "filename %s\n", filename);
104105 av_dlog(s, "resolution %dx%d\n", st->codec->width, st->codec->height);
libavformat/rmdec.c+2−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "libavutil/avstring.h"
2323 #include "libavutil/intreadwrite.h"
24+#include "libavutil/dict.h"
2425 #include "avformat.h"
2526 #include "riff.h"
2627 #include "rm.h"
@@ -104,7 +105,7 @@ static void rm_read_metadata(AVFormatContext *s, int wide) · 77 unmodified lines
104105 for (i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
105106 int len = wide ? avio_rb16(s->pb) : avio_r8(s->pb);
106107 get_strl(s->pb, buf, sizeof(buf), len);
107− av_metadata_set2(&s->metadata, ff_rm_metadata[i], buf, 0);
108+ av_dict_set(&s->metadata, ff_rm_metadata[i], buf, 0);
108109 }
109110 }
110111
libavformat/rmenc.c+4−3
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #include "avformat.h"
2222 #include "avio_internal.h"
2323 #include "rm.h"
24+#include "libavutil/dict.h"
2425
2526 typedef struct {
2627 int nb_packets;
@@ -71,7 +72,7 @@ static int rv10_write_header(AVFormatContext *ctx, · 44 unmodified lines
7172 const char *desc, *mimetype;
7273 int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i;
7374 int bit_rate, v, duration, flags, data_pos;
74− AVMetadataTag *tag;
75+ AVDictionaryEntry *tag;
7576
7677 start_ptr = s->buf_ptr;
7778
@@ -127,13 +128,13 @@ static int rv10_write_header(AVFormatContext *ctx, · 49 unmodified lines
127128 ffio_wfourcc(s,"CONT");
128129 size = 4 * 2 + 10;
129130 for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
130− tag = av_metadata_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
131+ tag = av_dict_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
131132 if(tag) size += strlen(tag->value);
132133 }
133134 avio_wb32(s,size);
134135 avio_wb16(s,0);
135136 for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
136− tag = av_metadata_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
137+ tag = av_dict_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
137138 put_str(s, tag ? tag->value : "");
138139 }
139140
libavformat/rpl.c+4−3
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 */
2121
2222 #include "libavutil/avstring.h"
23+#include "libavutil/dict.h"
2324 #include "avformat.h"
2425 #include <stdlib.h>
2526
@@ -131,11 +132,11 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap) · 105 unmodified lines
131132 // for the text in a few cases; samples needed.)
132133 error |= read_line(pb, line, sizeof(line)); // ARMovie
133134 error |= read_line(pb, line, sizeof(line)); // movie name
134− av_metadata_set2(&s->metadata, "title" , line, 0);
135+ av_dict_set(&s->metadata, "title" , line, 0);
135136 error |= read_line(pb, line, sizeof(line)); // date/copyright
136− av_metadata_set2(&s->metadata, "copyright", line, 0);
137+ av_dict_set(&s->metadata, "copyright", line, 0);
137138 error |= read_line(pb, line, sizeof(line)); // author and other
138− av_metadata_set2(&s->metadata, "author" , line, 0);
139+ av_dict_set(&s->metadata, "author" , line, 0);
139140
140141 // video headers
141142 vst = av_new_stream(s, 0);
libavformat/rtpdec_asf.c+1−1
@@ -113,7 +113,7 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) · 112 unmodified lines
113113 ret = av_open_input_stream(&rt->asf_ctx, &pb, "", &ff_asf_demuxer, NULL);
114114 if (ret < 0)
115115 return ret;
116− av_metadata_copy(&s->metadata, rt->asf_ctx->metadata, 0);
116+ av_dict_copy(&s->metadata, rt->asf_ctx->metadata, 0);
117117 rt->asf_pb_pos = avio_tell(&pb);
118118 av_free(buf);
119119 rt->asf_ctx->pb = NULL;
libavformat/rtsp.c+3−2
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include "libavutil/intreadwrite.h"
2525 #include "libavutil/parseutils.h"
2626 #include "libavutil/random_seed.h"
27+#include "libavutil/dict.h"
2728 #include "avformat.h"
2829 #include "avio_internal.h"
2930
@@ -281,11 +282,11 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, · 251 unmodified lines
281282 }
282283 break;
283284 case 's':
284− av_metadata_set2(&s->metadata, "title", p, 0);
285+ av_dict_set(&s->metadata, "title", p, 0);
285286 break;
286287 case 'i':
287288 if (s->nb_streams == 0) {
288− av_metadata_set2(&s->metadata, "comment", p, 0);
289+ av_dict_set(&s->metadata, "comment", p, 0);
289290 break;
290291 }
291292 break;
libavformat/sauce.c+3−2
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 */
2626
2727 #include "libavutil/intreadwrite.h"
28+#include "libavutil/dict.h"
2829 #include "avformat.h"
2930 #include "sauce.h"
3031
@@ -44,7 +45,7 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g · 13 unmodified lines
4445 #define GET_SAUCE_META(name,size) \
4546 if (avio_read(pb, buf, size) == size && buf[0]) { \
4647 buf[size] = 0; \
47− av_metadata_set2(&avctx->metadata, name, buf, 0); \
48+ av_dict_set(&avctx->metadata, name, buf, 0); \
4849 }
4950
5051 GET_SAUCE_META("title", 35)
@@ -95,7 +96,7 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g · 44 unmodified lines
9596 str[65*i + 64] = '\n';
9697 }
9798 str[65*i] = 0;
98− av_metadata_set2(&avctx->metadata, "comment", str, AV_METADATA_DONT_STRDUP_VAL);
99+ av_dict_set(&avctx->metadata, "comment", str, AV_DICT_DONT_STRDUP_VAL);
99100 }
100101 }
101102
libavformat/sdp.c+2−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #include <string.h>
2222 #include "libavutil/avstring.h"
2323 #include "libavutil/base64.h"
24+#include "libavutil/dict.h"
2425 #include "libavutil/parseutils.h"
2526 #include "libavcodec/xiph.h"
2627 #include "libavcodec/mpeg4audio.h"
@@ -550,7 +551,7 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des · 523 unmodified lines
550551
551552 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
552553 {
553− AVMetadataTag *title = av_metadata_get(ac[0]->metadata, "title", NULL, 0);
554+ AVDictionaryEntry *title = av_dict_get(ac[0]->metadata, "title", NULL, 0);
554555 struct sdp_session_level s;
555556 int i, j, port, ttl, is_multicast;
556557 char dst[32], dst_type[5];
libavformat/soxdec.c+3−2
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030 */
3131
3232 #include "libavutil/intreadwrite.h"
33+#include "libavutil/dict.h"
3334 #include "avformat.h"
3435 #include "pcm.h"
3536 #include "sox.h"
@@ -101,8 +102,8 @@ static int sox_read_header(AVFormatContext *s, · 65 unmodified lines
101102 }
102103 comment[comment_size] = 0;
103104
104− av_metadata_set2(&s->metadata, "comment", comment,
105− AV_METADATA_DONT_STRDUP_VAL);
105+ av_dict_set(&s->metadata, "comment", comment,
106+ AV_DICT_DONT_STRDUP_VAL);
106107 }
107108
108109 avio_skip(pb, header_size - SOX_FIXED_HDR - comment_size);
libavformat/soxenc.c+3−2
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030 */
3131
3232 #include "libavutil/intreadwrite.h"
33+#include "libavutil/dict.h"
3334 #include "avformat.h"
3435 #include "avio_internal.h"
3536 #include "sox.h"
@@ -43,10 +44,10 @@ static int sox_write_header(AVFormatContext *s) · 7 unmodified lines
4344 SoXContext *sox = s->priv_data;
4445 AVIOContext *pb = s->pb;
4546 AVCodecContext *enc = s->streams[0]->codec;
46− AVMetadataTag *comment;
47+ AVDictionaryEntry *comment;
4748 size_t comment_len = 0, comment_size;
4849
49− comment = av_metadata_get(s->metadata, "comment", NULL, 0);
50+ comment = av_dict_get(s->metadata, "comment", NULL, 0);
5051 if (comment)
5152 comment_len = strlen(comment->value);
5253 comment_size = (comment_len + 7) & ~7;
libavformat/tta.c+2−1
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 #include "libavcodec/get_bits.h"
2323 #include "avformat.h"
2424 #include "id3v1.h"
25+#include "libavutil/dict.h"
2526
2627 typedef struct {
2728 int totalframes, currentframe;
@@ -43,7 +44,7 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap) · 15 unmodified lines
4344 int i, channels, bps, samplerate, datalen, framelen;
4445 uint64_t framepos, start_offset;
4546
46− if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
47+ if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
4748 ff_id3v1_read(s);
4849
4950 start_offset = avio_tell(s->pb);
libavformat/tty.c+2−1
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "libavutil/intreadwrite.h"
2828 #include "libavutil/avstring.h"
2929 #include "libavutil/log.h"
30+#include "libavutil/dict.h"
3031 #include "libavutil/opt.h"
3132 #include "libavutil/parseutils.h"
3233 #include "avformat.h"
@@ -60,7 +61,7 @@ static int efi_read(AVFormatContext *avctx, uint64_t start_pos) · 27 unmodified lines
6061 return -1; \
6162 if (avio_read(pb, buf, size) == size) { \
6263 buf[len] = 0; \
63− av_metadata_set2(&avctx->metadata, name, buf, 0); \
64+ av_dict_set(&avctx->metadata, name, buf, 0); \
6465 }
6566
6667 GET_EFI_META("filename", 12)
libavformat/utils.c+14−13
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "libavcodec/internal.h"
2828 #include "libavcodec/raw.h"
2929 #include "libavutil/opt.h"
30+#include "libavutil/dict.h"
3031 #include "metadata.h"
3132 #include "id3v2.h"
3233 #include "libavutil/avstring.h"
@@ -2593,7 +2594,7 @@ void avformat_free_context(AVFormatContext *s) · 2560 unmodified lines
25932594 AVStream *st;
25942595
25952596 av_opt_free(s);
2596− if (s->iformat && s->iformat->priv_class)
2597+ if (s->iformat && s->iformat->priv_class && s->priv_data)
25972598 av_opt_free(s->priv_data);
25982599
25992600 for(i=0;i<s->nb_streams;i++) {
@@ -2603,7 +2604,7 @@ void avformat_free_context(AVFormatContext *s) · 3 unmodified lines
26032604 av_parser_close(st->parser);
26042605 av_free_packet(&st->cur_pkt);
26052606 }
2606− av_metadata_free(&st->metadata);
2607+ av_dict_free(&st->metadata);
26072608 av_free(st->index_entries);
26082609 av_free(st->codec->extradata);
26092610 av_free(st->codec->subtitle_header);
@@ -2613,18 +2614,18 @@ void avformat_free_context(AVFormatContext *s) · 3 unmodified lines
26132614 av_free(st);
26142615 }
26152616 for(i=s->nb_programs-1; i>=0; i--) {
2616− av_metadata_free(&s->programs[i]->metadata);
2617+ av_dict_free(&s->programs[i]->metadata);
26172618 av_freep(&s->programs[i]->stream_index);
26182619 av_freep(&s->programs[i]);
26192620 }
26202621 av_freep(&s->programs);
26212622 av_freep(&s->priv_data);
26222623 while(s->nb_chapters--) {
2623− av_metadata_free(&s->chapters[s->nb_chapters]->metadata);
2624+ av_dict_free(&s->chapters[s->nb_chapters]->metadata);
26242625 av_free(s->chapters[s->nb_chapters]);
26252626 }
26262627 av_freep(&s->chapters);
2627− av_metadata_free(&s->metadata);
2628+ av_dict_free(&s->metadata);
26282629 av_freep(&s->streams);
26292630 av_free(s);
26302631 }
@@ -2728,7 +2729,7 @@ AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int6 · 97 unmodified lines
27282729 return NULL;
27292730 dynarray_add(&s->chapters, &s->nb_chapters, chapter);
27302731 }
2731− av_metadata_set2(&chapter->metadata, "title", title, 0);
2732+ av_dict_set(&chapter->metadata, "title", title, 0);
27322733 chapter->id = id;
27332734 chapter->time_base= time_base;
27342735 chapter->start = start;
@@ -2923,7 +2924,7 @@ int av_write_header(AVFormatContext *s) · 188 unmodified lines
29232924
29242925 /* set muxer identification string */
29252926 if (s->nb_streams && !(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
2926− av_metadata_set2(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
2927+ av_dict_set(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
29272928 }
29282929
29292930 if(s->oformat->write_header){
@@ -3245,13 +3246,13 @@ static void print_fps(double d, const char *postfix){ · 315 unmodified lines
32453246 else av_log(NULL, AV_LOG_INFO, ", %1.0fk %s", d/1000, postfix);
32463247 }
32473248
3248−static void dump_metadata(void *ctx, AVMetadata *m, const char *indent)
3249+static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
32493250 {
3250− if(m && !(m->count == 1 && av_metadata_get(m, "language", NULL, 0))){
3251− AVMetadataTag *tag=NULL;
3251+ if(m && !(m->count == 1 && av_dict_get(m, "language", NULL, 0))){
3252+ AVDictionaryEntry *tag=NULL;
32523253
32533254 av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
3254− while((tag=av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
3255+ while((tag=av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
32553256 if(strcmp("language", tag->key))
32563257 av_log(ctx, AV_LOG_INFO, "%s %-16s: %s\n", indent, tag->key, tag->value);
32573258 }
@@ -3265,7 +3266,7 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out · 7 unmodified lines
32653266 int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
32663267 AVStream *st = ic->streams[i];
32673268 int g = av_gcd(st->time_base.num, st->time_base.den);
3268− AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL, 0);
3269+ AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
32693270 avcodec_string(buf, sizeof(buf), st->codec, is_output);
32703271 av_log(NULL, AV_LOG_INFO, " Stream #%d.%d", index, i);
32713272 /* the pid is an important information, so we display it */
@@ -3389,7 +3390,7 @@ void av_dump_format(AVFormatContext *ic, · 117 unmodified lines
33893390 if(ic->nb_programs) {
33903391 int j, k, total = 0;
33913392 for(j=0; j<ic->nb_programs; j++) {
3392− AVMetadataTag *name = av_metadata_get(ic->programs[j]->metadata,
3393+ AVDictionaryEntry *name = av_dict_get(ic->programs[j]->metadata,
33933394 "name", NULL, 0);
33943395 av_log(NULL, AV_LOG_INFO, " Program %d %s\n", ic->programs[j]->id,
33953396 name ? name->value : "");
libavformat/vorbiscomment.c+7−6
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include "metadata.h"
2424 #include "vorbiscomment.h"
2525 #include "libavcodec/bytestream.h"
26+#include "libavutil/dict.h"
2627
2728 /**
2829 * VorbisComment metadata conversion mapping.
@@ -36,15 +37,15 @@ const AVMetadataConv ff_vorbiscomment_metadata_conv[] = { · 7 unmodified lines
3637 { 0 }
3738 };
3839
39−int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
40+int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
4041 unsigned *count)
4142 {
4243 int len = 8;
4344 len += strlen(vendor_string);
4445 *count = 0;
4546 if (m) {
46− AVMetadataTag *tag = NULL;
47− while ((tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
47+ AVDictionaryEntry *tag = NULL;
48+ while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
4849 len += 4 +strlen(tag->key) + 1 + strlen(tag->value);
4950 (*count)++;
5051 }
@@ -52,15 +53,15 @@ int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string, · 1 unmodified line
5253 return len;
5354 }
5455
55−int ff_vorbiscomment_write(uint8_t **p, AVMetadata **m,
56+int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
5657 const char *vendor_string, const unsigned count)
5758 {
5859 bytestream_put_le32(p, strlen(vendor_string));
5960 bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
6061 if (*m) {
61− AVMetadataTag *tag = NULL;
62+ AVDictionaryEntry *tag = NULL;
6263 bytestream_put_le32(p, count);
63− while ((tag = av_metadata_get(*m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
64+ while ((tag = av_dict_get(*m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
6465 unsigned int len1 = strlen(tag->key);
6566 unsigned int len2 = strlen(tag->value);
6667 bytestream_put_le32(p, len1+1+len2);
libavformat/vorbiscomment.h+3−3
@@ -35,13 +35,13 @@ · 34 unmodified lines
3535 * @param count Pointer to store the number of tags in m because m->count is "not allowed"
3636 * @return The length in bytes.
3737 */
38−int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
38+int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
3939 unsigned *count);
4040
4141 /**
4242 * Writes a VorbisComment into a buffer. The buffer, p, must have enough
4343 * 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
4545 * ff_vorbiscomment_length()
4646 *
4747 * @param p The buffer in which to write.
@@ -49,7 +49,7 @@ int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string, · 1 unmodified line
4949 * @param vendor_string The vendor string to write.
5050 * @param count The number of tags in m because m->count is "not allowed"
5151 */
52−int ff_vorbiscomment_write(uint8_t **p, AVMetadata **m,
52+int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
5353 const char *vendor_string, const unsigned count);
5454
5555 extern const AVMetadataConv ff_vorbiscomment_metadata_conv[];
libavformat/vqf.c+2−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "avformat.h"
2323 #include "libavutil/intreadwrite.h"
24+#include "libavutil/dict.h"
2425
2526 typedef struct VqfContext {
2627 int frame_bit_len;
@@ -56,7 +57,7 @@ static void add_metadata(AVFormatContext *s, const char *tag, · 29 unmodified lines
5657 return;
5758 avio_read(s->pb, buf, len);
5859 buf[len] = 0;
59− av_metadata_set2(&s->metadata, tag, buf, AV_METADATA_DONT_STRDUP_VAL);
60+ av_dict_set(&s->metadata, tag, buf, AV_DICT_DONT_STRDUP_VAL);
6061 }
6162
6263 static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap)
libavformat/wc3movie.c+3−2
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 */
2929
3030 #include "libavutil/intreadwrite.h"
31+#include "libavutil/dict.h"
3132 #include "avformat.h"
3233
3334 #define FORM_TAG MKTAG('F', 'O', 'R', 'M')
@@ -130,8 +131,8 @@ static int wc3_read_header(AVFormatContext *s, · 96 unmodified lines
130131 if ((ret = avio_read(pb, buffer, size)) != size)
131132 return AVERROR(EIO);
132133 buffer[size] = 0;
133− av_metadata_set2(&s->metadata, "title", buffer,
134− AV_METADATA_DONT_STRDUP_VAL);
134+ av_dict_set(&s->metadata, "title", buffer,
135+ AV_DICT_DONT_STRDUP_VAL);
135136 break;
136137
137138 case SIZE_TAG:
libavformat/wv.c+2−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "libavutil/audioconvert.h"
2323 #include "libavutil/intreadwrite.h"
24+#include "libavutil/dict.h"
2425 #include "avformat.h"
2526 #include "apetag.h"
2627 #include "id3v1.h"
@@ -226,7 +227,7 @@ static int wv_read_header(AVFormatContext *s, · 199 unmodified lines
226227 if(s->pb->seekable) {
227228 int64_t cur = avio_tell(s->pb);
228229 ff_ape_parse_tag(s);
229− if(!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
230+ if(!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
230231 ff_id3v1_read(s);
231232 avio_seek(s->pb, cur, SEEK_SET);
232233 }
libavutil/Makefile+2−0
@@ -27,6 +27,7 @@ HEADERS = adler32.h \ · 26 unmodified lines
2727 mathematics.h \
2828 md5.h \
2929 mem.h \
30+ dict.h \
3031 opt.h \
3132 parseutils.h \
3233 pixdesc.h \
@@ -60,6 +61,7 @@ OBJS = adler32.o \ · 27 unmodified lines
6061 mathematics.o \
6162 md5.o \
6263 mem.o \
64+ dict.o \
6365 opt.o \
6466 parseutils.o \
6567 pixdesc.o \
libavutil/avutil.h+1−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
4040 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
4141
4242 #define LIBAVUTIL_VERSION_MAJOR 51
43−#define LIBAVUTIL_VERSION_MINOR 7
43+#define LIBAVUTIL_VERSION_MINOR 8
4444 #define LIBAVUTIL_VERSION_MICRO 0
4545
4646 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
libavutil/dict.c+110−0
@@ -0,0 +1,110 @@
1+/*
2+ * copyright (c) 2009 Michael Niedermayer
3+ *
4+ * This file is part of Libav.
5+ *
6+ * Libav is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * Libav is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with Libav; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#include <strings.h>
22+#include "dict.h"
23+#include "internal.h"
24+#include "mem.h"
25+
26+AVDictionaryEntry *
27+av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
28+{
29+ unsigned int i, j;
30+
31+ if(!m)
32+ return NULL;
33+
34+ if(prev) i= prev - m->elems + 1;
35+ else i= 0;
36+
37+ for(; i<m->count; i++){
38+ const char *s= m->elems[i].key;
39+ if(flags & AV_DICT_MATCH_CASE) for(j=0; s[j] == key[j] && key[j]; j++);
40+ else for(j=0; toupper(s[j]) == toupper(key[j]) && key[j]; j++);
41+ if(key[j])
42+ continue;
43+ if(s[j] && !(flags & AV_DICT_IGNORE_SUFFIX))
44+ continue;
45+ return &m->elems[i];
46+ }
47+ return NULL;
48+}
49+
50+int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
51+{
52+ AVDictionary *m = *pm;
53+ AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
54+
55+ if(!m)
56+ m = *pm = av_mallocz(sizeof(*m));
57+
58+ if(tag) {
59+ if (flags & AV_DICT_DONT_OVERWRITE)
60+ return 0;
61+ av_free(tag->value);
62+ av_free(tag->key);
63+ *tag = m->elems[--m->count];
64+ } else {
65+ AVDictionaryEntry *tmp = av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
66+ if(tmp) {
67+ m->elems = tmp;
68+ } else
69+ return AVERROR(ENOMEM);
70+ }
71+ if (value) {
72+ if (flags & AV_DICT_DONT_STRDUP_KEY) {
73+ m->elems[m->count].key = key;
74+ } else
75+ m->elems[m->count].key = av_strdup(key );
76+ if (flags & AV_DICT_DONT_STRDUP_VAL) {
77+ m->elems[m->count].value = value;
78+ } else
79+ m->elems[m->count].value = av_strdup(value);
80+ m->count++;
81+ }
82+ if (!m->count) {
83+ av_free(m->elems);
84+ av_freep(pm);
85+ }
86+
87+ return 0;
88+}
89+
90+void av_dict_free(AVDictionary **pm)
91+{
92+ AVDictionary *m = *pm;
93+
94+ if (m) {
95+ while(m->count--) {
96+ av_free(m->elems[m->count].key);
97+ av_free(m->elems[m->count].value);
98+ }
99+ av_free(m->elems);
100+ }
101+ av_freep(pm);
102+}
103+
104+void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags)
105+{
106+ AVDictionaryEntry *t = NULL;
107+
108+ while ((t = av_dict_get(src, "", t, AV_DICT_IGNORE_SUFFIX)))
109+ av_dict_set(dst, t->key, t->value, flags);
110+}
libavutil/dict.h+78−0
@@ -0,0 +1,78 @@
1+/*
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+/**
21+ * @file Public dictionary API.
22+ */
23+
24+#ifndef AVUTIL_DICT_H
25+#define AVUTIL_DICT_H
26+
27+#define AV_DICT_MATCH_CASE 1
28+#define AV_DICT_IGNORE_SUFFIX 2
29+#define AV_DICT_DONT_STRDUP_KEY 4
30+#define AV_DICT_DONT_STRDUP_VAL 8
31+#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries.
32+
33+typedef struct {
34+ char *key;
35+ char *value;
36+} AVDictionaryEntry;
37+
38+typedef struct AVDictionary AVDictionary;
39+
40+/**
41+ * Get a dictionary entry with matching key.
42+ *
43+ * @param prev Set to the previous matching element to find the next.
44+ * If set to NULL the first matching element is returned.
45+ * @param flags Allows case as well as suffix-insensitive comparisons.
46+ * @return Found entry or NULL, changing key or value leads to undefined behavior.
47+ */
48+AVDictionaryEntry *
49+av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
50+
51+/**
52+ * Set the given entry in *pm, overwriting an existing entry.
53+ *
54+ * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
55+ * a dictionary struct is allocated and put in *pm.
56+ * @param key entry key to add to *pm (will be av_strduped depending on flags)
57+ * @param value entry value to add to *pm (will be av_strduped depending on flags).
58+ * Passing a NULL value will cause an existing tag to be deleted.
59+ * @return >= 0 on success otherwise an error code <0
60+ */
61+int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
62+
63+/**
64+ * Copy entries from one AVDictionary struct into another.
65+ * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
66+ * this function will allocate a struct for you and put it in *dst
67+ * @param src pointer to source AVDictionary struct
68+ * @param flags flags to use when setting entries in *dst
69+ * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
70+ */
71+void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags);
72+
73+/**
74+ * Free all the memory allocated for an AVDictionary struct.
75+ */
76+void av_dict_free(AVDictionary **m);
77+
78+#endif // AVUTIL_DICT_H
libavutil/internal.h+6−0
@@ -38,6 +38,12 @@ · 37 unmodified lines
3838 #include "attributes.h"
3939 #include "timer.h"
4040 #include "cpu.h"
41+#include "dict.h"
42+
43+struct AVDictionary {
44+ int count;
45+ AVDictionaryEntry *elems;
46+};
4147
4248 #ifndef attribute_align_arg
4349 #if ARCH_X86_32 && AV_GCC_VERSION_AT_LEAST(4,2)
libswscale/swscale.c+8−34
@@ -380,40 +380,14 @@ yuv2NBPS(10, LE, 0); · 379 unmodified lines
380380 yuv2NBPS(16, BE, 1);
381381 yuv2NBPS(16, LE, 0);
382382
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)
417391 {
418392 //FIXME Optimize (just quickly written not optimized..)
419393 int i;
libswscale/x86/swscale_template.c+31−37
@@ -180,19 +180,6 @@ static inline void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, · 179 unmodified lines
180180 YSCALEYUV2YV12X_ACCURATE(LUM_MMX_FILTER_OFFSET, dest, dstW, 0)
181181 }
182182
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−
196183 static inline void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc,
197184 const int16_t *chrUSrc, const int16_t *chrVSrc,
198185 const int16_t *alpSrc,
@@ -208,32 +195,25 @@ static inline void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc, · 9 unmodified lines
208195 while (p--) {
209196 if (dst[p]) {
210197 __asm__ volatile(
211− YSCALEYUV2YV121
212− :: "r" (src[p]), "r" (dst[p] + counter[p]),
213− "g" (-counter[p])
214− : "%"REG_a
198+ "mov %2, %%"REG_a" \n\t"
199+ ".p2align 4 \n\t" /* FIXME Unroll? */
200+ "1: \n\t"
201+ "movq (%0, %%"REG_a", 2), %%mm0 \n\t"
202+ "movq 8(%0, %%"REG_a", 2), %%mm1 \n\t"
203+ "psraw $7, %%mm0 \n\t"
204+ "psraw $7, %%mm1 \n\t"
205+ "packuswb %%mm1, %%mm0 \n\t"
206+ MOVNTQ(%%mm0, (%1, %%REGa))
207+ "add $8, %%"REG_a" \n\t"
208+ "jnc 1b \n\t"
209+ :: "r" (src[p]), "r" (dst[p] + counter[p]),
210+ "g" (-counter[p])
211+ : "%"REG_a
215212 );
216213 }
217214 }
218215 }
219216
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−
237217 static inline void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc,
238218 const int16_t *chrUSrc, const int16_t *chrVSrc,
239219 const int16_t *alpSrc,
@@ -251,7 +231,21 @@ static inline void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc, · 11 unmodified lines
251231 int i;
252232 for(i=0; i<8; i++) c->dither16[i] = i<2 ? lumDither[i] : chrDither[i];
253233 __asm__ volatile(
254− YSCALEYUV2YV121_ACCURATE
234+ "mov %2, %%"REG_a" \n\t"
235+ "movq 0(%3), %%mm6 \n\t"
236+ "movq 8(%3), %%mm7 \n\t"
237+ ".p2align 4 \n\t" /* FIXME Unroll? */
238+ "1: \n\t"
239+ "movq (%0, %%"REG_a", 2), %%mm0 \n\t"
240+ "movq 8(%0, %%"REG_a", 2), %%mm1 \n\t"
241+ "paddsw %%mm6, %%mm0 \n\t"
242+ "paddsw %%mm7, %%mm1 \n\t"
243+ "psraw $7, %%mm0 \n\t"
244+ "psraw $7, %%mm1 \n\t"
245+ "packuswb %%mm1, %%mm0 \n\t"
246+ MOVNTQ(%%mm0, (%1, %%REGa))
247+ "add $8, %%"REG_a" \n\t"
248+ "jnc 1b \n\t"
255249 :: "r" (src[p]), "r" (dst[p] + counter[p]),
256250 "g" (-counter[p]), "r"(c->dither16)
257251 : "%"REG_a
@@ -2218,7 +2212,7 @@ static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst, · 1960 unmodified lines
22182212 int dstWidth, const uint8_t *src, int srcW,
22192213 int xInc)
22202214 {
2221− int32_t *filterPos = c->hLumFilterPos;
2215+ int16_t *filterPos = c->hLumFilterPos;
22222216 int16_t *filter = c->hLumFilter;
22232217 void *mmx2FilterCode= c->lumMmx2FilterCode;
22242218 int i;
@@ -2290,7 +2284,7 @@ static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *d · 65 unmodified lines
22902284 int dstWidth, const uint8_t *src1,
22912285 const uint8_t *src2, int srcW, int xInc)
22922286 {
2293− int32_t *filterPos = c->hChrFilterPos;
2287+ int16_t *filterPos = c->hChrFilterPos;
22942288 int16_t *filter = c->hChrFilter;
22952289 void *mmx2FilterCode= c->chrMmx2FilterCode;
22962290 int i;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t