]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/af_compand.c
avfilter/vaf_spectrumsynth: assert that variables are initialized by switch()
[ffmpeg] / libavfilter / af_compand.c
index 3848d67bd9c6688a9a5ff3da7a263be38a82ee71..b74636409c32b1b6cd174cbcd467218f380e0b2f 100644 (file)
@@ -205,7 +205,7 @@ static int compand_nodelay(AVFilterContext *ctx, AVFrame *frame)
         for (i = 0; i < nb_samples; i++) {
             update_volume(cp, fabs(src[i]));
 
-            dst[i] = av_clipd(src[i] * get_volume(s, cp->volume), -1, 1);
+            dst[i] = src[i] * get_volume(s, cp->volume);
         }
     }
 
@@ -266,8 +266,7 @@ static int compand_delay(AVFilterContext *ctx, AVFrame *frame)
                 }
 
                 dst = (double *)out_frame->extended_data[chan];
-                dst[oindex++] = av_clipd(dbuf[dindex] *
-                        get_volume(s, cp->volume), -1, 1);
+                dst[oindex++] = dbuf[dindex] * get_volume(s, cp->volume);
             } else {
                 count++;
             }
@@ -315,8 +314,7 @@ static int compand_drain(AVFilterLink *outlink)
 
         dindex = s->delay_index;
         for (i = 0; i < frame->nb_samples; i++) {
-            dst[i] = av_clipd(dbuf[dindex] * get_volume(s, cp->volume),
-                    -1, 1);
+            dst[i] = dbuf[dindex] * get_volume(s, cp->volume);
             dindex = MOD(dindex + 1, s->delay_samples);
         }
     }
@@ -450,14 +448,14 @@ static int config_output(AVFilterLink *outlink)
             S(j) = S(j + 1);
     }
 
-    for (i = 0; !i || s->segments[i - 2].x; i += 2) {
+    for (i = 0; i < s->nb_segments; i += 2) {
         s->segments[i].y += s->gain_dB;
         s->segments[i].x *= M_LN10 / 20;
         s->segments[i].y *= M_LN10 / 20;
     }
 
 #define L(x) s->segments[i - (x)]
-    for (i = 4; s->segments[i - 2].x; i += 2) {
+    for (i = 4; i < s->nb_segments; i += 2) {
         double x, y, cx, cy, in1, in2, out1, out2, theta, len, r;
 
         L(4).a = 0;
@@ -467,13 +465,13 @@ static int config_output(AVFilterLink *outlink)
         L(2).b = (L(0).y - L(2).y) / (L(0).x - L(2).x);
 
         theta = atan2(L(2).y - L(4).y, L(2).x - L(4).x);
-        len = sqrt(pow(L(2).x - L(4).x, 2.) + pow(L(2).y - L(4).y, 2.));
+        len = hypot(L(2).x - L(4).x, L(2).y - L(4).y);
         r = FFMIN(radius, len);
         L(3).x = L(2).x - r * cos(theta);
         L(3).y = L(2).y - r * sin(theta);
 
         theta = atan2(L(0).y - L(2).y, L(0).x - L(2).x);
-        len = sqrt(pow(L(0).x - L(2).x, 2.) + pow(L(0).y - L(2).y, 2.));
+        len = hypot(L(0).x - L(2).x, L(0).y - L(2).y);
         r = FFMIN(radius, len / 2);
         x = L(2).x + r * cos(theta);
         y = L(2).y + r * sin(theta);
@@ -508,7 +506,7 @@ static int config_output(AVFilterLink *outlink)
             cp->decay = 1.0 - exp(-1.0 / (sample_rate * cp->decay));
         else
             cp->decay = 1.0;
-        cp->volume = pow(10.0, s->initial_volume / 20);
+        cp->volume = ff_exp10(s->initial_volume / 20);
     }
 
     s->delay_samples = s->delay * sample_rate;