diff mbox series

[FFmpeg-devel,23/38] avfilter/avfilter: Remove redundant parsing code

Message ID AM7PR03MB6660E7B12BD1BB30FB6AE3CC8FD89@AM7PR03MB6660.eurprd03.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel,01/39] avfilter/vf_maskedminmax: Simplify init | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 fail Make fate failed
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 12, 2021, 10:53 a.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 all unrecognized options are reported
before erroring out in case there are unrecognized options, whereas
the current code stops after the first such option.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavfilter/avfilter.c | 18 ------------------
 1 file changed, 18 deletions(-)

Comments

Paul B Mahol Sept. 13, 2021, 11:49 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);