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 |
(...skipping 12 matching lines...) Expand all Loading... | |
23 sum += (vector1[i + 1] * vector2[i + 1]) >> scaling; | 23 sum += (vector1[i + 1] * vector2[i + 1]) >> scaling; |
24 sum += (vector1[i + 2] * vector2[i + 2]) >> scaling; | 24 sum += (vector1[i + 2] * vector2[i + 2]) >> scaling; |
25 sum += (vector1[i + 3] * vector2[i + 3]) >> scaling; | 25 sum += (vector1[i + 3] * vector2[i + 3]) >> scaling; |
26 } | 26 } |
27 for (; i < length; i++) { | 27 for (; i < length; i++) { |
28 sum += (vector1[i] * vector2[i]) >> scaling; | 28 sum += (vector1[i] * vector2[i]) >> scaling; |
29 } | 29 } |
30 | 30 |
31 return sum; | 31 return sum; |
32 } | 32 } |
33 | |
34 int64_t WebRtcSpl_DotProductWithScale_64b(const int16_t* vector1, | |
35 const int16_t* vector2, | |
36 size_t length, | |
37 int scaling) { | |
38 int64_t sum = 0; | |
39 size_t i = 0; | |
40 | |
41 /* Unroll the loop to improve performance. */ | |
42 for (i = 0; i + 3 < length; i += 4) { | |
43 sum += (vector1[i + 0] * vector2[i + 0]) >> scaling; | |
44 sum += (vector1[i + 1] * vector2[i + 1]) >> scaling; | |
45 sum += (vector1[i + 2] * vector2[i + 2]) >> scaling; | |
46 sum += (vector1[i + 3] * vector2[i + 3]) >> scaling; | |
47 } | |
48 for (; i < length; i++) { | |
49 sum += (vector1[i] * vector2[i]) >> scaling; | |
50 } | |
51 | |
52 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
| |
53 } | |
OLD | NEW |