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_Lsf2Poly.c 16 17 ******************************************************************/ 18 19 #include "modules/audio_coding/codecs/ilbc/lsf_to_poly.h" 20 21 #include "modules/audio_coding/codecs/ilbc/constants.h" 22 #include "modules/audio_coding/codecs/ilbc/defines.h" 23 #include "modules/audio_coding/codecs/ilbc/get_lsp_poly.h" 24 #include "modules/audio_coding/codecs/ilbc/lsf_to_lsp.h" 25 WebRtcIlbcfix_Lsf2Poly(int16_t * a,int16_t * lsf)26void WebRtcIlbcfix_Lsf2Poly( 27 int16_t *a, /* (o) predictor coefficients (order = 10) in Q12 */ 28 int16_t *lsf /* (i) line spectral frequencies in Q13 */ 29 ) { 30 int32_t f[2][6]; /* f[0][] and f[1][] corresponds to 31 F1(z) and F2(z) respectivly */ 32 int32_t *f1ptr, *f2ptr; 33 int16_t *a1ptr, *a2ptr; 34 int32_t tmpW32; 35 int16_t lsp[10]; 36 int i; 37 38 /* Convert lsf to lsp */ 39 WebRtcIlbcfix_Lsf2Lsp(lsf, lsp, LPC_FILTERORDER); 40 41 /* Get F1(z) and F2(z) from the lsp */ 42 f1ptr=f[0]; 43 f2ptr=f[1]; 44 WebRtcIlbcfix_GetLspPoly(&lsp[0],f1ptr); 45 WebRtcIlbcfix_GetLspPoly(&lsp[1],f2ptr); 46 47 /* for i = 5 down to 1 48 Compute f1[i] += f1[i-1]; 49 and f2[i] += f2[i-1]; 50 */ 51 f1ptr=&f[0][5]; 52 f2ptr=&f[1][5]; 53 for (i=5; i>0; i--) 54 { 55 (*f1ptr) += (*(f1ptr-1)); 56 (*f2ptr) -= (*(f2ptr-1)); 57 f1ptr--; 58 f2ptr--; 59 } 60 61 /* Get the A(z) coefficients 62 a[0] = 1.0 63 for i = 1 to 5 64 a[i] = (f1[i] + f2[i] + round)>>13; 65 for i = 1 to 5 66 a[11-i] = (f1[i] - f2[i] + round)>>13; 67 */ 68 a[0]=4096; 69 a1ptr=&a[1]; 70 a2ptr=&a[10]; 71 f1ptr=&f[0][1]; 72 f2ptr=&f[1][1]; 73 for (i=5; i>0; i--) 74 { 75 tmpW32 = (*f1ptr) + (*f2ptr); 76 *a1ptr = (int16_t)((tmpW32 + 4096) >> 13); 77 78 tmpW32 = (*f1ptr) - (*f2ptr); 79 *a2ptr = (int16_t)((tmpW32 + 4096) >> 13); 80 81 a1ptr++; 82 a2ptr--; 83 f1ptr++; 84 f2ptr++; 85 } 86 87 return; 88 } 89