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

Side by Side Diff: media/base/vector_math.h

Issue 2556993002: Experiment with AVX optimizations for FMAC, FMUL operations.
Patch Set: Created 4 years 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
« no previous file with comments | « media/base/sinc_resampler_unittest.cc ('k') | media/base/vector_math.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 enum {
16 enum { kRequiredAlignment = 16 }; 16 // Kernel size for use with Convolve(); must be a multiple of 32. Higher
17 // values increase the quality of the convolution.
18 kKernelSize = 32,
19
20 // Required alignment for inputs and outputs to all vector math functions
21 kRequiredAlignment = 32
22 };
23
24 // Sets up CPU specific optimizations.
25 MEDIA_EXPORT void Initialize();
26
27 // Compute convolution of |k1| and |k2| over |src|, resultant sums are
28 // linearly interpolated using |kernel_interpolation_factor|.
29 MEDIA_EXPORT float Convolve(const float* src,
30 const float* k1,
31 const float* k2,
32 double kernel_interpolation_factor);
33
34 // Computes the dot-product (scalar-product) of two vectors of length |len|.
35 MEDIA_EXPORT float DotProduct(const float* a, const float* b, int len);
17 36
18 // Multiply each element of |src| (up to |len|) by |scale| and add to |dest|. 37 // Multiply each element of |src| (up to |len|) by |scale| and add to |dest|.
19 // |src| and |dest| must be aligned by kRequiredAlignment. 38 // |src| and |dest| must be aligned by kRequiredAlignment.
20 MEDIA_EXPORT void FMAC(const float src[], float scale, int len, float dest[]); 39 MEDIA_EXPORT void FMAC(const float* src, float scale, int len, float* dest);
21 40
22 // Multiply each element of |src| by |scale| and store in |dest|. |src| and 41 // Multiply each element of |src| by |scale| and store in |dest|. |src| and
23 // |dest| must be aligned by kRequiredAlignment. 42 // |dest| must be aligned by kRequiredAlignment.
24 MEDIA_EXPORT void FMUL(const float src[], float scale, int len, float dest[]); 43 MEDIA_EXPORT void FMUL(const float* src, float scale, int len, float* dest);
25 44
26 // Computes the exponentially-weighted moving average power of a signal by 45 // Computes the exponentially-weighted moving average power of a signal by
27 // iterating the recurrence: 46 // iterating the recurrence:
28 // 47 //
29 // y[-1] = initial_value 48 // y[-1] = initial_value
30 // y[n] = smoothing_factor * src[n]^2 + (1-smoothing_factor) * y[n-1] 49 // y[n] = smoothing_factor * src[n]^2 + (1-smoothing_factor) * y[n-1]
31 // 50 //
32 // Returns the final average power and the maximum squared element value. 51 // Returns the final average power and the maximum squared element value.
33 MEDIA_EXPORT std::pair<float, float> EWMAAndMaxPower( 52 MEDIA_EXPORT std::pair<float, float> EWMAAndMaxPower(float initial_value,
34 float initial_value, const float src[], int len, float smoothing_factor); 53 const float* src,
35 54 int len,
36 MEDIA_EXPORT void Crossfade(const float src[], int len, float dest[]); 55 float smoothing_factor);
37 56
38 } // namespace vector_math 57 } // namespace vector_math
39 } // namespace media 58 } // namespace media
40 59
41 #endif // MEDIA_BASE_VECTOR_MATH_H_ 60 #endif // MEDIA_BASE_VECTOR_MATH_H_
OLDNEW
« no previous file with comments | « media/base/sinc_resampler_unittest.cc ('k') | media/base/vector_math.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698