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

Unified Diff: media/base/vector_math.cc

Issue 13726011: Add vector_math::FMUL. Replace audio_util::AdjustVolume. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix volume == 1 case. Created 7 years, 8 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_testing.h » ('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 96f94d95e4b60846a15001375ac1c8a62b2cf76a..f534d92de5fd05623affdc5e1c1ddb4c8993be66 100644
--- a/media/base/vector_math.cc
+++ b/media/base/vector_math.cc
@@ -16,14 +16,18 @@ void FMAC(const float src[], float scale, int len, float dest[]) {
DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(src) & (kRequiredAlignment - 1));
DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(dest) & (kRequiredAlignment - 1));
- // Rely on function level static initialization to keep VectorFMACProc
- // selection thread safe.
typedef void (*VectorFMACProc)(const float src[], float scale, int len,
float dest[]);
-#if defined(ARCH_CPU_X86_FAMILY)
+
+ // No NaCl code uses the SSE functionality of AudioBus and plumbing the -msse
+ // built library is non-trivial, so simply disable for now. iOS lies about
+ // its architecture, so we need to exclude it here.
+#if defined(ARCH_CPU_X86_FAMILY) && !defined(OS_NACL) && !defined(OS_IOS)
#if defined(__SSE__)
static const VectorFMACProc kVectorFMACProc = FMAC_SSE;
#else
+ // TODO(dalecurtis): Remove function level static initialization, it's not
+ // thread safe: http://crbug.com/224662.
static const VectorFMACProc kVectorFMACProc =
base::CPU().has_sse() ? FMAC_SSE : FMAC_C;
#endif
@@ -39,5 +43,37 @@ void FMAC_C(const float src[], float scale, int len, float dest[]) {
dest[i] += src[i] * scale;
}
+void FMUL(const float src[], float scale, int len, float dest[]) {
+ // Ensure |src| and |dest| are 16-byte aligned.
+ DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(src) & (kRequiredAlignment - 1));
+ DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(dest) & (kRequiredAlignment - 1));
+
+ typedef void (*VectorFMULProc)(const float src[], float scale, int len,
+ float dest[]);
+
+ // No NaCl code uses the SSE functionality of AudioBus and plumbing the -msse
+ // built library is non-trivial, so simply disable for now. iOS lies about
+ // its architecture, so we need to exclude it here.
+#if defined(ARCH_CPU_X86_FAMILY) && !defined(OS_NACL) && !defined(OS_IOS)
+#if defined(__SSE__)
+ static const VectorFMULProc kVectorFMULProc = FMUL_SSE;
+#else
+ // TODO(dalecurtis): Remove function level static initialization, it's not
+ // thread safe: http://crbug.com/224662.
+ static const VectorFMULProc kVectorFMULProc =
+ base::CPU().has_sse() ? FMUL_SSE : FMUL_C;
+#endif
+#else
+ static const VectorFMULProc kVectorFMULProc = FMUL_C;
+#endif
+
+ return kVectorFMULProc(src, scale, len, dest);
+}
+
+void FMUL_C(const float src[], float scale, int len, float dest[]) {
+ for (int i = 0; i < len; ++i)
+ dest[i] = src[i] * scale;
+}
+
} // namespace vector_math
} // namespace media
« no previous file with comments | « media/base/vector_math.h ('k') | media/base/vector_math_testing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698