History

avfilter/vf_amplify: add tolerance option

Paul B Mahol committed 7 years ago

Commit c6791191 parent 6f938682 files · +10 −2Browse files

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

Unified · Split

libavfilter/vf_amplify.c+5−2
@@ -34,6 +34,7 @@ typedef struct AmplifyContext { · 33 unmodified lines
34 int radius;34 int radius;
35 float factor;35 float factor;
36 float threshold;36 float threshold;
37 float tolerance;
37 int planes;38 int planes;
38 39
39 int llimit;40 int llimit;
@@ -104,6 +105,7 @@ static int amplify_frame(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs · 64 unmodified lines
104 const int radius = s->radius;105 const int radius = s->radius;
105 const int nb_inputs = s->nb_inputs;106 const int nb_inputs = s->nb_inputs;
106 const float threshold = s->threshold;107 const float threshold = s->threshold;
108 const float tolerance = s->tolerance;
107 const float factor = s->factor;109 const float factor = s->factor;
108 const int llimit = s->llimit;110 const int llimit = s->llimit;
109 const int hlimit = s->hlimit;111 const int hlimit = s->hlimit;
@@ -136,7 +138,7 @@ static int amplify_frame(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs · 26 unmodified lines
136 138
137 avg = sum / (float)nb_inputs;139 avg = sum / (float)nb_inputs;
138 diff = src - avg;140 diff = src - avg;
139 if (fabsf(diff) < threshold) {141 if (fabsf(diff) < threshold && fabsf(diff) > tolerance) {
140 int amp;142 int amp;
141 if (diff < 0) {143 if (diff < 0) {
142 amp = -FFMIN(FFABS(diff * factor), llimit);144 amp = -FFMIN(FFABS(diff * factor), llimit);
@@ -179,7 +181,7 @@ static int amplify_frame(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs · 36 unmodified lines
179 avg = sum / (float)nb_inputs;181 avg = sum / (float)nb_inputs;
180 diff = src - avg;182 diff = src - avg;
181 183
182 if (fabsf(diff) < threshold) {184 if (fabsf(diff) < threshold && fabsf(diff) > tolerance) {
183 int amp;185 int amp;
184 if (diff < 0) {186 if (diff < 0) {
185 amp = -FFMIN(FFABS(diff * factor), llimit);187 amp = -FFMIN(FFABS(diff * factor), llimit);
@@ -271,6 +273,7 @@ static const AVOption amplify_options[] = { · 85 unmodified lines
271 { "radius", "set radius", OFFSET(radius), AV_OPT_TYPE_INT, {.i64=2}, 1, 63, .flags = FLAGS },273 { "radius", "set radius", OFFSET(radius), AV_OPT_TYPE_INT, {.i64=2}, 1, 63, .flags = FLAGS },
272 { "factor", "set factor", OFFSET(factor), AV_OPT_TYPE_FLOAT, {.dbl=2}, 0, UINT16_MAX, .flags = FLAGS },274 { "factor", "set factor", OFFSET(factor), AV_OPT_TYPE_FLOAT, {.dbl=2}, 0, UINT16_MAX, .flags = FLAGS },
273 { "threshold", "set threshold", OFFSET(threshold), AV_OPT_TYPE_FLOAT, {.dbl=10}, 0, UINT16_MAX, .flags = FLAGS },275 { "threshold", "set threshold", OFFSET(threshold), AV_OPT_TYPE_FLOAT, {.dbl=10}, 0, UINT16_MAX, .flags = FLAGS },
276 { "tolerance", "set tolerance", OFFSET(tolerance), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, UINT16_MAX, .flags = FLAGS },
274 { "low", "set low limit for amplification", OFFSET(llimit), AV_OPT_TYPE_INT, {.i64=UINT16_MAX}, 0, UINT16_MAX, .flags = FLAGS },277 { "low", "set low limit for amplification", OFFSET(llimit), AV_OPT_TYPE_INT, {.i64=UINT16_MAX}, 0, UINT16_MAX, .flags = FLAGS },
275 { "high", "set high limit for amplification", OFFSET(hlimit), AV_OPT_TYPE_INT, {.i64=UINT16_MAX}, 0, UINT16_MAX, .flags = FLAGS },278 { "high", "set high limit for amplification", OFFSET(hlimit), AV_OPT_TYPE_INT, {.i64=UINT16_MAX}, 0, UINT16_MAX, .flags = FLAGS },
276 { "planes", "set what planes to filter", OFFSET(planes), AV_OPT_TYPE_FLAGS, {.i64=7}, 0, 15, FLAGS },279 { "planes", "set what planes to filter", OFFSET(planes), AV_OPT_TYPE_FLAGS, {.i64=7}, 0, 15, FLAGS },

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