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
7742@table @option7742@table @option
7743@item thres7743@item thres
7744Set threshold for averaging chrominance values.7744Set threshold for averaging chrominance values.
7745Sum of absolute difference of U and V pixel components or current7745Sum of absolute difference of Y, U and V pixel components of current
7746pixel and neighbour pixels lower than this threshold will be used in7746pixel and neighbour pixels lower than this threshold will be used in
7747averaging. Luma component is left unchanged and is copied to output.7747averaging. Luma component is left unchanged and is copied to output.
7748Default value is 30. Allowed range is from 1 to 200.7748Default value is 30. Allowed range is from 1 to 200.
@@ -7764,6 +7764,24 @@ Mostly useful to speed-up filtering. · 15 unmodified lines
7764Set vertical step when averaging. Default value is 1.7764Set vertical step when averaging. Default value is 1.
7765Allowed range is from 1 to 50.7765Allowed range is from 1 to 50.
7766Mostly useful to speed-up filtering.7766Mostly useful to speed-up filtering.
7767
7768@item threy
7769Set Y threshold for averaging chrominance values.
7770Set finer control for max allowed difference between Y components
7771of current pixel and neigbour pixels.
7772Default value is 200. Allowed range is from 1 to 200.
7773
7774@item threu
7775Set U threshold for averaging chrominance values.
7776Set finer control for max allowed difference between U components
7777of current pixel and neigbour pixels.
7778Default value is 200. Allowed range is from 1 to 200.
7779
7780@item threv
7781Set V threshold for averaging chrominance values.
7782Set finer control for max allowed difference between V components
7783of current pixel and neigbour pixels.
7784Default value is 200. Allowed range is from 1 to 200.
7767@end table7785@end table
7768 7786
7769@subsection Commands7787@subsection Commands
libavfilter/vf_chromanr.c+18−1
@@ -32,7 +32,13 @@ typedef struct ChromaNRContext { · 31 unmodified lines
32 const AVClass *class;32 const AVClass *class;
33 33
34 float threshold;34 float threshold;
35 float threshold_y;
36 float threshold_u;
37 float threshold_v;
35 int thres;38 int thres;
39 int thres_y;
40 int thres_u;
41 int thres_v;
36 int sizew;42 int sizew;
37 int sizeh;43 int sizeh;
38 int stepw;44 int stepw;
@@ -91,6 +97,9 @@ static int filter_slice##name(AVFilterContext *ctx, void *arg, int jobnr, int nb · 52 unmodified lines
91 const int sizew = s->sizew; \97 const int sizew = s->sizew; \
92 const int sizeh = s->sizeh; \98 const int sizeh = s->sizeh; \
93 const int thres = s->thres; \99 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; \
94 const int h = s->planeheight[1]; \103 const int h = s->planeheight[1]; \
95 const int w = s->planewidth[1]; \104 const int w = s->planewidth[1]; \
96 const int slice_start = (h * jobnr) / nb_jobs; \105 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
142 const int V = in_vptr[xx]; \151 const int V = in_vptr[xx]; \
143 \152 \
144 if (FFABS(cu - U) + FFABS(cv - V) + FFABS(cy - Y) < thres && \153 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 && \
145 xx != x && yy != y) { \156 xx != x && yy != y) { \
146 su += U; \157 su += U; \
147 sv += V; \158 sv += V; \
@@ -172,6 +183,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 24 unmodified lines
172 AVFrame *out;183 AVFrame *out;
173 184
174 s->thres = s->threshold * (1 << (s->depth - 8));185 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));
175 189
176 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);190 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
177 if (!out) {191 if (!out) {
@@ -217,11 +231,14 @@ static int config_input(AVFilterLink *inlink) · 39 unmodified lines
217#define VF AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM231#define VF AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
218 232
219static const AVOption chromanr_options[] = {233static 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 },
221 { "sizew", "set horizontal size", OFFSET(sizew), AV_OPT_TYPE_INT, {.i64=5}, 1, 100, VF },235 { "sizew", "set horizontal size", OFFSET(sizew), AV_OPT_TYPE_INT, {.i64=5}, 1, 100, VF },
222 { "sizeh", "set vertical size", OFFSET(sizeh), AV_OPT_TYPE_INT, {.i64=5}, 1, 100, VF },236 { "sizeh", "set vertical size", OFFSET(sizeh), AV_OPT_TYPE_INT, {.i64=5}, 1, 100, VF },
223 { "stepw", "set horizontal step", OFFSET(stepw), AV_OPT_TYPE_INT, {.i64=1}, 1, 50, VF },237 { "stepw", "set horizontal step", OFFSET(stepw), AV_OPT_TYPE_INT, {.i64=1}, 1, 50, VF },
224 { "steph", "set vertical step", OFFSET(steph), AV_OPT_TYPE_INT, {.i64=1}, 1, 50, VF },238 { "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 },
225 { NULL }242 { NULL }
226};243};
227 244

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