swscale/tests/swscale: parse flags from string

We don't actually have an SwsContext yet at this point, so just use
AV_OPT_SEARCH_FAKE_OBJ. For the actual evaluation, the signature only
requires that we pass a "pointer to a struct that contains an AVClass as
its first member", so passing a double pointer to the class itself is
sufficient.
This commit is contained in:
Niklas Haas
2025-12-08 17:26:09 +01:00
parent fba9fc0c6b
commit ea791a4ef1
2 changed files with 11 additions and 2 deletions

View File

@@ -509,6 +509,11 @@ int main(int argc, char **argv)
AVLFG rand;
int ret = -1;
const AVClass *sws_class = sws_get_class();
const AVOption *flags_opt = av_opt_find(&sws_class, "sws_flags", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ);
av_assert0(flags_opt);
for (int i = 1; i < argc; i += 2) {
if (!strcmp(argv[i], "-help") || !strcmp(argv[i], "--help")) {
fprintf(stderr,
@@ -576,7 +581,11 @@ int main(int argc, char **argv)
opts.w = 1920;
opts.h = 1080;
} else if (!strcmp(argv[i], "-flags")) {
opts.flags = strtol(argv[i + 1], NULL, 0);
ret = av_opt_eval_flags(&sws_class, flags_opt, argv[i + 1], &opts.flags);
if (ret < 0) {
fprintf(stderr, "invalid flags %s\n", argv[i + 1]);
goto error;
}
} else if (!strcmp(argv[i], "-dither")) {
opts.dither = atoi(argv[i + 1]);
} else if (!strcmp(argv[i], "-unscaled")) {

View File

@@ -34,7 +34,7 @@ fate-sws-yuv-range: CMD = framecrc \
# This self-check currently fails for legacy swscale, so pass SWS_UNSTABLE to use the new code
FATE_LIBSWSCALE-$(CONFIG_UNSTABLE) += fate-sws-unscaled
fate-sws-unscaled: libswscale/tests/swscale$(EXESUF)
fate-sws-unscaled: CMD = run libswscale/tests/swscale$(EXESUF) -unscaled 1 -flags 0x100000 -v 16
fate-sws-unscaled: CMD = run libswscale/tests/swscale$(EXESUF) -unscaled 1 -flags unstable -v 16
FATE_LIBSWSCALE-$(CONFIG_UNSTABLE) += fate-sws-ops-list
fate-sws-ops-list: libswscale/tests/sws_ops$(EXESUF)