1219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard/*
2219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard ** Copyright 2003-2010, VisualOn, Inc.
3219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard **
4219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard ** Licensed under the Apache License, Version 2.0 (the "License");
5219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard ** you may not use this file except in compliance with the License.
6219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard ** You may obtain a copy of the License at
7219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard **
8219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard **     http://www.apache.org/licenses/LICENSE-2.0
9219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard **
10219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard ** Unless required by applicable law or agreed to in writing, software
11219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard ** distributed under the License is distributed on an "AS IS" BASIS,
12219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard ** See the License for the specific language governing permissions and
14219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard ** limitations under the License.
15219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard */
16219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
17219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard/***********************************************************************
18219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*      File: isp_az.c                                                  *
19219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*                                                                      *
20219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*      Description:Compute the LPC coefficients from isp (order=M)     *
21219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*                                                                      *
22219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard************************************************************************/
23219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
24219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard#include "typedef.h"
25219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard#include "basic_op.h"
26219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard#include "oper_32b.h"
27219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard#include "cnst.h"
28219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
29219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard#define NC (M/2)
30219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard#define NC16k (M16k/2)
31219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
32219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard/* local function */
33219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
34219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgardstatic void Get_isp_pol(Word16 * isp, Word32 * f, Word16 n);
35219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgardstatic void Get_isp_pol_16kHz(Word16 * isp, Word32 * f, Word16 n);
36219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
37219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgardvoid Isp_Az(
38219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		Word16 isp[],                         /* (i) Q15 : Immittance spectral pairs            */
39219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		Word16 a[],                           /* (o) Q12 : predictor coefficients (order = M)   */
40219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		Word16 m,
41219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		Word16 adaptive_scaling               /* (i) 0   : adaptive scaling disabled */
42219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		                                      /*     1   : adaptive scaling enabled  */
43219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	   )
44219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard{
45219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	Word32 i, j;
46219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	Word16 hi, lo;
47219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	Word32 f1[NC16k + 1], f2[NC16k];
48219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	Word16 nc;
49219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	Word32 t0;
50219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	Word16 q, q_sug;
51219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	Word32 tmax;
52219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
53219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	nc = (m >> 1);
54219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	if(nc > 8)
55219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	{
56219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		Get_isp_pol_16kHz(&isp[0], f1, nc);
57219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		for (i = 0; i <= nc; i++)
58219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		{
59219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			f1[i] = f1[i] << 2;
60219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		}
61219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	} else
62219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		Get_isp_pol(&isp[0], f1, nc);
63219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
64219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	if (nc > 8)
65219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	{
66219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		Get_isp_pol_16kHz(&isp[1], f2, (nc - 1));
67219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		for (i = 0; i <= nc - 1; i++)
68219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		{
69219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			f2[i] = f2[i] << 2;
70219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		}
71219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	} else
72219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		Get_isp_pol(&isp[1], f2, (nc - 1));
73219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
74219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	/*-----------------------------------------------------*
75219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	 *  Multiply F2(z) by (1 - z^-2)                       *
76219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	 *-----------------------------------------------------*/
77219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
78219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	for (i = (nc - 1); i > 1; i--)
79219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	{
80219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		f2[i] = vo_L_sub(f2[i], f2[i - 2]);          /* f2[i] -= f2[i-2]; */
81219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	}
82219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
83219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	/*----------------------------------------------------------*
84219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	 *  Scale F1(z) by (1+isp[m-1])  and  F2(z) by (1-isp[m-1]) *
85219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	 *----------------------------------------------------------*/
86219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
87219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	for (i = 0; i < nc; i++)
88219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	{
89219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		/* f1[i] *= (1.0 + isp[M-1]); */
90219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
91219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		hi = f1[i] >> 16;
92219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		lo = (f1[i] & 0xffff)>>1;
93219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
94219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		t0 = Mpy_32_16(hi, lo, isp[m - 1]);
95219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		f1[i] = vo_L_add(f1[i], t0);
96219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
97219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		/* f2[i] *= (1.0 - isp[M-1]); */
98219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
99219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		hi = f2[i] >> 16;
100219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		lo = (f2[i] & 0xffff)>>1;
101219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		t0 = Mpy_32_16(hi, lo, isp[m - 1]);
102219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		f2[i] = vo_L_sub(f2[i], t0);
103219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	}
104219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
105219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	/*-----------------------------------------------------*
106219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	 *  A(z) = (F1(z)+F2(z))/2                             *
107219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	 *  F1(z) is symmetric and F2(z) is antisymmetric      *
108219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	 *-----------------------------------------------------*/
109219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
110219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	/* a[0] = 1.0; */
111219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	a[0] = 4096;
112219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	tmax = 1;
113219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	for (i = 1, j = m - 1; i < nc; i++, j--)
114219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	{
115219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		/* a[i] = 0.5*(f1[i] + f2[i]); */
116219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
117219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		t0 = vo_L_add(f1[i], f2[i]);          /* f1[i] + f2[i]             */
118219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		tmax |= L_abs(t0);
119219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		a[i] = (Word16)(vo_L_shr_r(t0, 12)); /* from Q23 to Q12 and * 0.5 */
120219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
121219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		/* a[j] = 0.5*(f1[i] - f2[i]); */
122219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
123219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		t0 = vo_L_sub(f1[i], f2[i]);          /* f1[i] - f2[i]             */
124219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		tmax |= L_abs(t0);
125219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		a[j] = (Word16)(vo_L_shr_r(t0, 12)); /* from Q23 to Q12 and * 0.5 */
126219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	}
127219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
128219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	/* rescale data if overflow has occured and reprocess the loop */
129219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	if(adaptive_scaling == 1)
130219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		q = 4 - norm_l(tmax);        /* adaptive scaling enabled */
131219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	else
132219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		q = 0;                           /* adaptive scaling disabled */
133219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
134219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	if (q > 0)
135219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	{
136219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		q_sug = (12 + q);
137219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		for (i = 1, j = m - 1; i < nc; i++, j--)
138219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		{
139219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			/* a[i] = 0.5*(f1[i] + f2[i]); */
140219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			t0 = vo_L_add(f1[i], f2[i]);          /* f1[i] + f2[i]             */
141219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			a[i] = (Word16)(vo_L_shr_r(t0, q_sug)); /* from Q23 to Q12 and * 0.5 */
142219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
143219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			/* a[j] = 0.5*(f1[i] - f2[i]); */
144219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			t0 = vo_L_sub(f1[i], f2[i]);          /* f1[i] - f2[i]             */
145219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			a[j] = (Word16)(vo_L_shr_r(t0, q_sug)); /* from Q23 to Q12 and * 0.5 */
146219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		}
147219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		a[0] = shr(a[0], q);
148219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	}
149219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	else
150219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	{
151219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		q_sug = 12;
152219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		q     = 0;
153219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	}
154219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	/* a[NC] = 0.5*f1[NC]*(1.0 + isp[M-1]); */
155219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	hi = f1[nc] >> 16;
156219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	lo = (f1[nc] & 0xffff)>>1;
157219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	t0 = Mpy_32_16(hi, lo, isp[m - 1]);
158219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	t0 = vo_L_add(f1[nc], t0);
159219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	a[nc] = (Word16)(L_shr_r(t0, q_sug));    /* from Q23 to Q12 and * 0.5 */
160219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	/* a[m] = isp[m-1]; */
161219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
162219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	a[m] = vo_shr_r(isp[m - 1], (3 + q));           /* from Q15 to Q12          */
163219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	return;
164219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard}
165219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
166219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard/*-----------------------------------------------------------*
167219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard* procedure Get_isp_pol:                                    *
168219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*           ~~~~~~~~~~~                                     *
169219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*   Find the polynomial F1(z) or F2(z) from the ISPs.       *
170219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard* This is performed by expanding the product polynomials:   *
171219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*                                                           *
172219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard* F1(z) =   product   ( 1 - 2 isp_i z^-1 + z^-2 )           *
173219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*         i=0,2,4,6,8                                       *
174219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard* F2(z) =   product   ( 1 - 2 isp_i z^-1 + z^-2 )           *
175219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*         i=1,3,5,7                                         *
176219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*                                                           *
177219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard* where isp_i are the ISPs in the cosine domain.            *
178219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*-----------------------------------------------------------*
179219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*                                                           *
180219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard* Parameters:                                               *
181219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*  isp[]   : isp vector (cosine domaine)         in Q15     *
182219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*  f[]     : the coefficients of F1 or F2        in Q23     *
183219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*  n       : == NC for F1(z); == NC-1 for F2(z)             *
184219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard*-----------------------------------------------------------*/
185219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
186219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgardstatic void Get_isp_pol(Word16 * isp, Word32 * f, Word16 n)
187219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard{
188219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	Word16 hi, lo;
189219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	Word32 i, j, t0;
190219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	/* All computation in Q23 */
191219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
192219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	f[0] = vo_L_mult(4096, 1024);               /* f[0] = 1.0;        in Q23  */
193219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	f[1] = vo_L_mult(isp[0], -256);             /* f[1] = -2.0*isp[0] in Q23  */
194219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
195219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	f += 2;                                  /* Advance f pointer          */
196219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	isp += 2;                                /* Advance isp pointer        */
197219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	for (i = 2; i <= n; i++)
198219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	{
199219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		*f = f[-2];
200219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		for (j = 1; j < i; j++, f--)
201219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		{
202219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			hi = f[-1]>>16;
203219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			lo = (f[-1] & 0xffff)>>1;
204219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
205219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			t0 = Mpy_32_16(hi, lo, *isp);  /* t0 = f[-1] * isp    */
206219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			t0 = t0 << 1;
207219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			*f = vo_L_sub(*f, t0);              /* *f -= t0            */
208219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			*f = vo_L_add(*f, f[-2]);           /* *f += f[-2]         */
209219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		}
210219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		*f -= (*isp << 9);           /* *f -= isp<<8        */
211219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		f += i;                            /* Advance f pointer   */
212219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		isp += 2;                          /* Advance isp pointer */
213219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	}
214219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	return;
215219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard}
216219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
217219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgardstatic void Get_isp_pol_16kHz(Word16 * isp, Word32 * f, Word16 n)
218219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard{
219219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	Word16 hi, lo;
220219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	Word32 i, j, t0;
221219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
222219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	/* All computation in Q23 */
223219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	f[0] = L_mult(4096, 256);                /* f[0] = 1.0;        in Q23  */
224219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	f[1] = L_mult(isp[0], -64);              /* f[1] = -2.0*isp[0] in Q23  */
225219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
226219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	f += 2;                                  /* Advance f pointer          */
227219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	isp += 2;                                /* Advance isp pointer        */
228219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
229219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	for (i = 2; i <= n; i++)
230219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	{
231219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		*f = f[-2];
232219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		for (j = 1; j < i; j++, f--)
233219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		{
234219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			VO_L_Extract(f[-1], &hi, &lo);
235219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			t0 = Mpy_32_16(hi, lo, *isp);  /* t0 = f[-1] * isp    */
236219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			t0 = L_shl2(t0, 1);
237219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			*f = L_sub(*f, t0);              /* *f -= t0            */
238219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard			*f = L_add(*f, f[-2]);           /* *f += f[-2]         */
239219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		}
240219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		*f = L_msu(*f, *isp, 64);            /* *f -= isp<<8        */
241219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		f += i;                            /* Advance f pointer   */
242219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard		isp += 2;                          /* Advance isp pointer */
243219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	}
244219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard	return;
245219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard}
246219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
247219e2627f1e062c10645664b0d2470d4dfaf5083Mans Rullgard
248