diff options
author | Kevin Mitchell <kevmitch@gmail.com> | 2017-12-23 19:14:16 -0700 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2017-12-26 03:33:18 -0700 |
commit | e2f71f509fde010e4d0f175014fd4219b7dc7681 (patch) | |
tree | e424fe1f86c79f5288b50b72996c4603756419e0 /common/tags.c | |
parent | e530783cdbdd95500aa86cfbcbfe005f6e0f5f41 (diff) | |
download | mpv-e2f71f509fde010e4d0f175014fd4219b7dc7681.tar.bz2 mpv-e2f71f509fde010e4d0f175014fd4219b7dc7681.tar.xz |
tags: add mp_tags_remove
This removes all tags matching the provided key. This will be used for removing
metadata tags during encoding.
Diffstat (limited to 'common/tags.c')
-rw-r--r-- | common/tags.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/common/tags.c b/common/tags.c index 29459d09e3..ffedab9b24 100644 --- a/common/tags.c +++ b/common/tags.c @@ -18,6 +18,7 @@ #include <stddef.h> #include <limits.h> #include <strings.h> +#include <assert.h> #include <libavutil/dict.h> #include "tags.h" #include "misc/bstr.h" @@ -44,6 +45,24 @@ void mp_tags_set_bstr(struct mp_tags *tags, bstr key, bstr value) tags->num_keys++; } +void mp_tags_remove_str(struct mp_tags *tags, const char *key) +{ + mp_tags_remove_bstr(tags, bstr0(key)); +} + +void mp_tags_remove_bstr(struct mp_tags *tags, bstr key) +{ + for (int n = 0; n < tags->num_keys; n++) { + if (bstrcasecmp0(key, tags->keys[n]) == 0) { + talloc_free(tags->keys[n]); + talloc_free(tags->values[n]); + int num_keys = tags->num_keys; // copy so it's only decremented once + MP_TARRAY_REMOVE_AT(tags->keys, num_keys, n); + MP_TARRAY_REMOVE_AT(tags->values, tags->num_keys, n); + } + } +} + char *mp_tags_get_str(struct mp_tags *tags, const char *key) { return mp_tags_get_bstr(tags, bstr0(key)); |