aboutsummaryrefslogtreecommitdiffstats
path: root/trunk/codecs/ilbc/syntFilter.c
blob: bb7f7a5599a2555eb57f57ab114d5c5ad555ebbf (plain)
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
/******************************************************************

    iLBC Speech Coder ANSI-C Source Code

    syntFilter.c 

    Copyright (C) The Internet Society (2004). 
    All Rights Reserved.

******************************************************************/

#include "iLBC_define.h"
#include "syntFilter.h"

/*----------------------------------------------------------------*
 *  LP synthesis filter.
 *---------------------------------------------------------------*/
    
void syntFilter(
    float *Out,     /* (i/o) Signal to be filtered */
    float *a,       /* (i) LP parameters */
    int len,    /* (i) Length of signal */
    float *mem      /* (i/o) Filter state */
){
    int i, j;
    float *po, *pi, *pa, *pm;

    po=Out;

    /* Filter first part using memory from past */

    for (i=0; i<LPC_FILTERORDER; i++) {
        pi=&Out[i-1];
        pa=&a[1];
        pm=&mem[LPC_FILTERORDER-1];
        for (j=1; j<=i; j++) {
            *po-=(*pa++)*(*pi--);
        }
        for (j=i+1; j<LPC_FILTERORDER+1; j++) {
            *po-=(*pa++)*(*pm--);
        }
        po++;
    }

    /* Filter last part where the state is entierly in 
       the output vector */
    
    for (i=LPC_FILTERORDER; i<len; i++) {


        pi=&Out[i-1];
        pa=&a[1];
        for (j=1; j<LPC_FILTERORDER+1; j++) {
            *po-=(*pa++)*(*pi--);
        }
        po++;
    }

    /* Update state vector */

    memcpy(mem, &Out[len-LPC_FILTERORDER], 
        LPC_FILTERORDER*sizeof(float));
}