| 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_GetCbVec.c | 15 WebRtcIlbcfix_GetCbVec.c |
| 16 | 16 |
| 17 ******************************************************************/ | 17 ******************************************************************/ |
| 18 | 18 |
| 19 #include "defines.h" | 19 #include "defines.h" |
| 20 #include "constants.h" | 20 #include "constants.h" |
| 21 #include "create_augmented_vec.h" | 21 #include "create_augmented_vec.h" |
| 22 | 22 |
| 23 /*----------------------------------------------------------------* | 23 /*----------------------------------------------------------------* |
| 24 * Construct codebook vector for given index. | 24 * Construct codebook vector for given index. |
| 25 *---------------------------------------------------------------*/ | 25 *---------------------------------------------------------------*/ |
| 26 | 26 |
| 27 void WebRtcIlbcfix_GetCbVec( | 27 int WebRtcIlbcfix_GetCbVec( |
| 28 int16_t *cbvec, /* (o) Constructed codebook vector */ | 28 int16_t *cbvec, /* (o) Constructed codebook vector */ |
| 29 int16_t *mem, /* (i) Codebook buffer */ | 29 int16_t *mem, /* (i) Codebook buffer */ |
| 30 size_t index, /* (i) Codebook index */ | 30 size_t index, /* (i) Codebook index */ |
| 31 size_t lMem, /* (i) Length of codebook buffer */ | 31 size_t lMem, /* (i) Length of codebook buffer */ |
| 32 size_t cbveclen /* (i) Codebook vector length */ | 32 size_t cbveclen /* (i) Codebook vector length */ |
| 33 ){ | 33 ){ |
| 34 size_t k, base_size; | 34 size_t k, base_size; |
| 35 size_t lag; | 35 size_t lag; |
| 36 /* Stack based */ | 36 /* Stack based */ |
| 37 int16_t tempbuff2[SUBL+5]; | 37 int16_t tempbuff2[SUBL+5]; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 /* do filtering to get the codebook vector */ | 86 /* do filtering to get the codebook vector */ |
| 87 | 87 |
| 88 WebRtcSpl_FilterMAFastQ12( | 88 WebRtcSpl_FilterMAFastQ12( |
| 89 &mem[memIndTest+4], cbvec, (int16_t*)WebRtcIlbcfix_kCbFiltersRev, | 89 &mem[memIndTest+4], cbvec, (int16_t*)WebRtcIlbcfix_kCbFiltersRev, |
| 90 CB_FILTERLEN, cbveclen); | 90 CB_FILTERLEN, cbveclen); |
| 91 } | 91 } |
| 92 | 92 |
| 93 /* interpolated vectors */ | 93 /* interpolated vectors */ |
| 94 | 94 |
| 95 else { | 95 else { |
| 96 if (cbveclen < SUBL) { |
| 97 // We're going to fill in cbveclen + 5 elements of tempbuff2 in |
| 98 // WebRtcSpl_FilterMAFastQ12, less than the SUBL + 5 elements we'll be |
| 99 // using in WebRtcIlbcfix_CreateAugmentedVec. This error is caused by |
| 100 // bad values in |index| (which come from the encoded stream). Tell the |
| 101 // caller that things went south, and that the decoder state is now |
| 102 // corrupt (because it's half-way through an update that we can't |
| 103 // complete). |
| 104 return 0; |
| 105 } |
| 106 |
| 96 /* Stuff zeros outside memory buffer */ | 107 /* Stuff zeros outside memory buffer */ |
| 97 memIndTest = lMem-cbveclen-CB_FILTERLEN; | 108 memIndTest = lMem-cbveclen-CB_FILTERLEN; |
| 98 WebRtcSpl_MemSetW16(mem+lMem, 0, CB_HALFFILTERLEN); | 109 WebRtcSpl_MemSetW16(mem+lMem, 0, CB_HALFFILTERLEN); |
| 99 | 110 |
| 100 /* do filtering */ | 111 /* do filtering */ |
| 101 WebRtcSpl_FilterMAFastQ12( | 112 WebRtcSpl_FilterMAFastQ12( |
| 102 &mem[memIndTest+7], tempbuff2, (int16_t*)WebRtcIlbcfix_kCbFiltersRev, | 113 &mem[memIndTest+7], tempbuff2, (int16_t*)WebRtcIlbcfix_kCbFiltersRev, |
| 103 CB_FILTERLEN, cbveclen+5); | 114 CB_FILTERLEN, cbveclen+5); |
| 104 | 115 |
| 105 /* Calculate lag index */ | 116 /* Calculate lag index */ |
| 106 lag = (cbveclen<<1)-20+index-base_size-lMem-1; | 117 lag = (cbveclen<<1)-20+index-base_size-lMem-1; |
| 107 | 118 |
| 108 WebRtcIlbcfix_CreateAugmentedVec(lag, tempbuff2+SUBL+5, cbvec); | 119 WebRtcIlbcfix_CreateAugmentedVec(lag, tempbuff2+SUBL+5, cbvec); |
| 109 } | 120 } |
| 110 } | 121 } |
| 122 |
| 123 return 1; // Success. |
| 111 } | 124 } |
| OLD | NEW |