1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

avformat/au: Store strings instead of pointers to strings in array

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt
2020-07-13 17:13:51 +02:00
parent fa8345cf05
commit 8d3556b7a3

View File

@@ -68,13 +68,13 @@ static int au_probe(const AVProbeData *p)
static int au_read_annotation(AVFormatContext *s, int size) static int au_read_annotation(AVFormatContext *s, int size)
{ {
static const char * keys[] = { static const char keys[][7] = {
"title", "title",
"artist", "artist",
"album", "album",
"track", "track",
"genre", "genre",
NULL }; };
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
enum { PARSE_KEY, PARSE_VALUE, PARSE_FINISHED } state = PARSE_KEY; enum { PARSE_KEY, PARSE_VALUE, PARSE_FINISHED } state = PARSE_KEY;
char c; char c;
@@ -107,7 +107,7 @@ static int au_read_annotation(AVFormatContext *s, int size)
av_log(s, AV_LOG_ERROR, "Memory error while parsing AU metadata.\n"); av_log(s, AV_LOG_ERROR, "Memory error while parsing AU metadata.\n");
} else { } else {
av_bprint_init(&bprint, 64, AV_BPRINT_SIZE_UNLIMITED); av_bprint_init(&bprint, 64, AV_BPRINT_SIZE_UNLIMITED);
for (i = 0; keys[i] != NULL && key != NULL; i++) { for (i = 0; i < FF_ARRAY_ELEMS(keys) && key != NULL; i++) {
if (av_strcasecmp(keys[i], key) == 0) { if (av_strcasecmp(keys[i], key) == 0) {
av_dict_set(&(s->metadata), keys[i], value, AV_DICT_DONT_STRDUP_VAL); av_dict_set(&(s->metadata), keys[i], value, AV_DICT_DONT_STRDUP_VAL);
av_freep(&key); av_freep(&key);
@@ -243,14 +243,13 @@ typedef struct AUContext {
static int au_get_annotations(AVFormatContext *s, char **buffer) static int au_get_annotations(AVFormatContext *s, char **buffer)
{ {
static const char * keys[] = { static const char keys[][7] = {
"Title", "Title",
"Artist", "Artist",
"Album", "Album",
"Track", "Track",
"Genre", "Genre",
NULL }; };
int i;
int cnt = 0; int cnt = 0;
AVDictionary *m = s->metadata; AVDictionary *m = s->metadata;
AVDictionaryEntry *t = NULL; AVDictionaryEntry *t = NULL;
@@ -258,7 +257,7 @@ static int au_get_annotations(AVFormatContext *s, char **buffer)
av_bprint_init(&bprint, 64, AV_BPRINT_SIZE_UNLIMITED); av_bprint_init(&bprint, 64, AV_BPRINT_SIZE_UNLIMITED);
for (i = 0; keys[i] != NULL; i++) { for (int i = 0; i < FF_ARRAY_ELEMS(keys); i++) {
t = av_dict_get(m, keys[i], NULL, 0); t = av_dict_get(m, keys[i], NULL, 0);
if (t != NULL) { if (t != NULL) {
if (cnt++) if (cnt++)