| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 initial_delay_(block_size_ - gcd(chunk_size, shift_amount)), | 112 initial_delay_(block_size_ - gcd(chunk_size, shift_amount)), |
| 113 frame_offset_(0), | 113 frame_offset_(0), |
| 114 input_buffer_(num_input_channels_, chunk_size_ + initial_delay_), | 114 input_buffer_(num_input_channels_, chunk_size_ + initial_delay_), |
| 115 output_buffer_(chunk_size_ + initial_delay_, num_output_channels_), | 115 output_buffer_(chunk_size_ + initial_delay_, num_output_channels_), |
| 116 input_block_(block_size_, num_input_channels_), | 116 input_block_(block_size_, num_input_channels_), |
| 117 output_block_(block_size_, num_output_channels_), | 117 output_block_(block_size_, num_output_channels_), |
| 118 window_(new float[block_size_]), | 118 window_(new float[block_size_]), |
| 119 shift_amount_(shift_amount), | 119 shift_amount_(shift_amount), |
| 120 callback_(callback) { | 120 callback_(callback) { |
| 121 CHECK_LE(num_output_channels_, num_input_channels_); | 121 CHECK_LE(num_output_channels_, num_input_channels_); |
| 122 CHECK(window); | 122 CHECK_LE(shift_amount_, block_size_); |
| 123 | 123 |
| 124 memcpy(window_.get(), window, block_size_ * sizeof(*window_.get())); | 124 memcpy(window_.get(), window, block_size_ * sizeof(*window_.get())); |
| 125 input_buffer_.MoveReadPosition(-initial_delay_); | 125 input_buffer_.MoveReadPositionBackward(initial_delay_); |
| 126 } | 126 } |
| 127 | 127 |
| 128 // When block_size < chunk_size the input and output buffers look like this: | 128 // When block_size < chunk_size the input and output buffers look like this: |
| 129 // | 129 // |
| 130 // delay* chunk_size chunk_size + delay* | 130 // delay* chunk_size chunk_size + delay* |
| 131 // buffer: <-------------|---------------------|---------------|> | 131 // buffer: <-------------|---------------------|---------------|> |
| 132 // _a_ _b_ _c_ | 132 // _a_ _b_ _c_ |
| 133 // | 133 // |
| 134 // On each call to ProcessChunk(): | 134 // On each call to ProcessChunk(): |
| 135 // 1. New input gets read into sections _b_ and _c_ of the input buffer. | 135 // 1. New input gets read into sections _b_ and _c_ of the input buffer. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 CHECK_EQ(num_input_channels, num_input_channels_); | 173 CHECK_EQ(num_input_channels, num_input_channels_); |
| 174 CHECK_EQ(num_output_channels, num_output_channels_); | 174 CHECK_EQ(num_output_channels, num_output_channels_); |
| 175 | 175 |
| 176 input_buffer_.Write(input, num_input_channels, chunk_size_); | 176 input_buffer_.Write(input, num_input_channels, chunk_size_); |
| 177 int first_frame_in_block = frame_offset_; | 177 int first_frame_in_block = frame_offset_; |
| 178 | 178 |
| 179 // Loop through blocks. | 179 // Loop through blocks. |
| 180 while (first_frame_in_block < chunk_size_) { | 180 while (first_frame_in_block < chunk_size_) { |
| 181 input_buffer_.Read(input_block_.channels(), num_input_channels, | 181 input_buffer_.Read(input_block_.channels(), num_input_channels, |
| 182 block_size_); | 182 block_size_); |
| 183 input_buffer_.MoveReadPosition(-block_size_ + shift_amount_); | 183 input_buffer_.MoveReadPositionBackward(block_size_ - shift_amount_); |
| 184 | 184 |
| 185 ApplyWindow(window_.get(), | 185 ApplyWindow(window_.get(), |
| 186 block_size_, | 186 block_size_, |
| 187 num_input_channels_, | 187 num_input_channels_, |
| 188 input_block_.channels()); | 188 input_block_.channels()); |
| 189 callback_->ProcessBlock(input_block_.channels(), | 189 callback_->ProcessBlock(input_block_.channels(), |
| 190 block_size_, | 190 block_size_, |
| 191 num_input_channels_, | 191 num_input_channels_, |
| 192 num_output_channels_, | 192 num_output_channels_, |
| 193 output_block_.channels()); | 193 output_block_.channels()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 ZeroOut(output_buffer_.channels(), | 227 ZeroOut(output_buffer_.channels(), |
| 228 initial_delay_, | 228 initial_delay_, |
| 229 chunk_size_, | 229 chunk_size_, |
| 230 num_output_channels_); | 230 num_output_channels_); |
| 231 | 231 |
| 232 // Calculate new starting frames. | 232 // Calculate new starting frames. |
| 233 frame_offset_ = first_frame_in_block - chunk_size_; | 233 frame_offset_ = first_frame_in_block - chunk_size_; |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace webrtc | 236 } // namespace webrtc |
| OLD | NEW |