OSDN Git Service

rtpdec: Don't pass non-const pointers to fmtp attribute parsing functions
[android-x86/external-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 Libav.
7  *
8  * Libav 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  * Libav 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 Libav; 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, const int16_t *fc_in,
40                            const int16_t *filter, int len);
41
42 /**
43  * Add an array to a rotated array.
44  *
45  * out[k] = in[k] + fac * lagged[k-lag] with wrap-around
46  *
47  * @param out result vector
48  * @param in samples to be added unfiltered
49  * @param lagged samples to be rotated, multiplied and added
50  * @param lag lagged vector delay in the range [0, n]
51  * @param fac scalefactor for lagged samples
52  * @param n number of samples
53  */
54 void ff_celp_circ_addf(float *out, const float *in,
55                        const float *lagged, int lag, float fac, int n);
56
57 /**
58  * LP synthesis filter.
59  * @param[out] out pointer to output buffer
60  * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
61  * @param in input signal
62  * @param buffer_length amount of data to process
63  * @param filter_length filter length (10 for 10th order LP filter)
64  * @param stop_on_overflow   1 - return immediately if overflow occurs
65  *                           0 - ignore overflows
66  * @param shift the result is shifted right by this value
67  * @param rounder the amount to add for rounding (usually 0x800 or 0xfff)
68  *
69  * @return 1 if overflow occurred, 0 - otherwise
70  *
71  * @note Output buffer must contain filter_length samples of past
72  *       speech data before pointer.
73  *
74  * Routine applies 1/A(z) filter to given speech data.
75  */
76 int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
77                                 const int16_t *in, int buffer_length,
78                                 int filter_length, int stop_on_overflow,
79                                 int shift, int rounder);
80
81 /**
82  * LP synthesis filter.
83  * @param[out] out pointer to output buffer
84  *        - the array out[-filter_length, -1] must
85  *        contain the previous result of this filter
86  * @param filter_coeffs filter coefficients.
87  * @param in input signal
88  * @param buffer_length amount of data to process
89  * @param filter_length filter length (10 for 10th order LP filter). Must be
90  *                      greater than 4 and even.
91  *
92  * @note Output buffer must contain filter_length samples of past
93  *       speech data before pointer.
94  *
95  * Routine applies 1/A(z) filter to given speech data.
96  */
97 void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
98                                   const float *in, int buffer_length,
99                                   int filter_length);
100
101 /**
102  * LP zero synthesis filter.
103  * @param[out] out pointer to output buffer
104  * @param filter_coeffs filter coefficients.
105  * @param in input signal
106  *        - the array in[-filter_length, -1] must
107  *        contain the previous input of this filter
108  * @param buffer_length amount of data to process
109  * @param filter_length filter length (10 for 10th order LP filter)
110  *
111  * @note Output buffer must contain filter_length samples of past
112  *       speech data before pointer.
113  *
114  * Routine applies A(z) filter to given speech data.
115  */
116 void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs,
117                                        const float *in, int buffer_length,
118                                        int filter_length);
119
120 #endif /* AVCODEC_CELP_FILTERS_H */