]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_limiter: add support for commands
authorPaul B Mahol <onemda@gmail.com>
Tue, 15 Dec 2020 19:31:25 +0000 (20:31 +0100)
committerPaul B Mahol <onemda@gmail.com>
Tue, 15 Dec 2020 19:35:01 +0000 (20:35 +0100)
doc/filters.texi
libavfilter/vf_limiter.c

index 89244dc543c11042774bab399bac40928a2714c4..62e34b99ee334ece748bee21c76814f5794863d0 100644 (file)
@@ -13551,6 +13551,10 @@ Upper bound. Defaults to the highest allowed value for the input.
 Specify which planes will be processed. Defaults to all available.
 @end table
 
+@subsection Commands
+
+This filter supports the all above options as @ref{commands}.
+
 @section loop
 
 Loop video frames.
index 8db28fee6453e66e995bba41e4930a092d9763ba..1779c63944ef344fe0aa94490c1a08f89451bba9 100644 (file)
@@ -46,7 +46,7 @@ typedef struct LimiterContext {
 } LimiterContext;
 
 #define OFFSET(x) offsetof(LimiterContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
 static const AVOption limiter_options[] = {
     { "min",    "set min value", OFFSET(min),    AV_OPT_TYPE_INT, {.i64=0},     0, 65535, .flags = FLAGS },
@@ -133,7 +133,7 @@ static void limiter16(const uint8_t *ssrc, uint8_t *ddst,
     }
 }
 
-static int config_props(AVFilterLink *inlink)
+static int config_input(AVFilterLink *inlink)
 {
     AVFilterContext *ctx = inlink->dst;
     LimiterContext *s = ctx->priv;
@@ -230,12 +230,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     return ff_filter_frame(outlink, out);
 }
 
+static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
+                           char *res, int res_len, int flags)
+{
+    int ret;
+
+    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
+    if (ret < 0)
+        return ret;
+
+    return config_input(ctx->inputs[0]);
+}
+
 static const AVFilterPad inputs[] = {
     {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
         .filter_frame = filter_frame,
-        .config_props = config_props,
+        .config_props = config_input,
     },
     { NULL }
 };
@@ -258,4 +270,5 @@ AVFilter ff_vf_limiter = {
     .inputs        = inputs,
     .outputs       = outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
+    .process_command = process_command,
 };