]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/blob - libavcodec/acelp_filters.h
acelp_filters.h needs stdint.h
[frescor/ffmpeg.git] / libavcodec / acelp_filters.h
1 /*
2  * various filters for ACELP-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 FFMPEG_ACELP_FILTERS_H
24 #define FFMPEG_ACELP_FILTERS_H
25
26 #include <stdint.h>
27
28 /**
29  * \brief 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_acelp_convolve_circ(
40         int16_t* fc_out,
41         const int16_t* fc_in,
42         const int16_t* filter,
43         int subframe_size);
44
45 /**
46  * \brief LP synthesis filter
47  * \param out [out] pointer to output buffer
48  * \param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
49  * \param in input signal
50  * \param buffer_length amount of data to process
51  * \param filter_length filter length (11 for 10th order LP filter)
52  * \param stop_on_overflow   1 - return immediately if overflow occurs
53  *                           0 - ignore overflows
54  *
55  * \return 1 if overflow occurred, 0 - otherwise
56  *
57  * \note Output buffer must contain 10 samples of past
58  *       speech data before pointer.
59  *
60  * Routine applies 1/A(z) filter to given speech data.
61  */
62 int ff_acelp_lp_synthesis_filter(
63         int16_t *out,
64         const int16_t* filter_coeffs,
65         const int16_t* in,
66         int buffer_length,
67         int filter_length,
68         int stop_on_overflow);
69
70 /**
71  * \brief Calculates coefficients of weighted A(z/weight) filter.
72  * \param out [out] weighted A(z/weight) result
73  *                  filter (-0x8000 <= (3.12) < 0x8000)
74  * \param in source filter (-0x8000 <= (3.12) < 0x8000)
75  * \param weight_pow array containing weight^i (-0x8000 <= (0.15) < 0x8000)
76  * \param filter_length filter length (11 for 10th order LP filter)
77  *
78  * out[i]=weight_pow[i]*in[i] , i=0..9
79  */
80 void ff_acelp_weighted_filter(
81         int16_t *out,
82         const int16_t* in,
83         const int16_t *weight_pow,
84         int filter_length);
85
86 /**
87  * \brief high-pass filtering and upscaling (4.2.5 of G.729)
88  * \param out [out] output buffer for filtered speech data
89  * \param hpf_f [in/out] past filtered data from previous (2 items long)
90  *                       frames (-0x20000000 <= (14.13) < 0x20000000)
91  * \param in speech data to process
92  * \param length input data size
93  *
94  * out[i] = 0.93980581 * in[i] - 1.8795834 * in[i-1] + 0.93980581 * in[i-2] +
95  *          1.9330735 * out[i-1] - 0.93589199 * out[i-2]
96  *
97  * The filter has a cut-off frequency of 100Hz
98  *
99  * \note Two items before the top of the out buffer must contain two items from the
100  *       tail of the previous subframe.
101  *
102  * \remark It is safe to pass the same array in in and out parameters.
103  *
104  * \remark AMR uses mostly the same filter (cut-off frequency 60Hz, same formula,
105  *         but constants differs in 5th sign after comma). Fortunately in
106  *         fixed-point all coefficients are the same as in G.729. Thus this
107  *         routine can be used for the fixed-point AMR decoder, too.
108  */
109 void ff_acelp_high_pass_filter(
110         int16_t* out,
111         int hpf_f[2],
112         const int16_t* in,
113         int length);
114
115 #endif // FFMPEG_ACELP_FILTERS_H