Chromium Code Reviews| Index: media/base/sinc_resampler.cc |
| diff --git a/media/base/sinc_resampler.cc b/media/base/sinc_resampler.cc |
| index 1df8d4d08f894201a823c15c2066ca3ad43904ec..0ceb7a85e271a155a244fbe0ad9ca982dbdf1967 100644 |
| --- a/media/base/sinc_resampler.cc |
| +++ b/media/base/sinc_resampler.cc |
| @@ -138,7 +138,7 @@ void SincResampler::InitializeCPUSpecificFeatures() {} |
| #endif |
| SincResampler::SincResampler(double io_sample_rate_ratio, |
| - size_t request_frames, |
| + int request_frames, |
| const ReadCB& read_cb) |
| : io_sample_rate_ratio_(io_sample_rate_ratio), |
| read_cb_(read_cb), |
| @@ -155,8 +155,9 @@ SincResampler::SincResampler(double io_sample_rate_ratio, |
| base::AlignedAlloc(sizeof(float) * input_buffer_size_, 16))), |
| r1_(input_buffer_.get()), |
| r2_(input_buffer_.get() + kKernelSize / 2) { |
| + CHECK_GT(request_frames_, 0); |
| Flush(); |
| - CHECK_GT(block_size_, static_cast<size_t>(kKernelSize)) |
| + CHECK_GT(block_size_, kKernelSize) |
| << "block_size must be greater than kKernelSize!"; |
| memset(kernel_storage_.get(), 0, |
| @@ -255,17 +256,26 @@ void SincResampler::Resample(int frames, float* destination) { |
| int remaining_frames = frames; |
| // Step (1) -- Prime the input buffer at the start of the input stream. |
| - if (!buffer_primed_) { |
| + if (!buffer_primed_ && remaining_frames) { |
| read_cb_.Run(request_frames_, r0_); |
| buffer_primed_ = true; |
| } |
| // Step (2) -- Resample! |
| while (remaining_frames) { |
| + // Avoid comparing a double to an int on most platforms. Provides a 3% to |
| + // 20% increase in some cases. http://llvm.org/bugs/show_bug.cgi?id=16578 |
| +#if defined(USE_NEON) || defined(__clang__) |
| while (virtual_source_idx_ < block_size_) { |
|
Ami GONE FROM CHROMIUM
2013/07/09 23:20:08
what happens if you try:
while ((const int source_
DaleCurtis
2013/07/10 21:06:31
As discussed offline, this doesn't compile, and mo
Ami GONE FROM CHROMIUM
2013/07/10 21:18:00
FTR that's only b/c of the "const"; declaring the
|
| + const int source_idx = virtual_source_idx_; |
| +#else |
| + while (true) { |
| + const int source_idx = virtual_source_idx_; |
| + if (source_idx >= block_size_) |
| + break; |
| +#endif |
|
Ami GONE FROM CHROMIUM
2013/07/10 21:18:00
Perverted sense of perversion leads me to wonder h
DaleCurtis
2013/07/10 23:01:34
Works well on my N4 w/ gcc and OSX w/ clang. I've
DaleCurtis
2013/07/11 21:04:34
Switched to for(), but needs a ceil() to be accura
|
| // |virtual_source_idx_| lies in between two kernel offsets so figure out |
| // what they are. |
| - const int source_idx = virtual_source_idx_; |
| const double subsample_remainder = virtual_source_idx_ - source_idx; |
| const double virtual_offset_idx = |