FFmpeg
celp_filters.h
Go to the documentation of this file.
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 typedef struct CELPFContext {
29  /**
30  * LP synthesis filter.
31  * @param[out] out pointer to output buffer
32  * - the array out[-filter_length, -1] must
33  * contain the previous result of this filter
34  * @param filter_coeffs filter coefficients.
35  * @param in input signal
36  * @param buffer_length amount of data to process
37  * @param filter_length filter length (10 for 10th order LP filter). Must be
38  * greater than 4 and even.
39  *
40  * @note Output buffer must contain filter_length samples of past
41  * speech data before pointer.
42  *
43  * Routine applies 1/A(z) filter to given speech data.
44  */
45  void (*celp_lp_synthesis_filterf)(float *out, const float *filter_coeffs,
46  const float *in, int buffer_length,
47  int filter_length);
48 
49  /**
50  * LP zero synthesis filter.
51  * @param[out] out pointer to output buffer
52  * @param filter_coeffs filter coefficients.
53  * @param in input signal
54  * - the array in[-filter_length, -1] must
55  * contain the previous input of this filter
56  * @param buffer_length amount of data to process (should be a multiple of eight)
57  * @param filter_length filter length (10 for 10th order LP filter;
58  * should be a multiple of two)
59  *
60  * @note Output buffer must contain filter_length samples of past
61  * speech data before pointer.
62  *
63  * Routine applies A(z) filter to given speech data.
64  */
65  void (*celp_lp_zero_synthesis_filterf)(float *out, const float *filter_coeffs,
66  const float *in, int buffer_length,
67  int filter_length);
68 
70 
71 /**
72  * Initialize CELPFContext.
73  */
76 
77 /**
78  * Circularly convolve fixed vector with a phase dispersion impulse
79  * response filter (D.6.2 of G.729 and 6.1.5 of AMR).
80  * @param fc_out vector with filter applied
81  * @param fc_in source vector
82  * @param filter phase filter coefficients
83  *
84  * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] }
85  *
86  * @note fc_in and fc_out should not overlap!
87  */
88 void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in,
89  const int16_t *filter, int len);
90 
91 /**
92  * Add an array to a rotated array.
93  *
94  * out[k] = in[k] + fac * lagged[k-lag] with wrap-around
95  *
96  * @param out result vector
97  * @param in samples to be added unfiltered
98  * @param lagged samples to be rotated, multiplied and added
99  * @param lag lagged vector delay in the range [0, n]
100  * @param fac scalefactor for lagged samples
101  * @param n number of samples
102  */
103 void ff_celp_circ_addf(float *out, const float *in,
104  const float *lagged, int lag, float fac, int n);
105 
106 /**
107  * LP synthesis filter.
108  * @param[out] out pointer to output buffer
109  * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
110  * @param in input signal
111  * @param buffer_length amount of data to process
112  * @param filter_length filter length (10 for 10th order LP filter)
113  * @param stop_on_overflow 1 - return immediately if overflow occurs
114  * 0 - ignore overflows
115  * @param shift the result is shifted right by this value
116  * @param rounder the amount to add for rounding (usually 0x800 or 0xfff)
117  *
118  * @return 1 if overflow occurred, 0 - otherwise
119  *
120  * @note Output buffer must contain filter_length samples of past
121  * speech data before pointer.
122  *
123  * Routine applies 1/A(z) filter to given speech data.
124  */
125 int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
126  const int16_t *in, int buffer_length,
127  int filter_length, int stop_on_overflow,
128  int shift, int rounder);
129 
130 /**
131  * LP synthesis filter.
132  * @param[out] out pointer to output buffer
133  * - the array out[-filter_length, -1] must
134  * contain the previous result of this filter
135  * @param filter_coeffs filter coefficients.
136  * @param in input signal
137  * @param buffer_length amount of data to process
138  * @param filter_length filter length (10 for 10th order LP filter). Must be
139  * greater than 4 and even.
140  *
141  * @note Output buffer must contain filter_length samples of past
142  * speech data before pointer.
143  *
144  * Routine applies 1/A(z) filter to given speech data.
145  */
146 void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
147  const float *in, int buffer_length,
148  int filter_length);
149 
150 /**
151  * LP zero synthesis filter.
152  * @param[out] out pointer to output buffer
153  * @param filter_coeffs filter coefficients.
154  * @param in input signal
155  * - the array in[-filter_length, -1] must
156  * contain the previous input of this filter
157  * @param buffer_length amount of data to process
158  * @param filter_length filter length (10 for 10th order LP filter)
159  *
160  * @note Output buffer must contain filter_length samples of past
161  * speech data before pointer.
162  *
163  * Routine applies A(z) filter to given speech data.
164  */
165 void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs,
166  const float *in, int buffer_length,
167  int filter_length);
168 
169 #endif /* AVCODEC_CELP_FILTERS_H */
out
FILE * out
Definition: movenc.c:54
filter
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
Definition: filter_design.txt:228
CELPFContext::celp_lp_synthesis_filterf
void(* celp_lp_synthesis_filterf)(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP synthesis filter.
Definition: celp_filters.h:45
CELPFContext::celp_lp_zero_synthesis_filterf
void(* celp_lp_zero_synthesis_filterf)(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP zero synthesis filter.
Definition: celp_filters.h:65
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
ff_celp_lp_synthesis_filter
int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs, const int16_t *in, int buffer_length, int filter_length, int stop_on_overflow, int shift, int rounder)
LP synthesis filter.
Definition: celp_filters.c:61
CELPFContext
Definition: celp_filters.h:28
ff_celp_convolve_circ
void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in, const int16_t *filter, int len)
Circularly convolve fixed vector with a phase dispersion impulse response filter (D....
Definition: celp_filters.c:31
len
int len
Definition: vorbis_enc_data.h:426
ff_celp_lp_zero_synthesis_filterf
void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP zero synthesis filter.
Definition: celp_filters.c:200
ff_celp_filter_init_mips
void ff_celp_filter_init_mips(CELPFContext *c)
Definition: celp_filters_mips.c:285
shift
static int shift(int a, int b)
Definition: sonic.c:83
ff_celp_filter_init
void ff_celp_filter_init(CELPFContext *c)
Initialize CELPFContext.
Definition: celp_filters.c:213
ff_celp_circ_addf
void ff_celp_circ_addf(float *out, const float *in, const float *lagged, int lag, float fac, int n)
Add an array to a rotated array.
Definition: celp_filters.c:51
ff_celp_lp_synthesis_filterf
void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP synthesis filter.
Definition: celp_filters.c:85