Using ring buffer for AudioVector in NetEq.

AudioVector used NetEq was based on a shift buffer, which has a high complexity, and the complexity is very much dependent on the capacity of the buffer.

This CL changes the shift buffer to a ring buffer.

Reduction in the CPU usages of NetEq is expected.

BUG=608644
R=henrik.lundin@webrtc.org

Review URL: https://codereview.webrtc.org/1948483002 .

Cr-Commit-Position: refs/heads/master@{#12676}
diff --git a/webrtc/modules/audio_coding/neteq/dsp_helper.cc b/webrtc/modules/audio_coding/neteq/dsp_helper.cc
index 4188914..3275665 100644
--- a/webrtc/modules/audio_coding/neteq/dsp_helper.cc
+++ b/webrtc/modules/audio_coding/neteq/dsp_helper.cc
@@ -80,6 +80,22 @@
   return RampSignal(signal, length, factor, increment, signal);
 }
 
+int DspHelper::RampSignal(AudioVector* signal,
+                          size_t start_index,
+                          size_t length,
+                          int factor,
+                          int increment) {
+  int factor_q20 = (factor << 6) + 32;
+  // TODO(hlundin): Add 32 to factor_q20 when converting back to Q14?
+  for (size_t i = start_index; i < start_index + length; ++i) {
+    (*signal)[i] = (factor * (*signal)[i] + 8192) >> 14;
+    factor_q20 += increment;
+    factor_q20 = std::max(factor_q20, 0);  // Never go negative.
+    factor = std::min(factor_q20 >> 6, 16384);
+  }
+  return factor;
+}
+
 int DspHelper::RampSignal(AudioMultiVector* signal,
                           size_t start_index,
                           size_t length,
@@ -94,7 +110,7 @@
   // Loop over the channels, starting at the same |factor| each time.
   for (size_t channel = 0; channel < signal->Channels(); ++channel) {
     end_factor =
-        RampSignal(&(*signal)[channel][start_index], length, factor, increment);
+        RampSignal(&(*signal)[channel], start_index, length, factor, increment);
   }
   return end_factor;
 }