1470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com/* 2470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * 4470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * Use of this source code is governed by a BSD-style license 5470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * that can be found in the LICENSE file in the root of the source 6470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * tree. An additional intellectual property rights grant can be found 7470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * in the file PATENTS. All contributing project authors may 8470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * be found in the AUTHORS file in the root of the source tree. 9470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com */ 10470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 11470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com/****************************************************************** 12470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 13470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com iLBC Speech Coder ANSI-C Source Code 14470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 15470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com WebRtcIlbcfix_Lsf2Poly.c 16470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 17470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com******************************************************************/ 18470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 19470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com#include "defines.h" 20470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com#include "lsf_to_lsp.h" 21470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com#include "get_lsp_poly.h" 22470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com#include "constants.h" 23470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 24470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.comvoid WebRtcIlbcfix_Lsf2Poly( 250946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int16_t *a, /* (o) predictor coefficients (order = 10) in Q12 */ 260946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int16_t *lsf /* (i) line spectral frequencies in Q13 */ 27470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com ) { 280946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int32_t f[2][6]; /* f[0][] and f[1][] corresponds to 29470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com F1(z) and F2(z) respectivly */ 300946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int32_t *f1ptr, *f2ptr; 310946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int16_t *a1ptr, *a2ptr; 320946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int32_t tmpW32; 330946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int16_t lsp[10]; 34470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com int i; 35470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 36470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com /* Convert lsf to lsp */ 37470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com WebRtcIlbcfix_Lsf2Lsp(lsf, lsp, LPC_FILTERORDER); 38470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 39470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com /* Get F1(z) and F2(z) from the lsp */ 40470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com f1ptr=f[0]; 41470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com f2ptr=f[1]; 42470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com WebRtcIlbcfix_GetLspPoly(&lsp[0],f1ptr); 43470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com WebRtcIlbcfix_GetLspPoly(&lsp[1],f2ptr); 44470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 45470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com /* for i = 5 down to 1 46470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com Compute f1[i] += f1[i-1]; 47470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com and f2[i] += f2[i-1]; 48470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com */ 49470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com f1ptr=&f[0][5]; 50470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com f2ptr=&f[1][5]; 51470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com for (i=5; i>0; i--) 52470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com { 53470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com (*f1ptr) += (*(f1ptr-1)); 54470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com (*f2ptr) -= (*(f2ptr-1)); 55470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com f1ptr--; 56470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com f2ptr--; 57470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 58470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 59470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com /* Get the A(z) coefficients 60470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com a[0] = 1.0 61470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com for i = 1 to 5 62470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com a[i] = (f1[i] + f2[i] + round)>>13; 63470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com for i = 1 to 5 64470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com a[11-i] = (f1[i] - f2[i] + round)>>13; 65470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com */ 66470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com a[0]=4096; 67470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com a1ptr=&a[1]; 68470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com a2ptr=&a[10]; 69470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com f1ptr=&f[0][1]; 70470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com f2ptr=&f[1][1]; 71470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com for (i=5; i>0; i--) 72470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com { 73470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com tmpW32 = (*f1ptr) + (*f2ptr); 7478ea06dd34a584acad4a2cf2142de218cb06eef4bjornv@webrtc.org *a1ptr = (int16_t)((tmpW32 + 4096) >> 13); 75470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 76470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com tmpW32 = (*f1ptr) - (*f2ptr); 7778ea06dd34a584acad4a2cf2142de218cb06eef4bjornv@webrtc.org *a2ptr = (int16_t)((tmpW32 + 4096) >> 13); 78470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 79470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com a1ptr++; 80470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com a2ptr--; 81470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com f1ptr++; 82470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com f2ptr++; 83470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 84470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 85470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com return; 86470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 87