[FFmpeg-cvslog] avfilter/af_afade: add logistic sigmoid curve

Paul B Mahol git at videolan.org
Sun Oct 7 18:43:36 EEST 2018


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Oct  7 17:38:22 2018 +0200| [3d308746eb4517ed368c8b6949768ed8b2dc91e1] | committer: Paul B Mahol

avfilter/af_afade: add logistic sigmoid curve

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3d308746eb4517ed368c8b6949768ed8b2dc91e1
---

 doc/filters.texi       |  2 ++
 libavfilter/af_afade.c | 12 +++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 2ed0aa2854..b523877cf3 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -955,6 +955,8 @@ select inverted half of sine wave
 select double-exponential seat
 @item desi
 select double-exponential sigmoid
+ at item losi
+select logistic sigmoid
 @end table
 @end table
 
diff --git a/libavfilter/af_afade.c b/libavfilter/af_afade.c
index d823e82d39..7216cea31d 100644
--- a/libavfilter/af_afade.c
+++ b/libavfilter/af_afade.c
@@ -57,7 +57,7 @@ typedef struct AudioFadeContext {
                               int curve0, int curve1);
 } AudioFadeContext;
 
-enum CurveType { TRI, QSIN, ESIN, HSIN, LOG, IPAR, QUA, CUB, SQU, CBR, PAR, EXP, IQSIN, IHSIN, DESE, DESI, NB_CURVES };
+enum CurveType { TRI, QSIN, ESIN, HSIN, LOG, IPAR, QUA, CUB, SQU, CBR, PAR, EXP, IQSIN, IHSIN, DESE, DESI, LOSI, NB_CURVES };
 
 #define OFFSET(x) offsetof(AudioFadeContext, x)
 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
@@ -151,6 +151,14 @@ static double fade_gain(int curve, int64_t index, int64_t range)
     case DESI:
         gain = gain <= 0.5 ? CUBE(2 * gain) / 2: 1 - CUBE(2 * (1 - gain)) / 2;
         break;
+    case LOSI: {
+                   const double a = 1. / (1. - 0.787) - 1;
+                   double A = 1. / (1.0 + exp(0 -((gain-0.5) * a * 2.0)));
+                   double B = 1. / (1.0 + exp(a));
+                   double C = 1. / (1.0 + exp(0-a));
+                   gain = (A - B) / (C - B);
+               }
+        break;
     }
 
     return gain;
@@ -257,6 +265,7 @@ static const AVOption afade_options[] = {
     { "ihsin",        "inverted half of sine wave",                  0,                    AV_OPT_TYPE_CONST,  {.i64 = IHSIN}, 0, 0, FLAGS, "curve" },
     { "dese",         "double-exponential seat",                     0,                    AV_OPT_TYPE_CONST,  {.i64 = DESE }, 0, 0, FLAGS, "curve" },
     { "desi",         "double-exponential sigmoid",                  0,                    AV_OPT_TYPE_CONST,  {.i64 = DESI }, 0, 0, FLAGS, "curve" },
+    { "losi",         "logistic sigmoid",                            0,                    AV_OPT_TYPE_CONST,  {.i64 = LOSI }, 0, 0, FLAGS, "curve" },
     { NULL }
 };
 
@@ -376,6 +385,7 @@ static const AVOption acrossfade_options[] = {
     {     "ihsin",    "inverted half of sine wave",                    0,                    AV_OPT_TYPE_CONST,  {.i64 = IHSIN}, 0, 0, FLAGS, "curve" },
     {     "dese",     "double-exponential seat",                       0,                    AV_OPT_TYPE_CONST,  {.i64 = DESE }, 0, 0, FLAGS, "curve" },
     {     "desi",     "double-exponential sigmoid",                    0,                    AV_OPT_TYPE_CONST,  {.i64 = DESI }, 0, 0, FLAGS, "curve" },
+    {     "losi",     "logistic sigmoid",                              0,                    AV_OPT_TYPE_CONST,  {.i64 = LOSI }, 0, 0, FLAGS, "curve" },
     { "curve2",       "set fade curve type for 2nd stream",            OFFSET(curve2),       AV_OPT_TYPE_INT,    {.i64 = TRI  }, 0, NB_CURVES - 1, FLAGS, "curve" },
     { "c2",           "set fade curve type for 2nd stream",            OFFSET(curve2),       AV_OPT_TYPE_INT,    {.i64 = TRI  }, 0, NB_CURVES - 1, FLAGS, "curve" },
     { NULL }



More information about the ffmpeg-cvslog mailing list