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
2316 2316
2317It accepts the following values:2317It accepts the following values:
2318@table @option2318@table @option
2319@item hard
2319@item tanh2320@item tanh
2320@item atan2321@item atan
2321@item cubic2322@item cubic
libavfilter/af_asoftclip.c+13−1
@@ -25,6 +25,7 @@ · 24 unmodified lines
25#include "formats.h"25#include "formats.h"
26 26
27enum ASoftClipTypes {27enum ASoftClipTypes {
28 ASC_HARD = -1,
28 ASC_TANH,29 ASC_TANH,
29 ASC_ATAN,30 ASC_ATAN,
30 ASC_CUBIC,31 ASC_CUBIC,
@@ -50,7 +51,8 @@ typedef struct ASoftClipContext { · 19 unmodified lines
50#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM51#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
51 52
52static const AVOption asoftclip_options[] = {53static 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 { "tanh", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_TANH}, 0, 0, A, "types" },56 { "tanh", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_TANH}, 0, 0, A, "types" },
55 { "atan", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ATAN}, 0, 0, A, "types" },57 { "atan", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ATAN}, 0, 0, A, "types" },
56 { "cubic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_CUBIC}, 0, 0, A, "types" },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 float *dst = dptr[c];111 float *dst = dptr[c];
110 112
111 switch (s->type) {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 case ASC_TANH:119 case ASC_TANH:
113 for (int n = 0; n < nb_samples; n++) {120 for (int n = 0; n < nb_samples; n++) {
114 dst[n] = tanhf(src[n] * param);121 dst[n] = tanhf(src[n] * param);
@@ -171,6 +178,11 @@ static void filter_dbl(ASoftClipContext *s, · 56 unmodified lines
171 double *dst = dptr[c];178 double *dst = dptr[c];
172 179
173 switch (s->type) {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 case ASC_TANH:186 case ASC_TANH:
175 for (int n = 0; n < nb_samples; n++) {187 for (int n = 0; n < nb_samples; n++) {
176 dst[n] = tanh(src[n] * param);188 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