Merge remote-tracking branch 'qatar/master'

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

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

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2011-06-09 04:47:19 +02:00
commit f9ecb849ef
65 changed files with 565 additions and 414 deletions

View File

@ -50,6 +50,11 @@ API changes, most recent first:
2011-05-XX - XXXXXX - lavfi 2.6.0 - avcodec.h
Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h.
2011-06-xx - xxxxxxx - lavu 51.5.0 - AVMetadata
Move AVMetadata from lavf to lavu and rename it to
AVDictionary -- new installed header dict.h.
All av_metadata_* functions renamed to av_dict_*.
2011-06-07 - a6703fa - lavu 51.4.0 - av_get_bytes_per_sample()
Add av_get_bytes_per_sample() in libavutil/samplefmt.h.
Deprecate av_get_bits_per_sample_fmt().

View File

@ -39,6 +39,7 @@
#include "libavutil/colorspace.h"
#include "libavutil/fifo.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "libavutil/pixdesc.h"
#include "libavutil/avstring.h"
#include "libavutil/libm.h"
@ -199,7 +200,7 @@ static int64_t start_time = 0;
static int64_t recording_timestamp = 0;
static int64_t input_ts_offset = 0;
static int file_overwrite = 0;
static AVMetadata *metadata;
static AVDictionary *metadata;
static int do_benchmark = 0;
static int do_hex_dump = 0;
static int do_pkt_dump = 0;
@ -1953,7 +1954,7 @@ static int copy_chapters(int infile, int outfile)
out_ch->end = FFMIN(rt, in_ch->end - ts_off);
if (metadata_chapters_autocopy)
av_metadata_copy(&out_ch->metadata, in_ch->metadata, 0);
av_dict_copy(&out_ch->metadata, in_ch->metadata, 0);
os->nb_chapters++;
os->chapters = av_realloc(os->chapters, sizeof(AVChapter)*os->nb_chapters);
@ -2181,8 +2182,8 @@ static int transcode(AVFormatContext **output_files,
icodec = ist->st->codec;
if (metadata_streams_autocopy)
av_metadata_copy(&ost->st->metadata, ist->st->metadata,
AV_METADATA_DONT_OVERWRITE);
av_dict_copy(&ost->st->metadata, ist->st->metadata,
AV_DICT_DONT_OVERWRITE);
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
@ -2419,7 +2420,7 @@ static int transcode(AVFormatContext **output_files,
/* set meta data information from input file if required */
for (i=0;i<nb_meta_data_maps;i++) {
AVFormatContext *files[2];
AVMetadata **meta[2];
AVDictionary **meta[2];
int j;
#define METADATA_CHECK_INDEX(index, nb_elems, desc)\
@ -2462,15 +2463,15 @@ static int transcode(AVFormatContext **output_files,
}
}
av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE);
av_dict_copy(meta[0], *meta[1], AV_DICT_DONT_OVERWRITE);
}
/* copy global metadata by default */
if (metadata_global_autocopy) {
for (i = 0; i < nb_output_files; i++)
av_metadata_copy(&output_files[i]->metadata, input_files[0].ctx->metadata,
AV_METADATA_DONT_OVERWRITE);
av_dict_copy(&output_files[i]->metadata, input_files[0].ctx->metadata,
AV_DICT_DONT_OVERWRITE);
}
/* copy chapters according to chapter maps */
@ -2943,7 +2944,7 @@ static int opt_metadata(const char *opt, const char *arg)
}
*mid++= 0;
av_metadata_set2(&metadata, arg, mid, 0);
av_dict_set(&metadata, arg, mid, 0);
return 0;
}
@ -3631,7 +3632,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx)
parse_forced_key_frames(forced_key_frames, ost, video_enc);
}
if (video_language) {
av_metadata_set2(&st->metadata, "language", video_language, 0);
av_dict_set(&st->metadata, "language", video_language, 0);
av_freep(&video_language);
}
@ -3711,7 +3712,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx)
}
audio_enc->time_base= (AVRational){1, audio_sample_rate};
if (audio_language) {
av_metadata_set2(&st->metadata, "language", audio_language, 0);
av_dict_set(&st->metadata, "language", audio_language, 0);
av_freep(&audio_language);
}
@ -3807,7 +3808,7 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx)
}
if (subtitle_language) {
av_metadata_set2(&st->metadata, "language", subtitle_language, 0);
av_dict_set(&st->metadata, "language", subtitle_language, 0);
av_freep(&subtitle_language);
}
@ -3926,8 +3927,8 @@ static int opt_output_file(const char *opt, const char *filename)
oc->timestamp = recording_timestamp;
av_metadata_copy(&oc->metadata, metadata, 0);
av_metadata_free(&metadata);
av_dict_copy(&oc->metadata, metadata, 0);
av_dict_free(&metadata);
}
output_files[nb_output_files++] = oc;

View File

