diff options
author | Paul B Mahol <onemda@gmail.com> | 2020-11-03 12:21:48 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2020-11-03 12:30:19 +0100 |
commit | de63b6fb549e98f20194561a077456f03e7dcfe9 (patch) | |
tree | b3caaf208ec1d47d5ae5fcbbad1bd2f65e9762d6 /libavfilter/af_asoftclip.c | |
parent | ee686236cd1dcceca2ecdfe64e509a7ef977e8f0 (diff) | |
download | ffmpeg-de63b6fb549e98f20194561a077456f03e7dcfe9.tar.gz |
avfitler/af_asoftclip: add hard type
Diffstat (limited to 'libavfilter/af_asoftclip.c')
-rw-r--r-- | libavfilter/af_asoftclip.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libavfilter/af_asoftclip.c b/libavfilter/af_asoftclip.c index c49ba5a49f..b656dcfa45 100644 --- a/libavfilter/af_asoftclip.c +++ b/libavfilter/af_asoftclip.c @@ -25,6 +25,7 @@ #include "formats.h" enum ASoftClipTypes { + ASC_HARD = -1, ASC_TANH, ASC_ATAN, ASC_CUBIC, @@ -50,7 +51,8 @@ typedef struct ASoftClipContext { #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM static const AVOption asoftclip_options[] = { - { "type", "set softclip type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_TYPES-1, A, "types" }, + { "type", "set softclip type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, -1, NB_TYPES-1, A, "types" }, + { "hard", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_HARD}, 0, 0, A, "types" }, { "tanh", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_TANH}, 0, 0, A, "types" }, { "atan", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ATAN}, 0, 0, A, "types" }, { "cubic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_CUBIC}, 0, 0, A, "types" }, @@ -109,6 +111,11 @@ static void filter_flt(ASoftClipContext *s, float *dst = dptr[c]; switch (s->type) { + case ASC_HARD: + for (int n = 0; n < nb_samples; n++) { + dst[n] = av_clipf(src[n], -1.f, 1.f); + } + break; case ASC_TANH: for (int n = 0; n < nb_samples; n++) { dst[n] = tanhf(src[n] * param); @@ -171,6 +178,11 @@ static void filter_dbl(ASoftClipContext *s, double *dst = dptr[c]; switch (s->type) { + case ASC_HARD: + for (int n = 0; n < nb_samples; n++) { + dst[n] = av_clipd(src[n], -1., 1.); + } + break; case ASC_TANH: for (int n = 0; n < nb_samples; n++) { dst[n] = tanh(src[n] * param); |