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
344 return ff_framesync_activate(&s->fs);344 return ff_framesync_activate(&s->fs);
345}345}
346 346
347static 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
347#define OFFSET(x) offsetof(XMedianContext, x)365#define OFFSET(x) offsetof(XMedianContext, x)
348#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM366#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
349 368
350static const AVOption xmedian_options[] = {369static const AVOption xmedian_options[] = {
351 { "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=3}, 3, 255, .flags = FLAGS },370 { "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 },371 { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=15}, 0, 15, .flags =TFLAGS },
353 { "percentile", "set percentile", OFFSET(percentile),AV_OPT_TYPE_FLOAT,{.dbl=0.5}, 0, 1, .flags = FLAGS },372 { "percentile", "set percentile", OFFSET(percentile),AV_OPT_TYPE_FLOAT,{.dbl=0.5}, 0, 1, .flags =TFLAGS },
354 { NULL },373 { NULL },
355};374};
356 375
@@ -377,6 +396,7 @@ AVFilter ff_vf_xmedian = { · 20 unmodified lines
377 .uninit = uninit,396 .uninit = uninit,
378 .activate = activate,397 .activate = activate,
379 .flags = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_SLICE_THREADS,398 .flags = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_SLICE_THREADS,
399 .process_command = process_command,
380};400};
381 401
382#endif /* CONFIG_XMEDIAN_FILTER */402#endif /* CONFIG_XMEDIAN_FILTER */
@@ -422,8 +442,8 @@ static int tmedian_filter_frame(AVFilterLink *inlink, AVFrame *in) · 39 unmodified lines
422 442
423static const AVOption tmedian_options[] = {443static const AVOption tmedian_options[] = {
424 { "radius", "set median filter radius", OFFSET(radius), AV_OPT_TYPE_INT, {.i64=1}, 1, 127, .flags = FLAGS },444 { "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 },445 { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=15}, 0, 15, .flags =TFLAGS },
426 { "percentile", "set percentile", OFFSET(percentile), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, .flags = FLAGS },446 { "percentile", "set percentile", OFFSET(percentile), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, .flags =TFLAGS },
427 { NULL },447 { NULL },
428};448};
429 449
@@ -458,6 +478,7 @@ AVFilter ff_vf_tmedian = { · 28 unmodified lines
458 .init = init,478 .init = init,
459 .uninit = uninit,479 .uninit = uninit,
460 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,480 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
481 .process_command = process_command,
461};482};
462 483
463#endif /* CONFIG_TMEDIAN_FILTER */484#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