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

Showing the changes to libavfilter (1 of 2 files). Show all

Unified · Split

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