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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/vector_math.h ('k') | media/base/vector_math_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/vector_math.cc
diff --git a/media/base/vector_math.cc b/media/base/vector_math.cc
index 32584f5cf64ad2a1ecf400cbccd8f9341851cfa4..6152204ff39f3c223fe10c6901c417e0c288fe1c 100644
--- a/media/base/vector_math.cc
+++ b/media/base/vector_math.cc
@@ -88,6 +88,13 @@ void FMUL_C(const float src[], float scale, int len, float dest[]) {
dest[i] = src[i] * scale;
}
+void Crossfade(const float src[], int len, float dest[]) {
+ float cf_ratio = 0;
+ const float cf_increment = 1.0f / len;
+ for (int i = 0; i < len; ++i, cf_ratio += cf_increment)
+ dest[i] = (1.0f - cf_ratio) * src[i] + cf_ratio * dest[i];
+}
+
std::pair<float, float> EWMAAndMaxPower(
float initial_value, const float src[], int len, float smoothing_factor) {
// Ensure |src| is 16-byte aligned.
« 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