| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // Copy source samples to 2nd half of input buffer. | 91 // Copy source samples to 2nd half of input buffer. |
| 92 bool isInputBufferGood = m_inputBuffer.size() == sourceFramesToProcess * 2 && | 92 bool isInputBufferGood = m_inputBuffer.size() == sourceFramesToProcess * 2 && |
| 93 halfSize <= sourceFramesToProcess; | 93 halfSize <= sourceFramesToProcess; |
| 94 ASSERT(isInputBufferGood); | 94 ASSERT(isInputBufferGood); |
| 95 if (!isInputBufferGood) | 95 if (!isInputBufferGood) |
| 96 return; | 96 return; |
| 97 | 97 |
| 98 float* inputP = m_inputBuffer.data() + sourceFramesToProcess; | 98 float* inputP = m_inputBuffer.data() + sourceFramesToProcess; |
| 99 memcpy(inputP, sourceP, sizeof(float) * sourceFramesToProcess); | 99 memcpy(inputP, sourceP, sizeof(float) * sourceFramesToProcess); |
| 100 | 100 |
| 101 // Copy even sample-frames 0,2,4,6... (delayed by the linear phase delay) dire
ctly into destP. | 101 // Copy even sample-frames 0,2,4,6... (delayed by the linear phase delay) |
| 102 // directly into destP. |
| 102 for (unsigned i = 0; i < sourceFramesToProcess; ++i) | 103 for (unsigned i = 0; i < sourceFramesToProcess; ++i) |
| 103 destP[i * 2] = *((inputP - halfSize) + i); | 104 destP[i * 2] = *((inputP - halfSize) + i); |
| 104 | 105 |
| 105 // Compute odd sample-frames 1,3,5,7... | 106 // Compute odd sample-frames 1,3,5,7... |
| 106 float* oddSamplesP = m_tempBuffer.data(); | 107 float* oddSamplesP = m_tempBuffer.data(); |
| 107 m_convolver.process(&m_kernel, sourceP, oddSamplesP, sourceFramesToProcess); | 108 m_convolver.process(&m_kernel, sourceP, oddSamplesP, sourceFramesToProcess); |
| 108 | 109 |
| 109 for (unsigned i = 0; i < sourceFramesToProcess; ++i) | 110 for (unsigned i = 0; i < sourceFramesToProcess; ++i) |
| 110 destP[i * 2 + 1] = oddSamplesP[i]; | 111 destP[i * 2 + 1] = oddSamplesP[i]; |
| 111 | 112 |
| 112 // Copy 2nd half of input buffer to 1st half. | 113 // Copy 2nd half of input buffer to 1st half. |
| 113 memcpy(m_inputBuffer.data(), inputP, sizeof(float) * sourceFramesToProcess); | 114 memcpy(m_inputBuffer.data(), inputP, sizeof(float) * sourceFramesToProcess); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void UpSampler::reset() { | 117 void UpSampler::reset() { |
| 117 m_convolver.reset(); | 118 m_convolver.reset(); |
| 118 m_inputBuffer.zero(); | 119 m_inputBuffer.zero(); |
| 119 } | 120 } |
| 120 | 121 |
| 121 size_t UpSampler::latencyFrames() const { | 122 size_t UpSampler::latencyFrames() const { |
| 122 // Divide by two since this is a linear phase kernel and the delay is at the c
enter of the kernel. | 123 // Divide by two since this is a linear phase kernel and the delay is at the |
| 124 // center of the kernel. |
| 123 return m_kernel.size() / 2; | 125 return m_kernel.size() / 2; |
| 124 } | 126 } |
| 125 | 127 |
| 126 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |