summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-02-22 23:32:27 +0100
committerPaul B Mahol <onemda@gmail.com>2019-02-22 23:32:27 +0100
commitc679119a73d96b834061bbed2cc38aa6bb5f79f0 (patch)
tree1b8108af64945213e58c9a7d03098a7ba224bd9f /libavfilter
parent6f93868e464da4871742679031579b71b2e225a6 (diff)
avfilter/vf_amplify: add tolerance option
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_amplify.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavfilter/vf_amplify.c b/libavfilter/vf_amplify.c
index 08243ad953..48dcb93a67 100644
--- a/libavfilter/vf_amplify.c
+++ b/libavfilter/vf_amplify.c
@@ -34,6 +34,7 @@ typedef struct AmplifyContext {
int radius;
float factor;
float threshold;
+ float tolerance;
int planes;
int llimit;
@@ -104,6 +105,7 @@ static int amplify_frame(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs
const int radius = s->radius;
const int nb_inputs = s->nb_inputs;
const float threshold = s->threshold;
+ const float tolerance = s->tolerance;
const float factor = s->factor;
const int llimit = s->llimit;
const int hlimit = s->hlimit;
@@ -136,7 +138,7 @@ static int amplify_frame(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs
avg = sum / (float)nb_inputs;
diff = src - avg;
- if (fabsf(diff) < threshold) {
+ if (fabsf(diff) < threshold && fabsf(diff) > tolerance) {
int amp;
if (diff < 0) {
amp = -FFMIN(FFABS(diff * factor), llimit);
@@ -179,7 +181,7 @@ static int amplify_frame(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs
avg = sum / (float)nb_inputs;
diff = src - avg;
- if (fabsf(diff) < threshold) {
+ if (fabsf(diff) < threshold && fabsf(diff) > tolerance) {
int amp;
if (diff < 0) {
amp = -FFMIN(FFABS(diff * factor), llimit);
@@ -271,6 +273,7 @@ static const AVOption amplify_options[] = {
{ "radius", "set radius", OFFSET(radius), AV_OPT_TYPE_INT, {.i64=2}, 1, 63, .flags = FLAGS },
{ "factor", "set factor", OFFSET(factor), AV_OPT_TYPE_FLOAT, {.dbl=2}, 0, UINT16_MAX, .flags = FLAGS },
{ "threshold", "set threshold", OFFSET(threshold), AV_OPT_TYPE_FLOAT, {.dbl=10}, 0, UINT16_MAX, .flags = FLAGS },
+ { "tolerance", "set tolerance", OFFSET(tolerance), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, UINT16_MAX, .flags = FLAGS },
{ "low", "set low limit for amplification", OFFSET(llimit), AV_OPT_TYPE_INT, {.i64=UINT16_MAX}, 0, UINT16_MAX, .flags = FLAGS },
{ "high", "set high limit for amplification", OFFSET(hlimit), AV_OPT_TYPE_INT, {.i64=UINT16_MAX}, 0, UINT16_MAX, .flags = FLAGS },
{ "planes", "set what planes to filter", OFFSET(planes), AV_OPT_TYPE_FLAGS, {.i64=7}, 0, 15, FLAGS },