decoder/ffmpeg: optimize ffmpeg_scan_dictionary()

Don't scan tag items if the handler doesn't implement the tag()
method.
This commit is contained in:
Max Kellermann 2014-12-10 09:35:28 +01:00
parent 4fed0b991c
commit 923c402f69
1 changed files with 9 additions and 7 deletions

View File

@ -62,6 +62,7 @@ void
ffmpeg_scan_dictionary(AVDictionary *dict, ffmpeg_scan_dictionary(AVDictionary *dict,
const struct tag_handler *handler, void *handler_ctx) const struct tag_handler *handler, void *handler_ctx)
{ {
if (handler->tag != nullptr) {
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
ffmpeg_copy_metadata(TagType(i), dict, tag_item_names[i], ffmpeg_copy_metadata(TagType(i), dict, tag_item_names[i],
handler, handler_ctx); handler, handler_ctx);
@ -70,6 +71,7 @@ ffmpeg_scan_dictionary(AVDictionary *dict,
i->name != nullptr; ++i) i->name != nullptr; ++i)
ffmpeg_copy_metadata(i->type, dict, i->name, ffmpeg_copy_metadata(i->type, dict, i->name,
handler, handler_ctx); handler, handler_ctx);
}
if (handler->pair != nullptr) if (handler->pair != nullptr)
ffmpeg_scan_pairs(dict, handler, handler_ctx); ffmpeg_scan_pairs(dict, handler, handler_ctx);