]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/blob - libavcodec/celp_filters.h
Do not hardcode filter order in ff_acelp_lspd2lpc()
[frescor/ffmpeg.git] / libavcodec / celp_filters.h
1 /*
2  * various filters for CELP-based codecs
3  *
4  * Copyright (c) 2008 Vladimir Voroshilov
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22
23 #ifndef AVCODEC_CELP_FILTERS_H
24 #define AVCODEC_CELP_FILTERS_H
25
26 #include <stdint.h>
27
28 /**
29  * Circularly convolve fixed vector with a phase dispersion impulse
30  *        response filter (D.6.2 of G.729 and 6.1.5 of AMR).
31  * @param fc_out vector with filter applied
32  * @param fc_in source vector
33  * @param filter phase filter coefficients
34  *
35  *  fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] }
36  *
37  * \note fc_in and fc_out should not overlap!
38  */
39 void ff_celp_convolve_circ(int16_t* fc_out,
40                            const int16_t* fc_in,
41                            const int16_t* filter,
42                            int len);
43
44 /**
45  * Add an array to a rotated array.
46  *
47  * out[k] = in[k] + fac * lagged[k-lag] with wrap-around
48  *
49  * @param out result vector
50  * @param in samples to be added unfiltered
51  * @param lagged samples to be rotated, multiplied and added
52  * @param lag lagged vector delay in the range [0, n]
53  * @param fac scalefactor for lagged samples
54  * @param n number of samples
55  */
56 void ff_celp_circ_addf(float *out, const float *in,
57                        const float *lagged, int lag, float fac, int n);
58
59 /**
60  * LP synthesis filter.
61  * @param out [out] pointer to output buffer
62  * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
63  * @param in input signal
64  * @param buffer_length amount of data to process
65  * @param filter_length filter length (10 for 10th order LP filter)
66  * @param stop_on_overflow   1 - return immediately if overflow occurs
67  *                           0 - ignore overflows
68  * @param rounder the amount to add for rounding (usually 0x800 or 0xfff)
69  *
70  * @return 1 if overflow occurred, 0 - otherwise
71  *
72  * @note Output buffer must contain filter_length samples of past
73  *       speech data before pointer.
74  *
75  * Routine applies 1/A(z) filter to given speech data.
76  */
77 int ff_celp_lp_synthesis_filter(int16_t *out,
78                                 const int16_t* filter_coeffs,
79                                 const int16_t* in,
80                                 int buffer_length,
81                                 int filter_length,
82                                 int stop_on_overflow,
83                                 int rounder);
84
85 /**
86  * LP synthesis filter.
87  * @param out [out] pointer to output buffer
88  *        - the array out[-filter_length, -1] must
89  *        contain the previous result of this filter
90  * @param filter_coeffs filter coefficients.
91  * @param in input signal
92  * @param buffer_length amount of data to process
93  * @param filter_length filter length (10 for 10th order LP filter)
94  *
95  * @note Output buffer must contain filter_length samples of past
96  *       speech data before pointer.
97  *
98  * Routine applies 1/A(z) filter to given speech data.
99  */
100 void ff_celp_lp_synthesis_filterf(float *out,
101                                   const float* filter_coeffs,
102                                   const float* in,
103                                   int buffer_length,
104                                   int filter_length);
105
106 /**
107  * LP zero synthesis filter.
108  * @param out [out] pointer to output buffer
109  * @param filter_coeffs filter coefficients.
110  * @param in input signal
111  *        - the array in[-filter_length, -1] must
112  *        contain the previous input of this filter
113  * @param buffer_length amount of data to process
114  * @param filter_length filter length (10 for 10th order LP filter)
115  *
116  * @note Output buffer must contain filter_length samples of past
117  *       speech data before pointer.
118  *
119  * Routine applies A(z) filter to given speech data.
120  */
121 void ff_celp_lp_zero_synthesis_filterf(float *out,
122                                        const float* filter_coeffs,
123                                        const float* in,
124                                        int buffer_length,
125                                        int filter_length);
126
127 #endif /* AVCODEC_CELP_FILTERS_H */