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