History

avfitler/af_asoftclip: add hard type

Paul B Mahol committed 6 years ago

Commit de63b6f1 parent ee686232 files · +14 −1Browse files

Unified · Split

2 files
  1. doc/filters.texi +1 −0
  2. libavfilter/af_asoftclip.c +13 −1
doc/filters.texi+1−0
@@ -2316,6 +2316,7 @@ Set type of soft-clipping. · 2315 unmodified lines
23162316
23172317 It accepts the following values:
23182318 @table @option
2319+@item hard
23192320 @item tanh
23202321 @item atan
23212322 @item cubic
libavfilter/af_asoftclip.c+13−1
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include "formats.h"
2626
2727 enum ASoftClipTypes {
28+ ASC_HARD = -1,
2829 ASC_TANH,
2930 ASC_ATAN,
3031 ASC_CUBIC,
@@ -50,7 +51,8 @@ typedef struct ASoftClipContext { · 19 unmodified lines
5051 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
5152
5253 static const AVOption asoftclip_options[] = {
53− { "type", "set softclip type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_TYPES-1, A, "types" },
54+ { "type", "set softclip type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, -1, NB_TYPES-1, A, "types" },
55+ { "hard", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_HARD}, 0, 0, A, "types" },
5456 { "tanh", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_TANH}, 0, 0, A, "types" },
5557 { "atan", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ATAN}, 0, 0, A, "types" },
5658 { "cubic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_CUBIC}, 0, 0, A, "types" },
@@ -109,6 +111,11 @@ static void filter_flt(ASoftClipContext *s, · 52 unmodified lines
109111 float *dst = dptr[c];
110112
111113 switch (s->type) {
114+ case ASC_HARD:
115+ for (int n = 0; n < nb_samples; n++) {
116+ dst[n] = av_clipf(src[n], -1.f, 1.f);
117+ }
118+ break;
112119 case ASC_TANH:
113120 for (int n = 0; n < nb_samples; n++) {
114121 dst[n] = tanhf(src[n] * param);
@@ -171,6 +178,11 @@ static void filter_dbl(ASoftClipContext *s, · 56 unmodified lines
171178 double *dst = dptr[c];
172179
173180 switch (s->type) {
181+ case ASC_HARD:
182+ for (int n = 0; n < nb_samples; n++) {
183+ dst[n] = av_clipd(src[n], -1., 1.);
184+ }
185+ break;
174186 case ASC_TANH:
175187 for (int n = 0; n < nb_samples; n++) {
176188 dst[n] = tanh(src[n] * param);

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