[FFmpeg-cvslog] avfitler/af_asoftclip: add hard type
Paul B Mahol
git at videolan.org
Tue Nov 3 13:31:28 EET 2020
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Nov 3 12:21:48 2020 +0100| [de63b6fb549e98f20194561a077456f03e7dcfe9] | committer: Paul B Mahol
avfitler/af_asoftclip: add hard type
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=de63b6fb549e98f20194561a077456f03e7dcfe9
---
doc/filters.texi | 1 +
libavfilter/af_asoftclip.c | 14 +++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index a186f9dca1..a6de827ebf 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2316,6 +2316,7 @@ Set type of soft-clipping.
It accepts the following values:
@table @option
+ at item hard
@item tanh
@item atan
@item cubic
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);
More information about the ffmpeg-cvslog
mailing list