@ -25,6 +25,7 @@
#include "libavcodec/avcodec.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/dict.h"
#include "libavdevice/avdevice.h"
#include "cmdutils.h"
@ -160,7 +161,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
AVCodecContext *dec_ctx;
AVCodec *dec;
char val_str[128];
AVMetadataTag *tag = NULL;
AVDictionaryEntry *tag = NULL;
AVRational display_aspect_ratio;
printf("[STREAM]\n");
@ -226,7 +227,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
if (stream->nb_frames)
printf("nb_frames=%"PRId64"\n", stream->nb_frames);
while ((tag = av_metadata_get(stream->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
printf("TAG:%s=%s\n", tag->key, tag->value);
printf("[/STREAM]\n");
@ -234,7 +235,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
static void show_format(AVFormatContext *fmt_ctx)
{
AVMetadataTag *tag = NULL;
AVDictionaryEntry *tag = NULL;
char val_str[128];
printf("[FORMAT]\n");
@ -252,7 +253,7 @@ static void show_format(AVFormatContext *fmt_ctx)
printf("bit_rate=%s\n", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate,
unit_bit_per_second_str));
while ((tag = av_metadata_get(fmt_ctx->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
printf("TAG:%s=%s\n", tag->key, tag->value);
printf("[/FORMAT]\n");

View File

@ -36,6 +36,7 @@
#include "libavformat/avio_internal.h"
#include "libavutil/avstring.h"
#include "libavutil/lfg.h"
#include "libavutil/dict.h"
#include "libavutil/random_seed.h"
#include "libavutil/parseutils.h"
#include "libavutil/opt.h"
@ -854,7 +855,7 @@ static void close_connection(HTTPContext *c)
ctx = c->rtp_ctx[i];
if (ctx) {
av_write_trailer(ctx);
av_metadata_free(&ctx->metadata);
av_dict_free(&ctx->metadata);
av_free(ctx->streams[0]);
av_free(ctx);
}
@ -2224,10 +2225,10 @@ static int http_prepare_data(HTTPContext *c)
switch(c->state) {
case HTTPSTATE_SEND_DATA_HEADER:
memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx));
av_metadata_set2(&c->fmt_ctx.metadata, "author" , c->stream->author , 0);
av_metadata_set2(&c->fmt_ctx.metadata, "comment" , c->stream->comment , 0);
av_metadata_set2(&c->fmt_ctx.metadata, "copyright", c->stream->copyright, 0);
av_metadata_set2(&c->fmt_ctx.metadata, "title" , c->stream->title , 0);
av_dict_set(&c->fmt_ctx.metadata, "author" , c->stream->author , 0);
av_dict_set(&c->fmt_ctx.metadata, "comment" , c->stream->comment , 0);
av_dict_set(&c->fmt_ctx.metadata, "copyright", c->stream->copyright, 0);
av_dict_set(&c->fmt_ctx.metadata, "title" , c->stream->title , 0);
c->fmt_ctx.streams = av_mallocz(sizeof(AVStream *) * c->stream->nb_streams);
@ -2272,7 +2273,7 @@ static int http_prepare_data(HTTPContext *c)
http_log("Error writing output header\n");
return -1;
}
av_metadata_free(&c->fmt_ctx.metadata);
av_dict_free(&c->fmt_ctx.metadata);
len = avio_close_dyn_buf(c->fmt_ctx.pb, &c->pb_buffer);
c->buffer_ptr = c->pb_buffer;
@ -2927,8 +2928,8 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
if (avc == NULL) {
return -1;
}
av_metadata_set2(&avc->metadata, "title",
stream->title[0] ? stream->title : "No Title", 0);
av_dict_set(&avc->metadata, "title",
stream->title[0] ? stream->title : "No Title", 0);
avc->nb_streams = stream->nb_streams;
if (stream->is_multicast) {
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,
sdp_done:
av_free(avc->streams);
av_metadata_free(&avc->metadata);
av_dict_free(&avc->metadata);
av_free(avc);
av_free(avs);

View File

@ -35,6 +35,7 @@
#ifdef DEBUG
#undef fprintf
#undef perror
#if 0
static void png_save(const char *filename, uint8_t *bitmap, int w, int h,
uint32_t *rgba_palette)
@ -49,7 +50,7 @@ static void png_save(const char *filename, uint8_t *bitmap, int w, int h,
f = fopen(fname, "w");
if (!f) {
perror(fname);
exit(1);
return;
}
fprintf(f, "P6\n"
"%d %d\n"
@ -71,7 +72,7 @@ static void png_save(const char *filename, uint8_t *bitmap, int w, int h,
f = fopen(fname2, "w");
if (!f) {
perror(fname2);
exit(1);
return;
}
fprintf(f, "P5\n"
"%d %d\n"
@ -105,7 +106,7 @@ static void png_save2(const char *filename, uint32_t *bitmap, int w, int h)
f = fopen(fname, "w");
if (!f) {
perror(fname);
exit(1);
return;
}
fprintf(f, "P6\n"
"%d %d\n"
@ -127,7 +128,7 @@ static void png_save2(const char *filename, uint32_t *bitmap, int w, int h)
f = fopen(fname2, "w");
if (!f) {
perror(fname2);
exit(1);
return;
}
fprintf(f, "P5\n"
"%d %d\n"

View File

@ -20,6 +20,7 @@
*/
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "pcm.h"
#include "aiff.h"

View File

@ -21,6 +21,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "apetag.h"
@ -57,7 +58,7 @@ static int ape_tag_read_field(AVFormatContext *s)
return AVERROR(ENOMEM);
avio_read(pb, value, size);
value[size] = 0;
av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL);
return 0;
}

View File

@ -28,6 +28,7 @@
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "internal.h"
#include <unistd.h>
@ -505,7 +506,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
avcodec_copy_context(st->codec, v->ctx->streams[j]->codec);
if (v->bandwidth)
av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str,
av_dict_set(&st->metadata, "variant_bitrate", bitrate_str,
0);
}
stream_offset += v->ctx->nb_streams;

View File

@ -24,6 +24,7 @@
#include "libavutil/bswap.h"
#include "libavutil/common.h"
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavcodec/mpegaudio.h"
#include "avformat.h"
#include "avio_internal.h"
@ -172,7 +173,8 @@ static void get_tag(AVFormatContext *s, const char *key, int type, int len)
av_log(s, AV_LOG_DEBUG, "Unsupported value type %d in tag %s.\n", type, key);
goto finish;
}
av_metadata_set2(&s->metadata, key, value, 0);
if (*value)
av_dict_set(&s->metadata, key, value, 0);
finish:
av_freep(&value);
avio_seek(s->pb, off + len, SEEK_SET);
@ -681,7 +683,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
const char primary_tag[3] = { rfc1766[0], rfc1766[1], '\0' }; // ignore country code if any
const char *iso6392 = av_convert_lang_to(primary_tag, AV_LANG_ISO639_2_BIBL);
if (iso6392)
av_metadata_set2(&st->metadata, "language", iso6392, 0);
av_dict_set(&st->metadata, "language", iso6392, 0);
}
}
}

View File

@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
#include "metadata.h"
#include "riff.h"
#include "asf.h"
#include "avio_internal.h"
#include "libavutil/dict.h"
#undef NDEBUG
#include <assert.h>
@ -296,7 +296,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
AVMetadataTag *tags[5];
AVDictionaryEntry *tags[5];
int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
int has_title;
int metadata_count;
@ -307,11 +307,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
ff_metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL);
tags[0] = av_metadata_get(s->metadata, "title" , NULL, 0);
tags[1] = av_metadata_get(s->metadata, "author" , NULL, 0);
tags[2] = av_metadata_get(s->metadata, "copyright", NULL, 0);
tags[3] = av_metadata_get(s->metadata, "comment" , NULL, 0);
tags[4] = av_metadata_get(s->metadata, "rating" , NULL, 0);
tags[0] = av_dict_get(s->metadata, "title" , NULL, 0);
tags[1] = av_dict_get(s->metadata, "author" , NULL, 0);
tags[2] = av_dict_get(s->metadata, "copyright", NULL, 0);
tags[3] = av_dict_get(s->metadata, "comment" , NULL, 0);
tags[4] = av_dict_get(s->metadata, "rating" , NULL, 0);
duration = asf->duration + PREROLL_TIME * 10000;
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
end_header(pb, hpos);
}
if (metadata_count) {
AVMetadataTag *tag = NULL;
AVDictionaryEntry *tag = NULL;
hpos = put_header(pb, &ff_asf_extended_content_header);
avio_wl16(pb, metadata_count);
while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
put_str16(pb, tag->key);
avio_wl16(pb, 0);
put_str16(pb, tag->value);

View File

@ -40,6 +40,7 @@ const char *avformat_license(void);
#include <time.h>
#include <stdio.h> /* FILE */
#include "libavcodec/avcodec.h"
#include "libavutil/dict.h"
#include "avio.h"
#include "libavformat/version.h"
@ -106,21 +107,24 @@ struct AVFormatContext;
* variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of
*/
#define AV_METADATA_MATCH_CASE 1
#define AV_METADATA_IGNORE_SUFFIX 2
#define AV_METADATA_DONT_STRDUP_KEY 4
#define AV_METADATA_DONT_STRDUP_VAL 8
#define AV_METADATA_DONT_OVERWRITE 16 ///< Don't overwrite existing tags.
typedef struct {
char *key;
char *value;
}AVMetadataTag;
typedef struct AVMetadata AVMetadata;
#if FF_API_OLD_METADATA2
/**
* @defgroup old_metadata Old metadata API
* The following functions are deprecated, use
* their equivalents from libavutil/dict.h instead.
* @{
*/
#define AV_METADATA_MATCH_CASE AV_DICT_MATCH_CASE
#define AV_METADATA_IGNORE_SUFFIX AV_DICT_IGNORE_SUFFIX
#define AV_METADATA_DONT_STRDUP_KEY AV_DICT_DONT_STRDUP_KEY
#define AV_METADATA_DONT_STRDUP_VAL AV_DICT_DONT_STRDUP_VAL
#define AV_METADATA_DONT_OVERWRITE AV_DICT_DONT_OVERWRITE
typedef attribute_deprecated AVDictionary AVMetadata;
typedef attribute_deprecated AVDictionaryEntry AVMetadataTag;
typedef struct AVMetadataConv AVMetadataConv;
#endif
/**
* Get a metadata element with matching key.
@ -130,8 +134,8 @@ typedef struct AVMetadataConv AVMetadataConv;
* @param flags Allows case as well as suffix-insensitive comparisons.
* @return Found tag or NULL, changing key or value leads to undefined behavior.
*/
AVMetadataTag *
av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags);
attribute_deprecated AVDictionaryEntry *
av_metadata_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
/**
* 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
* Passing a NULL value will cause an existing tag to be deleted.
* @return >= 0 on success otherwise an error code <0
*/
int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags);
attribute_deprecated int av_metadata_set2(AVDictionary **pm, const char *key, const char *value, int flags);
#if FF_API_OLD_METADATA2
/**
* This function is provided for compatibility reason and currently does nothing.
*/
attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
const AVMetadataConv *s_conv);
#endif
/**
* Copy metadata from one AVMetadata struct into another.
* @param dst pointer to a pointer to a AVMetadata struct. If *dst is NULL,
* Copy metadata from one AVDictionary struct into another.
* @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
* this function will allocate a struct for you and put it in *dst
* @param src pointer to source AVMetadata struct
* @param src pointer to source AVDictionary struct
* @param flags flags to use when setting metadata in *dst
* @note metadata is read using the AV_METADATA_IGNORE_SUFFIX flag
* @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
*/
void av_metadata_copy(AVMetadata **dst, AVMetadata *src, int flags);
attribute_deprecated void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags);
/**
* Free all the memory allocated for an AVMetadata struct.
* Free all the memory allocated for an AVDictionary struct.
*/
void av_metadata_free(AVMetadata **m);
attribute_deprecated void av_metadata_free(AVDictionary **m);
/**
* @}
*/
#endif
/* packet functions */
@ -563,7 +569,7 @@ typedef struct AVStream {
*/
AVRational sample_aspect_ratio;
AVMetadata *metadata;
AVDictionary *metadata;
/* Intended mostly for av_read_frame() support. Not supposed to be used by */
/* external applications; try to use something else if at all possible. */
@ -644,7 +650,7 @@ typedef struct AVProgram {
enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller
unsigned int *stream_index;
unsigned int nb_stream_indexes;
AVMetadata *metadata;
AVDictionary *metadata;
int program_num;
int pmt_pid;
@ -658,7 +664,7 @@ typedef struct AVChapter {
int id; ///< unique ID to identify the chapter
AVRational time_base; ///< time base in which the start/end timestamps are specified
int64_t start, end; ///< chapter start/end time in time_base units
AVMetadata *metadata;
AVDictionary *metadata;
} AVChapter;
/**
@ -824,7 +830,7 @@ typedef struct AVFormatContext {
struct AVPacketList *packet_buffer_end;
AVMetadata *metadata;
AVDictionary *metadata;
/**
* Remaining size available for raw_packet_buffer, in bytes.

View File

@ -26,6 +26,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/bswap.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "avi.h"
#include "dv.h"
@ -280,8 +281,8 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t
AV_WL32(key, tag);
return av_metadata_set2(st ? &st->metadata : &s->metadata, key, value,
AV_METADATA_DONT_STRDUP_VAL);
return av_dict_set(st ? &st->metadata : &s->metadata, key, value,
AV_DICT_DONT_STRDUP_VAL);
}
static void avi_read_info(AVFormatContext *s, uint64_t end)
@ -296,7 +297,7 @@ static void avi_read_info(AVFormatContext *s, uint64_t end)
static const char months[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
static void avi_metadata_creation_time(AVMetadata **metadata, char *date)
static void avi_metadata_creation_time(AVDictionary **metadata, char *date)
{
char month[4], time[9], buffer[64];
int i, day, year;
@ -307,11 +308,11 @@ static void avi_metadata_creation_time(AVMetadata **metadata, char *date)
if (!strcasecmp(month, months[i])) {
snprintf(buffer, sizeof(buffer), "%.4d-%.2d-%.2d %s",
year, i+1, day, time);
av_metadata_set2(metadata, "creation_time", buffer, 0);
av_dict_set(metadata, "creation_time", buffer, 0);
}
} else if (date[4] == '/' && date[7] == '/') {
date[4] = date[7] = '-';
av_metadata_set2(metadata, "creation_time", date, 0);
av_dict_set(metadata, "creation_time", date, 0);
}
}
@ -339,7 +340,7 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
break;
}
if (name)
av_metadata_set2(&s->metadata, name, buffer, 0);
av_dict_set(&s->metadata, name, buffer, 0);
avio_skip(s->pb, size);
}
break;
@ -795,7 +796,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt) {
ret = avio_get_str16le(pb, desc_len, desc, sizeof(desc));
avio_skip(pb, desc_len - ret);
if (*desc)
av_metadata_set2(&st->metadata, "title", desc, 0);
av_dict_set(&st->metadata, "title", desc, 0);
avio_rl16(pb); /* flags? */
avio_rl32(pb); /* data size */

View File

@ -23,6 +23,7 @@
#include "avio_internal.h"
#include "riff.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
/*
* TODO:
@ -157,7 +158,7 @@ static int avi_write_header(AVFormatContext *s)
int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
AVCodecContext *stream, *video_enc;
int64_t list1, list2, strh, strf;
AVMetadataTag *t = NULL;
AVDictionaryEntry *t = NULL;
if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n",
@ -297,7 +298,7 @@ static int avi_write_header(AVFormatContext *s)
return -1;
}
ff_end_tag(pb, strf);
if ((t = av_metadata_get(s->streams[i]->metadata, "title", NULL, 0))) {
if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) {
avi_write_info_tag(s->pb, "strn", t->value);
t = NULL;
}
@ -379,7 +380,7 @@ static int avi_write_header(AVFormatContext *s)
ffio_wfourcc(pb, "INFO");
ff_metadata_conv(&s->metadata, ff_avi_metadata_conv, NULL);
for (i = 0; *ff_avi_tags[i]; i++) {
if ((t = av_metadata_get(s->metadata, ff_avi_tags[i], NULL, AV_METADATA_MATCH_CASE)))
if ((t = av_dict_get(s->metadata, ff_avi_tags[i], NULL, AV_DICT_MATCH_CASE)))
avi_write_info_tag(s->pb, t->key, t->value);
}
ff_end_tag(pb, list2);

View File

@ -29,6 +29,7 @@
#include "riff.h"
#include "isom.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "caf.h"
typedef struct {
@ -187,7 +188,7 @@ static void read_info_chunk(AVFormatContext *s, int64_t size)
char value[1024];
get_strz(pb, key, sizeof(key));
get_strz(pb, value, sizeof(value));
av_metadata_set2(&s->metadata, key, value, 0);
av_dict_set(&s->metadata, key, value, 0);
}
}

View File

@ -22,6 +22,7 @@
#include "avformat.h"
#include "ffmeta.h"
#include "internal.h"
#include "libavutil/dict.h"
static int probe(AVProbeData *p)
{
@ -93,7 +94,7 @@ static uint8_t *unescape(uint8_t *buf, int size)
return ret;
}
static int read_tag(uint8_t *line, AVMetadata **m)
static int read_tag(uint8_t *line, AVDictionary **m)
{
uint8_t *key, *value, *p = line;
@ -117,13 +118,13 @@ static int read_tag(uint8_t *line, AVMetadata **m)
return AVERROR(ENOMEM);
}
av_metadata_set2(m, key, value, AV_METADATA_DONT_STRDUP_KEY | AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(m, key, value, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
return 0;
}
static int read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVMetadata **m = &s->metadata;
AVDictionary **m = &s->metadata;
uint8_t line[1024];
while(!url_feof(s->pb)) {

View File

@ -23,6 +23,7 @@
#include "avformat.h"
#include "ffmeta.h"
#include "libavutil/dict.h"
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)
}
}
static void write_tags(AVIOContext *s, AVMetadata *m)
static void write_tags(AVIOContext *s, AVDictionary *m)
{
AVMetadataTag *t = NULL;
while ((t = av_metadata_get(m, "", t, AV_METADATA_IGNORE_SUFFIX))) {
AVDictionaryEntry *t = NULL;
while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) {
write_escape_str(s, t->key);
avio_w8(s, '=');
write_escape_str(s, t->value);

View File

@ -22,7 +22,6 @@
#include "libavcodec/flac.h"
#include "avformat.h"
#include "flacenc.h"
#include "metadata.h"
#include "vorbiscomment.h"
#include "libavcodec/bytestream.h"
@ -39,7 +38,7 @@ static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_byte
return 0;
}
static int flac_write_block_comment(AVIOContext *pb, AVMetadata **m,
static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
int last_block, int bitexact)
{
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;

View File

@ -25,6 +25,7 @@
*/
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/mpeg4audio.h"
#include "avformat.h"
@ -259,17 +260,17 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
if(amf_type == AMF_DATA_TYPE_BOOL) {
av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val));
av_metadata_set2(&s->metadata, key, str_val, 0);
av_dict_set(&s->metadata, key, str_val, 0);
} else if(amf_type == AMF_DATA_TYPE_NUMBER) {
snprintf(str_val, sizeof(str_val), "%.f", num_val);
av_metadata_set2(&s->metadata, key, str_val, 0);
av_dict_set(&s->metadata, key, str_val, 0);
if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0))
vcodec->bit_rate = num_val * 1024.0;
else if(!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0))
acodec->bit_rate = num_val * 1024.0;
} else if (amf_type == AMF_DATA_TYPE_STRING)
av_metadata_set2(&s->metadata, key, str_val, 0);
av_dict_set(&s->metadata, key, str_val, 0);
}
return 0;

