Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(527)

Unified Diff: media/filters/wsola_internals.h

Issue 19111004: Upgrade AudioRendererAlgorithm to use WSOLA, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "Dale's and Marco's comments are addressed." Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/wsola_internals.h
diff --git a/media/filters/wsola_internals.h b/media/filters/wsola_internals.h
new file mode 100644
index 0000000000000000000000000000000000000000..a61331c6db07b050d2a4a772e03755eb1f3380f7
--- /dev/null
+++ b/media/filters/wsola_internals.h
@@ -0,0 +1,91 @@
+// Copyright 2013 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_WSOLA_INTERNALS_H_
+#define MEDIA_FILTERS_WSOLA_INTERNALS_H_
+
+#include <utility>
+
+namespace media {
+
+class AudioBus;
+
+namespace internal {
+
+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.
+// The number windows is |input->frames()| - (|frames_per_window| - 1), hence,
+// the method assumes |energy| must be, at least, of size
+// (|input->frames()| - (|frames_per_window| - 1)) * |input->channels()|.
+void MultiChannelMovingBlockEnergies(const AudioBus* input,
+ 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.
+//
+// It is not expected that this function is called with
+// y[0] == y[1] == y[2].
+void CubicInterpolation(const float* y_values,
+ 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_block|. |energy_target_block| is the energy of the
+// target block. |energy_candidate_blocks| is the energy of all blocks within
+// |search_block|.
+int FullSearch(int lim_low,
DaleCurtis 2013/08/13 21:11:04 low_limit, high_limit ?
turaj 2013/08/16 22:13:56 Done.
+ int lim_high,
+ Interval exclude_interval,
+ const AudioBus* target_block,
+ const AudioBus* search_block,
+ const float* energy_target_block,
+ const float* energy_candidate_blocks);
+
+// Find the index of the block, within |search_block|, that is most similar
+// to |target_block|. Obviously, the returned index is w.r.t. |search_block|.
+// |exclude_interval| is an interval that is excluded from the search.
+int OptimalIndex(const AudioBus* search_block,
+ 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 GetSymmetricHanningWindow(int window_length, float* window);
+
+} // namespace internal
+
+} // namespace media
+
+#endif // MEDIA_FILTERS_WSOLA_INTERNALS_H_

Powered by Google App Engine
This is Rietveld 408576698