Title: [105078] trunk/Source/WebCore
Revision
105078
Author
jer.no...@apple.com
Date
2012-01-16 10:53:11 -0800 (Mon, 16 Jan 2012)

Log Message

WebAudio: Optimize AudioChannel::maxAbsValue().
https://bugs.webkit.org/show_bug.cgi?id=74359

Reviewed by Eric Carlson.

No new tests; optimization of existing code, so covered by existing test cases.

* platform/audio/AudioChannel.cpp:
(WebCore::AudioChannel::maxAbsValue): Replace implementation with optimized vector math
    operation.
* platform/audio/VectorMath.cpp:
(WebCore::VectorMath::vmaxmgv): Vector math operation for determining maximum
    magnitude in a vector.
* platform/audio/VectorMath.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (105077 => 105078)


--- trunk/Source/WebCore/ChangeLog	2012-01-16 18:46:52 UTC (rev 105077)
+++ trunk/Source/WebCore/ChangeLog	2012-01-16 18:53:11 UTC (rev 105078)
@@ -1,3 +1,20 @@
+2011-12-12  Jer Noble  <jer.no...@apple.com>
+
+        WebAudio: Optimize AudioChannel::maxAbsValue().
+        https://bugs.webkit.org/show_bug.cgi?id=74359
+
+        Reviewed by Eric Carlson.
+
+        No new tests; optimization of existing code, so covered by existing test cases.
+
+        * platform/audio/AudioChannel.cpp:
+        (WebCore::AudioChannel::maxAbsValue): Replace implementation with optimized vector math 
+            operation.
+        * platform/audio/VectorMath.cpp:
+        (WebCore::VectorMath::vmaxmgv): Vector math operation for determining maximum
+            magnitude in a vector.
+        * platform/audio/VectorMath.h:
+
 2012-01-16  Joe Thomas  <joetho...@motorola.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=41210

Modified: trunk/Source/WebCore/platform/audio/AudioChannel.cpp (105077 => 105078)


--- trunk/Source/WebCore/platform/audio/AudioChannel.cpp	2012-01-16 18:46:52 UTC (rev 105077)
+++ trunk/Source/WebCore/platform/audio/AudioChannel.cpp	2012-01-16 18:53:11 UTC (rev 105078)
@@ -88,13 +88,10 @@
 
 float AudioChannel::maxAbsValue() const
 {
-    const float* p = data();
-    int n = length();
-
     float max = 0.0f;
-    while (n--)
-        max = std::max(max, fabsf(*p++));
 
+    vmaxmgv(data(), 1, &max, length());
+
     return max;
 }
 

Modified: trunk/Source/WebCore/platform/audio/VectorMath.cpp (105077 => 105078)


--- trunk/Source/WebCore/platform/audio/VectorMath.cpp	2012-01-16 18:46:52 UTC (rev 105077)
+++ trunk/Source/WebCore/platform/audio/VectorMath.cpp	2012-01-16 18:53:11 UTC (rev 105078)
@@ -95,6 +95,11 @@
     vDSP_vsma(sourceP, sourceStride, scale, destP, destStride, destP, destStride, framesToProcess);
 }
 
+void vmaxmgv(const float* sourceP, int sourceStride, float* maxP, size_t framesToProcess)
+{
+    vDSP_maxmgv(sourceP, sourceStride, maxP, framesToProcess);
+}
+
 void vsvesq(const float* sourceP, int sourceStride, float* sumP, size_t framesToProcess)
 {
     vDSP_svesq(const_cast<float*>(sourceP), sourceStride, sumP, framesToProcess);
@@ -429,6 +434,20 @@
     ASSERT(sumP);
     *sumP = sum;
 }
+
+void vmaxmgv(const float* sourceP, int sourceStride, float* maxP, size_t framesToProcess)
+{
+    // FIXME: optimize for SSE
+    int n = framesToProcess;
+    float max = 0;
+    while (n--) {
+        max = std::max(max, fabsf(*sourceP));
+        sourceP += sourceStride;
+    }
+
+    ASSERT(maxP);
+    *maxP = max;
+}
 #endif // OS(DARWIN)
 
 } // namespace VectorMath

Modified: trunk/Source/WebCore/platform/audio/VectorMath.h (105077 => 105078)


--- trunk/Source/WebCore/platform/audio/VectorMath.h	2012-01-16 18:46:52 UTC (rev 105077)
+++ trunk/Source/WebCore/platform/audio/VectorMath.h	2012-01-16 18:53:11 UTC (rev 105078)
@@ -37,6 +37,9 @@
 void vsmul(const float* sourceP, int sourceStride, const float* scale, float* destP, int destStride, size_t framesToProcess);
 void vadd(const float* source1P, int sourceStride1, const float* source2P, int sourceStride2, float* destP, int destStride, size_t framesToProcess);
 
+// Finds the maximum magnitude of a float vector.
+void vmaxmgv(const float* sourceP, int sourceStride, float* maxP, size_t framesToProcess);
+
 // Sums the squares of a float vector's elements.
 void vsvesq(const float* sourceP, int sourceStride, float* sumP, size_t framesToProcess);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to