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

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Sep 14 02:23:35 EEST 2021


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 at 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(-)

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);
-- 
2.30.2



More information about the ffmpeg-devel mailing list