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

Unified Diff: webrtc/common_audio/signal_processing/dot_product_with_scale.c

Issue 2571483002: Fix for integer overflow in NetEq. (Closed)
Patch Set: Created 4 years 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
Index: webrtc/common_audio/signal_processing/dot_product_with_scale.c
diff --git a/webrtc/common_audio/signal_processing/dot_product_with_scale.c b/webrtc/common_audio/signal_processing/dot_product_with_scale.c
index 1302d62541266fdc45b07576de5ff5026d69032f..c49e3fe95d31ff4ff01a716a4d54399b35d05a20 100644
--- a/webrtc/common_audio/signal_processing/dot_product_with_scale.c
+++ b/webrtc/common_audio/signal_processing/dot_product_with_scale.c
@@ -30,3 +30,24 @@ int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1,
return sum;
}
+
+int64_t WebRtcSpl_DotProductWithScale_64b(const int16_t* vector1,
+ const int16_t* vector2,
+ size_t length,
+ int scaling) {
+ int64_t sum = 0;
+ size_t i = 0;
+
+ /* Unroll the loop to improve performance. */
+ for (i = 0; i + 3 < length; i += 4) {
+ sum += (vector1[i + 0] * vector2[i + 0]) >> scaling;
+ sum += (vector1[i + 1] * vector2[i + 1]) >> scaling;
+ sum += (vector1[i + 2] * vector2[i + 2]) >> scaling;
+ sum += (vector1[i + 3] * vector2[i + 3]) >> scaling;
+ }
+ for (; i < length; i++) {
+ sum += (vector1[i] * vector2[i]) >> scaling;
+ }
+
+ return sum;
kwiberg-webrtc 2016/12/13 08:45:36 IIUC, the reason for having the right shifts in th
ivoc 2016/12/13 12:50:11 You're right that it's more accurate to not shift
+}

Powered by Google App Engine
This is Rietveld 408576698