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
3434 int radius;
3535 float factor;
3636 float threshold;
37+ float tolerance;
3738 int planes;
3839
3940 int llimit;
@@ -104,6 +105,7 @@ static int amplify_frame(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs · 64 unmodified lines
104105 const int radius = s->radius;
105106 const int nb_inputs = s->nb_inputs;
106107 const float threshold = s->threshold;
108+ const float tolerance = s->tolerance;
107109 const float factor = s->factor;
108110 const int llimit = s->llimit;
109111 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
136138
137139 avg = sum / (float)nb_inputs;
138140 diff = src - avg;
139− if (fabsf(diff) < threshold) {
141+ if (fabsf(diff) < threshold && fabsf(diff) > tolerance) {
140142 int amp;
141143 if (diff < 0) {
142144 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
179181 avg = sum / (float)nb_inputs;
180182 diff = src - avg;
181183
182− if (fabsf(diff) < threshold) {
184+ if (fabsf(diff) < threshold && fabsf(diff) > tolerance) {
183185 int amp;
184186 if (diff < 0) {
185187 amp = -FFMIN(FFABS(diff * factor), llimit);
@@ -271,6 +273,7 @@ static const AVOption amplify_options[] = { · 85 unmodified lines
271273 { "radius", "set radius", OFFSET(radius), AV_OPT_TYPE_INT, {.i64=2}, 1, 63, .flags = FLAGS },
272274 { "factor", "set factor", OFFSET(factor), AV_OPT_TYPE_FLOAT, {.dbl=2}, 0, UINT16_MAX, .flags = FLAGS },
273275 { "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 },
274277 { "low", "set low limit for amplification", OFFSET(llimit), AV_OPT_TYPE_INT, {.i64=UINT16_MAX}, 0, UINT16_MAX, .flags = FLAGS },
275278 { "high", "set high limit for amplification", OFFSET(hlimit), AV_OPT_TYPE_INT, {.i64=UINT16_MAX}, 0, UINT16_MAX, .flags = FLAGS },
276279 { "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