Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(926)

Side by Side Diff: webrtc/modules/audio_coding/neteq/merge.cc

Issue 1174813003: Prepare to convert various types to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix MSVC warning Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // in expanded_signal. Keep the first 210 * kMaxSampleRate / 8000 samples, 168 // in expanded_signal. Keep the first 210 * kMaxSampleRate / 8000 samples,
169 // but shift them towards the end of the buffer. This is ok, since all of 169 // but shift them towards the end of the buffer. This is ok, since all of
170 // the buffer will be expand data anyway, so as long as the beginning is 170 // the buffer will be expand data anyway, so as long as the beginning is
171 // left untouched, we're fine. 171 // left untouched, we're fine.
172 int16_t length_diff = *old_length - 210 * kMaxSampleRate / 8000; 172 int16_t length_diff = *old_length - 210 * kMaxSampleRate / 8000;
173 sync_buffer_->InsertZerosAtIndex(length_diff, sync_buffer_->next_index()); 173 sync_buffer_->InsertZerosAtIndex(length_diff, sync_buffer_->next_index());
174 *old_length = 210 * kMaxSampleRate / 8000; 174 *old_length = 210 * kMaxSampleRate / 8000;
175 // This is the truncated length. 175 // This is the truncated length.
176 } 176 }
177 // This assert should always be true thanks to the if statement above. 177 // This assert should always be true thanks to the if statement above.
178 assert(210 * kMaxSampleRate / 8000 - *old_length >= 0); 178 assert(210 * kMaxSampleRate / 8000 >= *old_length);
179 179
180 AudioMultiVector expanded_temp(num_channels_); 180 AudioMultiVector expanded_temp(num_channels_);
181 expand_->Process(&expanded_temp); 181 expand_->Process(&expanded_temp);
182 *expand_period = static_cast<int>(expanded_temp.Size()); // Samples per 182 *expand_period = static_cast<int>(expanded_temp.Size()); // Samples per
183 // channel. 183 // channel.
184 184
185 expanded_.Clear(); 185 expanded_.Clear();
186 // Copy what is left since earlier into the expanded vector. 186 // Copy what is left since earlier into the expanded vector.
187 expanded_.PushBackFromIndex(*sync_buffer_, sync_buffer_->next_index()); 187 expanded_.PushBackFromIndex(*sync_buffer_, sync_buffer_->next_index());
188 assert(expanded_.Size() == static_cast<size_t>(*old_length)); 188 assert(expanded_.Size() == static_cast<size_t>(*old_length));
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 correlation, norm_shift); 335 correlation, norm_shift);
336 336
337 // Calculate allowed starting point for peak finding. 337 // Calculate allowed starting point for peak finding.
338 // The peak location bestIndex must fulfill two criteria: 338 // The peak location bestIndex must fulfill two criteria:
339 // (1) w16_bestIndex + input_length < 339 // (1) w16_bestIndex + input_length <
340 // timestamps_per_call_ + expand_->overlap_length(); 340 // timestamps_per_call_ + expand_->overlap_length();
341 // (2) w16_bestIndex + input_length < start_position. 341 // (2) w16_bestIndex + input_length < start_position.
342 int start_index = timestamps_per_call_ + 342 int start_index = timestamps_per_call_ +
343 static_cast<int>(expand_->overlap_length()); 343 static_cast<int>(expand_->overlap_length());
344 start_index = std::max(start_position, start_index); 344 start_index = std::max(start_position, start_index);
345 start_index = std::max(start_index - input_length, 0); 345 start_index = (input_length > start_index) ? 0 : (start_index - input_length);
kwiberg-webrtc 2015/06/10 07:49:10 Not for now, perhaps, but it strikes me that you c
Peter Kasting 2015/06/11 04:14:53 Yeah. There isn't one available right now but it'
346 // Downscale starting index to 4kHz domain. (fs_mult_ * 2 = fs_hz_ / 4000.) 346 // Downscale starting index to 4kHz domain. (fs_mult_ * 2 = fs_hz_ / 4000.)
347 int start_index_downsamp = start_index / (fs_mult_ * 2); 347 int start_index_downsamp = start_index / (fs_mult_ * 2);
348 348
349 // Calculate a modified |stop_position_downsamp| to account for the increased 349 // Calculate a modified |stop_position_downsamp| to account for the increased
350 // start index |start_index_downsamp| and the effective array length. 350 // start index |start_index_downsamp| and the effective array length.
351 int modified_stop_pos = 351 int modified_stop_pos =
352 std::min(stop_position_downsamp, 352 std::min(stop_position_downsamp,
353 kMaxCorrelationLength + pad_length - start_index_downsamp); 353 kMaxCorrelationLength + pad_length - start_index_downsamp);
354 int best_correlation_index; 354 int best_correlation_index;
355 int16_t best_correlation; 355 int16_t best_correlation;
(...skipping 16 matching lines...) Expand all
372 } 372 }
373 return best_correlation_index; 373 return best_correlation_index;
374 } 374 }
375 375
376 int Merge::RequiredFutureSamples() { 376 int Merge::RequiredFutureSamples() {
377 return static_cast<int>(fs_hz_ / 100 * num_channels_); // 10 ms. 377 return static_cast<int>(fs_hz_ / 100 * num_channels_); // 10 ms.
378 } 378 }
379 379
380 380
381 } // namespace webrtc 381 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698