Commit 6357496d authored by Max Kellermann's avatar Max Kellermann

decoder/ffmpeg: merge code to _copy_dictionary()

Eliminate some duplicate code.
parent 001e2a60
...@@ -623,6 +623,13 @@ ffmpeg_copy_metadata(struct tag *tag, AVDictionary *m, ...@@ -623,6 +623,13 @@ ffmpeg_copy_metadata(struct tag *tag, AVDictionary *m,
tag_add_item(tag, tag_map.type, mt->value); 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 #endif
//no tag reading in ffmpeg, check if playable //no tag reading in ffmpeg, check if playable
...@@ -671,12 +678,10 @@ ffmpeg_stream_tag(struct input_stream *is) ...@@ -671,12 +678,10 @@ ffmpeg_stream_tag(struct input_stream *is)
av_metadata_conv(f, NULL, f->iformat->metadata_conv); av_metadata_conv(f, NULL, f->iformat->metadata_conv);
#endif #endif
for (unsigned i = 0; i < sizeof(ffmpeg_tag_maps)/sizeof(ffmpeg_tag_map); i++) { ffmpeg_copy_dictionary(tag, f->metadata);
int idx = ffmpeg_find_audio_stream(f); int idx = ffmpeg_find_audio_stream(f);
ffmpeg_copy_metadata(tag, f->metadata, ffmpeg_tag_maps[i]); if (idx >= 0)
if (idx >= 0) ffmpeg_copy_dictionary(tag, f->streams[idx]->metadata);
ffmpeg_copy_metadata(tag, f->streams[idx]->metadata, ffmpeg_tag_maps[i]);
}
#else #else
if (f->author[0]) if (f->author[0])
tag_add_item(tag, TAG_ARTIST, f->author); tag_add_item(tag, TAG_ARTIST, f->author);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment