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