From f370911c15476c4d69895b6de76dca942dd99c2c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Feb 2012 08:59:26 +0100 Subject: decoder/ffmpeg: _copy_metadata() returns void No interest in this return value. --- src/decoder/ffmpeg_decoder_plugin.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/decoder/ffmpeg_decoder_plugin.c') diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 8f4cf8c12..29bf804f1 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -607,7 +607,7 @@ static const ffmpeg_tag_map ffmpeg_tag_maps[] = { { TAG_DISC, "disc" }, }; -static bool +static void ffmpeg_copy_metadata(struct tag *tag, #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,1,0) AVDictionary *m, @@ -627,8 +627,6 @@ ffmpeg_copy_metadata(struct tag *tag, while ((mt = av_metadata_get(m, tag_map.name, mt, 0)) != NULL) tag_add_item(tag, tag_map.type, mt->value); #endif - - return mt != NULL; } #endif -- cgit v1.2.3 From 001e2a604b396d613671132300972b41567e0262 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Feb 2012 09:02:14 +0100 Subject: decoder/ffmpeg: add macros emulating AVDictionary Move the #ifdefs out of _copy_metadata(). --- src/decoder/ffmpeg_decoder_plugin.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/decoder/ffmpeg_decoder_plugin.c') diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 29bf804f1..5d7f33bd7 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -607,26 +607,20 @@ static const ffmpeg_tag_map ffmpeg_tag_maps[] = { { TAG_DISC, "disc" }, }; -static void -ffmpeg_copy_metadata(struct tag *tag, -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,1,0) - AVDictionary *m, -#else - AVMetadata *m, +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,1,0) +#define AVDictionary AVMetadata +#define AVDictionaryEntry AVMetadataTag +#define av_dict_get av_metadata_get #endif + +static void +ffmpeg_copy_metadata(struct tag *tag, AVDictionary *m, const ffmpeg_tag_map tag_map) { -#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0) AVDictionaryEntry *mt = NULL; while ((mt = av_dict_get(m, tag_map.name, mt, 0)) != NULL) tag_add_item(tag, tag_map.type, mt->value); -#else - AVMetadataTag *mt = NULL; - - while ((mt = av_metadata_get(m, tag_map.name, mt, 0)) != NULL) - tag_add_item(tag, tag_map.type, mt->value); -#endif } #endif -- cgit v1.2.3 From 6357496d17a4fbcf8280ba721b5235567137eafc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Feb 2012 09:00:19 +0100 Subject: decoder/ffmpeg: merge code to _copy_dictionary() Eliminate some duplicate code. --- src/decoder/ffmpeg_decoder_plugin.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/decoder/ffmpeg_decoder_plugin.c') diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 5d7f33bd7..947241599 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -623,6 +623,13 @@ ffmpeg_copy_metadata(struct tag *tag, AVDictionary *m, tag_add_item(tag, tag_map.type, mt->value); } +static void +ffmpeg_copy_dictionary(struct tag *tag, AVDictionary *dict) +{ + for (unsigned i = 0; i < G_N_ELEMENTS(ffmpeg_tag_maps); i++) + ffmpeg_copy_metadata(tag, dict, ffmpeg_tag_maps[i]); +} + #endif //no tag reading in ffmpeg, check if playable @@ -671,12 +678,10 @@ ffmpeg_stream_tag(struct input_stream *is) av_metadata_conv(f, NULL, f->iformat->metadata_conv); #endif - for (unsigned i = 0; i < sizeof(ffmpeg_tag_maps)/sizeof(ffmpeg_tag_map); i++) { - int idx = ffmpeg_find_audio_stream(f); - ffmpeg_copy_metadata(tag, f->metadata, ffmpeg_tag_maps[i]); - if (idx >= 0) - ffmpeg_copy_metadata(tag, f->streams[idx]->metadata, ffmpeg_tag_maps[i]); - } + ffmpeg_copy_dictionary(tag, f->metadata); + int idx = ffmpeg_find_audio_stream(f); + if (idx >= 0) + ffmpeg_copy_dictionary(tag, f->streams[idx]->metadata); #else if (f->author[0]) tag_add_item(tag, TAG_ARTIST, f->author); -- cgit v1.2.3 From 4764daf3c29d22c2b21473612c1acfc55b1c4775 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Feb 2012 09:08:06 +0100 Subject: decoder/ffmpeg: pass tag_type and name to _copy_metadata() Allow using this function without the ffmpeg_tag_map struct. --- src/decoder/ffmpeg_decoder_plugin.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/decoder/ffmpeg_decoder_plugin.c') diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 947241599..0340e9506 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -614,20 +614,21 @@ static const ffmpeg_tag_map ffmpeg_tag_maps[] = { #endif static void -ffmpeg_copy_metadata(struct tag *tag, AVDictionary *m, - const ffmpeg_tag_map tag_map) +ffmpeg_copy_metadata(struct tag *tag, enum tag_type type, + AVDictionary *m, const char *name) { AVDictionaryEntry *mt = NULL; - while ((mt = av_dict_get(m, tag_map.name, mt, 0)) != NULL) - tag_add_item(tag, tag_map.type, mt->value); + while ((mt = av_dict_get(m, name, mt, 0)) != NULL) + tag_add_item(tag, type, mt->value); } static void ffmpeg_copy_dictionary(struct tag *tag, AVDictionary *dict) { for (unsigned i = 0; i < G_N_ELEMENTS(ffmpeg_tag_maps); i++) - ffmpeg_copy_metadata(tag, dict, ffmpeg_tag_maps[i]); + ffmpeg_copy_metadata(tag, ffmpeg_tag_maps[i].type, + dict, ffmpeg_tag_maps[i].name); } #endif -- cgit v1.2.3 From 378fa5ee6af1d127d4fa363de4af5294778e89cc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Feb 2012 09:07:31 +0100 Subject: decoder/ffmpeg: support all MPD tags Use the tag_item_names table to look up the names of all MPD tags, and remove the duplicate entries from ffmpeg_tag_maps. --- src/decoder/ffmpeg_decoder_plugin.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/decoder/ffmpeg_decoder_plugin.c') diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 0340e9506..2616d95c7 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -587,24 +587,13 @@ typedef struct ffmpeg_tag_map { } ffmpeg_tag_map; static const ffmpeg_tag_map ffmpeg_tag_maps[] = { - { TAG_TITLE, "title" }, -#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(50<<8)) - { TAG_ARTIST, "artist" }, - { TAG_DATE, "date" }, -#else +#if LIBAVFORMAT_VERSION_INT < ((52<<16)+(50<<8)) { TAG_ARTIST, "author" }, { TAG_DATE, "year" }, #endif - { TAG_ALBUM, "album" }, - { TAG_COMMENT, "comment" }, - { TAG_GENRE, "genre" }, - { TAG_TRACK, "track" }, { TAG_ARTIST_SORT, "author-sort" }, { TAG_ALBUM_ARTIST, "album_artist" }, { TAG_ALBUM_ARTIST_SORT, "album_artist-sort" }, - { TAG_COMPOSER, "composer" }, - { TAG_PERFORMER, "performer" }, - { TAG_DISC, "disc" }, }; #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,1,0) @@ -626,6 +615,10 @@ ffmpeg_copy_metadata(struct tag *tag, enum tag_type type, static void ffmpeg_copy_dictionary(struct tag *tag, AVDictionary *dict) { + for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) + ffmpeg_copy_metadata(tag, i, + dict, tag_item_names[i]); + for (unsigned i = 0; i < G_N_ELEMENTS(ffmpeg_tag_maps); i++) ffmpeg_copy_metadata(tag, ffmpeg_tag_maps[i].type, dict, ffmpeg_tag_maps[i].name); -- cgit v1.2.3 From 083340a9373537faacf67cc2ba8bc82238e104c4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Feb 2012 09:18:05 +0100 Subject: decoder/ffmpeg: use sentinel for the ffmpeg_tag_maps table Minor optimisation. --- src/decoder/ffmpeg_decoder_plugin.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/decoder/ffmpeg_decoder_plugin.c') diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 2616d95c7..b3c3744a1 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -594,6 +594,9 @@ static const ffmpeg_tag_map ffmpeg_tag_maps[] = { { TAG_ARTIST_SORT, "author-sort" }, { TAG_ALBUM_ARTIST, "album_artist" }, { TAG_ALBUM_ARTIST_SORT, "album_artist-sort" }, + + /* sentinel */ + { TAG_NUM_OF_ITEM_TYPES, NULL } }; #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,1,0) @@ -619,9 +622,9 @@ ffmpeg_copy_dictionary(struct tag *tag, AVDictionary *dict) ffmpeg_copy_metadata(tag, i, dict, tag_item_names[i]); - for (unsigned i = 0; i < G_N_ELEMENTS(ffmpeg_tag_maps); i++) - ffmpeg_copy_metadata(tag, ffmpeg_tag_maps[i].type, - dict, ffmpeg_tag_maps[i].name); + for (const struct ffmpeg_tag_map *i = ffmpeg_tag_maps; + i->name != NULL; ++i) + ffmpeg_copy_metadata(tag, i->type, dict, i->name); } #endif -- cgit v1.2.3 From 5d9876e33825e3ce526e480dc5311073078aba64 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Feb 2012 09:55:25 +0100 Subject: decoder/ffmpeg: use AV_SAMPLE_FMT_* if available Implements support for libavcodec 0.9, which removes the compatibility macros SAMPLE_FMT_* --- src/decoder/ffmpeg_decoder_plugin.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/decoder/ffmpeg_decoder_plugin.c') diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index b3c3744a1..52632dc4a 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -371,10 +371,18 @@ ffmpeg_sample_format(G_GNUC_UNUSED const AVCodecContext *codec_context) { #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(51, 41, 0) switch (codec_context->sample_fmt) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 94, 1) + case AV_SAMPLE_FMT_S16: +#else case SAMPLE_FMT_S16: +#endif return SAMPLE_FORMAT_S16; +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 94, 1) + case AV_SAMPLE_FMT_S32: +#else case SAMPLE_FMT_S32: +#endif return SAMPLE_FORMAT_S32; default: -- cgit v1.2.3