OLD | NEW |
1 /* | 1 /* |
2 * SpanDSP - a series of DSP components for telephony | 2 * SpanDSP - a series of DSP components for telephony |
3 * | 3 * |
4 * g722_decode.c - The ITU G.722 codec, decode part. | 4 * g722_decode.c - The ITU G.722 codec, decode part. |
5 * | 5 * |
6 * Written by Steve Underwood <steveu@coppice.org> | 6 * Written by Steve Underwood <steveu@coppice.org> |
7 * | 7 * |
8 * Copyright (C) 2005 Steve Underwood | 8 * Copyright (C) 2005 Steve Underwood |
9 * | 9 * |
10 * Despite my general liking of the GPL, I place my own contributions | 10 * Despite my general liking of the GPL, I place my own contributions |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 s->band[band].sz = saturate(s->band[band].sz); | 150 s->band[band].sz = saturate(s->band[band].sz); |
151 | 151 |
152 /* Block 4, PREDIC */ | 152 /* Block 4, PREDIC */ |
153 s->band[band].s = saturate(s->band[band].sp + s->band[band].sz); | 153 s->band[band].s = saturate(s->band[band].sp + s->band[band].sz); |
154 } | 154 } |
155 /*- End of function --------------------------------------------------------*/ | 155 /*- End of function --------------------------------------------------------*/ |
156 | 156 |
157 G722DecoderState* WebRtc_g722_decode_init(G722DecoderState* s, | 157 G722DecoderState* WebRtc_g722_decode_init(G722DecoderState* s, |
158 int rate, | 158 int rate, |
159 int options) { | 159 int options) { |
160 if (s == NULL) | 160 s = s ? s : malloc(sizeof(*s)); |
161 { | |
162 if ((s = (G722DecoderState *) malloc(sizeof(*s))) == NULL) | |
163 return NULL; | |
164 } | |
165 memset(s, 0, sizeof(*s)); | 161 memset(s, 0, sizeof(*s)); |
166 if (rate == 48000) | 162 if (rate == 48000) |
167 s->bits_per_sample = 6; | 163 s->bits_per_sample = 6; |
168 else if (rate == 56000) | 164 else if (rate == 56000) |
169 s->bits_per_sample = 7; | 165 s->bits_per_sample = 7; |
170 else | 166 else |
171 s->bits_per_sample = 8; | 167 s->bits_per_sample = 8; |
172 if ((options & G722_SAMPLE_RATE_8000)) | 168 if ((options & G722_SAMPLE_RATE_8000)) |
173 s->eight_k = TRUE; | 169 s->eight_k = TRUE; |
174 if ((options & G722_PACKED) && s->bits_per_sample != 8) | 170 if ((options & G722_PACKED) && s->bits_per_sample != 8) |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 /* WebRtc, tlegrand: added saturation */ | 395 /* WebRtc, tlegrand: added saturation */ |
400 amp[outlen++] = saturate(xout1 >> 11); | 396 amp[outlen++] = saturate(xout1 >> 11); |
401 amp[outlen++] = saturate(xout2 >> 11); | 397 amp[outlen++] = saturate(xout2 >> 11); |
402 } | 398 } |
403 } | 399 } |
404 } | 400 } |
405 return outlen; | 401 return outlen; |
406 } | 402 } |
407 /*- End of function --------------------------------------------------------*/ | 403 /*- End of function --------------------------------------------------------*/ |
408 /*- End of file ------------------------------------------------------------*/ | 404 /*- End of file ------------------------------------------------------------*/ |
OLD | NEW |