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
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