OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 | 30 |
31 #if ENABLE(WEB_AUDIO) | 31 #if ENABLE(WEB_AUDIO) |
32 | 32 |
33 #include "platform/audio/SincResampler.h" | 33 #include "platform/audio/SincResampler.h" |
34 | 34 |
35 #include "platform/audio/AudioBus.h" | 35 #include "platform/audio/AudioBus.h" |
| 36 #include "wtf/CPU.h" |
36 #include "wtf/MathExtras.h" | 37 #include "wtf/MathExtras.h" |
37 | 38 |
38 #ifdef __SSE2__ | 39 #if CPU(X86) || CPU(X86_64) |
39 #include <emmintrin.h> | 40 #include <emmintrin.h> |
40 #endif | 41 #endif |
41 | 42 |
42 using namespace std; | 43 using namespace std; |
43 | 44 |
44 // Input buffer layout, dividing the total buffer into regions (r0 - r5): | 45 // Input buffer layout, dividing the total buffer into regions (r0 - r5): |
45 // | 46 // |
46 // |----------------|-----------------------------------------------------------
-----|----------------| | 47 // |----------------|-----------------------------------------------------------
-----|----------------| |
47 // | 48 // |
48 // blockSize + kernelSize / 2 | 49 // blockSize + kernelSize / 2 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 #define CONVOLVE_ONE_SAMPLE \ | 256 #define CONVOLVE_ONE_SAMPLE \ |
256 input = *inputP++; \ | 257 input = *inputP++; \ |
257 sum1 += input * *k1; \ | 258 sum1 += input * *k1; \ |
258 sum2 += input * *k2; \ | 259 sum2 += input * *k2; \ |
259 ++k1; \ | 260 ++k1; \ |
260 ++k2; | 261 ++k2; |
261 | 262 |
262 { | 263 { |
263 float input; | 264 float input; |
264 | 265 |
265 #ifdef __SSE2__ | 266 #if CPU(X86) || CPU(X86_64) |
266 // If the sourceP address is not 16-byte aligned, the first seve
ral frames (at most three) should be processed seperately. | 267 // If the sourceP address is not 16-byte aligned, the first seve
ral frames (at most three) should be processed seperately. |
267 while ((reinterpret_cast<uintptr_t>(inputP) & 0x0F) && n) { | 268 while ((reinterpret_cast<uintptr_t>(inputP) & 0x0F) && n) { |
268 CONVOLVE_ONE_SAMPLE | 269 CONVOLVE_ONE_SAMPLE |
269 n--; | 270 n--; |
270 } | 271 } |
271 | 272 |
272 // Now the inputP is aligned and start to apply SSE. | 273 // Now the inputP is aligned and start to apply SSE. |
273 float* endP = inputP + n - n % 4; | 274 float* endP = inputP + n - n % 4; |
274 __m128 mInput; | 275 __m128 mInput; |
275 __m128 mK1; | 276 __m128 mK1; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 | 466 |
466 // Step (4) | 467 // Step (4) |
467 // Refresh the buffer with more input. | 468 // Refresh the buffer with more input. |
468 consumeSource(r5, m_blockSize); | 469 consumeSource(r5, m_blockSize); |
469 } | 470 } |
470 } | 471 } |
471 | 472 |
472 } // namespace WebCore | 473 } // namespace WebCore |
473 | 474 |
474 #endif // ENABLE(WEB_AUDIO) | 475 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |