History

avfilter/vf_chromanr: add options for finer controls of filtering

Paul B Mahol committed 5 years ago

Commit 7adb7471 parent b607f192 files · +37 −2Browse files

Unified · Split

2 files
  1. doc/filters.texi +19 −1
  2. libavfilter/vf_chromanr.c +18 −1
doc/filters.texi+19−1
@@ -7742,7 +7742,7 @@ The filter accepts the following options: · 7741 unmodified lines
77427742 @table @option
77437743 @item thres
77447744 Set threshold for averaging chrominance values.
7745−Sum of absolute difference of U and V pixel components or current
7745+Sum of absolute difference of Y, U and V pixel components of current
77467746 pixel and neighbour pixels lower than this threshold will be used in
77477747 averaging. Luma component is left unchanged and is copied to output.
77487748 Default value is 30. Allowed range is from 1 to 200.
@@ -7764,6 +7764,24 @@ Mostly useful to speed-up filtering. · 15 unmodified lines
77647764 Set vertical step when averaging. Default value is 1.
77657765 Allowed range is from 1 to 50.
77667766 Mostly useful to speed-up filtering.
7767+
7768+@item threy
7769+Set Y threshold for averaging chrominance values.
7770+Set finer control for max allowed difference between Y components
7771+of current pixel and neigbour pixels.
7772+Default value is 200. Allowed range is from 1 to 200.
7773+
7774+@item threu
7775+Set U threshold for averaging chrominance values.
7776+Set finer control for max allowed difference between U components
7777+of current pixel and neigbour pixels.
7778+Default value is 200. Allowed range is from 1 to 200.
7779+
7780+@item threv
7781+Set V threshold for averaging chrominance values.
7782+Set finer control for max allowed difference between V components
7783+of current pixel and neigbour pixels.
7784+Default value is 200. Allowed range is from 1 to 200.
77677785 @end table
77687786
77697787 @subsection Commands
libavfilter/vf_chromanr.c+18−1
@@ -32,7 +32,13 @@ typedef struct ChromaNRContext { · 31 unmodified lines
3232 const AVClass *class;
3333
3434 float threshold;
35+ float threshold_y;
36+ float threshold_u;
37+ float threshold_v;
3538 int thres;
39+ int thres_y;
40+ int thres_u;
41+ int thres_v;
3642 int sizew;
3743 int sizeh;
3844 int stepw;
@@ -91,6 +97,9 @@ static int filter_slice##name(AVFilterContext *ctx, void *arg, int jobnr, int nb · 52 unmodified lines
9197 const int sizew = s->sizew; \
9298 const int sizeh = s->sizeh; \
9399 const int thres = s->thres; \
100+ const int thres_y = s->thres_y; \
101+ const int thres_u = s->thres_u; \
102+ const int thres_v = s->thres_v; \
94103 const int h = s->planeheight[1]; \
95104 const int w = s->planewidth[1]; \
96105 const int slice_start = (h * jobnr) / nb_jobs; \
@@ -142,6 +151,8 @@ static int filter_slice##name(AVFilterContext *ctx, void *arg, int jobnr, int nb · 45 unmodified lines
142151 const int V = in_vptr[xx]; \
143152 \
144153 if (FFABS(cu - U) + FFABS(cv - V) + FFABS(cy - Y) < thres && \
154+ FFABS(cu - U) < thres_u && FFABS(cv - V) < thres_v && \
155+ FFABS(cy - Y) < thres_y && \
145156 xx != x && yy != y) { \
146157 su += U; \
147158 sv += V; \
@@ -172,6 +183,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 24 unmodified lines
172183 AVFrame *out;
173184
174185 s->thres = s->threshold * (1 << (s->depth - 8));
186+ s->thres_y = s->threshold_y * (1 << (s->depth - 8));
187+ s->thres_u = s->threshold_u * (1 << (s->depth - 8));
188+ s->thres_v = s->threshold_v * (1 << (s->depth - 8));
175189
176190 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
177191 if (!out) {
@@ -217,11 +231,14 @@ static int config_input(AVFilterLink *inlink) · 39 unmodified lines
217231 #define VF AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
218232
219233 static const AVOption chromanr_options[] = {
220− { "thres", "set u/v threshold", OFFSET(threshold), AV_OPT_TYPE_FLOAT, {.dbl=30}, 1, 200, VF },
234+ { "thres", "set y+u+v threshold", OFFSET(threshold), AV_OPT_TYPE_FLOAT, {.dbl=30}, 1, 200, VF },
221235 { "sizew", "set horizontal size", OFFSET(sizew), AV_OPT_TYPE_INT, {.i64=5}, 1, 100, VF },
222236 { "sizeh", "set vertical size", OFFSET(sizeh), AV_OPT_TYPE_INT, {.i64=5}, 1, 100, VF },
223237 { "stepw", "set horizontal step", OFFSET(stepw), AV_OPT_TYPE_INT, {.i64=1}, 1, 50, VF },
224238 { "steph", "set vertical step", OFFSET(steph), AV_OPT_TYPE_INT, {.i64=1}, 1, 50, VF },
239+ { "threy", "set y threshold", OFFSET(threshold_y), AV_OPT_TYPE_FLOAT, {.dbl=200},1, 200, VF },
240+ { "threu", "set u threshold", OFFSET(threshold_u), AV_OPT_TYPE_FLOAT, {.dbl=200},1, 200, VF },
241+ { "threv", "set v threshold", OFFSET(threshold_v), AV_OPT_TYPE_FLOAT, {.dbl=200},1, 200, VF },
225242 { NULL }
226243 };
227244

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