OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 <assert.h> | 11 #include "webrtc/base/checks.h" |
12 | |
13 #include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h" | 12 #include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h" |
14 | 13 |
15 // Autocorrelation function in fixed point. | 14 // Autocorrelation function in fixed point. |
16 // NOTE! Different from SPLIB-version in how it scales the signal. | 15 // NOTE! Different from SPLIB-version in how it scales the signal. |
17 int WebRtcIsacfix_AutocorrC(int32_t* __restrict r, | 16 int WebRtcIsacfix_AutocorrC(int32_t* __restrict r, |
18 const int16_t* __restrict x, | 17 const int16_t* __restrict x, |
19 int16_t N, | 18 int16_t N, |
20 int16_t order, | 19 int16_t order, |
21 int16_t* __restrict scale) { | 20 int16_t* __restrict scale) { |
22 int i = 0; | 21 int i = 0; |
23 int j = 0; | 22 int j = 0; |
24 int16_t scaling = 0; | 23 int16_t scaling = 0; |
25 int32_t sum = 0; | 24 int32_t sum = 0; |
26 uint32_t temp = 0; | 25 uint32_t temp = 0; |
27 int64_t prod = 0; | 26 int64_t prod = 0; |
28 | 27 |
29 // The ARM assembly code assumptoins. | 28 // The ARM assembly code assumptoins. |
30 assert(N % 4 == 0); | 29 RTC_DCHECK_EQ(0, N % 4); |
31 assert(N >= 8); | 30 RTC_DCHECK_GE(N, 8); |
32 | 31 |
33 // Calculate r[0]. | 32 // Calculate r[0]. |
34 for (i = 0; i < N; i++) { | 33 for (i = 0; i < N; i++) { |
35 prod += x[i] * x[i]; | 34 prod += x[i] * x[i]; |
36 } | 35 } |
37 | 36 |
38 // Calculate scaling (the value of shifting). | 37 // Calculate scaling (the value of shifting). |
39 temp = (uint32_t)(prod >> 31); | 38 temp = (uint32_t)(prod >> 31); |
40 if(temp == 0) { | 39 if(temp == 0) { |
41 scaling = 0; | 40 scaling = 0; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 103 |
105 | 104 |
106 | 105 |
107 AllpassFilterForDec32(data_vec+1, kApUpperQ15, N, state_in); | 106 AllpassFilterForDec32(data_vec+1, kApUpperQ15, N, state_in); |
108 AllpassFilterForDec32(data_vec, kApLowerQ15, N, state_in+ALLPASSSECTIONS); | 107 AllpassFilterForDec32(data_vec, kApLowerQ15, N, state_in+ALLPASSSECTIONS); |
109 | 108 |
110 for (n=0;n<N/2;n++) { | 109 for (n=0;n<N/2;n++) { |
111 out[n] = WebRtcSpl_AddSatW16(data_vec[2 * n], data_vec[2 * n + 1]); | 110 out[n] = WebRtcSpl_AddSatW16(data_vec[2 * n], data_vec[2 * n + 1]); |
112 } | 111 } |
113 } | 112 } |
OLD | NEW |