1 /* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 /****************************************************************** 12 13 iLBC Speech Coder ANSI-C Source Code 14 15 WebRtcIlbcfix_GetLspPoly.c 16 17 ******************************************************************/ 18 19 #include "modules/audio_coding/codecs/ilbc/get_lsp_poly.h" 20 21 #include "modules/audio_coding/codecs/ilbc/defines.h" 22 23 /*----------------------------------------------------------------* 24 * Construct the polynomials F1(z) and F2(z) from the LSP 25 * (Computations are done in Q24) 26 * 27 * The expansion is performed using the following recursion: 28 * 29 * f[0] = 1; 30 * tmp = -2.0 * lsp[0]; 31 * f[1] = tmp; 32 * for (i=2; i<=5; i++) { 33 * b = -2.0 * lsp[2*i-2]; 34 * f[i] = tmp*f[i-1] + 2.0*f[i-2]; 35 * for (j=i; j>=2; j--) { 36 * f[j] = f[j] + tmp*f[j-1] + f[j-2]; 37 * } 38 * f[i] = f[i] + tmp; 39 * } 40 *---------------------------------------------------------------*/ 41 WebRtcIlbcfix_GetLspPoly(int16_t * lsp,int32_t * f)42void WebRtcIlbcfix_GetLspPoly( 43 int16_t *lsp, /* (i) LSP in Q15 */ 44 int32_t *f) /* (o) polonymial in Q24 */ 45 { 46 int32_t tmpW32; 47 int i, j; 48 int16_t high, low; 49 int16_t *lspPtr; 50 int32_t *fPtr; 51 52 lspPtr = lsp; 53 fPtr = f; 54 /* f[0] = 1.0 (Q24) */ 55 (*fPtr) = (int32_t)16777216; 56 fPtr++; 57 58 (*fPtr) = WEBRTC_SPL_MUL((*lspPtr), -1024); 59 fPtr++; 60 lspPtr+=2; 61 62 for(i=2; i<=5; i++) 63 { 64 (*fPtr) = fPtr[-2]; 65 66 for(j=i; j>1; j--) 67 { 68 /* Compute f[j] = f[j] + tmp*f[j-1] + f[j-2]; */ 69 high = (int16_t)(fPtr[-1] >> 16); 70 low = (int16_t)((fPtr[-1] & 0xffff) >> 1); 71 72 tmpW32 = 4 * high * *lspPtr + 4 * ((low * *lspPtr) >> 15); 73 74 (*fPtr) += fPtr[-2]; 75 (*fPtr) -= tmpW32; 76 fPtr--; 77 } 78 *fPtr -= *lspPtr * (1 << 10); 79 80 fPtr+=i; 81 lspPtr+=2; 82 } 83 return; 84 } 85