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 10 matching lines...) Expand all Loading... |
21 #include "decoder_interpolate_lsf.h" | 21 #include "decoder_interpolate_lsf.h" |
22 #include "index_conv_dec.h" | 22 #include "index_conv_dec.h" |
23 #include "do_plc.h" | 23 #include "do_plc.h" |
24 #include "constants.h" | 24 #include "constants.h" |
25 #include "enhancer_interface.h" | 25 #include "enhancer_interface.h" |
26 #include "xcorr_coef.h" | 26 #include "xcorr_coef.h" |
27 #include "lsf_check.h" | 27 #include "lsf_check.h" |
28 #include "decode_residual.h" | 28 #include "decode_residual.h" |
29 #include "unpack_bits.h" | 29 #include "unpack_bits.h" |
30 #include "hp_output.h" | 30 #include "hp_output.h" |
| 31 #include "init_decode.h" |
31 #ifndef WEBRTC_ARCH_BIG_ENDIAN | 32 #ifndef WEBRTC_ARCH_BIG_ENDIAN |
32 #include "swap_bytes.h" | 33 #include "swap_bytes.h" |
33 #endif | 34 #endif |
34 | 35 |
35 /*----------------------------------------------------------------* | 36 /*----------------------------------------------------------------* |
36 * main decoder function | 37 * main decoder function |
37 *---------------------------------------------------------------*/ | 38 *---------------------------------------------------------------*/ |
38 | 39 |
39 void WebRtcIlbcfix_DecodeImpl( | 40 int WebRtcIlbcfix_DecodeImpl( |
40 int16_t *decblock, /* (o) decoded signal block */ | 41 int16_t *decblock, /* (o) decoded signal block */ |
41 const uint16_t *bytes, /* (i) encoded signal bits */ | 42 const uint16_t *bytes, /* (i) encoded signal bits */ |
42 IlbcDecoder *iLBCdec_inst, /* (i/o) the decoder state | 43 IlbcDecoder *iLBCdec_inst, /* (i/o) the decoder state |
43 structure */ | 44 structure */ |
44 int16_t mode /* (i) 0: bad packet, PLC, | 45 int16_t mode /* (i) 0: bad packet, PLC, |
45 1: normal */ | 46 1: normal */ |
46 ) { | 47 ) { |
| 48 const int old_mode = iLBCdec_inst->mode; |
| 49 const int old_use_enhancer = iLBCdec_inst->use_enhancer; |
| 50 |
47 size_t i; | 51 size_t i; |
48 int16_t order_plus_one; | 52 int16_t order_plus_one; |
49 | 53 |
50 int16_t last_bit; | 54 int16_t last_bit; |
51 int16_t *data; | 55 int16_t *data; |
52 /* Stack based */ | 56 /* Stack based */ |
53 int16_t decresidual[BLOCKL_MAX]; | 57 int16_t decresidual[BLOCKL_MAX]; |
54 int16_t PLCresidual[BLOCKL_MAX + LPC_FILTERORDER]; | 58 int16_t PLCresidual[BLOCKL_MAX + LPC_FILTERORDER]; |
55 int16_t syntdenum[NSUB_MAX*(LPC_FILTERORDER+1)]; | 59 int16_t syntdenum[NSUB_MAX*(LPC_FILTERORDER+1)]; |
56 int16_t PLClpc[LPC_FILTERORDER + 1]; | 60 int16_t PLClpc[LPC_FILTERORDER + 1]; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 /* adjust index */ | 97 /* adjust index */ |
94 WebRtcIlbcfix_IndexConvDec(iLBCbits_inst->cb_index); | 98 WebRtcIlbcfix_IndexConvDec(iLBCbits_inst->cb_index); |
95 | 99 |
96 /* decode the lsf */ | 100 /* decode the lsf */ |
97 WebRtcIlbcfix_SimpleLsfDeQ(lsfdeq, (int16_t*)(iLBCbits_inst->lsf), iLBCdec
_inst->lpc_n); | 101 WebRtcIlbcfix_SimpleLsfDeQ(lsfdeq, (int16_t*)(iLBCbits_inst->lsf), iLBCdec
_inst->lpc_n); |
98 WebRtcIlbcfix_LsfCheck(lsfdeq, LPC_FILTERORDER, iLBCdec_inst->lpc_n); | 102 WebRtcIlbcfix_LsfCheck(lsfdeq, LPC_FILTERORDER, iLBCdec_inst->lpc_n); |
99 WebRtcIlbcfix_DecoderInterpolateLsp(syntdenum, weightdenum, | 103 WebRtcIlbcfix_DecoderInterpolateLsp(syntdenum, weightdenum, |
100 lsfdeq, LPC_FILTERORDER, iLBCdec_inst)
; | 104 lsfdeq, LPC_FILTERORDER, iLBCdec_inst)
; |
101 | 105 |
102 /* Decode the residual using the cb and gain indexes */ | 106 /* Decode the residual using the cb and gain indexes */ |
103 WebRtcIlbcfix_DecodeResidual(iLBCdec_inst, iLBCbits_inst, decresidual, syn
tdenum); | 107 if (!WebRtcIlbcfix_DecodeResidual(iLBCdec_inst, iLBCbits_inst, |
| 108 decresidual, syntdenum)) |
| 109 goto error; |
104 | 110 |
105 /* preparing the plc for a future loss! */ | 111 /* preparing the plc for a future loss! */ |
106 WebRtcIlbcfix_DoThePlc( | 112 WebRtcIlbcfix_DoThePlc( |
107 PLCresidual, PLClpc, 0, decresidual, | 113 PLCresidual, PLClpc, 0, decresidual, |
108 syntdenum + (LPC_FILTERORDER + 1) * (iLBCdec_inst->nsub - 1), | 114 syntdenum + (LPC_FILTERORDER + 1) * (iLBCdec_inst->nsub - 1), |
109 iLBCdec_inst->last_lag, iLBCdec_inst); | 115 iLBCdec_inst->last_lag, iLBCdec_inst); |
110 | 116 |
111 /* Use the output from doThePLC */ | 117 /* Use the output from doThePLC */ |
112 WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl); | 118 WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl); |
113 } | 119 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 iLBCdec_inst->blockl); | 240 iLBCdec_inst->blockl); |
235 | 241 |
236 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->old_syntdenum, | 242 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->old_syntdenum, |
237 syntdenum, iLBCdec_inst->nsub*(LPC_FILTERORDER+1)); | 243 syntdenum, iLBCdec_inst->nsub*(LPC_FILTERORDER+1)); |
238 | 244 |
239 iLBCdec_inst->prev_enh_pl=0; | 245 iLBCdec_inst->prev_enh_pl=0; |
240 | 246 |
241 if (mode==0) { /* PLC was used */ | 247 if (mode==0) { /* PLC was used */ |
242 iLBCdec_inst->prev_enh_pl=1; | 248 iLBCdec_inst->prev_enh_pl=1; |
243 } | 249 } |
| 250 |
| 251 return 0; // Success. |
| 252 |
| 253 error: |
| 254 // The decoder got sick from eating that data. Reset it and return. |
| 255 WebRtcIlbcfix_InitDecode(iLBCdec_inst, old_mode, old_use_enhancer); |
| 256 return -1; // Error |
244 } | 257 } |
OLD | NEW |