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

Unified Diff: webrtc/modules/audio_coding/neteq/time_stretch.cc

Issue 1908623002: Avoiding overflow in cross correlation in NetEq. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: turn off ubsan as it was Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/neteq/time_stretch.cc
diff --git a/webrtc/modules/audio_coding/neteq/time_stretch.cc b/webrtc/modules/audio_coding/neteq/time_stretch.cc
index 6a91ea487b59fe076a951c0621996450e145a8cf..880b1f82ea595271ee0f92795f8a39542e5039f4 100644
--- a/webrtc/modules/audio_coding/neteq/time_stretch.cc
+++ b/webrtc/modules/audio_coding/neteq/time_stretch.cc
@@ -16,6 +16,7 @@
#include "webrtc/base/safe_conversions.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
#include "webrtc/modules/audio_coding/neteq/background_noise.h"
+#include "webrtc/modules/audio_coding/neteq/cross_correlation.h"
#include "webrtc/modules/audio_coding/neteq/dsp_helper.h"
namespace webrtc {
@@ -158,20 +159,15 @@ TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input,
}
void TimeStretch::AutoCorrelation() {
- // Set scaling factor for cross correlation to protect against overflow.
- int scaling = kLogCorrelationLen - WebRtcSpl_NormW32(
- max_input_value_ * max_input_value_);
- scaling = std::max(0, scaling);
-
// Calculate correlation from lag kMinLag to lag kMaxLag in 4 kHz domain.
int32_t auto_corr[kCorrelationLen];
- WebRtcSpl_CrossCorrelation(auto_corr, &downsampled_input_[kMaxLag],
- &downsampled_input_[kMaxLag - kMinLag],
- kCorrelationLen, kMaxLag - kMinLag, scaling, -1);
+ CrossCorrelationWithAutoShift(
+ &downsampled_input_[kMaxLag], &downsampled_input_[kMaxLag - kMinLag],
+ kCorrelationLen, kMaxLag - kMinLag, -1, auto_corr);
// Normalize correlation to 14 bits and write to |auto_correlation_|.
int32_t max_corr = WebRtcSpl_MaxAbsValueW32(auto_corr, kCorrelationLen);
- scaling = std::max(0, 17 - WebRtcSpl_NormW32(max_corr));
+ int scaling = std::max(0, 17 - WebRtcSpl_NormW32(max_corr));
WebRtcSpl_VectorBitShiftW32ToW16(auto_correlation_, kCorrelationLen,
auto_corr, scaling);
}
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698