View File

@ -25,6 +25,7 @@
#include "internal.h"
#include "avc.h"
#include "metadata.h"
#include "libavutil/dict.h"
#undef NDEBUG
#include <assert.h>
@ -179,7 +180,7 @@ static int flv_write_header(AVFormatContext *s)
int i;
double framerate = 0.0;
int metadata_size_pos, data_size;
AVMetadataTag *tag = NULL;
AVDictionaryEntry *tag = NULL;
for(i=0; i<s->nb_streams; i++){
AVCodecContext *enc = s->streams[i]->codec;
@ -276,7 +277,7 @@ static int flv_write_header(AVFormatContext *s)
put_amf_double(pb, audio_enc->codec_tag);
}
while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
put_amf_string(pb, tag->key);
avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, tag->value);

View File

@ -21,6 +21,7 @@
#include "id3v1.h"
#include "libavcodec/avcodec.h"
#include "libavutil/dict.h"
const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + 1] = {
[0] = "Blues",
@ -191,7 +192,7 @@ static void get_string(AVFormatContext *s, const char *key,
*q = '\0';
if (*str)
av_metadata_set2(&s->metadata, key, str, 0);
av_dict_set(&s->metadata, key, str, 0);
}
/**
@ -215,11 +216,11 @@ static int parse_tag(AVFormatContext *s, const uint8_t *buf)
get_string(s, "comment", buf + 97, 30);
if (buf[125] == 0 && buf[126] != 0) {
snprintf(str, sizeof(str), "%d", buf[126]);
av_metadata_set2(&s->metadata, "track", str, 0);
av_dict_set(&s->metadata, "track", str, 0);
}
genre = buf[127];
if (genre <= ID3v1_GENRE_MAX)
av_metadata_set2(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0);
av_dict_set(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0);
return 0;
}

View File

@ -30,7 +30,7 @@
#include "id3v1.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "metadata.h"
#include "libavutil/dict.h"
#include "avio_internal.h"
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
val = dst;
if (val)
av_metadata_set2(&s->metadata, key, val, AV_METADATA_DONT_OVERWRITE);
av_dict_set(&s->metadata, key, val, AV_DICT_DONT_OVERWRITE);
}
static int is_number(const char *str)
@ -149,44 +149,44 @@ static int is_number(const char *str)
return !*str;
}
static AVMetadataTag* get_date_tag(AVMetadata *m, const char *tag)
static AVDictionaryEntry* get_date_tag(AVDictionary *m, const char *tag)
{
AVMetadataTag *t;
if ((t = av_metadata_get(m, tag, NULL, AV_METADATA_MATCH_CASE)) &&
AVDictionaryEntry *t;
if ((t = av_dict_get(m, tag, NULL, AV_DICT_MATCH_CASE)) &&
strlen(t->value) == 4 && is_number(t->value))
return t;
return NULL;
}
static void merge_date(AVMetadata **m)
static void merge_date(AVDictionary **m)
{
AVMetadataTag *t;
AVDictionaryEntry *t;
char date[17] = {0}; // YYYY-MM-DD hh:mm
if (!(t = get_date_tag(*m, "TYER")) &&
!(t = get_date_tag(*m, "TYE")))
return;
av_strlcpy(date, t->value, 5);
av_metadata_set2(m, "TYER", NULL, 0);
av_metadata_set2(m, "TYE", NULL, 0);
av_dict_set(m, "TYER", NULL, 0);
av_dict_set(m, "TYE", NULL, 0);
if (!(t = get_date_tag(*m, "TDAT")) &&
!(t = get_date_tag(*m, "TDA")))
goto finish;
snprintf(date + 4, sizeof(date) - 4, "-%.2s-%.2s", t->value + 2, t->value);
av_metadata_set2(m, "TDAT", NULL, 0);
av_metadata_set2(m, "TDA", NULL, 0);
av_dict_set(m, "TDAT", NULL, 0);
av_dict_set(m, "TDA", NULL, 0);
if (!(t = get_date_tag(*m, "TIME")) &&
!(t = get_date_tag(*m, "TIM")))
goto finish;
snprintf(date + 10, sizeof(date) - 10, " %.2s:%.2s", t->value, t->value + 2);
av_metadata_set2(m, "TIME", NULL, 0);
av_metadata_set2(m, "TIM", NULL, 0);
av_dict_set(m, "TIME", NULL, 0);
av_dict_set(m, "TIM", NULL, 0);
finish:
if (date[0])
av_metadata_set2(m, "date", date, 0);
av_dict_set(m, "date", date, 0);
}
static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)

View File

@ -30,6 +30,7 @@
#include "libavcodec/bytestream.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#define ID_8SVX MKTAG('8','S','V','X')
@ -109,7 +110,7 @@ static int get_metadata(AVFormatContext *s,
return AVERROR(EIO);
}
buf[data_size] = 0;
av_metadata_set2(&s->metadata, tag, buf, AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(&s->metadata, tag, buf, AV_DICT_DONT_STRDUP_VAL);
return 0;
}

View File

@ -42,6 +42,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/avstring.h"
#include "libavutil/lzo.h"
#include "libavutil/dict.h"
#if CONFIG_ZLIB
#include <zlib.h>
#endif
@ -1073,7 +1074,7 @@ static void matroska_merge_packets(AVPacket *out, AVPacket *in)
}
static void matroska_convert_tag(AVFormatContext *s, EbmlList *list,
AVMetadata **metadata, char *prefix)
AVDictionary **metadata, char *prefix)
{
MatroskaTag *tags = list->elem;
char key[1024];
@ -1089,14 +1090,14 @@ static void matroska_convert_tag(AVFormatContext *s, EbmlList *list,
if (prefix) snprintf(key, sizeof(key), "%s/%s", prefix, tags[i].name);
else av_strlcpy(key, tags[i].name, sizeof(key));
if (tags[i].def || !lang) {
av_metadata_set2(metadata, key, tags[i].string, 0);
av_dict_set(metadata, key, tags[i].string, 0);
if (tags[i].sub.nb_elem)
matroska_convert_tag(s, &tags[i].sub, metadata, key);
}
if (lang) {
av_strlcat(key, "-", sizeof(key));
av_strlcat(key, lang, sizeof(key));
av_metadata_set2(metadata, key, tags[i].string, 0);
av_dict_set(metadata, key, tags[i].string, 0);
if (tags[i].sub.nb_elem)
matroska_convert_tag(s, &tags[i].sub, metadata, key);
}
@ -1269,7 +1270,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (matroska->duration)
matroska->ctx->duration = matroska->duration * matroska->time_scale
* 1000 / AV_TIME_BASE;
av_metadata_set2(&s->metadata, "title", matroska->title, 0);
av_dict_set(&s->metadata, "title", matroska->title, 0);
tracks = matroska->tracks.elem;
for (i=0; i < matroska->tracks.nb_elem; i++) {
@ -1467,8 +1468,8 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_id = codec_id;
st->start_time = 0;
if (strcmp(track->language, "und"))
av_metadata_set2(&st->metadata, "language", track->language, 0);
av_metadata_set2(&st->metadata, "title", track->name, 0);
av_dict_set(&st->metadata, "language", track->language, 0);
av_dict_set(&st->metadata, "title", track->name, 0);
if (track->flag_default)
st->disposition |= AV_DISPOSITION_DEFAULT;
@ -1550,7 +1551,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVStream *st = av_new_stream(s, 0);
if (st == NULL)
break;
av_metadata_set2(&st->metadata, "filename",attachements[j].filename, 0);
av_dict_set(&st->metadata, "filename",attachements[j].filename, 0);
st->codec->codec_id = CODEC_ID_NONE;
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codec->extradata = av_malloc(attachements[j].bin.size);
@ -1578,7 +1579,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000},
chapters[i].start, chapters[i].end,
chapters[i].title);
av_metadata_set2(&chapters[i].chapter->metadata,
av_dict_set(&chapters[i].chapter->metadata,
"title", chapters[i].title, 0);
max_start = chapters[i].start;
}

View File

@ -30,6 +30,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/random_seed.h"
#include "libavutil/lfg.h"
#include "libavutil/dict.h"
#include "libavcodec/xiph.h"
#include "libavcodec/mpeg4audio.h"
#include <strings.h>
@ -523,7 +524,7 @@ static int mkv_write_tracks(AVFormatContext *s)
int bit_depth = av_get_bits_per_sample(codec->codec_id);
int sample_rate = codec->sample_rate;
int output_sample_rate = 0;
AVMetadataTag *tag;
AVDictionaryEntry *tag;
if (!bit_depth)
bit_depth = av_get_bits_per_sample_fmt(codec->sample_fmt);
@ -536,9 +537,9 @@ static int mkv_write_tracks(AVFormatContext *s)
put_ebml_uint (pb, MATROSKA_ID_TRACKUID , i + 1);
put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0); // no lacing (yet)
if ((tag = av_metadata_get(st->metadata, "title", NULL, 0)))
if ((tag = av_dict_get(st->metadata, "title", NULL, 0)))
put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value);
tag = av_metadata_get(st->metadata, "language", NULL, 0);
tag = av_dict_get(st->metadata, "language", NULL, 0);
put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag ? tag->value:"und");
if (st->disposition)
@ -587,8 +588,8 @@ static int mkv_write_tracks(AVFormatContext *s)
put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width);
put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, codec->height);
if ((tag = av_metadata_get(st->metadata, "stereo_mode", NULL, 0)) ||
(tag = av_metadata_get( s->metadata, "stereo_mode", NULL, 0))) {
if ((tag = av_dict_get(st->metadata, "stereo_mode", NULL, 0)) ||
(tag = av_dict_get( s->metadata, "stereo_mode", NULL, 0))) {
// save stereo mode flag
uint64_t st_mode = MATROSKA_VIDEO_STEREO_MODE_COUNT;
@ -677,7 +678,7 @@ static int mkv_write_chapters(AVFormatContext *s)
for (i = 0; i < s->nb_chapters; i++) {
ebml_master chapteratom, chapterdisplay;
AVChapter *c = s->chapters[i];
AVMetadataTag *t = NULL;
AVDictionaryEntry *t = NULL;
chapteratom = start_ebml_master(pb, MATROSKA_ID_CHAPTERATOM, 0);
put_ebml_uint(pb, MATROSKA_ID_CHAPTERUID, c->id);
@ -687,7 +688,7 @@ static int mkv_write_chapters(AVFormatContext *s)
av_rescale_q(c->end, c->time_base, scale));
put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGHIDDEN , 0);
put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGENABLED, 1);
if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
chapterdisplay = start_ebml_master(pb, MATROSKA_ID_CHAPTERDISPLAY, 0);
put_ebml_string(pb, MATROSKA_ID_CHAPSTRING, t->value);
put_ebml_string(pb, MATROSKA_ID_CHAPLANG , "und");
@ -700,7 +701,7 @@ static int mkv_write_chapters(AVFormatContext *s)
return 0;
}
static void mkv_write_simpletag(AVIOContext *pb, AVMetadataTag *t)
static void mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t)
{
uint8_t *key = av_strdup(t->key);
uint8_t *p = key;
@ -730,12 +731,12 @@ static void mkv_write_simpletag(AVIOContext *pb, AVMetadataTag *t)
av_freep(&key);
}
static int mkv_write_tag(AVFormatContext *s, AVMetadata *m, unsigned int elementid,
static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int elementid,
unsigned int uid, ebml_master *tags)
{
MatroskaMuxContext *mkv = s->priv_data;
ebml_master tag, targets;
AVMetadataTag *t = NULL;
AVDictionaryEntry *t = NULL;
int ret;
if (!tags->pos) {
@ -751,7 +752,7 @@ static int mkv_write_tag(AVFormatContext *s, AVMetadata *m, unsigned int element
put_ebml_uint(s->pb, elementid, uid);
end_ebml_master(s->pb, targets);
while ((t = av_metadata_get(m, "", t, AV_METADATA_IGNORE_SUFFIX)))
while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX)))
if (strcasecmp(t->key, "title") && strcasecmp(t->key, "stereo_mode"))
mkv_write_simpletag(s->pb, t);
@ -766,7 +767,7 @@ static int mkv_write_tags(AVFormatContext *s)
ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL);
if (av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX)) {
if (av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
ret = mkv_write_tag(s, s->metadata, 0, 0, &tags);
if (ret < 0) return ret;
}
@ -774,7 +775,7 @@ static int mkv_write_tags(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (!av_metadata_get(st->metadata, "", 0, AV_METADATA_IGNORE_SUFFIX))
if (!av_dict_get(st->metadata, "", 0, AV_DICT_IGNORE_SUFFIX))
continue;
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)
for (i = 0; i < s->nb_chapters; i++) {
AVChapter *ch = s->chapters[i];
if (!av_metadata_get(ch->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
if (!av_dict_get(ch->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
continue;
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)
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb = s->pb;
ebml_master ebml_header, segment_info;
AVMetadataTag *tag;
AVDictionaryEntry *tag;
int ret, i;
if (!strcmp(s->oformat->name, "webm")) mkv->mode = MODE_WEBM;
@ -838,7 +839,7 @@ static int mkv_write_header(AVFormatContext *s)
segment_info = start_ebml_master(pb, MATROSKA_ID_INFO, 0);
put_ebml_uint(pb, MATROSKA_ID_TIMECODESCALE, 1000000);
if ((tag = av_metadata_get(s->metadata, "title", NULL, 0)))
if ((tag = av_dict_get(s->metadata, "title", NULL, 0)))
put_ebml_string(pb, MATROSKA_ID_TITLE, tag->value);
if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
uint32_t segment_uid[4];

View File

@ -21,107 +21,51 @@
#include <strings.h>
#include "avformat.h"
#include "metadata.h"
AVMetadataTag *
av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags)
{
unsigned int i, j;
if(!m)
return NULL;
if(prev) i= prev - m->elems + 1;
else i= 0;
for(; i<m->count; i++){
const char *s= m->elems[i].key;
if(flags & AV_METADATA_MATCH_CASE) for(j=0; s[j] == key[j] && key[j]; j++);
else for(j=0; toupper(s[j]) == toupper(key[j]) && key[j]; j++);
if(key[j])
continue;
if(s[j] && !(flags & AV_METADATA_IGNORE_SUFFIX))
continue;
return &m->elems[i];
}
return NULL;
}
int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags)
{
AVMetadata *m= *pm;
AVMetadataTag *tag= av_metadata_get(m, key, NULL, flags);
if(!m)
m=*pm= av_mallocz(sizeof(*m));
if(tag){
if (flags & AV_METADATA_DONT_OVERWRITE)
return 0;
av_free(tag->value);
av_free(tag->key);
*tag= m->elems[--m->count];
}else{
AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
if(tmp){
m->elems= tmp;
}else
return AVERROR(ENOMEM);
}
if(value){
if(flags & AV_METADATA_DONT_STRDUP_KEY){
m->elems[m->count].key = key;
}else
m->elems[m->count].key = av_strdup(key );
if(flags & AV_METADATA_DONT_STRDUP_VAL){
m->elems[m->count].value= value;
}else
m->elems[m->count].value= av_strdup(value);
m->count++;
}
if(!m->count) {
av_free(m->elems);
av_freep(pm);
}
return 0;
}
#include "libavutil/dict.h"
#if FF_API_OLD_METADATA2
AVDictionaryEntry *
av_metadata_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
{
return av_dict_get(m, key, prev, flags);
}
int av_metadata_set2(AVDictionary **pm, const char *key, const char *value, int flags)
{
return av_dict_set(pm, key, value, flags);
}
void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv,
const AVMetadataConv *s_conv)
{
return;
}
#endif
void av_metadata_free(AVMetadata **pm)
void av_metadata_free(AVDictionary **pm)
{
AVMetadata *m= *pm;
if(m){
while(m->count--){
av_free(m->elems[m->count].key);
av_free(m->elems[m->count].value);
}
av_free(m->elems);
}
av_freep(pm);
av_dict_free(pm);
}
void ff_metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags)
{
av_dict_copy(dst, src, flags);
}
#endif
void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
const AVMetadataConv *s_conv)
{
/* TODO: use binary search to look up the two conversion tables
if the tables are getting big enough that it would matter speed wise */
const AVMetadataConv *sc, *dc;
AVMetadataTag *mtag = NULL;
AVMetadata *dst = NULL;
AVDictionaryEntry *mtag = NULL;
AVDictionary *dst = NULL;
const char *key;
if (d_conv == s_conv)
return;
while((mtag=av_metadata_get(*pm, "", mtag, AV_METADATA_IGNORE_SUFFIX))) {
while ((mtag = av_dict_get(*pm, "", mtag, AV_DICT_IGNORE_SUFFIX))) {
key = mtag->key;
if (s_conv)
for (sc=s_conv; sc->native; sc++)
@ -135,9 +79,9 @@ void ff_metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
key = dc->native;
break;
}
av_metadata_set2(&dst, key, mtag->value, 0);
av_dict_set(&dst, key, mtag->value, 0);
}
av_metadata_free(pm);
av_dict_free(pm);
*pm = dst;
}
@ -154,10 +98,3 @@ void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
ff_metadata_conv(&ctx->programs[i]->metadata, d_conv, s_conv);
}
void av_metadata_copy(AVMetadata **dst, AVMetadata *src, int flags)
{
AVMetadataTag *t = NULL;
while ((t = av_metadata_get(src, "", t, AV_METADATA_IGNORE_SUFFIX)))
av_metadata_set2(dst, t->key, t->value, flags);
}

