History

avfilter/vf_xmedian: add support for commands

Paul B Mahol committed 5 years ago

Commit 5b48d2a1 parent 4848eb42 files · +33 −4Browse files

Showing the changes to libavfilter (1 of 2 files). Show all

Unified · Split

libavfilter/vf_xmedian.c+25−4
@@ -344,13 +344,32 @@ static int activate(AVFilterContext *ctx) · 343 unmodified lines
344344 return ff_framesync_activate(&s->fs);
345345 }
346346
347+static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
348+ char *res, int res_len, int flags)
349+{
350+ XMedianContext *s = ctx->priv;
351+ int ret;
352+
353+ ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
354+ if (ret < 0)
355+ return ret;
356+
357+ if (s->nb_inputs & 1)
358+ s->index = s->radius * 2.f * s->percentile;
359+ else
360+ s->index = av_clip(s->radius * 2.f * s->percentile, 1, s->nb_inputs - 1);
361+
362+ return 0;
363+}
364+
347365 #define OFFSET(x) offsetof(XMedianContext, x)
348366 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
367+#define TFLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
349368
350369 static const AVOption xmedian_options[] = {
351370 { "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=3}, 3, 255, .flags = FLAGS },
352− { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=15}, 0, 15, .flags = FLAGS },
353− { "percentile", "set percentile", OFFSET(percentile),AV_OPT_TYPE_FLOAT,{.dbl=0.5}, 0, 1, .flags = FLAGS },
371+ { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=15}, 0, 15, .flags =TFLAGS },
372+ { "percentile", "set percentile", OFFSET(percentile),AV_OPT_TYPE_FLOAT,{.dbl=0.5}, 0, 1, .flags =TFLAGS },
354373 { NULL },
355374 };
356375
@@ -377,6 +396,7 @@ AVFilter ff_vf_xmedian = { · 20 unmodified lines
377396 .uninit = uninit,
378397 .activate = activate,
379398 .flags = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_SLICE_THREADS,
399+ .process_command = process_command,
380400 };
381401
382402 #endif /* CONFIG_XMEDIAN_FILTER */
@@ -422,8 +442,8 @@ static int tmedian_filter_frame(AVFilterLink *inlink, AVFrame *in) · 39 unmodified lines
422442
423443 static const AVOption tmedian_options[] = {
424444 { "radius", "set median filter radius", OFFSET(radius), AV_OPT_TYPE_INT, {.i64=1}, 1, 127, .flags = FLAGS },
425− { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=15}, 0, 15, .flags = FLAGS },
426− { "percentile", "set percentile", OFFSET(percentile), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, .flags = FLAGS },
445+ { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=15}, 0, 15, .flags =TFLAGS },
446+ { "percentile", "set percentile", OFFSET(percentile), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, .flags =TFLAGS },
427447 { NULL },
428448 };
429449
@@ -458,6 +478,7 @@ AVFilter ff_vf_tmedian = { · 28 unmodified lines
458478 .init = init,
459479 .uninit = uninit,
460480 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
481+ .process_command = process_command,
461482 };
462483
463484 #endif /* CONFIG_TMEDIAN_FILTER */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t