Changeset 104893 in webkit
- Timestamp:
- Jan 12, 2012 8:27:54 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r104887 r104893 1 2012-01-12 Wei James <james.wei@intel.com> 2 3 Add vsma in VectorMath to handle vector scale multiply and add and use it in AudioBus 4 https://bugs.webkit.org/show_bug.cgi?id=75835 5 6 When summing a audio bus, the source is multiplied with the scale and 7 then summed into the destination bus. Add this function to fulfill it. 8 9 Reviewed by Kenneth Russell. 10 11 * platform/audio/AudioBus.cpp: 12 * platform/audio/VectorMath.cpp: 13 (WebCore::VectorMath::vsma): 14 * platform/audio/VectorMath.h: 15 1 16 2012-01-12 James Simonsen <simonjam@chromium.org> 2 17 -
trunk/Source/WebCore/platform/audio/AudioBus.cpp
r104859 r104893 253 253 } 254 254 255 // FIXME: this can be optimized with additional VectorMath functions.256 255 #define STEREO_SUM_V \ 257 for (; k < framesToProcess; ++k) \ 258 STEREO_SUM 256 { \ 257 vsma(sourceL, 1, &gain, destinationL, 1, framesToProcess - k); \ 258 vsma(sourceR, 1, &gain, destinationR, 1, framesToProcess - k); \ 259 } 259 260 260 261 // Mono -> stereo (mix equally into L and R) … … 270 271 271 272 #define MONO2STEREO_SUM_V \ 272 for (; k < framesToProcess; ++k) \ 273 MONO2STEREO_SUM 273 { \ 274 vsma(sourceL, 1, &gain, destinationL, 1, framesToProcess - k); \ 275 vsma(sourceL, 1, &gain, destinationR, 1, framesToProcess - k); \ 276 } 274 277 275 278 #define MONO_SUM \ … … 280 283 281 284 #define MONO_SUM_V \ 282 for (; k < framesToProcess; ++k) \ 283 MONO_SUM 285 { \ 286 vsma(sourceL, 1, &gain, destinationL, 1, framesToProcess - k); \ 287 } 284 288 285 289 #define STEREO_NO_SUM \ -
trunk/Source/WebCore/platform/audio/VectorMath.cpp
r104147 r104893 91 91 } 92 92 93 void vsma(const float* sourceP, int sourceStride, const float* scale, float* destP, int destStride, size_t framesToProcess) 94 { 95 vDSP_vsma(sourceP, sourceStride, scale, destP, destStride, destP, destStride, framesToProcess); 96 } 97 93 98 #else 99 100 void vsma(const float* sourceP, int sourceStride, const float* scale, float* destP, int destStride, size_t framesToProcess) 101 { 102 int n = framesToProcess; 103 104 #ifdef __SSE2__ 105 if ((sourceStride == 1) && (destStride == 1)) { 106 float k = *scale; 107 108 // If the sourceP address is not 16-byte aligned, the first several frames (at most three) should be processed seperately. 109 while ((reinterpret_cast<uintptr_t>(sourceP) & 0x0F) && n) { 110 *destP += k * *sourceP; 111 sourceP++; 112 destP++; 113 n--; 114 } 115 116 // Now the sourceP address aligned and start to apply SSE. 117 int tailFrames = n % 4; 118 float* endP = destP + n - tailFrames; 119 120 __m128 pSource; 121 __m128 dest; 122 __m128 temp; 123 __m128 mScale = _mm_set_ps1(k); 124 125 bool destAligned = !(reinterpret_cast<uintptr_t>(destP) & 0x0F); 126 127 #define SSE2_MULT_ADD(loadInstr, storeInstr) \ 128 while (destP < endP) \ 129 { \ 130 pSource = _mm_load_ps(sourceP); \ 131 temp = _mm_mul_ps(pSource, mScale); \ 132 dest = _mm_##loadInstr##_ps(destP); \ 133 dest = _mm_add_ps(dest, temp); \ 134 _mm_##storeInstr##_ps(destP, dest); \ 135 sourceP += 4; \ 136 destP += 4; \ 137 } 138 139 if (destAligned) 140 SSE2_MULT_ADD(load, store) 141 else 142 SSE2_MULT_ADD(loadu, storeu) 143 144 n = tailFrames; 145 } 146 #endif 147 while (n) { 148 *destP += *sourceP * *scale; 149 sourceP += sourceStride; 150 destP += destStride; 151 n--; 152 } 153 } 154 94 155 95 156 void vsmul(const float* sourceP, int sourceStride, const float* scale, float* destP, int destStride, size_t framesToProcess) -
trunk/Source/WebCore/platform/audio/VectorMath.h
r104143 r104893 32 32 namespace VectorMath { 33 33 34 // Vector scalar multiply and then add. 35 void vsma(const float* sourceP, int sourceStride, const float* scale, float* destP, int destStride, size_t framesToProcess); 36 34 37 void vsmul(const float* sourceP, int sourceStride, const float* scale, float* destP, int destStride, size_t framesToProcess); 35 38 void vadd(const float* source1P, int sourceStride1, const float* source2P, int sourceStride2, float* destP, int destStride, size_t framesToProcess);
Note: See TracChangeset
for help on using the changeset viewer.