View File

@ -29,11 +29,7 @@
#include "avformat.h"
struct AVMetadata{
int count;
AVMetadataTag *elems;
};
#include "libavutil/dict.h"
struct AVMetadataConv{
const char *native;
@ -43,7 +39,7 @@ struct AVMetadataConv{
typedef struct AVMetadataConv AVMetadataConv;
#endif
void ff_metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
const AVMetadataConv *s_conv);
void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
const AVMetadataConv *s_conv);

View File

@ -27,6 +27,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "avio_internal.h"
#include "riff.h"
@ -84,7 +85,7 @@ static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, uns
avio_rb16(pb); // unknown
snprintf(buf, sizeof(buf), "%d", avio_rb16(pb));
av_metadata_set2(&c->fc->metadata, type, buf, 0);
av_dict_set(&c->fc->metadata, type, buf, 0);
avio_rb16(pb); // total tracks/discs
@ -208,10 +209,10 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
avio_read(pb, str, str_size);
str[str_size] = 0;
}
av_metadata_set2(&c->fc->metadata, key, str, 0);
av_dict_set(&c->fc->metadata, key, str, 0);
if (*language && strcmp(language, "und")) {
snprintf(key2, sizeof(key2), "%s-%s", key, language);
av_metadata_set2(&c->fc->metadata, key2, str, 0);
av_dict_set(&c->fc->metadata, key2, str, 0);
}
}
av_dlog(c->fc, "lang \"%3s\" ", language);
@ -557,10 +558,10 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (strcmp(type, "qt "))
c->isom = 1;
av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type);
av_metadata_set2(&c->fc->metadata, "major_brand", type, 0);
av_dict_set(&c->fc->metadata, "major_brand", type, 0);
minor_ver = avio_rb32(pb); /* minor version */
snprintf(minor_ver_str, sizeof(minor_ver_str), "%d", minor_ver);
av_metadata_set2(&c->fc->metadata, "minor_version", minor_ver_str, 0);
av_dict_set(&c->fc->metadata, "minor_version", minor_ver_str, 0);
comp_brand_size = atom.size - 8;
if (comp_brand_size < 0)
@ -570,7 +571,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR(ENOMEM);
avio_read(pb, comp_brands_str, comp_brand_size);
comp_brands_str[comp_brand_size] = 0;
av_metadata_set2(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
av_dict_set(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
av_freep(&comp_brands_str);
return 0;
@ -594,7 +595,7 @@ static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return mov_read_default(c, pb, atom);
}
static void mov_metadata_creation_time(AVMetadata **metadata, time_t time)
static void mov_metadata_creation_time(AVDictionary **metadata, time_t time)
{
char buffer[32];
if (time) {
@ -603,7 +604,7 @@ static void mov_metadata_creation_time(AVMetadata **metadata, time_t time)
ptm = gmtime(&time);
if (!ptm) return;
strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm);
av_metadata_set2(metadata, "creation_time", buffer, 0);
av_dict_set(metadata, "creation_time", buffer, 0);
}
}
@ -640,7 +641,7 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
lang = avio_rb16(pb); /* language */
if (ff_mov_lang_to_iso639(lang, language))
av_metadata_set2(&st->metadata, "language", language, 0);
av_dict_set(&st->metadata, "language", language, 0);
avio_rb16(pb); /* quality */
return 0;
@ -2147,9 +2148,6 @@ static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
goto free_and_return;
atom.type = MKTAG('m','o','o','v');
atom.size = moov_len;
#ifdef DEBUG
// { int fd = open("/tmp/uncompheader.mov", O_WRONLY | O_CREAT); write(fd, moov_data, moov_len); close(fd); }
#endif
ret = mov_read_default(c, &ctx, atom);
free_and_return:
av_free(moov_data);

