| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 // Window the sinc() function. | 66 // Window the sinc() function. |
| 67 m_kernel[i] = sinc * window; | 67 m_kernel[i] = sinc * window; |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void UpSampler::process(const float* sourceP, | 71 void UpSampler::process(const float* sourceP, |
| 72 float* destP, | 72 float* destP, |
| 73 size_t sourceFramesToProcess) { | 73 size_t sourceFramesToProcess) { |
| 74 bool isInputBlockSizeGood = sourceFramesToProcess == m_inputBlockSize; | 74 bool isInputBlockSizeGood = sourceFramesToProcess == m_inputBlockSize; |
| 75 ASSERT(isInputBlockSizeGood); | 75 DCHECK(isInputBlockSizeGood); |
| 76 if (!isInputBlockSizeGood) | 76 if (!isInputBlockSizeGood) |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 bool isTempBufferGood = sourceFramesToProcess == m_tempBuffer.size(); | 79 bool isTempBufferGood = sourceFramesToProcess == m_tempBuffer.size(); |
| 80 ASSERT(isTempBufferGood); | 80 DCHECK(isTempBufferGood); |
| 81 if (!isTempBufferGood) | 81 if (!isTempBufferGood) |
| 82 return; | 82 return; |
| 83 | 83 |
| 84 bool isKernelGood = m_kernel.size() == DefaultKernelSize; | 84 bool isKernelGood = m_kernel.size() == DefaultKernelSize; |
| 85 ASSERT(isKernelGood); | 85 DCHECK(isKernelGood); |
| 86 if (!isKernelGood) | 86 if (!isKernelGood) |
| 87 return; | 87 return; |
| 88 | 88 |
| 89 size_t halfSize = m_kernel.size() / 2; | 89 size_t halfSize = m_kernel.size() / 2; |
| 90 | 90 |
| 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 DCHECK(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) | 101 // Copy even sample-frames 0,2,4,6... (delayed by the linear phase delay) |
| 102 // directly into destP. | 102 // directly into destP. |
| 103 for (unsigned i = 0; i < sourceFramesToProcess; ++i) | 103 for (unsigned i = 0; i < sourceFramesToProcess; ++i) |
| 104 destP[i * 2] = *((inputP - halfSize) + i); | 104 destP[i * 2] = *((inputP - halfSize) + i); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 119 m_inputBuffer.zero(); | 119 m_inputBuffer.zero(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 size_t UpSampler::latencyFrames() const { | 122 size_t UpSampler::latencyFrames() const { |
| 123 // Divide by two since this is a linear phase kernel and the delay is at the | 123 // Divide by two since this is a linear phase kernel and the delay is at the |
| 124 // center of the kernel. | 124 // center of the kernel. |
| 125 return m_kernel.size() / 2; | 125 return m_kernel.size() / 2; |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |