OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_BASE_VECTOR_MATH_H_ | 5 #ifndef MEDIA_BASE_VECTOR_MATH_H_ |
6 #define MEDIA_BASE_VECTOR_MATH_H_ | 6 #define MEDIA_BASE_VECTOR_MATH_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
11 | 11 |
12 namespace media { | 12 namespace media { |
13 namespace vector_math { | 13 namespace vector_math { |
14 | 14 |
15 // Required alignment for inputs and outputs to all vector math functions | 15 // Required alignment for inputs and outputs to all vector math functions |
16 enum { kRequiredAlignment = 16 }; | 16 enum { kRequiredAlignment = 16 }; |
17 | 17 |
18 // Selects runtime specific optimizations such as SSE. Must be called prior to | |
19 // calling FMAC() or FMUL(). Called during media library initialization; most | |
20 // users should never have to call this. | |
21 MEDIA_EXPORT void Initialize(); | |
22 | |
23 // Multiply each element of |src| (up to |len|) by |scale| and add to |dest|. | 18 // Multiply each element of |src| (up to |len|) by |scale| and add to |dest|. |
24 // |src| and |dest| must be aligned by kRequiredAlignment. | 19 // |src| and |dest| must be aligned by kRequiredAlignment. |
25 MEDIA_EXPORT void FMAC(const float src[], float scale, int len, float dest[]); | 20 MEDIA_EXPORT void FMAC(const float src[], float scale, int len, float dest[]); |
26 | 21 |
27 // Multiply each element of |src| by |scale| and store in |dest|. |src| and | 22 // Multiply each element of |src| by |scale| and store in |dest|. |src| and |
28 // |dest| must be aligned by kRequiredAlignment. | 23 // |dest| must be aligned by kRequiredAlignment. |
29 MEDIA_EXPORT void FMUL(const float src[], float scale, int len, float dest[]); | 24 MEDIA_EXPORT void FMUL(const float src[], float scale, int len, float dest[]); |
30 | 25 |
31 // Computes the exponentially-weighted moving average power of a signal by | 26 // Computes the exponentially-weighted moving average power of a signal by |
32 // iterating the recurrence: | 27 // iterating the recurrence: |
33 // | 28 // |
34 // y[-1] = initial_value | 29 // y[-1] = initial_value |
35 // y[n] = smoothing_factor * src[n]^2 + (1-smoothing_factor) * y[n-1] | 30 // y[n] = smoothing_factor * src[n]^2 + (1-smoothing_factor) * y[n-1] |
36 // | 31 // |
37 // Returns the final average power and the maximum squared element value. | 32 // Returns the final average power and the maximum squared element value. |
38 MEDIA_EXPORT std::pair<float, float> EWMAAndMaxPower( | 33 MEDIA_EXPORT std::pair<float, float> EWMAAndMaxPower( |
39 float initial_value, const float src[], int len, float smoothing_factor); | 34 float initial_value, const float src[], int len, float smoothing_factor); |
40 | 35 |
41 MEDIA_EXPORT void Crossfade(const float src[], int len, float dest[]); | 36 MEDIA_EXPORT void Crossfade(const float src[], int len, float dest[]); |
42 | 37 |
43 } // namespace vector_math | 38 } // namespace vector_math |
44 } // namespace media | 39 } // namespace media |
45 | 40 |
46 #endif // MEDIA_BASE_VECTOR_MATH_H_ | 41 #endif // MEDIA_BASE_VECTOR_MATH_H_ |
OLD | NEW |