View File

@ -33,6 +33,7 @@
#include "internal.h"
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
#undef NDEBUG
#include <assert.h>
@ -1534,15 +1535,15 @@ static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb,
int long_style)
{
int l, lang = 0, len, len2;
AVMetadataTag *t, *t2 = NULL;
AVDictionaryEntry *t, *t2 = NULL;
char tag2[16];
if (!(t = av_metadata_get(s->metadata, tag, NULL, 0)))
if (!(t = av_dict_get(s->metadata, tag, NULL, 0)))
return 0;
len = strlen(t->key);
snprintf(tag2, sizeof(tag2), "%s-", tag);
while ((t2 = av_metadata_get(s->metadata, tag2, t2, AV_METADATA_IGNORE_SUFFIX))) {
while ((t2 = av_dict_get(s->metadata, tag2, t2, AV_DICT_IGNORE_SUFFIX))) {
len2 = strlen(t2->key);
if (len2 == len+4 && !strcmp(t->value, t2->value)
&& (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,
static int mov_write_trkn_tag(AVIOContext *pb, MOVMuxContext *mov,
AVFormatContext *s)
{
AVMetadataTag *t = av_metadata_get(s->metadata, "track", NULL, 0);
AVDictionaryEntry *t = av_dict_get(s->metadata, "track", NULL, 0);
int size = 0, track = t ? atoi(t->value) : 0;
if (track) {
avio_wb32(pb, 32); /* size */
@ -1649,7 +1650,7 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s,
const char *tag, const char *str)
{
int64_t pos = avio_tell(pb);
AVMetadataTag *t = av_metadata_get(s->metadata, str, NULL, 0);
AVDictionaryEntry *t = av_dict_get(s->metadata, str, NULL, 0);
if (!t || !utf8len(t->value))
return 0;
avio_wb32(pb, 0); /* size */
@ -1661,7 +1662,7 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s,
avio_wb16(pb, language_code("eng")); /* language */
avio_write(pb, t->value, strlen(t->value)+1); /* UTF8 string value */
if (!strcmp(tag, "albm") &&
(t = av_metadata_get(s->metadata, "track", NULL, 0)))
(t = av_dict_get(s->metadata, "track", NULL, 0)))
avio_w8(pb, atoi(t->value));
}
return updateSize(pb, pos);
@ -1680,10 +1681,10 @@ static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s)
for (i = 0; i < nb_chapters; i++) {
AVChapter *c = s->chapters[i];
AVMetadataTag *t;
AVDictionaryEntry *t;
avio_wb64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000}));
if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
int len = FFMIN(strlen(t->value), 255);
avio_w8(pb, len);
avio_write(pb, t->value, len);
@ -1761,7 +1762,7 @@ static void mov_write_psp_udta_tag(AVIOContext *pb,
static int mov_write_uuidusmt_tag(AVIOContext *pb, AVFormatContext *s)
{
AVMetadataTag *title = av_metadata_get(s->metadata, "title", NULL, 0);
AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0);
int64_t pos, pos2;
if (title) {
@ -2115,13 +2116,13 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
for (i = 0; i < s->nb_chapters; i++) {
AVChapter *c = s->chapters[i];
AVMetadataTag *t;
AVDictionaryEntry *t;
int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
pkt.duration = end - pkt.dts;
if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
len = strlen(t->value);
pkt.size = len+2;
pkt.data = av_malloc(pkt.size);
@ -2195,7 +2196,7 @@ static int mov_write_header(AVFormatContext *s)
for(i=0; i<s->nb_streams; i++){
AVStream *st= s->streams[i];
MOVTrack *track= &mov->tracks[i];
AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0);
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
track->enc = st->codec;
track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV);

View File

@ -21,6 +21,7 @@
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "id3v2.h"
#include "id3v1.h"
@ -149,7 +150,7 @@ static int mp3_read_header(AVFormatContext *s,
off = avio_tell(s->pb);
if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
ff_id3v1_read(s);
if (mp3_parse_vbr_tags(s, st, off) < 0)

View File

@ -31,19 +31,20 @@
#include "libavcodec/mpegaudiodata.h"
#include "libavcodec/mpegaudiodecheader.h"
#include "libavformat/avio_internal.h"
#include "libavutil/dict.h"
static int id3v1_set_string(AVFormatContext *s, const char *key,
uint8_t *buf, int buf_size)
{
AVMetadataTag *tag;
if ((tag = av_metadata_get(s->metadata, key, NULL, 0)))
AVDictionaryEntry *tag;
if ((tag = av_dict_get(s->metadata, key, NULL, 0)))
av_strlcpy(buf, tag->value, buf_size);
return !!tag;
}
static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
{
AVMetadataTag *tag;
AVDictionaryEntry *tag;
int i, count = 0;
memset(buf, 0, ID3v1_TAG_SIZE); /* fail safe */
@ -55,13 +56,13 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
count += id3v1_set_string(s, "TALB", buf + 63, 30); //album
count += id3v1_set_string(s, "TDRL", buf + 93, 4); //date
count += id3v1_set_string(s, "comment", buf + 97, 30);
if ((tag = av_metadata_get(s->metadata, "TRCK", NULL, 0))) { //track
if ((tag = av_dict_get(s->metadata, "TRCK", NULL, 0))) { //track
buf[125] = 0;
buf[126] = atoi(tag->value);
count++;
}
buf[127] = 0xFF; /* default to unknown genre */
if ((tag = av_metadata_get(s->metadata, "TCON", NULL, 0))) { //genre
if ((tag = av_dict_get(s->metadata, "TCON", NULL, 0))) { //genre
for(i = 0; i <= ID3v1_GENRE_MAX; i++) {
if (!strcasecmp(tag->value, ff_id3v1_genre_str[i])) {
buf[127] = i;
@ -186,7 +187,7 @@ static const AVClass mp3_muxer_class = {
.version = LIBAVUTIL_VERSION_INT,
};
static int id3v2_check_write_tag(AVFormatContext *s, AVMetadataTag *t, const char table[][4],
static int id3v2_check_write_tag(AVFormatContext *s, AVDictionaryEntry *t, const char table[][4],
enum ID3v2Encoding enc)
{
uint32_t tag;
@ -345,7 +346,7 @@ static void mp3_fix_xing(AVFormatContext *s)
static int mp3_write_header(struct AVFormatContext *s)
{
MP3Context *mp3 = s->priv_data;
AVMetadataTag *t = NULL;
AVDictionaryEntry *t = NULL;
int totlen = 0, enc = mp3->id3v2_version == 3 ? ID3v2_ENCODING_UTF16BOM :
ID3v2_ENCODING_UTF8;
int64_t size_pos, cur_pos;
@ -362,7 +363,7 @@ static int mp3_write_header(struct AVFormatContext *s)
if (mp3->id3v2_version == 4)
ff_metadata_conv(&s->metadata, ff_id3v2_4_metadata_conv, NULL);
while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
int ret;
if ((ret = id3v2_check_write_tag(s, t, ff_id3v2_tags, enc)) > 0) {

View File

@ -23,6 +23,7 @@
#include "avformat.h"
#include "apetag.h"
#include "id3v1.h"
#include "libavutil/dict.h"
#define MPC_FRAMESIZE 1152
#define DELAY_FRAMES 32
@ -96,7 +97,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (s->pb->seekable) {
int64_t pos = avio_tell(s->pb);
ff_ape_parse_tag(s);
if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
ff_id3v1_read(s);
avio_seek(s->pb, pos, SEEK_SET);
}

View File

@ -26,6 +26,7 @@
#include "libavutil/crc.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
#include "libavutil/dict.h"
#include "libavutil/opt.h"
#include "libavcodec/bytestream.h"
#include "avformat.h"
@ -950,7 +951,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
language[1] = get8(pp, desc_end);
language[2] = get8(pp, desc_end);
language[3] = 0;
av_metadata_set2(&st->metadata, "language", language, 0);
av_dict_set(&st->metadata, "language", language, 0);
break;
case 0x59: /* subtitling descriptor */
language[0] = get8(pp, desc_end);
@ -979,7 +980,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
}
}
*pp += 4;
av_metadata_set2(&st->metadata, "language", language, 0);
av_dict_set(&st->metadata, "language", language, 0);
break;
case 0x0a: /* ISO 639 language descriptor */
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
}
if (i) {
language[i - 1] = 0;
av_metadata_set2(&st->metadata, "language", language, 0);
av_dict_set(&st->metadata, "language", language, 0);
}
break;
case 0x05: /* registration descriptor */
@ -1248,8 +1249,8 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
if (name) {
AVProgram *program = av_new_program(ts->stream, sid);
if(program) {
av_metadata_set2(&program->metadata, "service_name", name, 0);
av_metadata_set2(&program->metadata, "service_provider", provider_name, 0);
av_dict_set(&program->metadata, "service_name", name, 0);
av_dict_set(&program->metadata, "service_provider", provider_name, 0);
}
}
av_free(name);

View File

@ -21,6 +21,7 @@
#include "libavutil/bswap.h"
#include "libavutil/crc.h"
#include "libavutil/dict.h"
#include "libavutil/opt.h"
#include "libavcodec/mpegvideo.h"
#include "avformat.h"
@ -244,7 +245,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
for(i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
MpegTSWriteStream *ts_st = st->priv_data;
AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0);
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
switch(st->codec->codec_id) {
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
@ -443,7 +444,7 @@ static int mpegts_write_header(AVFormatContext *s)
MpegTSWriteStream *ts_st;
MpegTSService *service;
AVStream *st, *pcr_st = NULL;
AVMetadataTag *title, *provider;
AVDictionaryEntry *title, *provider;
int i, j;
const char *service_name;
const char *provider_name;
@ -452,11 +453,11 @@ static int mpegts_write_header(AVFormatContext *s)
ts->tsid = ts->transport_stream_id;
ts->onid = ts->original_network_id;
/* allocate a single DVB service */
title = av_metadata_get(s->metadata, "service_name", NULL, 0);
title = av_dict_get(s->metadata, "service_name", NULL, 0);
if (!title)
title = av_metadata_get(s->metadata, "title", NULL, 0);
title = av_dict_get(s->metadata, "title", NULL, 0);
service_name = title ? title->value : DEFAULT_SERVICE_NAME;
provider = av_metadata_get(s->metadata, "service_provider", NULL, 0);
provider = av_dict_get(s->metadata, "service_provider", NULL, 0);
provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
service = mpegts_add_service(ts, ts->service_id, provider_name, service_name);
service->pmt.write_packet = section_write_packet;

View File

@ -20,6 +20,7 @@
*/
#include "avformat.h"
#include "riff.h"
#include "libavutil/dict.h"
//#define DEBUG
//#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)
break;
*p++ = '\0';
av_dlog(s, "NSV NSVf INFO: %s='%s'\n", token, value);
av_metadata_set2(&s->metadata, token, value, 0);
av_dict_set(&s->metadata, token, value, 0);
}
av_free(strings);
}

View File

@ -23,6 +23,7 @@
#include <strings.h>
#include "libavutil/avstring.h"
#include "libavutil/bswap.h"
#include "libavutil/dict.h"
#include "libavutil/tree.h"
#include "avio_internal.h"
#include "nut.h"
@ -401,7 +402,7 @@ static int decode_info_header(NUTContext *nut){
const char *type;
AVChapter *chapter= NULL;
AVStream *st= NULL;
AVMetadata **metadata = NULL;
AVDictionary **metadata = NULL;
end= get_packetheader(nut, bc, 1, INFO_STARTCODE);
end += avio_tell(bc);
@ -459,7 +460,7 @@ static int decode_info_header(NUTContext *nut){
}
if(metadata && strcasecmp(name,"Uses")
&& strcasecmp(name,"Depends") && strcasecmp(name,"Replaces"))
av_metadata_set2(metadata, name, str_value, 0);
av_dict_set(metadata, name, str_value, 0);
}
}

View File

@ -21,6 +21,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/tree.h"
#include "libavutil/dict.h"
#include "libavcodec/mpegaudiodata.h"
#include "nut.h"
#include "internal.h"
@ -432,7 +433,7 @@ static int add_info(AVIOContext *bc, const char *type, const char *value){
static int write_globalinfo(NUTContext *nut, AVIOContext *bc){
AVFormatContext *s= nut->avf;
AVMetadataTag *t = NULL;
AVDictionaryEntry *t = NULL;
AVIOContext *dyn_bc;
uint8_t *dyn_buf=NULL;
int count=0, dyn_size;
@ -440,7 +441,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext *bc){
if(ret < 0)
return ret;
while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
count += add_info(dyn_bc, t->key, t->value);
ff_put_v(bc, 0); //stream_if_plus1
@ -491,7 +492,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id)
{
AVIOContext *dyn_bc;
uint8_t *dyn_buf = NULL;
AVMetadataTag *t = NULL;
AVDictionaryEntry *t = NULL;
AVChapter *ch = nut->avf->chapters[id];
int ret, dyn_size, count = 0;
@ -504,7 +505,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id)
put_tt(nut, nut->chapter[id].time_base, bc, ch->start); // chapter_start
ff_put_v(bc, ch->end - ch->start); // chapter_len
while ((t = av_metadata_get(ch->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
while ((t = av_dict_get(ch->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
count += add_info(dyn_bc, t->key, t->value);
ff_put_v(bc, count);

View File

@ -112,7 +112,7 @@ extern const struct ogg_codec ff_speex_codec;
extern const struct ogg_codec ff_theora_codec;
extern const struct ogg_codec ff_vorbis_codec;
int ff_vorbis_comment(AVFormatContext *ms, AVMetadata **m, const uint8_t *buf, int size);
int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, const uint8_t *buf, int size);
static inline int
ogg_find_stream (struct ogg * ogg, int serial)

View File

@ -241,7 +241,7 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
}
static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
int *header_len, AVMetadata **m, int framing_bit)
int *header_len, AVDictionary **m, int framing_bit)
{
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
int size;
@ -267,7 +267,7 @@ static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
static int ogg_build_flac_headers(AVCodecContext *avctx,
OGGStreamContext *oggstream, int bitexact,
AVMetadata **m)
AVDictionary **m)
{
enum FLACExtradataFormat format;
uint8_t *streaminfo;
@ -307,7 +307,7 @@ static int ogg_build_flac_headers(AVCodecContext *avctx,
static int ogg_build_speex_headers(AVCodecContext *avctx,
OGGStreamContext *oggstream, int bitexact,
AVMetadata **m)
AVDictionary **m)
{
uint8_t *p;

View File

@ -25,6 +25,7 @@
#include <stdlib.h>
#include "libavutil/avstring.h"
#include "libavutil/bswap.h"
#include "libavutil/dict.h"
#include "libavcodec/get_bits.h"
#include "libavcodec/bytestream.h"
#include "avformat.h"
@ -57,8 +58,8 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
if (!chapter)
return 0;
av_metadata_set2(&chapter->metadata, "title", val,
AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(&chapter->metadata, "title", val,
AV_DICT_DONT_STRDUP_VAL);
} else
return 0;
@ -67,7 +68,7 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
}
int
ff_vorbis_comment(AVFormatContext * as, AVMetadata **m, const uint8_t *buf, int size)
ff_vorbis_comment(AVFormatContext * as, AVDictionary **m, const uint8_t *buf, int size)
{
const uint8_t *p = buf;
const uint8_t *end = buf + size;
@ -127,9 +128,9 @@ ff_vorbis_comment(AVFormatContext * as, AVMetadata **m, const uint8_t *buf, int
ct[vl] = 0;
if (!ogm_chapter(as, tt, ct))
av_metadata_set2(m, tt, ct,
AV_METADATA_DONT_STRDUP_KEY |
AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(m, tt, ct,
AV_DICT_DONT_STRDUP_KEY |
AV_DICT_DONT_STRDUP_VAL);
}
}

View File

@ -62,7 +62,7 @@ static const AVOption options[]={
{"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"},
{"ts", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"},
{"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E|D},
{"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), FF_OPT_TYPE_INT, -1, -1, INT_MAX-1, D},
{"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), FF_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D},
{NULL},
};

View File

@ -22,6 +22,7 @@
//#define DEBUG
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
typedef struct {
@ -98,7 +99,7 @@ static int r3d_read_red1(AVFormatContext *s)
avio_read(s->pb, filename, 257);
filename[sizeof(filename)-1] = 0;
av_metadata_set2(&st->metadata, "filename", filename, 0);
av_dict_set(&st->metadata, "filename", filename, 0);
av_dlog(s, "filename %s\n", filename);
av_dlog(s, "resolution %dx%d\n", st->codec->width, st->codec->height);

View File

@ -21,6 +21,7 @@
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "riff.h"
#include "rm.h"
@ -104,7 +105,7 @@ static void rm_read_metadata(AVFormatContext *s, int wide)
for (i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
int len = wide ? avio_rb16(s->pb) : avio_r8(s->pb);
get_strl(s->pb, buf, sizeof(buf), len);
av_metadata_set2(&s->metadata, ff_rm_metadata[i], buf, 0);
av_dict_set(&s->metadata, ff_rm_metadata[i], buf, 0);
}
}

View File

@ -21,6 +21,7 @@
#include "avformat.h"
#include "avio_internal.h"
#include "rm.h"
#include "libavutil/dict.h"
typedef struct {
int nb_packets;
@ -71,7 +72,7 @@ static int rv10_write_header(AVFormatContext *ctx,
const char *desc, *mimetype;
int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i;
int bit_rate, v, duration, flags, data_pos;
AVMetadataTag *tag;
AVDictionaryEntry *tag;
start_ptr = s->buf_ptr;
@ -127,13 +128,13 @@ static int rv10_write_header(AVFormatContext *ctx,
ffio_wfourcc(s,"CONT");
size = 4 * 2 + 10;
for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
tag = av_metadata_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
tag = av_dict_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
if(tag) size += strlen(tag->value);
}
avio_wb32(s,size);
avio_wb16(s,0);
for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
tag = av_metadata_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
tag = av_dict_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
put_str(s, tag ? tag->value : "");
}

View File

@ -20,6 +20,7 @@
*/
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include <stdlib.h>
@ -131,11 +132,11 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap)
// for the text in a few cases; samples needed.)
error |= read_line(pb, line, sizeof(line)); // ARMovie
error |= read_line(pb, line, sizeof(line)); // movie name
av_metadata_set2(&s->metadata, "title" , line, 0);
av_dict_set(&s->metadata, "title" , line, 0);
error |= read_line(pb, line, sizeof(line)); // date/copyright
av_metadata_set2(&s->metadata, "copyright", line, 0);
av_dict_set(&s->metadata, "copyright", line, 0);
error |= read_line(pb, line, sizeof(line)); // author and other
av_metadata_set2(&s->metadata, "author" , line, 0);
av_dict_set(&s->metadata, "author" , line, 0);
// video headers
vst = av_new_stream(s, 0);

View File

@ -113,7 +113,7 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
ret = av_open_input_stream(&rt->asf_ctx, &pb, "", &ff_asf_demuxer, NULL);
if (ret < 0)
return ret;
av_metadata_copy(&s->metadata, rt->asf_ctx->metadata, 0);
av_dict_copy(&s->metadata, rt->asf_ctx->metadata, 0);
rt->asf_pb_pos = avio_tell(&pb);
av_free(buf);
rt->asf_ctx->pb = NULL;

View File

@ -24,6 +24,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/parseutils.h"
#include "libavutil/random_seed.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "avio_internal.h"
@ -281,11 +282,11 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
}
break;
case 's':
av_metadata_set2(&s->metadata, "title", p, 0);
av_dict_set(&s->metadata, "title", p, 0);
break;
case 'i':
if (s->nb_streams == 0) {
av_metadata_set2(&s->metadata, "comment", p, 0);
av_dict_set(&s->metadata, "comment", p, 0);
break;
}
break;

View File

@ -25,6 +25,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "sauce.h"
@ -44,7 +45,7 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g
#define GET_SAUCE_META(name,size) \
if (avio_read(pb, buf, size) == size && buf[0]) { \
buf[size] = 0; \
av_metadata_set2(&avctx->metadata, name, buf, 0); \
av_dict_set(&avctx->metadata, name, buf, 0); \
}
GET_SAUCE_META("title", 35)
@ -95,7 +96,7 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g
str[65*i + 64] = '\n';
}
str[65*i] = 0;
av_metadata_set2(&avctx->metadata, "comment", str, AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(&avctx->metadata, "comment", str, AV_DICT_DONT_STRDUP_VAL);
}
}

View File

@ -21,6 +21,7 @@
#include <string.h>
#include "libavutil/avstring.h"
#include "libavutil/base64.h"
#include "libavutil/dict.h"
#include "libavutil/parseutils.h"
#include "libavcodec/xiph.h"
#include "libavcodec/mpeg4audio.h"
@ -550,7 +551,7 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
{
AVMetadataTag *title = av_metadata_get(ac[0]->metadata, "title", NULL, 0);
AVDictionaryEntry *title = av_dict_get(ac[0]->metadata, "title", NULL, 0);
struct sdp_session_level s;
int i, j, port, ttl, is_multicast;
char dst[32], dst_type[5];

View File

@ -30,6 +30,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "pcm.h"
#include "sox.h"
@ -101,8 +102,8 @@ static int sox_read_header(AVFormatContext *s,
}
comment[comment_size] = 0;
av_metadata_set2(&s->metadata, "comment", comment,
AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(&s->metadata, "comment", comment,
AV_DICT_DONT_STRDUP_VAL);
}
avio_skip(pb, header_size - SOX_FIXED_HDR - comment_size);

View File

@ -30,6 +30,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "avio_internal.h"
#include "sox.h"
@ -43,10 +44,10 @@ static int sox_write_header(AVFormatContext *s)
SoXContext *sox = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
AVMetadataTag *comment;
AVDictionaryEntry *comment;
size_t comment_len = 0, comment_size;
comment = av_metadata_get(s->metadata, "comment", NULL, 0);
comment = av_dict_get(s->metadata, "comment", NULL, 0);
if (comment)
comment_len = strlen(comment->value);
comment_size = (comment_len + 7) & ~7;

View File

@ -22,6 +22,7 @@
#include "libavcodec/get_bits.h"
#include "avformat.h"
#include "id3v1.h"
#include "libavutil/dict.h"
typedef struct {
int totalframes, currentframe;
@ -43,7 +44,7 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
int i, channels, bps, samplerate, datalen, framelen;
uint64_t framepos, start_offset;
if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
ff_id3v1_read(s);
start_offset = avio_tell(s->pb);

View File

@ -27,6 +27,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/avstring.h"
#include "libavutil/log.h"
#include "libavutil/dict.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "avformat.h"
@ -60,7 +61,7 @@ static int efi_read(AVFormatContext *avctx, uint64_t start_pos)
return -1; \
if (avio_read(pb, buf, size) == size) { \
buf[len] = 0; \
av_metadata_set2(&avctx->metadata, name, buf, 0); \
av_dict_set(&avctx->metadata, name, buf, 0); \
}
GET_EFI_META("filename", 12)

View File

@ -27,6 +27,7 @@
#include "libavcodec/internal.h"
#include "libavcodec/raw.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
#include "metadata.h"
#include "id3v2.h"
#include "libavutil/avstring.h"
@ -2593,7 +2594,7 @@ void avformat_free_context(AVFormatContext *s)
AVStream *st;
av_opt_free(s);
if (s->iformat && s->iformat->priv_class)
if (s->iformat && s->iformat->priv_class && s->priv_data)
av_opt_free(s->priv_data);
for(i=0;i<s->nb_streams;i++) {
@ -2603,7 +2604,7 @@ void avformat_free_context(AVFormatContext *s)
av_parser_close(st->parser);
av_free_packet(&st->cur_pkt);
}
av_metadata_free(&st->metadata);
av_dict_free(&st->metadata);
av_free(st->index_entries);
av_free(st->codec->extradata);
av_free(st->codec->subtitle_header);
@ -2613,18 +2614,18 @@ void avformat_free_context(AVFormatContext *s)
av_free(st);
}
for(i=s->nb_programs-1; i>=0; i--) {
av_metadata_free(&s->programs[i]->metadata);
av_dict_free(&s->programs[i]->metadata);
av_freep(&s->programs[i]->stream_index);
av_freep(&s->programs[i]);
}
av_freep(&s->programs);
av_freep(&s->priv_data);
while(s->nb_chapters--) {
av_metadata_free(&s->chapters[s->nb_chapters]->metadata);
av_dict_free(&s->chapters[s->nb_chapters]->metadata);
av_free(s->chapters[s->nb_chapters]);
}
av_freep(&s->chapters);
av_metadata_free(&s->metadata);
av_dict_free(&s->metadata);
av_freep(&s->streams);
av_free(s);
}
@ -2728,7 +2729,7 @@ AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int6
return NULL;
dynarray_add(&s->chapters, &s->nb_chapters, chapter);
}
av_metadata_set2(&chapter->metadata, "title", title, 0);
av_dict_set(&chapter->metadata, "title", title, 0);
chapter->id = id;
chapter->time_base= time_base;
chapter->start = start;
@ -2923,7 +2924,7 @@ int av_write_header(AVFormatContext *s)
/* set muxer identification string */
if (s->nb_streams && !(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
av_metadata_set2(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
av_dict_set(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
}
if(s->oformat->write_header){
@ -3245,13 +3246,13 @@ static void print_fps(double d, const char *postfix){
else av_log(NULL, AV_LOG_INFO, ", %1.0fk %s", d/1000, postfix);
}
static void dump_metadata(void *ctx, AVMetadata *m, const char *indent)
static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
{
if(m && !(m->count == 1 && av_metadata_get(m, "language", NULL, 0))){
AVMetadataTag *tag=NULL;
if(m && !(m->count == 1 && av_dict_get(m, "language", NULL, 0))){
AVDictionaryEntry *tag=NULL;
av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
while((tag=av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
while((tag=av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
if(strcmp("language", tag->key))
av_log(ctx, AV_LOG_INFO, "%s %-16s: %s\n", indent, tag->key, tag->value);
}
@ -3265,7 +3266,7 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out
int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
AVStream *st = ic->streams[i];
int g = av_gcd(st->time_base.num, st->time_base.den);
AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL, 0);
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
avcodec_string(buf, sizeof(buf), st->codec, is_output);
av_log(NULL, AV_LOG_INFO, " Stream #%d.%d", index, i);
/* the pid is an important information, so we display it */
@ -3389,7 +3390,7 @@ void av_dump_format(AVFormatContext *ic,
if(ic->nb_programs) {
int j, k, total = 0;
for(j=0; j<ic->nb_programs; j++) {
AVMetadataTag *name = av_metadata_get(ic->programs[j]->metadata,
AVDictionaryEntry *name = av_dict_get(ic->programs[j]->metadata,
"name", NULL, 0);
av_log(NULL, AV_LOG_INFO, " Program %d %s\n", ic->programs[j]->id,
name ? name->value : "");

View File

@ -23,6 +23,7 @@
#include "metadata.h"
#include "vorbiscomment.h"
#include "libavcodec/bytestream.h"
#include "libavutil/dict.h"
/**
* VorbisComment metadata conversion mapping.
@ -36,15 +37,15 @@ const AVMetadataConv ff_vorbiscomment_metadata_conv[] = {
{ 0 }
};
int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
unsigned *count)
{
int len = 8;
len += strlen(vendor_string);
*count = 0;
if (m) {
AVMetadataTag *tag = NULL;
while ((tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
AVDictionaryEntry *tag = NULL;
while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
len += 4 +strlen(tag->key) + 1 + strlen(tag->value);
(*count)++;
}
@ -52,15 +53,15 @@ int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
return len;
}
int ff_vorbiscomment_write(uint8_t **p, AVMetadata **m,
int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
const char *vendor_string, const unsigned count)
{
bytestream_put_le32(p, strlen(vendor_string));
bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
if (*m) {
AVMetadataTag *tag = NULL;
AVDictionaryEntry *tag = NULL;
bytestream_put_le32(p, count);
while ((tag = av_metadata_get(*m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
while ((tag = av_dict_get(*m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
unsigned int len1 = strlen(tag->key);
unsigned int len2 = strlen(tag->value);
bytestream_put_le32(p, len1+1+len2);

View File

@ -35,13 +35,13 @@
* @param count Pointer to store the number of tags in m because m->count is "not allowed"
* @return The length in bytes.
*/
int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
unsigned *count);
/**
* Writes a VorbisComment into a buffer. The buffer, p, must have enough
* data to hold the whole VorbisComment. The minimum size required can be
* obtained by passing the same AVMetadata and vendor_string to
* obtained by passing the same AVDictionary and vendor_string to
* ff_vorbiscomment_length()
*
* @param p The buffer in which to write.
@ -49,7 +49,7 @@ int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
* @param vendor_string The vendor string to write.
* @param count The number of tags in m because m->count is "not allowed"
*/
int ff_vorbiscomment_write(uint8_t **p, AVMetadata **m,
int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
const char *vendor_string, const unsigned count);
extern const AVMetadataConv ff_vorbiscomment_metadata_conv[];

View File

@ -21,6 +21,7 @@
#include "avformat.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
typedef struct VqfContext {
int frame_bit_len;
@ -56,7 +57,7 @@ static void add_metadata(AVFormatContext *s, const char *tag,
return;
avio_read(s->pb, buf, len);
buf[len] = 0;
av_metadata_set2(&s->metadata, tag, buf, AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(&s->metadata, tag, buf, AV_DICT_DONT_STRDUP_VAL);
}
static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap)

View File

@ -28,6 +28,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#define FORM_TAG MKTAG('F', 'O', 'R', 'M')
@ -130,8 +131,8 @@ static int wc3_read_header(AVFormatContext *s,
if ((ret = avio_read(pb, buffer, size)) != size)
return AVERROR(EIO);
buffer[size] = 0;
av_metadata_set2(&s->metadata, "title", buffer,
AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(&s->metadata, "title", buffer,
AV_DICT_DONT_STRDUP_VAL);
break;
case SIZE_TAG:

View File

@ -21,6 +21,7 @@
#include "libavutil/audioconvert.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "apetag.h"
#include "id3v1.h"
@ -226,7 +227,7 @@ static int wv_read_header(AVFormatContext *s,
if(s->pb->seekable) {
int64_t cur = avio_tell(s->pb);
ff_ape_parse_tag(s);
if(!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
if(!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
ff_id3v1_read(s);
avio_seek(s->pb, cur, SEEK_SET);
}

View File

@ -27,6 +27,7 @@ HEADERS = adler32.h \
mathematics.h \
md5.h \
mem.h \
dict.h \
opt.h \
parseutils.h \
pixdesc.h \
@ -60,6 +61,7 @@ OBJS = adler32.o \
mathematics.o \
md5.o \
mem.o \
dict.o \
opt.o \
parseutils.o \
pixdesc.o \

View File

@ -40,7 +40,7 @@
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
#define LIBAVUTIL_VERSION_MAJOR 51
#define LIBAVUTIL_VERSION_MINOR 7
#define LIBAVUTIL_VERSION_MINOR 8
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

110
libavutil/dict.c Normal file
View File

@ -0,0 +1,110 @@
/*
* copyright (c) 2009 Michael Niedermayer
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <strings.h>
#include "dict.h"
#include "internal.h"
#include "mem.h"
AVDictionaryEntry *
av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
{
unsigned int i, j;
if(!m)
return NULL;
if(prev) i= prev - m->elems + 1;
else i= 0;
for(; i<m->count; i++){
const char *s= m->elems[i].key;
if(flags & AV_DICT_MATCH_CASE) for(j=0; s[j] == key[j] && key[j]; j++);
else for(j=0; toupper(s[j]) == toupper(key[j]) && key[j]; j++);
if(key[j])
continue;
if(s[j] && !(flags & AV_DICT_IGNORE_SUFFIX))
continue;
return &m->elems[i];
}
return NULL;
}
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
{
AVDictionary *m = *pm;
AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
if(!m)
m = *pm = av_mallocz(sizeof(*m));
if(tag) {
if (flags & AV_DICT_DONT_OVERWRITE)
return 0;
av_free(tag->value);
av_free(tag->key);
*tag = m->elems[--m->count];
} else {
AVDictionaryEntry *tmp = av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
if(tmp) {
m->elems = tmp;
} else
return AVERROR(ENOMEM);
}
if (value) {
if (flags & AV_DICT_DONT_STRDUP_KEY) {
m->elems[m->count].key = key;
} else
m->elems[m->count].key = av_strdup(key );
if (flags & AV_DICT_DONT_STRDUP_VAL) {
m->elems[m->count].value = value;
} else
m->elems[m->count].value = av_strdup(value);
m->count++;
}
if (!m->count) {
av_free(m->elems);
av_freep(pm);
}
return 0;
}
void av_dict_free(AVDictionary **pm)
{
AVDictionary *m = *pm;
if (m) {
while(m->count--) {
av_free(m->elems[m->count].key);
av_free(m->elems[m->count].value);
}
av_free(m->elems);
}
av_freep(pm);
}
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags)
{
AVDictionaryEntry *t = NULL;
while ((t = av_dict_get(src, "", t, AV_DICT_IGNORE_SUFFIX)))
av_dict_set(dst, t->key, t->value, flags);
}

78
libavutil/dict.h Normal file
View File

@ -0,0 +1,78 @@
/*
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file Public dictionary API.
*/
#ifndef AVUTIL_DICT_H
#define AVUTIL_DICT_H
#define AV_DICT_MATCH_CASE 1
#define AV_DICT_IGNORE_SUFFIX 2
#define AV_DICT_DONT_STRDUP_KEY 4
#define AV_DICT_DONT_STRDUP_VAL 8
#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries.
typedef struct {
char *key;
char *value;
} AVDictionaryEntry;
typedef struct AVDictionary AVDictionary;
/**
* Get a dictionary entry with matching key.
*
* @param prev Set to the previous matching element to find the next.
* If set to NULL the first matching element is returned.
* @param flags Allows case as well as suffix-insensitive comparisons.
* @return Found entry or NULL, changing key or value leads to undefined behavior.
*/
AVDictionaryEntry *
av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
/**
* Set the given entry in *pm, overwriting an existing entry.
*
* @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
* a dictionary struct is allocated and put in *pm.
* @param key entry key to add to *pm (will be av_strduped depending on flags)
* @param value entry value to add to *pm (will be av_strduped depending on flags).
* Passing a NULL value will cause an existing tag to be deleted.
* @return >= 0 on success otherwise an error code <0
*/
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
/**
* Copy entries from one AVDictionary struct into another.
* @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
* this function will allocate a struct for you and put it in *dst
* @param src pointer to source AVDictionary struct
* @param flags flags to use when setting entries in *dst
* @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
*/
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags);
/**
* Free all the memory allocated for an AVDictionary struct.
*/
void av_dict_free(AVDictionary **m);
#endif // AVUTIL_DICT_H

View File

@ -38,6 +38,12 @@
#include "attributes.h"
#include "timer.h"
#include "cpu.h"
#include "dict.h"
struct AVDictionary {
int count;
AVDictionaryEntry *elems;
};
#ifndef attribute_align_arg
#if ARCH_X86_32 && AV_GCC_VERSION_AT_LEAST(4,2)

View File

@ -380,40 +380,14 @@ yuv2NBPS(10, LE, 0);
yuv2NBPS(16, BE, 1);
yuv2NBPS(16, LE, 0);
static inline void yuv2yuvX16_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, int dstW, int chrDstW,
enum PixelFormat dstFormat)
{
if (isNBPS(dstFormat)) {
const int depth = av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1+1;
yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrUSrc, chrVSrc, chrFilterSize,
alpSrc,
dest, uDest, vDest, aDest,
dstW, chrDstW, isBE(dstFormat), depth);
} else {
if (isBE(dstFormat)) {
yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrUSrc, chrVSrc, chrFilterSize,
alpSrc,
dest, uDest, vDest, aDest,
dstW, chrDstW, 1, 16);
} else {
yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrUSrc, chrVSrc, chrFilterSize,
alpSrc,
dest, uDest, vDest, aDest,
dstW, chrDstW, 0, 16);
}
}
}
static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, int dstW, int chrDstW,
const uint8_t *lumDither, const uint8_t *chrDither)
static inline void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc,
int chrFilterSize, const int16_t **alpSrc,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest,
uint8_t *aDest, int dstW, int chrDstW,
const uint8_t *lumDither, const uint8_t *chrDither)
{
//FIXME Optimize (just quickly written not optimized..)
int i;

View File

@ -180,19 +180,6 @@ static inline void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter,
YSCALEYUV2YV12X_ACCURATE(LUM_MMX_FILTER_OFFSET, dest, dstW, 0)
}
#define YSCALEYUV2YV121 \
"mov %2, %%"REG_a" \n\t"\
".p2align 4 \n\t" /* FIXME Unroll? */\
"1: \n\t"\
"movq (%0, %%"REG_a", 2), %%mm0 \n\t"\
"movq 8(%0, %%"REG_a", 2), %%mm1 \n\t"\
"psraw $7, %%mm0 \n\t"\
"psraw $7, %%mm1 \n\t"\
"packuswb %%mm1, %%mm0 \n\t"\
MOVNTQ(%%mm0, (%1, %%REGa))\
"add $8, %%"REG_a" \n\t"\
"jnc 1b \n\t"
static inline void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc,
const int16_t *chrUSrc, const int16_t *chrVSrc,
const int16_t *alpSrc,
@ -208,32 +195,25 @@ static inline void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc,
while (p--) {
if (dst[p]) {
__asm__ volatile(
YSCALEYUV2YV121
:: "r" (src[p]), "r" (dst[p] + counter[p]),
"g" (-counter[p])
: "%"REG_a
"mov %2, %%"REG_a" \n\t"
".p2align 4 \n\t" /* FIXME Unroll? */
"1: \n\t"
"movq (%0, %%"REG_a", 2), %%mm0 \n\t"
"movq 8(%0, %%"REG_a", 2), %%mm1 \n\t"
"psraw $7, %%mm0 \n\t"
"psraw $7, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
MOVNTQ(%%mm0, (%1, %%REGa))
"add $8, %%"REG_a" \n\t"
"jnc 1b \n\t"
:: "r" (src[p]), "r" (dst[p] + counter[p]),
"g" (-counter[p])
: "%"REG_a
);
}
}
}
#define YSCALEYUV2YV121_ACCURATE \
"mov %2, %%"REG_a" \n\t"\
"movq 0(%3), %%mm6 \n\t"\
"movq 8(%3), %%mm7 \n\t"\
".p2align 4 \n\t" /* FIXME Unroll? */\
"1: \n\t"\
"movq (%0, %%"REG_a", 2), %%mm0 \n\t"\
"movq 8(%0, %%"REG_a", 2), %%mm1 \n\t"\
"paddsw %%mm6, %%mm0 \n\t"\
"paddsw %%mm7, %%mm1 \n\t"\
"psraw $7, %%mm0 \n\t"\
"psraw $7, %%mm1 \n\t"\
"packuswb %%mm1, %%mm0 \n\t"\
MOVNTQ(%%mm0, (%1, %%REGa))\
"add $8, %%"REG_a" \n\t"\
"jnc 1b \n\t"
static inline void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc,
const int16_t *chrUSrc, const int16_t *chrVSrc,
const int16_t *alpSrc,
@ -251,7 +231,21 @@ static inline void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc,
int i;
for(i=0; i<8; i++) c->dither16[i] = i<2 ? lumDither[i] : chrDither[i];
__asm__ volatile(
YSCALEYUV2YV121_ACCURATE
"mov %2, %%"REG_a" \n\t"
"movq 0(%3), %%mm6 \n\t"
"movq 8(%3), %%mm7 \n\t"
".p2align 4 \n\t" /* FIXME Unroll? */
"1: \n\t"
"movq (%0, %%"REG_a", 2), %%mm0 \n\t"
"movq 8(%0, %%"REG_a", 2), %%mm1 \n\t"
"paddsw %%mm6, %%mm0 \n\t"
"paddsw %%mm7, %%mm1 \n\t"
"psraw $7, %%mm0 \n\t"
"psraw $7, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
MOVNTQ(%%mm0, (%1, %%REGa))
"add $8, %%"REG_a" \n\t"
"jnc 1b \n\t"
:: "r" (src[p]), "r" (dst[p] + counter[p]),
"g" (-counter[p]), "r"(c->dither16)
: "%"REG_a
@ -2218,7 +2212,7 @@ static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src, int srcW,
int xInc)
{
int32_t *filterPos = c->hLumFilterPos;
int16_t *filterPos = c->hLumFilterPos;
int16_t *filter = c->hLumFilter;
void *mmx2FilterCode= c->lumMmx2FilterCode;
int i;
@ -2290,7 +2284,7 @@ static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *d
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
int32_t *filterPos = c->hChrFilterPos;
int16_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
void *mmx2FilterCode= c->chrMmx2FilterCode;
int i;