Index: media/filters/audio_renderer_algorithm_util.h |
diff --git a/media/filters/audio_renderer_algorithm_util.h b/media/filters/audio_renderer_algorithm_util.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5a0c0e727ded74f62d952ecf6b72218c77ef3dfa |
--- /dev/null |
+++ b/media/filters/audio_renderer_algorithm_util.h |
@@ -0,0 +1,81 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// A set of utility functions to perform WSOLA. |
+ |
+#ifndef MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_UTIL_H_ |
+#define MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_UTIL_H_ |
+ |
+#include <utility> |
+ |
+namespace media { |
+ |
+class AudioBus; |
+ |
+typedef std::pair<int, int> interval; |
+ |
+// Dot-product of channels of two AudioBus. For each AudioBus an offset is |
+// given. |dot_product[k]| is the dot-product of channel |k|. The caller should |
+// allocate sufficient space for |dot_product|. |
+void MultiChannelDotProduct(const AudioBus* a, |
+ int frame_offset_a, |
+ const AudioBus* b, |
+ int frame_offset_b, |
+ int num_frames, |
+ float* dot_product); |
+ |
+// Energies of sliding windows of channels are interleaved. |
+void MultiChannelMovingWindowEnergies(const AudioBus* input, |
ajm
2013/07/23 18:03:28
More comments here explaining how it works and the
turaj
2013/07/29 22:09:57
Done.
|
+ int frames_per_window, |
+ float* energy); |
+ |
+// Fit the curve f(x) = a * x^2 + b * x + c such that |
+// |
+// f(-1) = |y[0]| |
+// f(0) = |y[1]| |
+// f(1) = |y[2]|. |
+// |
+// Then compute the |extremum| point -b / (2*a) and |extremum_value| |
+// b^2 / (4*a) - b^2 / (2*a) + c. |
+void CubicInterpol(const float* y_values, |
ajm
2013/07/23 18:03:28
CubicInterpolation?
turaj
2013/07/29 22:09:57
Done.
|
+ float* extremum, |
+ float* extremum_value); |
+ |
+// Search a subset of all candid blocks. The search is performed every |
+// |decimation| frames. This reduces complexity by a factor of about |
+// 1 / |decimation|. A cubic interpolation is used to have a better estimate of |
+// the best match. |
+int DecimatedSearch(int decimation, |
+ interval exclude_interval, |
+ const AudioBus* target_block, |
+ const AudioBus* search_segment, |
+ const float* energy_target_block, |
+ const float* energy_candid_blocks); |
+ |
+// Search [|lim_low|, |lim_high|] of |search_segment| to find a block that is |
+// most similar to |target_interval|. |energy_target_block| is the energy of the |
+// target block. |energy_candid_blocks| is the energy of all blocks within |
+// |search_segment|. |
+int PartialSearch(int lim_low, |
+ int lim_high, |
+ interval exclude_interval, |
+ const AudioBus* target_block, |
+ const AudioBus* search_segment, |
+ const float* energy_target_block, |
+ const float* energy_candid_blocks); |
+ |
+// Find the index of the block, within |search_segment|, that is most similar |
+// to |target_block|. Obviously, the returned index is w.r.t. |search_segment|. |
+// |exclude_interval| is an interval that is excluded from the search. |
+int OptimalIndex(const AudioBus* search_segment, |
+ const AudioBus* target_block, |
+ interval exclude_interval); |
+ |
+// Return a "periodic" Hann window. This is the first L samples of an L+1 |
+// Hann window. It is perfect reconstruction for overlap-and-add. |
+void HannSym(int window_length, float* window); |
ajm
2013/07/23 18:03:28
GetHannWindow?
turaj
2013/07/29 22:09:57
I would keep "Symmetric" as this window is known a
|
+ |
+} // namespace media |
+ |
+#endif // MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_UTIL_H_ |