| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Input buffer layout, dividing the total buffer into regions (r0_ - r5_): | 5 // Input buffer layout, dividing the total buffer into regions (r0_ - r5_): |
| 6 // | 6 // |
| 7 // |----------------|-----------------------------------------|----------------| | 7 // |----------------|-----------------------------------------|----------------| |
| 8 // | 8 // |
| 9 // kBlockSize + kKernelSize / 2 | 9 // kBlockSize + kKernelSize / 2 |
| 10 // <---------------------------------------------------------> | 10 // <---------------------------------------------------------> |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // Step (4) | 207 // Step (4) |
| 208 // Refresh the buffer with more input. | 208 // Refresh the buffer with more input. |
| 209 read_cb_.Run(r5_, kBlockSize); | 209 read_cb_.Run(r5_, kBlockSize); |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 | 212 |
| 213 int SincResampler::ChunkSize() { | 213 int SincResampler::ChunkSize() { |
| 214 return kBlockSize / io_sample_rate_ratio_; | 214 return kBlockSize / io_sample_rate_ratio_; |
| 215 } | 215 } |
| 216 | 216 |
| 217 void SincResampler::Flush() { |
| 218 virtual_source_idx_ = 0; |
| 219 buffer_primed_ = false; |
| 220 memset(input_buffer_.get(), 0, sizeof(*input_buffer_.get()) * kBufferSize); |
| 221 } |
| 222 |
| 217 float SincResampler::Convolve(const float* input_ptr, const float* k1, | 223 float SincResampler::Convolve(const float* input_ptr, const float* k1, |
| 218 const float* k2, | 224 const float* k2, |
| 219 double kernel_interpolation_factor) { | 225 double kernel_interpolation_factor) { |
| 220 // Rely on function level static initialization to keep ConvolveProc selection | 226 // Rely on function level static initialization to keep ConvolveProc selection |
| 221 // thread safe. | 227 // thread safe. |
| 222 typedef float (*ConvolveProc)(const float* src, const float* k1, | 228 typedef float (*ConvolveProc)(const float* src, const float* k1, |
| 223 const float* k2, | 229 const float* k2, |
| 224 double kernel_interpolation_factor); | 230 double kernel_interpolation_factor); |
| 225 #if defined(ARCH_CPU_X86_FAMILY) && defined(__SSE__) | 231 #if defined(ARCH_CPU_X86_FAMILY) && defined(__SSE__) |
| 226 static const ConvolveProc kConvolveProc = | 232 static const ConvolveProc kConvolveProc = |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 float result; | 295 float result; |
| 290 m_sums2 = _mm_add_ps(_mm_movehl_ps(m_sums1, m_sums1), m_sums1); | 296 m_sums2 = _mm_add_ps(_mm_movehl_ps(m_sums1, m_sums1), m_sums1); |
| 291 _mm_store_ss(&result, _mm_add_ss(m_sums2, _mm_shuffle_ps( | 297 _mm_store_ss(&result, _mm_add_ss(m_sums2, _mm_shuffle_ps( |
| 292 m_sums2, m_sums2, 1))); | 298 m_sums2, m_sums2, 1))); |
| 293 | 299 |
| 294 return result; | 300 return result; |
| 295 } | 301 } |
| 296 #endif | 302 #endif |
| 297 | 303 |
| 298 } // namespace media | 304 } // namespace media |
| OLD | NEW |