[FFmpeg-cvslog] avfilter/af_stereotools: add two more modes

Paul B Mahol git at videolan.org
Fri Dec 4 12:59:56 EET 2020


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Dec  4 11:53:34 2020 +0100| [456146356a524ca7ff6ca148ee4c19fc66ee531e] | committer: Paul B Mahol

avfilter/af_stereotools: add two more modes

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

 doc/filters.texi             |  6 ++++++
 libavfilter/af_stereotools.c | 16 ++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index a4662e78f2..1288821170 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -5499,6 +5499,12 @@ Mid/Side to Left/Left.
 
 @item ms>rr
 Mid/Side to Right/Right.
+
+ at item ms>rl
+Mid/Side to Right/Left.
+
+ at item lr>l-r
+Left/Right to Left - Right.
 @end table
 
 @item slev
diff --git a/libavfilter/af_stereotools.c b/libavfilter/af_stereotools.c
index 7e529783d5..94e9b150dd 100644
--- a/libavfilter/af_stereotools.c
+++ b/libavfilter/af_stereotools.c
@@ -69,7 +69,7 @@ static const AVOption stereotools_options[] = {
     { "muter",       "mute R",           OFFSET(mute_r),      AV_OPT_TYPE_BOOL,   {.i64=0},   0,          1, A },
     { "phasel",      "phase L",          OFFSET(phase_l),     AV_OPT_TYPE_BOOL,   {.i64=0},   0,          1, A },
     { "phaser",      "phase R",          OFFSET(phase_r),     AV_OPT_TYPE_BOOL,   {.i64=0},   0,          1, A },
-    { "mode",        "set stereo mode",  OFFSET(mode),        AV_OPT_TYPE_INT,    {.i64=0},   0,          8, A, "mode" },
+    { "mode",        "set stereo mode",  OFFSET(mode),        AV_OPT_TYPE_INT,    {.i64=0},   0,         10, A, "mode" },
     {     "lr>lr",   0,                  0,                   AV_OPT_TYPE_CONST,  {.i64=0},   0,          0, A, "mode" },
     {     "lr>ms",   0,                  0,                   AV_OPT_TYPE_CONST,  {.i64=1},   0,          0, A, "mode" },
     {     "ms>lr",   0,                  0,                   AV_OPT_TYPE_CONST,  {.i64=2},   0,          0, A, "mode" },
@@ -79,6 +79,8 @@ static const AVOption stereotools_options[] = {
     {     "lr>rl",   0,                  0,                   AV_OPT_TYPE_CONST,  {.i64=6},   0,          0, A, "mode" },
     {     "ms>ll",   0,                  0,                   AV_OPT_TYPE_CONST,  {.i64=7},   0,          0, A, "mode" },
     {     "ms>rr",   0,                  0,                   AV_OPT_TYPE_CONST,  {.i64=8},   0,          0, A, "mode" },
+    {     "ms>rl",   0,                  0,                   AV_OPT_TYPE_CONST,  {.i64=9},   0,          0, A, "mode" },
+    {     "lr>l-r",  0,                  0,                   AV_OPT_TYPE_CONST,  {.i64=10},  0,          0, A, "mode" },
     { "slev",        "set side level",   OFFSET(slev),        AV_OPT_TYPE_DOUBLE, {.dbl=1},   0.015625,  64, A },
     { "sbal",        "set side balance", OFFSET(sbal),        AV_OPT_TYPE_DOUBLE, {.dbl=0},  -1,          1, A },
     { "mlev",        "set middle level", OFFSET(mlev),        AV_OPT_TYPE_DOUBLE, {.dbl=1},   0.015625,  64, A },
@@ -235,7 +237,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             L = R;
             break;
         case 5:
-            L = (L + R) / 2;
+            L = (L + R) * 0.5;
             R = L;
             break;
         case 6:
@@ -259,6 +261,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             L = r;
             R = r;
             break;
+        case 9:
+            l = L * mlev * FFMIN(1., 2. - mpan) + R * slev * FFMIN(1., 2. - sbal);
+            r = L * mlev * FFMIN(1., mpan)      - R * slev * FFMIN(1., sbal);
+            L = r;
+            R = l;
+            break;
+        case 10:
+            L = (L - R) * 0.5;
+            R = L;
+            break;
         }
 
         L *= 1. - mute_l;



More information about the ffmpeg-cvslog mailing list