avfilter/vf_median: implement percentile option

This commit is contained in:
Paul B Mahol 2020-02-12 11:25:25 +01:00
parent d9751a1162
commit 28743f1803
3 changed files with 8 additions and 1 deletions

View File

@ -13289,6 +13289,11 @@ Set which planes to process. Default is @code{15}, which is all available planes
Set vertical radius size. Default value is @code{0}.
Allowed range is integer from 0 to 127.
If it is 0, value will be picked from horizontal @code{radius} option.
@item percentile
Set median percentile. Default value is @code{0.5}.
Default value of @code{0.5} will pick always median values, while @code{0} will pick
minimum values, and @code{1} maximum values.
@end table
@subsection Commands

View File

@ -31,6 +31,7 @@ typedef struct MedianContext {
int planes;
int radius;
int radiusV;
float percentile;
int planewidth[4];
int planeheight[4];

View File

@ -60,6 +60,7 @@ static const AVOption median_options[] = {
{ "radius", "set median radius", OFFSET(radius), AV_OPT_TYPE_INT, {.i64=1}, 1, 127, FLAGS },
{ "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
{ "radiusV", "set median vertical radius", OFFSET(radiusV), AV_OPT_TYPE_INT, {.i64=0},0, 127, FLAGS },
{ "percentile", "set median percentile", OFFSET(percentile), AV_OPT_TYPE_FLOAT, {.dbl=.5}, 0., 1., FLAGS },
{ NULL }
};
@ -127,7 +128,7 @@ static void check_params(MedianContext *s, AVFilterLink *inlink)
}
}
s->t = 2 * s->radius * s->radiusV + 2 * s->radius;
s->t = (2 * s->radius * s->radiusV + s->radiusV + s->radius) * 2.f * s->percentile;
}
static int config_input(AVFilterLink *inlink)