| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 a2 * std::cos(twoPiDouble * 2.0 * x); | 125 a2 * std::cos(twoPiDouble * 2.0 * x); |
| 126 | 126 |
| 127 // Window the sinc() function and store at the correct offset. | 127 // Window the sinc() function and store at the correct offset. |
| 128 m_kernelStorage[i + offsetIndex * m_kernelSize] = sinc * window; | 128 m_kernelStorage[i + offsetIndex * m_kernelSize] = sinc * window; |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 void SincResampler::consumeSource(float* buffer, | 133 void SincResampler::consumeSource(float* buffer, |
| 134 unsigned numberOfSourceFrames) { | 134 unsigned numberOfSourceFrames) { |
| 135 ASSERT(m_sourceProvider); | 135 DCHECK(m_sourceProvider); |
| 136 if (!m_sourceProvider) | 136 if (!m_sourceProvider) |
| 137 return; | 137 return; |
| 138 | 138 |
| 139 // Wrap the provided buffer by an AudioBus for use by the source provider. | 139 // Wrap the provided buffer by an AudioBus for use by the source provider. |
| 140 RefPtr<AudioBus> bus = AudioBus::create(1, numberOfSourceFrames, false); | 140 RefPtr<AudioBus> bus = AudioBus::create(1, numberOfSourceFrames, false); |
| 141 | 141 |
| 142 // FIXME: Find a way to make the following const-correct: | 142 // FIXME: Find a way to make the following const-correct: |
| 143 bus->setChannelMemory(0, buffer, numberOfSourceFrames); | 143 bus->setChannelMemory(0, buffer, numberOfSourceFrames); |
| 144 | 144 |
| 145 m_sourceProvider->provideInput(bus.get(), numberOfSourceFrames); | 145 m_sourceProvider->provideInput(bus.get(), numberOfSourceFrames); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 remaining -= framesThisTime; | 200 remaining -= framesThisTime; |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 void SincResampler::process(AudioSourceProvider* sourceProvider, | 204 void SincResampler::process(AudioSourceProvider* sourceProvider, |
| 205 float* destination, | 205 float* destination, |
| 206 size_t framesToProcess) { | 206 size_t framesToProcess) { |
| 207 bool isGood = sourceProvider && m_blockSize > m_kernelSize && | 207 bool isGood = sourceProvider && m_blockSize > m_kernelSize && |
| 208 m_inputBuffer.size() >= m_blockSize + m_kernelSize && | 208 m_inputBuffer.size() >= m_blockSize + m_kernelSize && |
| 209 !(m_kernelSize % 2); | 209 !(m_kernelSize % 2); |
| 210 ASSERT(isGood); | 210 DCHECK(isGood); |
| 211 if (!isGood) | 211 if (!isGood) |
| 212 return; | 212 return; |
| 213 | 213 |
| 214 m_sourceProvider = sourceProvider; | 214 m_sourceProvider = sourceProvider; |
| 215 | 215 |
| 216 unsigned numberOfDestinationFrames = framesToProcess; | 216 unsigned numberOfDestinationFrames = framesToProcess; |
| 217 | 217 |
| 218 // Setup various region pointers in the buffer (see diagram above). | 218 // Setup various region pointers in the buffer (see diagram above). |
| 219 float* r0 = m_inputBuffer.data() + m_kernelSize / 2; | 219 float* r0 = m_inputBuffer.data() + m_kernelSize / 2; |
| 220 float* r1 = m_inputBuffer.data(); | 220 float* r1 = m_inputBuffer.data(); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 memcpy(r1, r3, sizeof(float) * (m_kernelSize / 2)); | 474 memcpy(r1, r3, sizeof(float) * (m_kernelSize / 2)); |
| 475 memcpy(r2, r4, sizeof(float) * (m_kernelSize / 2)); | 475 memcpy(r2, r4, sizeof(float) * (m_kernelSize / 2)); |
| 476 | 476 |
| 477 // Step (4) | 477 // Step (4) |
| 478 // Refresh the buffer with more input. | 478 // Refresh the buffer with more input. |
| 479 consumeSource(r5, m_blockSize); | 479 consumeSource(r5, m_blockSize); |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 | 482 |
| 483 } // namespace blink | 483 } // namespace blink |
| OLD | NEW |