| OLD | NEW |
| 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 |
| 11 #include "webrtc/modules/audio_coding/neteq/merge.h" | 11 #include "webrtc/modules/audio_coding/neteq/merge.h" |
| 12 | 12 |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 #include <string.h> // memmove, memcpy, memset, size_t | 14 #include <string.h> // memmove, memcpy, memset, size_t |
| 15 | 15 |
| 16 #include <algorithm> // min, max | 16 #include <algorithm> // min, max |
| 17 #include <memory> |
| 17 | 18 |
| 18 #include "webrtc/base/scoped_ptr.h" | |
| 19 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 19 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
| 20 #include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h" | 20 #include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h" |
| 21 #include "webrtc/modules/audio_coding/neteq/dsp_helper.h" | 21 #include "webrtc/modules/audio_coding/neteq/dsp_helper.h" |
| 22 #include "webrtc/modules/audio_coding/neteq/expand.h" | 22 #include "webrtc/modules/audio_coding/neteq/expand.h" |
| 23 #include "webrtc/modules/audio_coding/neteq/sync_buffer.h" | 23 #include "webrtc/modules/audio_coding/neteq/sync_buffer.h" |
| 24 | 24 |
| 25 namespace webrtc { | 25 namespace webrtc { |
| 26 | 26 |
| 27 Merge::Merge(int fs_hz, | 27 Merge::Merge(int fs_hz, |
| 28 size_t num_channels, | 28 size_t num_channels, |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 320 } |
| 321 | 321 |
| 322 int32_t correlation[kMaxCorrelationLength]; | 322 int32_t correlation[kMaxCorrelationLength]; |
| 323 WebRtcSpl_CrossCorrelation(correlation, input_downsampled_, | 323 WebRtcSpl_CrossCorrelation(correlation, input_downsampled_, |
| 324 expanded_downsampled_, kInputDownsampLength, | 324 expanded_downsampled_, kInputDownsampLength, |
| 325 stop_position_downsamp, correlation_shift, 1); | 325 stop_position_downsamp, correlation_shift, 1); |
| 326 | 326 |
| 327 // Normalize correlation to 14 bits and copy to a 16-bit array. | 327 // Normalize correlation to 14 bits and copy to a 16-bit array. |
| 328 const size_t pad_length = expand_->overlap_length() - 1; | 328 const size_t pad_length = expand_->overlap_length() - 1; |
| 329 const size_t correlation_buffer_size = 2 * pad_length + kMaxCorrelationLength; | 329 const size_t correlation_buffer_size = 2 * pad_length + kMaxCorrelationLength; |
| 330 rtc::scoped_ptr<int16_t[]> correlation16( | 330 std::unique_ptr<int16_t[]> correlation16( |
| 331 new int16_t[correlation_buffer_size]); | 331 new int16_t[correlation_buffer_size]); |
| 332 memset(correlation16.get(), 0, correlation_buffer_size * sizeof(int16_t)); | 332 memset(correlation16.get(), 0, correlation_buffer_size * sizeof(int16_t)); |
| 333 int16_t* correlation_ptr = &correlation16[pad_length]; | 333 int16_t* correlation_ptr = &correlation16[pad_length]; |
| 334 int32_t max_correlation = WebRtcSpl_MaxAbsValueW32(correlation, | 334 int32_t max_correlation = WebRtcSpl_MaxAbsValueW32(correlation, |
| 335 stop_position_downsamp); | 335 stop_position_downsamp); |
| 336 int norm_shift = std::max(0, 17 - WebRtcSpl_NormW32(max_correlation)); | 336 int norm_shift = std::max(0, 17 - WebRtcSpl_NormW32(max_correlation)); |
| 337 WebRtcSpl_VectorBitShiftW32ToW16(correlation_ptr, stop_position_downsamp, | 337 WebRtcSpl_VectorBitShiftW32ToW16(correlation_ptr, stop_position_downsamp, |
| 338 correlation, norm_shift); | 338 correlation, norm_shift); |
| 339 | 339 |
| 340 // Calculate allowed starting point for peak finding. | 340 // Calculate allowed starting point for peak finding. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 } | 374 } |
| 375 return best_correlation_index; | 375 return best_correlation_index; |
| 376 } | 376 } |
| 377 | 377 |
| 378 size_t Merge::RequiredFutureSamples() { | 378 size_t Merge::RequiredFutureSamples() { |
| 379 return fs_hz_ / 100 * num_channels_; // 10 ms. | 379 return fs_hz_ / 100 * num_channels_; // 10 ms. |
| 380 } | 380 } |
| 381 | 381 |
| 382 | 382 |
| 383 } // namespace webrtc | 383 } // namespace webrtc |
| OLD | NEW |