OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 real = _mm_sub_ps(real, _mm_mul_ps(imag1, imag2)); | 411 real = _mm_sub_ps(real, _mm_mul_ps(imag1, imag2)); |
412 __m128 imag = _mm_mul_ps(real1, imag2); | 412 __m128 imag = _mm_mul_ps(real1, imag2); |
413 imag = _mm_add_ps(imag, _mm_mul_ps(imag1, real2)); | 413 imag = _mm_add_ps(imag, _mm_mul_ps(imag1, real2)); |
414 _mm_store_ps(realDestP + i, real); | 414 _mm_store_ps(realDestP + i, real); |
415 _mm_store_ps(imagDestP + i, imag); | 415 _mm_store_ps(imagDestP + i, imag); |
416 i += 4; | 416 i += 4; |
417 } | 417 } |
418 } | 418 } |
419 #endif | 419 #endif |
420 for (; i < framesToProcess; ++i) { | 420 for (; i < framesToProcess; ++i) { |
421 realDestP[i] = real1P[i] * real2P[i] - imag1P[i] * imag2P[i]; | 421 // Read and compute result before storing them, in case the |
422 imagDestP[i] = real1P[i] * imag2P[i] + imag1P[i] * real2P[i]; | 422 // destination is the same as one of the sources. |
| 423 float realResult = real1P[i] * real2P[i] - imag1P[i] * imag2P[i]; |
| 424 float imagResult = real1P[i] * imag2P[i] + imag1P[i] * real2P[i]; |
| 425 |
| 426 realDestP[i] = realResult; |
| 427 imagDestP[i] = imagResult; |
423 } | 428 } |
424 } | 429 } |
425 | 430 |
426 void vsvesq(const float* sourceP, int sourceStride, float* sumP, size_t framesTo
Process) | 431 void vsvesq(const float* sourceP, int sourceStride, float* sumP, size_t framesTo
Process) |
427 { | 432 { |
428 // FIXME: optimize for SSE | 433 // FIXME: optimize for SSE |
429 int n = framesToProcess; | 434 int n = framesToProcess; |
430 float sum = 0; | 435 float sum = 0; |
431 while (n--) { | 436 while (n--) { |
432 float sample = *sourceP; | 437 float sample = *sourceP; |
(...skipping 18 matching lines...) Expand all Loading... |
451 ASSERT(maxP); | 456 ASSERT(maxP); |
452 *maxP = max; | 457 *maxP = max; |
453 } | 458 } |
454 #endif // OS(DARWIN) | 459 #endif // OS(DARWIN) |
455 | 460 |
456 } // namespace VectorMath | 461 } // namespace VectorMath |
457 | 462 |
458 } // namespace WebCore | 463 } // namespace WebCore |
459 | 464 |
460 #endif // ENABLE(WEB_AUDIO) | 465 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |