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