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

Side by Side Diff: media/filters/audio_renderer_algorithm_util.h

Issue 19111004: Upgrade AudioRendererAlgorithm to use WSOLA, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 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_AUDIO_RENDERER_ALGORITHM_UTIL_H_
8 #define MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_UTIL_H_
9
10 #include <utility>
11
12 namespace media {
13
14 class AudioBus;
15
16 typedef std::pair<int, int> interval;
17
18 // Dot-product of channels of two AudioBus. For each AudioBus an offset is
19 // given. |dot_product[k]| is the dot-product of channel |k|. The caller should
20 // allocate sufficient space for |dot_product|.
21 void MultiChannelDotProduct(const AudioBus* a,
22 int frame_offset_a,
23 const AudioBus* b,
24 int frame_offset_b,
25 int num_frames,
26 float* dot_product);
27
28 // Energies of sliding windows of channels are interleaved.
29 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.
30 int frames_per_window,
31 float* energy);
32
33 // Fit the curve f(x) = a * x^2 + b * x + c such that
34 //
35 // f(-1) = |y[0]|
36 // f(0) = |y[1]|
37 // f(1) = |y[2]|.
38 //
39 // Then compute the |extremum| point -b / (2*a) and |extremum_value|
40 // b^2 / (4*a) - b^2 / (2*a) + c.
41 void CubicInterpol(const float* y_values,
ajm 2013/07/23 18:03:28 CubicInterpolation?
turaj 2013/07/29 22:09:57 Done.
42 float* extremum,
43 float* extremum_value);
44
45 // Search a subset of all candid blocks. The search is performed every
46 // |decimation| frames. This reduces complexity by a factor of about
47 // 1 / |decimation|. A cubic interpolation is used to have a better estimate of
48 // the best match.
49 int DecimatedSearch(int decimation,
50 interval exclude_interval,
51 const AudioBus* target_block,
52 const AudioBus* search_segment,
53 const float* energy_target_block,
54 const float* energy_candid_blocks);
55
56 // Search [|lim_low|, |lim_high|] of |search_segment| to find a block that is
57 // most similar to |target_interval|. |energy_target_block| is the energy of the
58 // target block. |energy_candid_blocks| is the energy of all blocks within
59 // |search_segment|.
60 int PartialSearch(int lim_low,
61 int lim_high,
62 interval exclude_interval,
63 const AudioBus* target_block,
64 const AudioBus* search_segment,
65 const float* energy_target_block,
66 const float* energy_candid_blocks);
67
68 // Find the index of the block, within |search_segment|, that is most similar
69 // to |target_block|. Obviously, the returned index is w.r.t. |search_segment|.
70 // |exclude_interval| is an interval that is excluded from the search.
71 int OptimalIndex(const AudioBus* search_segment,
72 const AudioBus* target_block,
73 interval exclude_interval);
74
75 // Return a "periodic" Hann window. This is the first L samples of an L+1
76 // Hann window. It is perfect reconstruction for overlap-and-add.
77 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
78
79 } // namespace media
80
81 #endif // MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698