1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-13 21:28:01 +02:00

avformat/utils: Remove duplicated AV_DISPOSITION_FOO <-> "foo" table

Instead reuse stream_options.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2021-11-18 07:19:58 +01:00
parent 17c8533745
commit 53c8b16c19

View File

@ -1985,34 +1985,17 @@ void ff_format_set_url(AVFormatContext *s, char *url)
s->url = url; s->url = url;
} }
static const struct { static int option_is_disposition(const AVOption *opt)
const char *str; {
int disposition; return opt->type == AV_OPT_TYPE_CONST &&
} dispositions[] = { opt->unit && !strcmp(opt->unit, "disposition");
{ "default", AV_DISPOSITION_DEFAULT }, }
{ "dub", AV_DISPOSITION_DUB },
{ "original", AV_DISPOSITION_ORIGINAL },
{ "comment", AV_DISPOSITION_COMMENT },
{ "lyrics", AV_DISPOSITION_LYRICS },
{ "karaoke", AV_DISPOSITION_KARAOKE },
{ "forced", AV_DISPOSITION_FORCED },
{ "hearing_impaired", AV_DISPOSITION_HEARING_IMPAIRED },
{ "visual_impaired", AV_DISPOSITION_VISUAL_IMPAIRED },
{ "clean_effects", AV_DISPOSITION_CLEAN_EFFECTS },
{ "attached_pic", AV_DISPOSITION_ATTACHED_PIC },
{ "timed_thumbnails", AV_DISPOSITION_TIMED_THUMBNAILS },
{ "captions", AV_DISPOSITION_CAPTIONS },
{ "descriptions", AV_DISPOSITION_DESCRIPTIONS },
{ "metadata", AV_DISPOSITION_METADATA },
{ "dependent", AV_DISPOSITION_DEPENDENT },
{ "still_image", AV_DISPOSITION_STILL_IMAGE },
};
int av_disposition_from_string(const char *disp) int av_disposition_from_string(const char *disp)
{ {
for (int i = 0; i < FF_ARRAY_ELEMS(dispositions); i++) for (const AVOption *opt = stream_options; opt->name; opt++)
if (!strcmp(disp, dispositions[i].str)) if (option_is_disposition(opt) && !strcmp(disp, opt->name))
return dispositions[i].disposition; return opt->default_val.i64;
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
@ -2024,9 +2007,9 @@ const char *av_disposition_to_string(int disposition)
return NULL; return NULL;
val = 1 << ff_ctz(disposition); val = 1 << ff_ctz(disposition);
for (int i = 0; i < FF_ARRAY_ELEMS(dispositions); i++) for (const AVOption *opt = stream_options; opt->name; opt++)
if (dispositions[i].disposition == val) if (option_is_disposition(opt) && opt->default_val.i64 == val)
return dispositions[i].str; return opt->name;
return NULL; return NULL;
} }