Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -344,13 +344,32 @@ static int activate(AVFilterContext *ctx) · 343 unmodified lines | ||
| 344 | 344 | return ff_framesync_activate(&s->fs); |
| 345 | 345 | } |
| 346 | 346 | |
| 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 | + | |
| 347 | 365 | #define OFFSET(x) offsetof(XMedianContext, x) |
| 348 | 366 | #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 | |
| 350 | 369 | static const AVOption xmedian_options[] = { |
| 351 | 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 }, | |
| 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 }, | |
| 354 | 373 | { NULL }, |
| 355 | 374 | }; |
| 356 | 375 | |
| @@ -377,6 +396,7 @@ AVFilter ff_vf_xmedian = { · 20 unmodified lines | ||
| 377 | 396 | .uninit = uninit, |
| 378 | 397 | .activate = activate, |
| 379 | 398 | .flags = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_SLICE_THREADS, |
| 399 | + .process_command = process_command, | |
| 380 | 400 | }; |
| 381 | 401 | |
| 382 | 402 | #endif /* CONFIG_XMEDIAN_FILTER */ |
| @@ -422,8 +442,8 @@ static int tmedian_filter_frame(AVFilterLink *inlink, AVFrame *in) · 39 unmodified lines | ||
| 422 | 442 | |
| 423 | 443 | static const AVOption tmedian_options[] = { |
| 424 | 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 }, | |
| 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 }, | |
| 427 | 447 | { NULL }, |
| 428 | 448 | }; |
| 429 | 449 | |
| @@ -458,6 +478,7 @@ AVFilter ff_vf_tmedian = { · 28 unmodified lines | ||
| 458 | 478 | .init = init, |
| 459 | 479 | .uninit = uninit, |
| 460 | 480 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS, |
| 481 | + .process_command = process_command, | |
| 461 | 482 | }; |
| 462 | 483 | |
| 463 | 484 | #endif /* CONFIG_TMEDIAN_FILTER */ |