diff mbox series

[FFmpeg-devel,v2,13/14] avfilter/avfilter: Don't fail upon options for filter without AVClass

Message ID AM7PR03MB6660B0FD89B6A3BE25C451878FD99@AM7PR03MB6660.eurprd03.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel,v2,01/14] avfilter/vsrc_testsrc: Deduplicate AVClasses
Related show

Checks

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

Commit Message

Andreas Rheinhardt Sept. 13, 2021, 11:23 p.m. UTC
Commit 62549f9655c48f0ec061087fa33a96040ce01145 added a check to
(the predecessor of) avfilter_init_str() to error out if options
were provided to a filter without options (or rather, without private
class). This was fine at the time, yet soon afterwards commit
fdd93eabfb2644f541f7aac9943abce26776ea73 added a generic option
for all AVFilterContexts and since then it is wrong to error out
in case options have been provided to a filter without AVClass.

To workaround this issue, several filters with timeline support
added AVClasses and empty options; these will be removed in subsequent
commits. Furthermore, the super2xsai filter supports slice threading,
but no options and so has no AVClass, making it impossible to set
the number of threads when using avfilter_init_str() (and therefore
from the ffmpeg-tool). This is fixed by this commit, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Now with a comment explaining the two functions of checking for priv.

 libavfilter/avfilter.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Nicolas George Sept. 16, 2021, 12:57 p.m. UTC | #1
Andreas Rheinhardt (12021-09-14):
> Commit 62549f9655c48f0ec061087fa33a96040ce01145 added a check to
> (the predecessor of) avfilter_init_str() to error out if options
> were provided to a filter without options (or rather, without private
> class). This was fine at the time, yet soon afterwards commit
> fdd93eabfb2644f541f7aac9943abce26776ea73 added a generic option
> for all AVFilterContexts and since then it is wrong to error out
> in case options have been provided to a filter without AVClass.
> 
> To workaround this issue, several filters with timeline support
> added AVClasses and empty options; these will be removed in subsequent
> commits. Furthermore, the super2xsai filter supports slice threading,
> but no options and so has no AVClass, making it impossible to set
> the number of threads when using avfilter_init_str() (and therefore
> from the ffmpeg-tool). This is fixed by this commit, too.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> Now with a comment explaining the two functions of checking for priv.
> 
>  libavfilter/avfilter.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)

Ok, I suppose.

Regards,
diff mbox series

Patch

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 165ab1f44a..4971ad9d9f 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -825,6 +825,9 @@  static int process_options(AVFilterContext *ctx, AVDictionary **options,
         const char *shorthand = NULL;
         int flags = AV_DICT_DONT_STRDUP_VAL;
 
+        /* Besides ensuring that shorthand options after long options
+         * are rejected checking for priv also ensures that we don't call
+         * av_opt_next when ctx->priv is not AVOpt-enabled. */
         if (priv && (o = av_opt_next(ctx->priv, o))) {
             if (o->type == AV_OPT_TYPE_CONST || o->offset == offset)
                 continue;
@@ -922,12 +925,6 @@  int avfilter_init_str(AVFilterContext *filter, const char *args)
     int ret = 0;
 
     if (args && *args) {
-        if (!filter->filter->priv_class) {
-            av_log(filter, AV_LOG_ERROR, "This filter does not take any "
-                   "options, but options were provided: %s.\n", args);
-            return AVERROR(EINVAL);
-        }
-
         ret = process_options(filter, &options, args);
         if (ret < 0)
             goto fail;