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 * | 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 { | 52 { |
53 ASSERT(impulseResponse); | 53 ASSERT(impulseResponse); |
54 ASSERT(accumulationBuffer); | 54 ASSERT(accumulationBuffer); |
55 | 55 |
56 if (!m_directMode) { | 56 if (!m_directMode) { |
57 m_fftKernel = adoptPtr(new FFTFrame(fftSize)); | 57 m_fftKernel = adoptPtr(new FFTFrame(fftSize)); |
58 m_fftKernel->doPaddedFFT(impulseResponse + stageOffset, stageLength); | 58 m_fftKernel->doPaddedFFT(impulseResponse + stageOffset, stageLength); |
59 m_fftConvolver = adoptPtr(new FFTConvolver(fftSize)); | 59 m_fftConvolver = adoptPtr(new FFTConvolver(fftSize)); |
60 } else { | 60 } else { |
61 m_directKernel = adoptPtr(new AudioFloatArray(fftSize / 2)); | 61 m_directKernel = adoptPtr(new AudioFloatArray(fftSize / 2)); |
62 m_directKernel->copyToRange(impulseResponse + stageOffset, 0, fftSize / 2); | 62 m_directKernel->copyToRange(impulseResponse + stageOffset, 0, std::min(s tageLength, fftSize / 2)); |
Ken Russell (switch to Gerrit)
2013/08/29 21:49:23
Why does this guarantee that we won't read beyond
| |
63 m_directConvolver = adoptPtr(new DirectConvolver(renderSliceSize)); | 63 m_directConvolver = adoptPtr(new DirectConvolver(renderSliceSize)); |
64 } | 64 } |
65 m_temporaryBuffer.allocate(renderSliceSize); | 65 m_temporaryBuffer.allocate(renderSliceSize); |
66 | 66 |
67 // The convolution stage at offset stageOffset needs to have a corresponding delay to cancel out the offset. | 67 // The convolution stage at offset stageOffset needs to have a corresponding delay to cancel out the offset. |
68 size_t totalDelay = stageOffset + reverbTotalLatency; | 68 size_t totalDelay = stageOffset + reverbTotalLatency; |
69 | 69 |
70 // But, the FFT convolution itself incurs fftSize / 2 latency, so subtract t his out... | 70 // But, the FFT convolution itself incurs fftSize / 2 latency, so subtract t his out... |
71 size_t halfSize = fftSize / 2; | 71 size_t halfSize = fftSize / 2; |
72 if (!m_directMode) { | 72 if (!m_directMode) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 m_directConvolver->reset(); | 173 m_directConvolver->reset(); |
174 m_preDelayBuffer.zero(); | 174 m_preDelayBuffer.zero(); |
175 m_accumulationReadIndex = 0; | 175 m_accumulationReadIndex = 0; |
176 m_inputReadIndex = 0; | 176 m_inputReadIndex = 0; |
177 m_framesProcessed = 0; | 177 m_framesProcessed = 0; |
178 } | 178 } |
179 | 179 |
180 } // namespace WebCore | 180 } // namespace WebCore |
181 | 181 |
182 #endif // ENABLE(WEB_AUDIO) | 182 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |