avfilter/af_asoftclip: add erf soft clip type
authorPaul B Mahol <onemda@gmail.com>
Tue, 3 Nov 2020 11:05:24 +0000 (12:05 +0100)
committerPaul B Mahol <onemda@gmail.com>
Tue, 3 Nov 2020 11:30:19 +0000 (12:30 +0100)
doc/filters.texi
libavfilter/af_asoftclip.c

index d98c696..a186f9d 100644 (file)
@@ -2323,6 +2323,7 @@ It accepts the following values:
 @item alg
 @item quintic
 @item sin
+@item erf
 @end table
 
 @item param
index e9e3666..c49ba5a 100644 (file)
@@ -32,6 +32,7 @@ enum ASoftClipTypes {
     ASC_ALG,
     ASC_QUINTIC,
     ASC_SIN,
+    ASC_ERF,
     NB_TYPES,
 };
 
@@ -57,6 +58,7 @@ static const AVOption asoftclip_options[] = {
     { "alg",                 NULL,            0, AV_OPT_TYPE_CONST,  {.i64=ASC_ALG},    0,          0, A, "types" },
     { "quintic",             NULL,            0, AV_OPT_TYPE_CONST,  {.i64=ASC_QUINTIC},0,          0, A, "types" },
     { "sin",                 NULL,            0, AV_OPT_TYPE_CONST,  {.i64=ASC_SIN},    0,          0, A, "types" },
+    { "erf",                 NULL,            0, AV_OPT_TYPE_CONST,  {.i64=ASC_ERF},    0,          0, A, "types" },
     { "param", "set softclip parameter", OFFSET(param), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.01,        3, A },
     { NULL }
 };
@@ -148,6 +150,11 @@ static void filter_flt(ASoftClipContext *s,
                     dst[n] = sinf(src[n]);
             }
             break;
+        case ASC_ERF:
+            for (int n = 0; n < nb_samples; n++) {
+                dst[n] = erff(src[n]);
+            }
+            break;
         }
     }
 }
@@ -205,6 +212,11 @@ static void filter_dbl(ASoftClipContext *s,
                     dst[n] = sin(src[n]);
             }
             break;
+        case ASC_ERF:
+            for (int n = 0; n < nb_samples; n++) {
+                dst[n] = erf(src[n]);
+            }
+            break;
         }
     }
 }