Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -25,6 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "formats.h" |
| 26 | 26 | |
| 27 | 27 | enum ASoftClipTypes { |
| 28 | + ASC_HARD = -1, | |
| 28 | 29 | ASC_TANH, |
| 29 | 30 | ASC_ATAN, |
| 30 | 31 | ASC_CUBIC, |
| @@ -50,7 +51,8 @@ typedef struct ASoftClipContext { · 19 unmodified lines | ||
| 50 | 51 | #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM |
| 51 | 52 | |
| 52 | 53 | 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" }, | |
| 54 | 56 | { "tanh", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_TANH}, 0, 0, A, "types" }, |
| 55 | 57 | { "atan", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ATAN}, 0, 0, A, "types" }, |
| 56 | 58 | { "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 | ||
| 109 | 111 | float *dst = dptr[c]; |
| 110 | 112 | |
| 111 | 113 | 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; | |
| 112 | 119 | case ASC_TANH: |
| 113 | 120 | for (int n = 0; n < nb_samples; n++) { |
| 114 | 121 | dst[n] = tanhf(src[n] * param); |
| @@ -171,6 +178,11 @@ static void filter_dbl(ASoftClipContext *s, · 56 unmodified lines | ||
| 171 | 178 | double *dst = dptr[c]; |
| 172 | 179 | |
| 173 | 180 | 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; | |
| 174 | 186 | case ASC_TANH: |
| 175 | 187 | for (int n = 0; n < nb_samples; n++) { |
| 176 | 188 | dst[n] = tanh(src[n] * param); |