Message ID | 20210903125222.591-1-jamrial@gmail.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] ffmpeg: allow to pass "auto" to filter_threads | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
James Almer: > This way it accepts the same values as the libavcodec specific option "threads" > > Fixes FATE with THREADS=auto which was broken in bdc1bdf3f5 > > Signed-off-by: James Almer <jamrial@gmail.com> > --- > fftools/ffmpeg_opt.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c > index 428934a3d8..2a0b3fbd4f 100644 > --- a/fftools/ffmpeg_opt.c > +++ b/fftools/ffmpeg_opt.c > @@ -264,6 +264,24 @@ static AVDictionary *strip_specifiers(AVDictionary *dict) > return ret; > } > > +static int opt_filter_threads(void *optctx, const char *opt, const char *arg) > +{ > + static const AVOption opts[] = { > + { "filter_threads", NULL, 0, AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, .unit = "filter_threads"}, > + { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, .unit = "filter_threads"}, > + { NULL }, > + }; > + static const AVClass class = { > + .class_name = "", > + .item_name = av_default_item_name, > + .option = opts, > + .version = LIBAVUTIL_VERSION_INT, > + }; > + const AVClass *pclass = &class; > + > + return av_opt_eval_int(&pclass, &opts[0], arg, &filter_nbthreads); > +} > + > static int opt_abort_on(void *optctx, const char *opt, const char *arg) > { > static const AVOption opts[] = { > @@ -3620,7 +3638,7 @@ const OptionDef options[] = { > "set profile", "profile" }, > { "filter", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filters) }, > "set stream filtergraph", "filter_graph" }, > - { "filter_threads", HAS_ARG | OPT_INT, { &filter_nbthreads }, > + { "filter_threads", HAS_ARG, { .func_arg = opt_filter_threads }, > "number of non-complex filter threads" }, > { "filter_script", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filter_scripts) }, > "read stream filtergraph description from a file", "filename" }, > Why aren't you using the same approach as in libavcodec and accept "auto" in libavfilter via a dedicated AV_OPT_TYPE_CONST? - Andreas
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 428934a3d8..2a0b3fbd4f 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -264,6 +264,24 @@ static AVDictionary *strip_specifiers(AVDictionary *dict) return ret; } +static int opt_filter_threads(void *optctx, const char *opt, const char *arg) +{ + static const AVOption opts[] = { + { "filter_threads", NULL, 0, AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, .unit = "filter_threads"}, + { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, .unit = "filter_threads"}, + { NULL }, + }; + static const AVClass class = { + .class_name = "", + .item_name = av_default_item_name, + .option = opts, + .version = LIBAVUTIL_VERSION_INT, + }; + const AVClass *pclass = &class; + + return av_opt_eval_int(&pclass, &opts[0], arg, &filter_nbthreads); +} + static int opt_abort_on(void *optctx, const char *opt, const char *arg) { static const AVOption opts[] = { @@ -3620,7 +3638,7 @@ const OptionDef options[] = { "set profile", "profile" }, { "filter", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filters) }, "set stream filtergraph", "filter_graph" }, - { "filter_threads", HAS_ARG | OPT_INT, { &filter_nbthreads }, + { "filter_threads", HAS_ARG, { .func_arg = opt_filter_threads }, "number of non-complex filter threads" }, { "filter_script", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filter_scripts) }, "read stream filtergraph description from a file", "filename" },
This way it accepts the same values as the libavcodec specific option "threads" Fixes FATE with THREADS=auto which was broken in bdc1bdf3f5 Signed-off-by: James Almer <jamrial@gmail.com> --- fftools/ffmpeg_opt.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)