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

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

Issue 1179953003: Revert "Upconvert various types to int." (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 304 }
305 } 305 }
306 306
307 int16_t Merge::CorrelateAndPeakSearch(int16_t expanded_max, int16_t input_max, 307 int16_t Merge::CorrelateAndPeakSearch(int16_t expanded_max, int16_t input_max,
308 int start_position, int input_length, 308 int start_position, int input_length,
309 int expand_period) const { 309 int expand_period) const {
310 // Calculate correlation without any normalization. 310 // Calculate correlation without any normalization.
311 const int max_corr_length = kMaxCorrelationLength; 311 const int max_corr_length = kMaxCorrelationLength;
312 int stop_position_downsamp = std::min( 312 int stop_position_downsamp = std::min(
313 max_corr_length, expand_->max_lag() / (fs_mult_ * 2) + 1); 313 max_corr_length, expand_->max_lag() / (fs_mult_ * 2) + 1);
314 int correlation_shift = 0; 314 int16_t correlation_shift = 0;
315 if (expanded_max * input_max > 26843546) { 315 if (expanded_max * input_max > 26843546) {
316 correlation_shift = 3; 316 correlation_shift = 3;
317 } 317 }
318 318
319 int32_t correlation[kMaxCorrelationLength]; 319 int32_t correlation[kMaxCorrelationLength];
320 WebRtcSpl_CrossCorrelation(correlation, input_downsampled_, 320 WebRtcSpl_CrossCorrelation(correlation, input_downsampled_,
321 expanded_downsampled_, kInputDownsampLength, 321 expanded_downsampled_, kInputDownsampLength,
322 stop_position_downsamp, correlation_shift, 1); 322 stop_position_downsamp, correlation_shift, 1);
323 323
324 // Normalize correlation to 14 bits and copy to a 16-bit array. 324 // Normalize correlation to 14 bits and copy to a 16-bit array.
325 const int pad_length = static_cast<int>(expand_->overlap_length() - 1); 325 const int pad_length = static_cast<int>(expand_->overlap_length() - 1);
326 const int correlation_buffer_size = 2 * pad_length + kMaxCorrelationLength; 326 const int correlation_buffer_size = 2 * pad_length + kMaxCorrelationLength;
327 rtc::scoped_ptr<int16_t[]> correlation16( 327 rtc::scoped_ptr<int16_t[]> correlation16(
328 new int16_t[correlation_buffer_size]); 328 new int16_t[correlation_buffer_size]);
329 memset(correlation16.get(), 0, correlation_buffer_size * sizeof(int16_t)); 329 memset(correlation16.get(), 0, correlation_buffer_size * sizeof(int16_t));
330 int16_t* correlation_ptr = &correlation16[pad_length]; 330 int16_t* correlation_ptr = &correlation16[pad_length];
331 int32_t max_correlation = WebRtcSpl_MaxAbsValueW32(correlation, 331 int32_t max_correlation = WebRtcSpl_MaxAbsValueW32(correlation,
332 stop_position_downsamp); 332 stop_position_downsamp);
333 int norm_shift = std::max(0, 17 - WebRtcSpl_NormW32(max_correlation)); 333 int16_t norm_shift = std::max(0, 17 - WebRtcSpl_NormW32(max_correlation));
334 WebRtcSpl_VectorBitShiftW32ToW16(correlation_ptr, stop_position_downsamp, 334 WebRtcSpl_VectorBitShiftW32ToW16(correlation_ptr, stop_position_downsamp,
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());
(...skipping 28 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
« no previous file with comments | « webrtc/modules/audio_coding/neteq/expand.cc ('k') | webrtc/modules/audio_coding/neteq/neteq_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698