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

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

Issue 156783003: Enhance AudioSplicer to crossfade marked splice frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 6 years, 9 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/base/vector_math.h ('k') | media/base/vector_math_unittest.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 #include "media/base/vector_math.h" 5 #include "media/base/vector_math.h"
6 #include "media/base/vector_math_testing.h" 6 #include "media/base/vector_math_testing.h"
7 7
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/cpu.h" 10 #include "base/cpu.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(src) & (kRequiredAlignment - 1)); 81 DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(src) & (kRequiredAlignment - 1));
82 DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(dest) & (kRequiredAlignment - 1)); 82 DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(dest) & (kRequiredAlignment - 1));
83 return FMUL_FUNC(src, scale, len, dest); 83 return FMUL_FUNC(src, scale, len, dest);
84 } 84 }
85 85
86 void FMUL_C(const float src[], float scale, int len, float dest[]) { 86 void FMUL_C(const float src[], float scale, int len, float dest[]) {
87 for (int i = 0; i < len; ++i) 87 for (int i = 0; i < len; ++i)
88 dest[i] = src[i] * scale; 88 dest[i] = src[i] * scale;
89 } 89 }
90 90
91 void Crossfade(const float src[], int len, float dest[]) {
92 float cf_ratio = 0;
93 const float cf_increment = 1.0f / len;
94 for (int i = 0; i < len; ++i, cf_ratio += cf_increment)
95 dest[i] = (1.0f - cf_ratio) * src[i] + cf_ratio * dest[i];
96 }
97
91 std::pair<float, float> EWMAAndMaxPower( 98 std::pair<float, float> EWMAAndMaxPower(
92 float initial_value, const float src[], int len, float smoothing_factor) { 99 float initial_value, const float src[], int len, float smoothing_factor) {
93 // Ensure |src| is 16-byte aligned. 100 // Ensure |src| is 16-byte aligned.
94 DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(src) & (kRequiredAlignment - 1)); 101 DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(src) & (kRequiredAlignment - 1));
95 return EWMAAndMaxPower_FUNC(initial_value, src, len, smoothing_factor); 102 return EWMAAndMaxPower_FUNC(initial_value, src, len, smoothing_factor);
96 } 103 }
97 104
98 std::pair<float, float> EWMAAndMaxPower_C( 105 std::pair<float, float> EWMAAndMaxPower_C(
99 float initial_value, const float src[], int len, float smoothing_factor) { 106 float initial_value, const float src[], int len, float smoothing_factor) {
100 std::pair<float, float> result(initial_value, 0.0f); 107 std::pair<float, float> result(initial_value, 0.0f);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 result.first += sample_squared * smoothing_factor; 204 result.first += sample_squared * smoothing_factor;
198 result.second = std::max(result.second, sample_squared); 205 result.second = std::max(result.second, sample_squared);
199 } 206 }
200 207
201 return result; 208 return result;
202 } 209 }
203 #endif 210 #endif
204 211
205 } // namespace vector_math 212 } // namespace vector_math
206 } // namespace media 213 } // namespace media
OLDNEW
« no previous file with comments | « media/base/vector_math.h ('k') | media/base/vector_math_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698