diff mbox series

[FFmpeg-devel,v2,10/14] avfilter/avfilter: Remove redundant parsing code

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

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
avfilter_init_str() (via process_options()) both applies options
extracted from the given string directly to the relevant (private)
context as well as to an AVDictionary that is later given to
avfilter_init_dict() which applies these options again. This is
unnecessary, so leave applying the options to avfilter_init_dict();
this also has the advantage that it will be possible to report
all unrecognized options before erroring out in case of unrecognized
options, whereas the current code automatically stops after the first
such option.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
The reason I am resending this is that most filters using init_dict
ignored its requirements; without the preceding patches fixing them
the scaling filters init function would succeed, but one would get
an error message lateron in case of unrecognized options.

 libavfilter/avfilter.c | 18 ------------------
 1 file changed, 18 deletions(-)

Comments

Paul B Mahol Sept. 14, 2021, 5:38 a.m. UTC | #1
lgtm
diff mbox series

Patch

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index c614eb0740..11d4e01807 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -853,25 +853,7 @@  static int process_options(AVFilterContext *ctx, AVDictionary **options,
 
         av_log(ctx, AV_LOG_DEBUG, "Setting '%s' to value '%s'\n", key, value);
 
-        if (av_opt_find(ctx, key, NULL, 0, 0)) {
-            ret = av_opt_set(ctx, key, value, 0);
-            if (ret < 0) {
-                av_free(value);
-                av_free(parsed_key);
-                return ret;
-            }
-        } else {
             av_dict_set(options, key, value, 0);
-            if ((ret = av_opt_set(ctx->priv, key, value, AV_OPT_SEARCH_CHILDREN)) < 0) {
-                if (!av_opt_find(ctx->priv, key, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) {
-                    if (ret == AVERROR_OPTION_NOT_FOUND)
-                        av_log(ctx, AV_LOG_ERROR, "Option '%s' not found\n", key);
-                    av_free(value);
-                    av_free(parsed_key);
-                    return ret;
-                }
-            }
-        }
 
         av_free(value);
         av_free(parsed_key);