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

Side by Side 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: Comments addressed, AudioRendererAlgorithmTest::WsolaTest modified. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/filters/audio_renderer_algorithm_unittest.cc ('k') | media/filters/wsola_internals.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // A set of utility functions to perform WSOLA.
6
7 #ifndef MEDIA_FILTERS_WSOLA_INTERNALS_H_
8 #define MEDIA_FILTERS_WSOLA_INTERNALS_H_
9
10 #include <utility>
11
12 namespace media {
13
14 class AudioBus;
15
16 namespace internal {
17
18 typedef std::pair<int, int> Interval;
19
20 // Dot-product of channels of two AudioBus. For each AudioBus an offset is
21 // given. |dot_product[k]| is the dot-product of channel |k|. The caller should
22 // allocate sufficient space for |dot_product|.
23 void MultiChannelDotProduct(const AudioBus* a,
24 int frame_offset_a,
25 const AudioBus* b,
26 int frame_offset_b,
27 int num_frames,
28 float* dot_product);
29
30 // Energies of sliding windows of channels are interleaved.
31 // The number windows is |input->frames()| - (|frames_per_window| - 1), hence,
32 // the method assumes |energy| must be, at least, of size
33 // (|input->frames()| - (|frames_per_window| - 1)) * |input->channels()|.
34 void MultiChannelMovingBlockEnergies(const AudioBus* input,
35 int frames_per_window,
36 float* energy);
37
38 // Fit the curve f(x) = a * x^2 + b * x + c such that
39 //
40 // f(-1) = |y[0]|
41 // f(0) = |y[1]|
42 // f(1) = |y[2]|.
43 //
44 // Then compute the |extremum| point -b / (2*a) and |extremum_value|
45 // b^2 / (4*a) - b^2 / (2*a) + c.
46 //
47 // It is not expected that this function is called with
48 // y[0] == y[1] == y[2].
49 void CubicInterpolation(const float* y_values,
50 float* extremum,
51 float* extremum_value);
52
53 // Search a subset of all candid blocks. The search is performed every
54 // |decimation| frames. This reduces complexity by a factor of about
55 // 1 / |decimation|. A cubic interpolation is used to have a better estimate of
56 // the best match.
57 int DecimatedSearch(int decimation,
58 Interval exclude_interval,
59 const AudioBus* target_block,
60 const AudioBus* search_segment,
61 const float* energy_target_block,
62 const float* energy_candid_blocks);
63
64 // Search [|low_limit|, |high_limit|] of |search_segment| to find a block that
65 // is most similar to |target_block|. |energy_target_block| is the energy of the
66 // |target_block_|. |energy_candidate_blocks| is the energy of all blocks within
turaj 2013/08/21 01:01:19 Will be corrected in the next upload.
67 // |search_block|.
68 int FullSearch(int low_limit,
69 int hight_limimit,
70 Interval exclude_interval,
71 const AudioBus* target_block,
72 const AudioBus* search_block,
73 const float* energy_target_block,
74 const float* energy_candidate_blocks);
75
76 // Find the index of the block, within |search_block|, that is most similar
77 // to |target_block|. Obviously, the returned index is w.r.t. |search_block|.
78 // |exclude_interval| is an interval that is excluded from the search.
79 int OptimalIndex(const AudioBus* search_block,
80 const AudioBus* target_block,
81 Interval exclude_interval);
82
83 // Return a "periodic" Hann window. This is the first L samples of an L+1
84 // Hann window. It is perfect reconstruction for overlap-and-add.
85 void GetSymmetricHanningWindow(int window_length, float* window);
86
87 } // namespace internal
88
89 } // namespace media
90
91 #endif // MEDIA_FILTERS_WSOLA_INTERNALS_H_
OLDNEW
« no previous file with comments | « media/filters/audio_renderer_algorithm_unittest.cc ('k') | media/filters/wsola_internals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698