common/tags: add mp_tags_move_from_av_dictionary()

Abstracts a common pattern,
in which the av dictionary is cleared
immediately after copying to mp tags,
so that additional tags later in the stream
get appended to empty tags,
instead of being appended to existing tags
that were already copied.
This commit is contained in:
Claude Heiland-Allen 2023-10-11 12:02:32 +01:00 committed by sfan5
parent 02d009bc5c
commit a6d1c9dd0f
2 changed files with 9 additions and 0 deletions

View File

@ -142,3 +142,10 @@ void mp_tags_copy_from_av_dictionary(struct mp_tags *tags,
while ((entry = av_dict_get(av_dict, "", entry, AV_DICT_IGNORE_SUFFIX))) while ((entry = av_dict_get(av_dict, "", entry, AV_DICT_IGNORE_SUFFIX)))
mp_tags_set_str(tags, entry->key, entry->value); mp_tags_set_str(tags, entry->key, entry->value);
} }
void mp_tags_move_from_av_dictionary(struct mp_tags *tags,
struct AVDictionary **av_dict_ptr)
{
mp_tags_copy_from_av_dictionary(tags, *av_dict_ptr);
av_dict_free(av_dict_ptr);
}

View File

@ -25,5 +25,7 @@ void mp_tags_merge(struct mp_tags *tags, struct mp_tags *src);
struct AVDictionary; struct AVDictionary;
void mp_tags_copy_from_av_dictionary(struct mp_tags *tags, void mp_tags_copy_from_av_dictionary(struct mp_tags *tags,
struct AVDictionary *av_dict); struct AVDictionary *av_dict);
void mp_tags_move_from_av_dictionary(struct mp_tags *tags,
struct AVDictionary **av_dict_ptr);
#endif #endif