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(-) 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(-) 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(-) 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(-) 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. --- NEWS | 1 + src/decoder/ffmpeg_decoder_plugin.c | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index 8b2949a23..67d29a0e0 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ ver 0.16.7 (2011/??/??) - ffmpeg: support libavformat 0.7 * decoder: - ffmpeg: support libavformat 0.8, libavcodec 0.8 + - ffmpeg: support all MPD tags * output: - httpd: fix excessive buffering - openal: force 16 bit playback, as 8 bit doesn't work 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(-) 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_* --- NEWS | 2 +- src/decoder/ffmpeg_decoder_plugin.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 67d29a0e0..803428bd1 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ ver 0.16.7 (2011/??/??) * input: - ffmpeg: support libavformat 0.7 * decoder: - - ffmpeg: support libavformat 0.8, libavcodec 0.8 + - ffmpeg: support libavformat 0.8, libavcodec 0.9 - ffmpeg: support all MPD tags * output: - httpd: fix excessive buffering 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 From 5646dcc791c99439a321b7e73dffff2a60e47a16 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 13 Sep 2011 22:46:47 +0200 Subject: test/read_tags: initialize the tag_pool library --- test/read_tags.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/read_tags.c b/test/read_tags.c index 3e5e523bf..07d1afcba 100644 --- a/test/read_tags.c +++ b/test/read_tags.c @@ -24,6 +24,7 @@ #include "input_stream.h" #include "audio_format.h" #include "pcm_volume.h" +#include "tag_pool.h" #include "tag_ape.h" #include "tag_id3.h" #include "idle.h" @@ -164,6 +165,8 @@ int main(int argc, char **argv) decoder_name = argv[1]; path = argv[2]; + tag_pool_init(); + if (!input_stream_global_init(&error)) { g_warning("%s", error->message); g_error_free(error); @@ -215,5 +218,7 @@ int main(int argc, char **argv) } } + tag_pool_deinit(); + return 0; } -- cgit v1.2.3 From 48eb3ff8d993e4d6977898ccec1d9377b7397f16 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 4 Feb 2012 17:18:37 +0100 Subject: test/run_decoder: initialize the tag_pool library --- test/run_decoder.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/run_decoder.c b/test/run_decoder.c index c997ebf8f..8dbd53017 100644 --- a/test/run_decoder.c +++ b/test/run_decoder.c @@ -20,6 +20,7 @@ #include "config.h" #include "decoder_list.h" #include "decoder_api.h" +#include "tag_pool.h" #include "input_init.h" #include "input_stream.h" #include "audio_format.h" @@ -180,6 +181,8 @@ int main(int argc, char **argv) g_log_set_default_handler(my_log_func, NULL); + tag_pool_init(); + if (!input_stream_global_init(&error)) { g_warning("%s", error->message); g_error_free(error); @@ -228,5 +231,7 @@ int main(int argc, char **argv) return 1; } + tag_pool_deinit(); + return 0; } -- cgit v1.2.3