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 /****************************************************************** | 11 /****************************************************************** |
12 | 12 |
13 iLBC Speech Coder ANSI-C Source Code | 13 iLBC Speech Coder ANSI-C Source Code |
14 | 14 |
15 WebRtcIlbcfix_CbConstruct.c | 15 WebRtcIlbcfix_CbConstruct.c |
16 | 16 |
17 ******************************************************************/ | 17 ******************************************************************/ |
18 | 18 |
| 19 #include "cb_construct.h" |
| 20 |
19 #include "defines.h" | 21 #include "defines.h" |
20 #include "gain_dequant.h" | 22 #include "gain_dequant.h" |
21 #include "get_cd_vec.h" | 23 #include "get_cd_vec.h" |
22 | 24 |
23 /*----------------------------------------------------------------* | 25 /*----------------------------------------------------------------* |
24 * Construct decoded vector from codebook and gains. | 26 * Construct decoded vector from codebook and gains. |
25 *---------------------------------------------------------------*/ | 27 *---------------------------------------------------------------*/ |
26 | 28 |
27 void WebRtcIlbcfix_CbConstruct( | 29 bool WebRtcIlbcfix_CbConstruct( |
28 int16_t *decvector, /* (o) Decoded vector */ | 30 int16_t *decvector, /* (o) Decoded vector */ |
29 int16_t *index, /* (i) Codebook indices */ | 31 int16_t *index, /* (i) Codebook indices */ |
30 int16_t *gain_index, /* (i) Gain quantization indices */ | 32 int16_t *gain_index, /* (i) Gain quantization indices */ |
31 int16_t *mem, /* (i) Buffer for codevector construction */ | 33 int16_t *mem, /* (i) Buffer for codevector construction */ |
32 size_t lMem, /* (i) Length of buffer */ | 34 size_t lMem, /* (i) Length of buffer */ |
33 size_t veclen /* (i) Length of vector */ | 35 size_t veclen /* (i) Length of vector */ |
34 ){ | 36 ){ |
35 size_t j; | 37 size_t j; |
36 int16_t gain[CB_NSTAGES]; | 38 int16_t gain[CB_NSTAGES]; |
37 /* Stack based */ | 39 /* Stack based */ |
38 int16_t cbvec0[SUBL]; | 40 int16_t cbvec0[SUBL]; |
39 int16_t cbvec1[SUBL]; | 41 int16_t cbvec1[SUBL]; |
40 int16_t cbvec2[SUBL]; | 42 int16_t cbvec2[SUBL]; |
41 int32_t a32; | 43 int32_t a32; |
42 int16_t *gainPtr; | 44 int16_t *gainPtr; |
43 | 45 |
44 /* gain de-quantization */ | 46 /* gain de-quantization */ |
45 | 47 |
46 gain[0] = WebRtcIlbcfix_GainDequant(gain_index[0], 16384, 0); | 48 gain[0] = WebRtcIlbcfix_GainDequant(gain_index[0], 16384, 0); |
47 gain[1] = WebRtcIlbcfix_GainDequant(gain_index[1], gain[0], 1); | 49 gain[1] = WebRtcIlbcfix_GainDequant(gain_index[1], gain[0], 1); |
48 gain[2] = WebRtcIlbcfix_GainDequant(gain_index[2], gain[1], 2); | 50 gain[2] = WebRtcIlbcfix_GainDequant(gain_index[2], gain[1], 2); |
49 | 51 |
50 /* codebook vector construction and construction of total vector */ | 52 /* codebook vector construction and construction of total vector */ |
51 | 53 |
52 /* Stack based */ | 54 /* Stack based */ |
53 WebRtcIlbcfix_GetCbVec(cbvec0, mem, (size_t)index[0], lMem, veclen); | 55 if (!WebRtcIlbcfix_GetCbVec(cbvec0, mem, (size_t)index[0], lMem, veclen)) |
54 WebRtcIlbcfix_GetCbVec(cbvec1, mem, (size_t)index[1], lMem, veclen); | 56 return false; // Failure. |
55 WebRtcIlbcfix_GetCbVec(cbvec2, mem, (size_t)index[2], lMem, veclen); | 57 if (!WebRtcIlbcfix_GetCbVec(cbvec1, mem, (size_t)index[1], lMem, veclen)) |
| 58 return false; // Failure. |
| 59 if (!WebRtcIlbcfix_GetCbVec(cbvec2, mem, (size_t)index[2], lMem, veclen)) |
| 60 return false; // Failure. |
56 | 61 |
57 gainPtr = &gain[0]; | 62 gainPtr = &gain[0]; |
58 for (j=0;j<veclen;j++) { | 63 for (j=0;j<veclen;j++) { |
59 a32 = (*gainPtr++) * cbvec0[j]; | 64 a32 = (*gainPtr++) * cbvec0[j]; |
60 a32 += (*gainPtr++) * cbvec1[j]; | 65 a32 += (*gainPtr++) * cbvec1[j]; |
61 a32 += (*gainPtr) * cbvec2[j]; | 66 a32 += (*gainPtr) * cbvec2[j]; |
62 gainPtr -= 2; | 67 gainPtr -= 2; |
63 decvector[j] = (int16_t)((a32 + 8192) >> 14); | 68 decvector[j] = (int16_t)((a32 + 8192) >> 14); |
64 } | 69 } |
65 | 70 |
66 return; | 71 return true; // Success. |
67 } | 72 } |
OLD | NEW |