1/*
2 ** Copyright 2003-2010, VisualOn, Inc.
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 **     http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16
17/***********************************************************************
18*  File: residu.c                                                      *
19*                                                                      *
20*  Description: Compute the LPC residual by filtering                  *
21*             the input speech through A(z)                            *
22*                                                                      *
23************************************************************************/
24
25#include "typedef.h"
26#include "basic_op.h"
27
28void Residu(
29        Word16 a[],                           /* (i) Q12 : prediction coefficients                     */
30        Word16 x[],                           /* (i)     : speech (values x[-m..-1] are needed         */
31        Word16 y[],                           /* (o) x2  : residual signal                             */
32        Word16 lg                             /* (i)     : size of filtering                           */
33        )
34{
35    Word16 i,*p1, *p2;
36    Word32 s;
37    for (i = 0; i < lg; i++)
38    {
39        p1 = a;
40        p2 = &x[i];
41        s  = vo_mult32((*p1++), (*p2--));
42        s += vo_mult32((*p1++), (*p2--));
43        s += vo_mult32((*p1++), (*p2--));
44        s += vo_mult32((*p1++), (*p2--));
45        s += vo_mult32((*p1++), (*p2--));
46        s += vo_mult32((*p1++), (*p2--));
47        s += vo_mult32((*p1++), (*p2--));
48        s += vo_mult32((*p1++), (*p2--));
49        s += vo_mult32((*p1++), (*p2--));
50        s += vo_mult32((*p1++), (*p2--));
51        s += vo_mult32((*p1++), (*p2--));
52        s += vo_mult32((*p1++), (*p2--));
53        s += vo_mult32((*p1++), (*p2--));
54        s += vo_mult32((*p1++), (*p2--));
55        s += vo_mult32((*p1++), (*p2--));
56        s += vo_mult32((*p1++), (*p2--));
57        s += vo_mult32((*p1), (*p2));
58
59        s = L_shl2(s, 5);
60        y[i] = extract_h(L_add(s, 0x8000));
61    }
62
63    return;
64}
65
66
67
68