void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv, const AVMetadataConv *s_conv) { /* TODO: use binary search to look up the two conversion tables if the tables are getting big enough that it would matter speed wise */ const AVMetadataConv *sc, *dc; AVDictionaryEntry *mtag = NULL, *tag; AVDictionary *dst = NULL; const char *key; if (d_conv == s_conv) return; while ((mtag = av_dict_get(*pm, "", mtag, AV_DICT_IGNORE_SUFFIX))) { key = mtag->key; if (s_conv) for (sc=s_conv; sc->native; sc++) if (!strcasecmp(key, sc->native)) { key = sc->generic; break; } if (d_conv) for (dc=d_conv; dc->native; dc++) if (!strcasecmp(key, dc->generic)) { key = dc->native; break; } av_dict_set_custom(&dst, &tag, mtag->type, key, mtag->value, mtag->len, 0); av_metadata_copy_attributes(tag, mtag); } av_dict_free(pm); *pm = dst; }
void av_metadata_copy(AVMetadata **dst, AVMetadata *src, int flags) { AVMetadataTag *t = NULL, *tag; while ((t = av_metadata_get(src, "", t, AV_METADATA_IGNORE_SUFFIX))) { av_metadata_set_custom(dst, &tag, t->type, t->key, t->value, t->len, flags); if (tag) av_metadata_copy_attributes(tag, t); } }