You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
lavu/dict: add AV_DICT_DEDUP
This is useful when multiple metadata inputs may set the same value (e.g. both a container-specific header and an ID3 tag). Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
committed by
Michael Niedermayer
parent
779cbc2b97
commit
19e9a203b7
@ -101,6 +101,17 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
|
|||||||
}
|
}
|
||||||
if (!(flags & AV_DICT_MULTIKEY)) {
|
if (!(flags & AV_DICT_MULTIKEY)) {
|
||||||
tag = av_dict_get(m, key, NULL, flags);
|
tag = av_dict_get(m, key, NULL, flags);
|
||||||
|
} else if (flags & AV_DICT_DEDUP) {
|
||||||
|
while ((tag = av_dict_get(m, key, tag, flags))) {
|
||||||
|
if ((!value && !tag->value) ||
|
||||||
|
(value && tag->value && !strcmp(value, tag->value))) {
|
||||||
|
if (flags & AV_DICT_DONT_STRDUP_KEY)
|
||||||
|
av_free((void*)key);
|
||||||
|
if (flags & AV_DICT_DONT_STRDUP_VAL)
|
||||||
|
av_free((void*)value);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (flags & AV_DICT_DONT_STRDUP_KEY)
|
if (flags & AV_DICT_DONT_STRDUP_KEY)
|
||||||
copy_key = (void *)key;
|
copy_key = (void *)key;
|
||||||
|
@ -82,6 +82,7 @@
|
|||||||
#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no
|
#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no
|
||||||
delimiter is added, the strings are simply concatenated. */
|
delimiter is added, the strings are simply concatenated. */
|
||||||
#define AV_DICT_MULTIKEY 64 /**< Allow to store several equal keys in the dictionary */
|
#define AV_DICT_MULTIKEY 64 /**< Allow to store several equal keys in the dictionary */
|
||||||
|
#define AV_DICT_DEDUP 128 /**< If inserting a value that already exists for a key, do nothing. Only relevant with AV_DICT_MULTIKEY. */
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user