Modified: trunk/Source/WebCore/ChangeLog (104307 => 104308)
--- trunk/Source/WebCore/ChangeLog 2012-01-06 19:47:02 UTC (rev 104307)
+++ trunk/Source/WebCore/ChangeLog 2012-01-06 19:51:19 UTC (rev 104308)
@@ -1,3 +1,13 @@
+2012-01-06 Wei James <james....@intel.com>
+
+ Use VectorMath lib when possible to optimize the processing in WebAudio AudioBus
+ https://bugs.webkit.org/show_bug.cgi?id=75334
+
+ Reviewed by Kenneth Russell.
+
+ * platform/audio/AudioBus.cpp:
+ (WebCore::AudioBus::processWithGainFromMonoStereo):
+
2012-01-06 Jer Noble <jer.no...@apple.com>
Fullscreen video controller can't be dragged the first time I enter fullscreen
Modified: trunk/Source/WebCore/platform/audio/AudioBus.cpp (104307 => 104308)
--- trunk/Source/WebCore/platform/audio/AudioBus.cpp 2012-01-06 19:47:02 UTC (rev 104307)
+++ trunk/Source/WebCore/platform/audio/AudioBus.cpp 2012-01-06 19:51:19 UTC (rev 104308)
@@ -244,8 +244,7 @@
GAIN_DEZIPPER \
} \
gain = totalDesiredGain; \
- for (; k < framesToProcess; ++k) \
- OP
+ OP##_V
#define STEREO_SUM \
{ \
@@ -255,6 +254,11 @@
*destinationR++ = sumR; \
}
+// FIXME: this can be optimized with additional VectorMath functions.
+#define STEREO_SUM_V \
+ for (; k < framesToProcess; ++k) \
+ STEREO_SUM
+
// Mono -> stereo (mix equally into L and R)
// FIXME: Really we should apply an equal-power scaling factor here, since we're effectively panning center...
#define MONO2STEREO_SUM \
@@ -266,12 +270,20 @@
*destinationR++ = sumR; \
}
+#define MONO2STEREO_SUM_V \
+ for (; k < framesToProcess; ++k) \
+ MONO2STEREO_SUM
+
#define MONO_SUM \
{ \
float sum = DenormalDisabler::flushDenormalFloatToZero(*destinationL + gain * *sourceL++); \
*destinationL++ = sum; \
}
+#define MONO_SUM_V \
+ for (; k < framesToProcess; ++k) \
+ MONO_SUM
+
#define STEREO_NO_SUM \
{ \
float sampleL = *sourceL++; \
@@ -280,6 +292,12 @@
*destinationR++ = DenormalDisabler::flushDenormalFloatToZero(gain * sampleR); \
}
+#define STEREO_NO_SUM_V \
+ { \
+ vsmul(sourceL, 1, &gain, destinationL, 1, framesToProcess - k); \
+ vsmul(sourceR, 1, &gain, destinationR, 1, framesToProcess - k); \
+ }
+
// Mono -> stereo (mix equally into L and R)
// FIXME: Really we should apply an equal-power scaling factor here, since we're effectively panning center...
#define MONO2STEREO_NO_SUM \
@@ -289,18 +307,28 @@
*destinationR++ = DenormalDisabler::flushDenormalFloatToZero(gain * sample); \
}
+#define MONO2STEREO_NO_SUM_V \
+ { \
+ vsmul(sourceL, 1, &gain, destinationL, 1, framesToProcess - k); \
+ vsmul(sourceL, 1, &gain, destinationR, 1, framesToProcess - k); \
+ }
+
#define MONO_NO_SUM \
{ \
float sampleL = *sourceL++; \
*destinationL++ = DenormalDisabler::flushDenormalFloatToZero(gain * sampleL); \
}
+#define MONO_NO_SUM_V \
+ { \
+ vsmul(sourceL, 1, &gain, destinationL, 1, framesToProcess - k); \
+ }
+
void AudioBus::processWithGainFromMonoStereo(const AudioBus &sourceBus, double* lastMixGain, double targetGain, bool sumToBus)
{
// We don't want to suddenly change the gain from mixing one time slice to the next,
// so we "de-zipper" by slowly changing the gain each sample-frame until we've achieved the target gain.
- // FIXME: optimize this method (SSE, etc.)
// FIXME: targetGain and lastMixGain should be changed to floats instead of doubles.
// Take master bus gain into account as well as the targetGain.
@@ -351,8 +379,6 @@
if (this == &sourceBus && *lastMixGain == targetGain && targetGain == 1.0)
return;
- // FIXME: if (framesToDezipper == 0) and DenormalDisabler::flushDenormalFloatToZero() is a NOP (gcc vs. Visual Studio)
- // then we can further optimize the PROCESS_WITH_GAIN codepaths below using vsmul().
if (sourceR && destinationR) {
// Stereo
PROCESS_WITH_GAIN(STEREO_NO_SUM)