[FFmpeg-cvslog] avformat/utils: Remove duplicated AV_DISPOSITION_FOO <-> "foo" table
Andreas Rheinhardt
git at videolan.org
Fri Nov 19 22:10:03 EET 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Nov 18 07:19:58 2021 +0100| [53c8b16c19bfda815ec7bcad3ad3c5548b53d8d5] | committer: Andreas Rheinhardt
avformat/utils: Remove duplicated AV_DISPOSITION_FOO <-> "foo" table
Instead reuse stream_options.
Reviewed-by: Anton Khirnov <anton at khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=53c8b16c19bfda815ec7bcad3ad3c5548b53d8d5
---
libavformat/utils.c | 39 +++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6eac3f721e..7840e8717c 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1985,34 +1985,17 @@ void ff_format_set_url(AVFormatContext *s, char *url)
s->url = url;
}
-static const struct {
- const char *str;
- int disposition;
-} dispositions[] = {
- { "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 },
-};
+static int option_is_disposition(const AVOption *opt)
+{
+ return opt->type == AV_OPT_TYPE_CONST &&
+ opt->unit && !strcmp(opt->unit, "disposition");
+}
int av_disposition_from_string(const char *disp)
{
- for (int i = 0; i < FF_ARRAY_ELEMS(dispositions); i++)
- if (!strcmp(disp, dispositions[i].str))
- return dispositions[i].disposition;
+ for (const AVOption *opt = stream_options; opt->name; opt++)
+ if (option_is_disposition(opt) && !strcmp(disp, opt->name))
+ return opt->default_val.i64;
return AVERROR(EINVAL);
}
@@ -2024,9 +2007,9 @@ const char *av_disposition_to_string(int disposition)
return NULL;
val = 1 << ff_ctz(disposition);
- for (int i = 0; i < FF_ARRAY_ELEMS(dispositions); i++)
- if (dispositions[i].disposition == val)
- return dispositions[i].str;
+ for (const AVOption *opt = stream_options; opt->name; opt++)
+ if (option_is_disposition(opt) && opt->default_val.i64 == val)
+ return opt->name;
return NULL;
}
More information about the ffmpeg-cvslog
mailing list