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 |
(...skipping 13 matching lines...) Expand all Loading... |
24 * find the smoothed output data | 24 * find the smoothed output data |
25 *---------------------------------------------------------------*/ | 25 *---------------------------------------------------------------*/ |
26 | 26 |
27 void WebRtcIlbcfix_Smooth( | 27 void WebRtcIlbcfix_Smooth( |
28 int16_t *odata, /* (o) smoothed output */ | 28 int16_t *odata, /* (o) smoothed output */ |
29 int16_t *current, /* (i) the un enhanced residual for | 29 int16_t *current, /* (i) the un enhanced residual for |
30 this block */ | 30 this block */ |
31 int16_t *surround /* (i) The approximation from the | 31 int16_t *surround /* (i) The approximation from the |
32 surrounding sequences */ | 32 surrounding sequences */ |
33 ) { | 33 ) { |
34 int16_t maxtot, scale, scale1, scale2; | 34 int16_t scale, scale1, scale2; |
35 int16_t A, B, C, denomW16; | 35 int16_t A, B, C, denomW16; |
36 int32_t B_W32, denom, num; | 36 int32_t B_W32, denom, num; |
37 int32_t errs; | 37 int32_t errs; |
38 int32_t w00,w10,w11, endiff, crit; | 38 int32_t w00,w10,w11, endiff, crit; |
39 int32_t w00prim, w10prim, w11_div_w00; | 39 int32_t w00prim, w10prim, w11_div_w00; |
40 int16_t w11prim; | 40 int16_t w11prim; |
41 int16_t bitsw00, bitsw10, bitsw11; | 41 int16_t bitsw00, bitsw10, bitsw11; |
42 int32_t w11w00, w10w10, w00w00; | 42 int32_t w11w00, w10w10, w00w00; |
43 int16_t max1, max2; | 43 uint32_t max1, max2, max12; |
44 | 44 |
45 /* compute some inner products (ensure no overflow by first calculating proper
scale factor) */ | 45 /* compute some inner products (ensure no overflow by first calculating proper
scale factor) */ |
46 | 46 |
47 w00 = w10 = w11 = 0; | 47 w00 = w10 = w11 = 0; |
48 | 48 |
49 max1=WebRtcSpl_MaxAbsValueW16(current, ENH_BLOCKL); | 49 // Calculate a right shift that will let us sum ENH_BLOCKL pairwise products |
50 max2=WebRtcSpl_MaxAbsValueW16(surround, ENH_BLOCKL); | 50 // of values from the two sequences without overflowing an int32_t. (The +1 |
51 maxtot=WEBRTC_SPL_MAX(max1, max2); | 51 // in max1 and max2 are because WebRtcSpl_MaxAbsValueW16 will return 2**15 - |
52 | 52 // 1 if the input array contains -2**15.) |
53 scale=WebRtcSpl_GetSizeInBits(maxtot); | 53 max1 = WebRtcSpl_MaxAbsValueW16(current, ENH_BLOCKL) + 1; |
54 scale = (int16_t)(2 * scale) - 26; | 54 max2 = WebRtcSpl_MaxAbsValueW16(surround, ENH_BLOCKL) + 1; |
| 55 max12 = WEBRTC_SPL_MAX(max1, max2); |
| 56 scale = (64 - 31) - |
| 57 WebRtcSpl_CountLeadingZeros64((max12 * max12) * (uint64_t)ENH_BLOCKL); |
55 scale=WEBRTC_SPL_MAX(0, scale); | 58 scale=WEBRTC_SPL_MAX(0, scale); |
56 | 59 |
57 w00=WebRtcSpl_DotProductWithScale(current,current,ENH_BLOCKL,scale); | 60 w00=WebRtcSpl_DotProductWithScale(current,current,ENH_BLOCKL,scale); |
58 w11=WebRtcSpl_DotProductWithScale(surround,surround,ENH_BLOCKL,scale); | 61 w11=WebRtcSpl_DotProductWithScale(surround,surround,ENH_BLOCKL,scale); |
59 w10=WebRtcSpl_DotProductWithScale(surround,current,ENH_BLOCKL,scale); | 62 w10=WebRtcSpl_DotProductWithScale(surround,current,ENH_BLOCKL,scale); |
60 | 63 |
61 if (w00<0) w00 = WEBRTC_SPL_WORD32_MAX; | 64 if (w00<0) w00 = WEBRTC_SPL_WORD32_MAX; |
62 if (w11<0) w11 = WEBRTC_SPL_WORD32_MAX; | 65 if (w11<0) w11 = WEBRTC_SPL_WORD32_MAX; |
63 | 66 |
64 /* Rescale w00 and w11 to w00prim and w11prim, so that w00prim/w11prim | 67 /* Rescale w00 and w11 to w00prim and w11prim, so that w00prim/w11prim |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 201 } |
199 | 202 |
200 /* create smoothed sequence */ | 203 /* create smoothed sequence */ |
201 | 204 |
202 WebRtcSpl_ScaleAndAddVectors(surround, A, 9, | 205 WebRtcSpl_ScaleAndAddVectors(surround, A, 9, |
203 current, B, 14, | 206 current, B, 14, |
204 odata, ENH_BLOCKL); | 207 odata, ENH_BLOCKL); |
205 } | 208 } |
206 return; | 209 return; |
207 } | 210 } |
OLD | NEW |