diff mbox series

[FFmpeg-devel,2/2] avfilter: handle duplicates in the options string

Message ID 20220315085812.13916-2-anton@khirnov.net
State Accepted
Commit 1b7ecb3eef260da0f5cdcc295ae87c0cf777966a
Headers show
Series [FFmpeg-devel,1/2] avfilter: simplify processing child context options | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Anton Khirnov March 15, 2022, 8:58 a.m. UTC
Use the same logic as fftools/cmdutils - when a flag-type option starts
with [+-], append it to the existing value.
---
 libavfilter/avfilter.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 030f1823ee..a6f2181efb 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -860,13 +860,17 @@  static int process_options(AVFilterContext *ctx, AVDictionary **options,
                 return ret;
             }
         } else {
-            av_dict_set(options, key, value, 0);
-            if (!av_opt_find(ctx->priv, key, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) {
+            o = av_opt_find(ctx->priv, key, NULL, 0,
+                            AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
+            if (!o) {
                 av_log(ctx, AV_LOG_ERROR, "Option '%s' not found\n", key);
                 av_free(value);
                 av_free(parsed_key);
                 return AVERROR_OPTION_NOT_FOUND;
             }
+            av_dict_set(options, key, value,
+                        (o->type == AV_OPT_TYPE_FLAGS &&
+                         (value[0] == '-' || value[0] == '+')) ? AV_DICT_APPEND : 0);
         }
 
         av_free(value);