-
Notifications
You must be signed in to change notification settings - Fork 3
/
lpc.c
644 lines (524 loc) · 22.5 KB
/
lpc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
/*
ITU-T G.729A Speech Coder with Annex B ANSI-C Source Code
Version 1.3 Last modified: August 1997
Copyright (c) 1996,
AT&T, France Telecom, NTT, Universite de Sherbrooke, Lucent Technologies,
Rockwell International
All rights reserved.
*/
/*-----------------------------------------------------*
* Function Autocorr() *
* *
* Compute autocorrelations of signal with windowing *
* *
*-----------------------------------------------------*/
#include "typedef.h"
#include "basic_op.h"
#include "oper_32b.h"
#include "ld8a.h"
#include "tab_ld8a.h"
void Autocorr(
int16_t x[], /* (i) : Input signal */
int16_t m, /* (i) : LPC order */
int16_t r_h[], /* (o) : Autocorrelations (msb) */
int16_t r_l[], /* (o) : Autocorrelations (lsb) */
int16_t *exp_R0
)
{
int16_t i, j, norm;
int16_t y[L_WINDOW];
int32_t sum;
extern int32_t Overflow;
/* Windowing of signal */
for(i=0; i<L_WINDOW; i++)
{
y[i] = mult_r(x[i], hamwindow[i]);
}
/* Compute r[0] and test for overflow */
*exp_R0 = 1;
do {
Overflow = 0;
sum = 1; /* Avoid case of all zeros */
for(i=0; i<L_WINDOW; i++)
sum = L_mac(sum, y[i], y[i]);
/* If overflow divide y[] by 4 */
if(Overflow != 0)
{
for(i=0; i<L_WINDOW; i++)
{
y[i] = shr(y[i], 2);
}
*exp_R0 = add((*exp_R0), 4);
Overflow = 1;
}
}while (Overflow != 0);
/* Normalization of r[0] */
norm = norm_l(sum);
sum = L_shl(sum, norm);
L_Extract(sum, &r_h[0], &r_l[0]); /* Put in DPF format (see oper_32b) */
*exp_R0 = sub(*exp_R0, norm);
/* r[1] to r[m] */
for (i = 1; i <= m; i++)
{
sum = 0;
for(j=0; j<L_WINDOW-i; j++)
sum = L_mac(sum, y[j], y[j+i]);
sum = L_shl(sum, norm);
L_Extract(sum, &r_h[i], &r_l[i]);
}
return;
}
/*-------------------------------------------------------*
* Function Lag_window() *
* *
* Lag_window on autocorrelations. *
* *
* r[i] *= lag_wind[i] *
* *
* r[i] and lag_wind[i] are in special double precision.*
* See "oper_32b.c" for the format *
* *
*-------------------------------------------------------*/
void Lag_window(
int16_t m, /* (i) : LPC order */
int16_t r_h[], /* (i/o) : Autocorrelations (msb) */
int16_t r_l[] /* (i/o) : Autocorrelations (lsb) */
)
{
int16_t i;
int32_t x;
for(i=1; i<=m; i++)
{
x = Mpy_32(r_h[i], r_l[i], lag_h[i-1], lag_l[i-1]);
L_Extract(x, &r_h[i], &r_l[i]);
}
return;
}
/*___________________________________________________________________________
| |
| LEVINSON-DURBIN algorithm in double precision |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---------------------------------------------------------------------------|
| |
| Algorithm |
| |
| R[i] autocorrelations. |
| A[i] filter coefficients. |
| K reflection coefficients. |
| Alpha prediction gain. |
| |
| Initialization: |
| A[0] = 1 |
| K = -R[1]/R[0] |
| A[1] = K |
| Alpha = R[0] * (1-K**2] |
| |
| Do for i = 2 to M |
| |
| S = SUM ( R[j]*A[i-j] ,j=1,i-1 ) + R[i] |
| |
| K = -S / Alpha |
| |
| An[j] = A[j] + K*A[i-j] for j=1 to i-1 |
| where An[i] = new A[i] |
| An[i]=K |
| |
| Alpha=Alpha * (1-K**2) |
| |
| END |
| |
| Remarks on the dynamics of the calculations. |
| |
| The numbers used are in double precision in the following format : |
| A = AH <<16 + AL<<1. AH and AL are 16 bit signed integers. |
| Since the LSB's also contain a sign bit, this format does not |
| correspond to standard 32 bit integers. We use this format since |
| it allows fast execution of multiplications and divisions. |
| |
| "DPF" will refer to this special format in the following text. |
| See oper_32b.c |
| |
| The R[i] were normalized in routine AUTO (hence, R[i] < 1.0). |
| The K[i] and Alpha are theoretically < 1.0. |
| The A[i], for a sampling frequency of 8 kHz, are in practice |
| always inferior to 16.0. |
| |
| These characteristics allow straigthforward fixed-point |
| implementation. We choose to represent the parameters as |
| follows : |
| |
| R[i] Q31 +- .99.. |
| K[i] Q31 +- .99.. |
| Alpha Normalized -> mantissa in Q31 plus exponent |
| A[i] Q27 +- 15.999.. |
| |
| The additions are performed in 32 bit. For the summation used |
| to calculate the K[i], we multiply numbers in Q31 by numbers |
| in Q27, with the result of the multiplications in Q27, |
| resulting in a dynamic of +- 16. This is sufficient to avoid |
| overflow, since the final result of the summation is |
| necessarily < 1.0 as both the K[i] and Alpha are |
| theoretically < 1.0. |
|___________________________________________________________________________|
*/
/* Last A(z) for case of unstable filter */
static int16_t old_A[M+1]={4096,0,0,0,0,0,0,0,0,0,0};
static int16_t old_rc[2]={0,0};
void Levinson(
int16_t Rh[], /* (i) : Rh[M+1] Vector of autocorrelations (msb) */
int16_t Rl[], /* (i) : Rl[M+1] Vector of autocorrelations (lsb) */
int16_t A[], /* (o) Q12 : A[M] LPC coefficients (m = 10) */
int16_t rc[], /* (o) Q15 : rc[M] Reflection coefficients. */
int16_t *Err /* (o) : Residual energy */
)
{
int16_t i, j;
int16_t hi, lo;
int16_t Kh, Kl; /* reflection coefficient; hi and lo */
int16_t alp_h, alp_l, alp_exp; /* Prediction gain; hi lo and exponent */
int16_t Ah[M+1], Al[M+1]; /* LPC coef. in double prec. */
int16_t Anh[M+1], Anl[M+1]; /* LPC coef.for next iteration in double prec. */
int32_t t0, t1, t2; /* temporary variable */
/* K = A[1] = -R[1] / R[0] */
t1 = L_Comp(Rh[1], Rl[1]); /* R[1] in Q31 */
t2 = L_abs(t1); /* abs R[1] */
t0 = Div_32(t2, Rh[0], Rl[0]); /* R[1]/R[0] in Q31 */
if(t1 > 0) t0= L_negate(t0); /* -R[1]/R[0] */
L_Extract(t0, &Kh, &Kl); /* K in DPF */
rc[0] = Kh;
t0 = L_shr(t0,4); /* A[1] in Q27 */
L_Extract(t0, &Ah[1], &Al[1]); /* A[1] in DPF */
/* Alpha = R[0] * (1-K**2) */
t0 = Mpy_32(Kh ,Kl, Kh, Kl); /* K*K in Q31 */
t0 = L_abs(t0); /* Some case <0 !! */
t0 = L_sub( (int32_t)0x7fffffffL, t0 ); /* 1 - K*K in Q31 */
L_Extract(t0, &hi, &lo); /* DPF format */
t0 = Mpy_32(Rh[0] ,Rl[0], hi, lo); /* Alpha in Q31 */
/* Normalize Alpha */
alp_exp = norm_l(t0);
t0 = L_shl(t0, alp_exp);
L_Extract(t0, &alp_h, &alp_l); /* DPF format */
/*--------------------------------------*
* ITERATIONS I=2 to M *
*--------------------------------------*/
for(i= 2; i<=M; i++)
{
/* t0 = SUM ( R[j]*A[i-j] ,j=1,i-1 ) + R[i] */
t0 = 0;
for(j=1; j<i; j++)
t0 = L_add(t0, Mpy_32(Rh[j], Rl[j], Ah[i-j], Al[i-j]));
t0 = L_shl(t0,4); /* result in Q27 -> convert to Q31 */
/* No overflow possible */
t1 = L_Comp(Rh[i],Rl[i]);
t0 = L_add(t0, t1); /* add R[i] in Q31 */
/* K = -t0 / Alpha */
t1 = L_abs(t0);
t2 = Div_32(t1, alp_h, alp_l); /* abs(t0)/Alpha */
if(t0 > 0) t2= L_negate(t2); /* K =-t0/Alpha */
t2 = L_shl(t2, alp_exp); /* denormalize; compare to Alpha */
L_Extract(t2, &Kh, &Kl); /* K in DPF */
rc[i-1] = Kh;
/* Test for unstable filter. If unstable keep old A(z) */
if (sub(abs_s(Kh), 32750) > 0)
{
for(j=0; j<=M; j++)
{
A[j] = old_A[j];
}
rc[0] = old_rc[0]; /* only two rc coefficients are needed */
rc[1] = old_rc[1];
return;
}
/*------------------------------------------*
* Compute new LPC coeff. -> An[i] *
* An[j]= A[j] + K*A[i-j] , j=1 to i-1 *
* An[i]= K *
*------------------------------------------*/
for(j=1; j<i; j++)
{
t0 = Mpy_32(Kh, Kl, Ah[i-j], Al[i-j]);
t0 = L_add(t0, L_Comp(Ah[j], Al[j]));
L_Extract(t0, &Anh[j], &Anl[j]);
}
t2 = L_shr(t2, 4); /* t2 = K in Q31 ->convert to Q27 */
L_Extract(t2, &Anh[i], &Anl[i]); /* An[i] in Q27 */
/* Alpha = Alpha * (1-K**2) */
t0 = Mpy_32(Kh ,Kl, Kh, Kl); /* K*K in Q31 */
t0 = L_abs(t0); /* Some case <0 !! */
t0 = L_sub( (int32_t)0x7fffffffL, t0 ); /* 1 - K*K in Q31 */
L_Extract(t0, &hi, &lo); /* DPF format */
t0 = Mpy_32(alp_h , alp_l, hi, lo); /* Alpha in Q31 */
/* Normalize Alpha */
j = norm_l(t0);
t0 = L_shl(t0, j);
L_Extract(t0, &alp_h, &alp_l); /* DPF format */
alp_exp = add(alp_exp, j); /* Add normalization to alp_exp */
/* A[j] = An[j] */
for(j=1; j<=i; j++)
{
Ah[j] =Anh[j];
Al[j] =Anl[j];
}
}
*Err = shr(alp_h, alp_exp);
/* Truncate A[i] in Q27 to Q12 with rounding */
A[0] = 4096;
for(i=1; i<=M; i++)
{
t0 = L_Comp(Ah[i], Al[i]);
old_A[i] = A[i] = _round(L_shl(t0, 1));
}
old_rc[0] = rc[0];
old_rc[1] = rc[1];
return;
}
/*-------------------------------------------------------------*
* procedure Az_lsp: *
* ~~~~~~ *
* Compute the LSPs from the LPC coefficients (order=10) *
*-------------------------------------------------------------*/
/* local function */
static int16_t Chebps_11(int16_t x, int16_t f[], int16_t n);
static int16_t Chebps_10(int16_t x, int16_t f[], int16_t n);
void Az_lsp(
int16_t a[], /* (i) Q12 : predictor coefficients */
int16_t lsp[], /* (o) Q15 : line spectral pairs */
int16_t old_lsp[] /* (i) : old lsp[] (in case not found 10 roots) */
)
{
int16_t i, j, nf, ip;
int16_t xlow, ylow, xhigh, yhigh, xmid, ymid, xint;
int16_t x, y, sign, exp;
int16_t *coef;
int16_t f1[M/2+1], f2[M/2+1];
int32_t t0, L_temp;
int32_t ovf_coef;
int16_t (*pChebps)(int16_t x, int16_t f[], int16_t n);
/*-------------------------------------------------------------*
* find the sum and diff. pol. F1(z) and F2(z) *
* F1(z) <--- F1(z)/(1+z**-1) & F2(z) <--- F2(z)/(1-z**-1) *
* *
* f1[0] = 1.0; *
* f2[0] = 1.0; *
* *
* for (i = 0; i< NC; i++) *
* { *
* f1[i+1] = a[i+1] + a[M-i] - f1[i] ; *
* f2[i+1] = a[i+1] - a[M-i] + f2[i] ; *
* } *
*-------------------------------------------------------------*/
ovf_coef = 0;
pChebps = Chebps_11;
f1[0] = 2048; /* f1[0] = 1.0 is in Q11 */
f2[0] = 2048; /* f2[0] = 1.0 is in Q11 */
for (i = 0; i< NC; i++)
{
Overflow = 0;
t0 = L_mult(a[i+1], 16384); /* x = (a[i+1] + a[M-i]) >> 1 */
t0 = L_mac(t0, a[M-i], 16384); /* -> From Q12 to Q11 */
x = extract_h(t0);
if ( Overflow ) {
ovf_coef = 1; }
Overflow = 0;
f1[i+1] = sub(x, f1[i]); /* f1[i+1] = a[i+1] + a[M-i] - f1[i] */
if ( Overflow ) {
ovf_coef = 1; }
Overflow = 0;
t0 = L_mult(a[i+1], 16384); /* x = (a[i+1] - a[M-i]) >> 1 */
t0 = L_msu(t0, a[M-i], 16384); /* -> From Q12 to Q11 */
x = extract_h(t0);
if ( Overflow ) {
ovf_coef = 1; }
Overflow = 0;
f2[i+1] = add(x, f2[i]); /* f2[i+1] = a[i+1] - a[M-i] + f2[i] */
if ( Overflow ) {
ovf_coef = 1; }
}
if ( ovf_coef ) {
/*printf("===== OVF ovf_coef =====\n");*/
pChebps = Chebps_10;
f1[0] = 1024; /* f1[0] = 1.0 is in Q10 */
f2[0] = 1024; /* f2[0] = 1.0 is in Q10 */
for (i = 0; i< NC; i++)
{
t0 = L_mult(a[i+1], 8192); /* x = (a[i+1] + a[M-i]) >> 1 */
t0 = L_mac(t0, a[M-i], 8192); /* -> From Q11 to Q10 */
x = extract_h(t0);
f1[i+1] = sub(x, f1[i]); /* f1[i+1] = a[i+1] + a[M-i] - f1[i] */
t0 = L_mult(a[i+1], 8192); /* x = (a[i+1] - a[M-i]) >> 1 */
t0 = L_msu(t0, a[M-i], 8192); /* -> From Q11 to Q10 */
x = extract_h(t0);
f2[i+1] = add(x, f2[i]); /* f2[i+1] = a[i+1] - a[M-i] + f2[i] */
}
}
/*-------------------------------------------------------------*
* find the LSPs using the Chebichev pol. evaluation *
*-------------------------------------------------------------*/
nf=0; /* number of found frequencies */
ip=0; /* indicator for f1 or f2 */
coef = f1;
xlow = grid[0];
ylow = (*pChebps)(xlow, coef, NC);
j = 0;
while ( (nf < M) && (j < GRID_POINTS) )
{
j =add(j,1);
xhigh = xlow;
yhigh = ylow;
xlow = grid[j];
ylow = (*pChebps)(xlow,coef,NC);
L_temp = L_mult(ylow ,yhigh);
if ( L_temp <= (int32_t)0)
{
/* divide 2 times the interval */
for (i = 0; i < 2; i++)
{
xmid = add( shr(xlow, 1) , shr(xhigh, 1)); /* xmid = (xlow + xhigh)/2 */
ymid = (*pChebps)(xmid,coef,NC);
L_temp = L_mult(ylow,ymid);
if ( L_temp <= (int32_t)0)
{
yhigh = ymid;
xhigh = xmid;
}
else
{
ylow = ymid;
xlow = xmid;
}
}
/*-------------------------------------------------------------*
* Linear interpolation *
* xint = xlow - ylow*(xhigh-xlow)/(yhigh-ylow); *
*-------------------------------------------------------------*/
x = sub(xhigh, xlow);
y = sub(yhigh, ylow);
if(y == 0)
{
xint = xlow;
}
else
{
sign= y;
y = abs_s(y);
exp = norm_s(y);
y = shl(y, exp);
y = div_s( (int16_t)16383, y);
t0 = L_mult(x, y);
t0 = L_shr(t0, sub(20, exp) );
y = extract_l(t0); /* y= (xhigh-xlow)/(yhigh-ylow) in Q11 */
if(sign < 0) y = negate(y);
t0 = L_mult(ylow, y); /* result in Q26 */
t0 = L_shr(t0, 11); /* result in Q15 */
xint = sub(xlow, extract_l(t0)); /* xint = xlow - ylow*y */
}
lsp[nf] = xint;
xlow = xint;
nf =add(nf,1);
if(ip == 0)
{
ip = 1;
coef = f2;
}
else
{
ip = 0;
coef = f1;
}
ylow = (*pChebps)(xlow,coef,NC);
}
}
/* Check if M roots found */
if( sub(nf, M) < 0)
{
for(i=0; i<M; i++)
{
lsp[i] = old_lsp[i];
}
/* printf("\n !!Not 10 roots found in Az_lsp()!!!\n"); */
}
return;
}
/*--------------------------------------------------------------*
* function Chebps_11, Chebps_10: *
* ~~~~~~~~~~~~~~~~~~~~ *
* Evaluates the Chebichev polynomial series *
*--------------------------------------------------------------*
* *
* The polynomial order is *
* n = M/2 (M is the prediction order) *
* The polynomial is given by *
* C(x) = T_n(x) + f(1)T_n-1(x) + ... +f(n-1)T_1(x) + f(n)/2 *
* Arguments: *
* x: input value of evaluation; x = cos(frequency) in Q15 *
* f[]: coefficients of the pol. *
* in Q11(Chebps_11), in Q10(Chebps_10) *
* n: order of the pol. *
* *
* The value of C(x) is returned. (Saturated to +-1.99 in Q14) *
* *
*--------------------------------------------------------------*/
static int16_t Chebps_11(int16_t x, int16_t f[], int16_t n)
{
int16_t i, cheb;
int16_t b0_h, b0_l, b1_h, b1_l, b2_h, b2_l;
int32_t t0;
/* Note: All computation are done in Q24. */
b2_h = 256; /* b2 = 1.0 in Q24 DPF */
b2_l = 0;
t0 = L_mult(x, 512); /* 2*x in Q24 */
t0 = L_mac(t0, f[1], 4096); /* + f[1] in Q24 */
L_Extract(t0, &b1_h, &b1_l); /* b1 = 2*x + f[1] */
for (i = 2; i<n; i++)
{
t0 = Mpy_32_16(b1_h, b1_l, x); /* t0 = 2.0*x*b1 */
t0 = L_shl(t0, 1);
t0 = L_mac(t0,b2_h,(int16_t)-32768L);/* t0 = 2.0*x*b1 - b2 */
t0 = L_msu(t0, b2_l, 1);
t0 = L_mac(t0, f[i], 4096); /* t0 = 2.0*x*b1 - b2 + f[i]; */
L_Extract(t0, &b0_h, &b0_l); /* b0 = 2.0*x*b1 - b2 + f[i]; */
b2_l = b1_l; /* b2 = b1; */
b2_h = b1_h;
b1_l = b0_l; /* b1 = b0; */
b1_h = b0_h;
}
t0 = Mpy_32_16(b1_h, b1_l, x); /* t0 = x*b1; */
t0 = L_mac(t0, b2_h,(int16_t)-32768L); /* t0 = x*b1 - b2 */
t0 = L_msu(t0, b2_l, 1);
t0 = L_mac(t0, f[i], 2048); /* t0 = x*b1 - b2 + f[i]/2 */
t0 = L_shl(t0, 6); /* Q24 to Q30 with saturation */
cheb = extract_h(t0); /* Result in Q14 */
return(cheb);
}
static int16_t Chebps_10(int16_t x, int16_t f[], int16_t n)
{
int16_t i, cheb;
int16_t b0_h, b0_l, b1_h, b1_l, b2_h, b2_l;
int32_t t0;
/* Note: All computation are done in Q23. */
b2_h = 128; /* b2 = 1.0 in Q23 DPF */
b2_l = 0;
t0 = L_mult(x, 256); /* 2*x in Q23 */
t0 = L_mac(t0, f[1], 4096); /* + f[1] in Q23 */
L_Extract(t0, &b1_h, &b1_l); /* b1 = 2*x + f[1] */
for (i = 2; i<n; i++)
{
t0 = Mpy_32_16(b1_h, b1_l, x); /* t0 = 2.0*x*b1 */
t0 = L_shl(t0, 1);
t0 = L_mac(t0,b2_h,(int16_t)-32768L);/* t0 = 2.0*x*b1 - b2 */
t0 = L_msu(t0, b2_l, 1);
t0 = L_mac(t0, f[i], 4096); /* t0 = 2.0*x*b1 - b2 + f[i]; */
L_Extract(t0, &b0_h, &b0_l); /* b0 = 2.0*x*b1 - b2 + f[i]; */
b2_l = b1_l; /* b2 = b1; */
b2_h = b1_h;
b1_l = b0_l; /* b1 = b0; */
b1_h = b0_h;
}
t0 = Mpy_32_16(b1_h, b1_l, x); /* t0 = x*b1; */
t0 = L_mac(t0, b2_h,(int16_t)-32768L); /* t0 = x*b1 - b2 */
t0 = L_msu(t0, b2_l, 1);
t0 = L_mac(t0, f[i], 2048); /* t0 = x*b1 - b2 + f[i]/2 */
t0 = L_shl(t0, 7); /* Q23 to Q30 with saturation */
cheb = extract_h(t0); /* Result in Q14 */
return(cheb);
}