]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/af_afir: remove again option, merge it with gtype
authorPaul B Mahol <onemda@gmail.com>
Wed, 10 Oct 2018 17:55:30 +0000 (19:55 +0200)
committerPaul B Mahol <onemda@gmail.com>
Wed, 10 Oct 2018 18:04:25 +0000 (20:04 +0200)
doc/filters.texi
libavfilter/af_afir.c
libavfilter/af_afir.h

index ceeee0e78540a6639b4456926ccfc32791b936e7..c327b2c22b30d3e7baad269f2998e4b3d00d5693 100644 (file)
@@ -1173,14 +1173,15 @@ Set wet gain. This sets final output gain.
 @item length
 Set Impulse Response filter length. Default is 1, which means whole IR is processed.
 
-@item again
-Enable applying gain measured from power of IR. For approach to use for measuring power
-of IR see next option.
-
 @item gtype
+Enable applying gain measured from power of IR.
+
 Set which approach to use for auto gain measurement.
 
 @table @option
+@item none
+Do not apply any gain.
+
 @item peak
 select peak gain, very conservative approach. This is default value.
 
index b2d158c17e0c45b93fe0efa354fcf4d926ca0b06..244da3ab4cff3db84d5cd16df6305385442523f0 100644 (file)
@@ -335,38 +335,39 @@ static int convert_coeffs(AVFilterContext *ctx)
 
     s->gain = 1;
 
-    if (s->again) {
-        switch (s->gtype) {
-        case 0:
-            for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {
-                float *time = (float *)s->in[1]->extended_data[!s->one2many * ch];
-
-                for (i = 0; i < s->nb_taps; i++)
-                    power += FFABS(time[i]);
-            }
-            s->gain = ctx->inputs[1]->channels / power;
-            break;
-        case 1:
-            for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {
-                float *time = (float *)s->in[1]->extended_data[!s->one2many * ch];
-
-                for (i = 0; i < s->nb_taps; i++)
-                    power += time[i];
-            }
-            s->gain = ctx->inputs[1]->channels / power;
-            break;
-        case 2:
-            for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {
-                float *time = (float *)s->in[1]->extended_data[!s->one2many * ch];
-
-                for (i = 0; i < s->nb_taps; i++)
-                    power += time[i] * time[i];
-            }
-            s->gain = sqrtf(ch / power);
-            break;
-        default:
-            return AVERROR_BUG;
+    switch (s->gtype) {
+    case -1:
+        /* nothinkg to do */
+        break;
+    case 0:
+        for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {
+            float *time = (float *)s->in[1]->extended_data[!s->one2many * ch];
+
+            for (i = 0; i < s->nb_taps; i++)
+                power += FFABS(time[i]);
+        }
+        s->gain = ctx->inputs[1]->channels / power;
+        break;
+    case 1:
+        for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {
+            float *time = (float *)s->in[1]->extended_data[!s->one2many * ch];
+
+            for (i = 0; i < s->nb_taps; i++)
+                power += time[i];
         }
+        s->gain = ctx->inputs[1]->channels / power;
+        break;
+    case 2:
+        for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {
+            float *time = (float *)s->in[1]->extended_data[!s->one2many * ch];
+
+            for (i = 0; i < s->nb_taps; i++)
+                power += time[i] * time[i];
+        }
+        s->gain = sqrtf(ch / power);
+        break;
+    default:
+        return AVERROR_BUG;
     }
 
     s->gain = FFMIN(s->gain * s->ir_gain, 1.f);
@@ -738,8 +739,8 @@ static const AVOption afir_options[] = {
     { "dry",    "set dry gain",      OFFSET(dry_gain),   AV_OPT_TYPE_FLOAT, {.dbl=1},    0, 10, AF },
     { "wet",    "set wet gain",      OFFSET(wet_gain),   AV_OPT_TYPE_FLOAT, {.dbl=1},    0, 10, AF },
     { "length", "set IR length",     OFFSET(length),     AV_OPT_TYPE_FLOAT, {.dbl=1},    0,  1, AF },
-    { "again",  "enable auto gain",  OFFSET(again),      AV_OPT_TYPE_BOOL,  {.i64=1},    0,  1, AF },
-    { "gtype",  "set auto gain type",OFFSET(gtype),      AV_OPT_TYPE_INT,   {.i64=0},    0,  2, AF, "gtype" },
+    { "gtype",  "set IR auto gain type",OFFSET(gtype),   AV_OPT_TYPE_INT,   {.i64=0},   -1,  2, AF, "gtype" },
+    {  "none",  "without auto gain", 0,                  AV_OPT_TYPE_CONST, {.i64=-1},   0,  0, AF, "gtype" },
     {  "peak",  "peak gain",         0,                  AV_OPT_TYPE_CONST, {.i64=0},    0,  0, AF, "gtype" },
     {  "dc",    "DC gain",           0,                  AV_OPT_TYPE_CONST, {.i64=1},    0,  0, AF, "gtype" },
     {  "gn",    "gain to noise",     0,                  AV_OPT_TYPE_CONST, {.i64=2},    0,  0, AF, "gtype" },
index ecc0d6064174ed818e09750e976f824706be16f7..7d4f32eaebc993d021171249d9b982fc95350703 100644 (file)
@@ -38,7 +38,6 @@ typedef struct AudioFIRContext {
     float wet_gain;
     float dry_gain;
     float length;
-    int again;
     int gtype;
     float ir_gain;
     int ir_format;