Mercurial > libavcodec.hg
comparison acelp_filters.h @ 6856:94465a2c3b34 libavcodec
Move pitch vector interpolation code to acelp_filters
and convert it to a generic interpolation routine.
author | voroshil |
---|---|
date | Sat, 24 May 2008 17:18:42 +0000 |
parents | 3e5f5f14f796 |
children | 2b763a495c07 |
comparison
equal
deleted
inserted
replaced
6855:128af7cac045 | 6856:94465a2c3b34 |
---|---|
22 | 22 |
23 #ifndef FFMPEG_ACELP_FILTERS_H | 23 #ifndef FFMPEG_ACELP_FILTERS_H |
24 #define FFMPEG_ACELP_FILTERS_H | 24 #define FFMPEG_ACELP_FILTERS_H |
25 | 25 |
26 #include <stdint.h> | 26 #include <stdint.h> |
27 | |
28 /** | |
29 * low-pass FIR (Finite Impulse Response) filter coefficients | |
30 * | |
31 * A similar filter is named b30 in G.729. | |
32 * | |
33 * G.729 specification says: | |
34 * b30 is based on Hamming windowed sinc functions, truncated at +/-29 and | |
35 * padded with zeros at +/-30 b30[30]=0. | |
36 * The filter has a cut-off frequency (-3 dB) at 3600 Hz in the oversampled | |
37 * domain. | |
38 * | |
39 * After some analysis, I found this approximation: | |
40 * | |
41 * PI * x | |
42 * Hamm(x,N) = 0.53836-0.46164*cos(--------) | |
43 * N-1 | |
44 * --- | |
45 * 2 | |
46 * | |
47 * PI * x | |
48 * Hamm'(x,k) = Hamm(x - k, 2*k+1) = 0.53836 + 0.46164*cos(--------) | |
49 * k | |
50 * | |
51 * sin(PI * x) | |
52 * Sinc(x) = ----------- (normalized sinc function) | |
53 * PI * x | |
54 * | |
55 * h(t,B) = 2 * B * Sinc(2 * B * t) (impulse response of sinc low-pass filter) | |
56 * | |
57 * b(k,B, n) = Hamm'(n, k) * h(n, B) | |
58 * | |
59 * | |
60 * 3600 | |
61 * B = ---- | |
62 * 8000 | |
63 * | |
64 * 3600 - cut-off frequency | |
65 * 8000 - sampling rate | |
66 * k - filter order | |
67 * | |
68 * ff_acelp_interp_filter[6*i+j] = b(10, 3600/8000, i+j/6) | |
69 * | |
70 * The filter assumes the following order of fractions (X - integer delay): | |
71 * | |
72 * 1/3 precision: X 1/3 2/3 X 1/3 2/3 X | |
73 * 1/6 precision: X 1/6 2/6 3/6 4/6 5/6 X 1/6 2/6 3/6 4/6 5/6 X | |
74 * | |
75 * The filter can be used for 1/3 precision, too, by | |
76 * passing 2*pitch_delay_frac as third parameter to the interpolation routine. | |
77 * | |
78 */ | |
79 extern const int16_t ff_acelp_interp_filter[61]; | |
80 | |
81 /** | |
82 * \brief Generic interpolation routine | |
83 * \param out [out] buffer for interpolated data | |
84 * \param in input data | |
85 * \param filter_coeffs interpolation filter coefficients (0.15) | |
86 * \param precision filter is able to interpolate with 1/precision precision of pitch delay | |
87 * \param pitch_delay_frac pitch delay, fractional part [0..precision-1] | |
88 * \param filter_length filter length | |
89 * \param length length of speech data to process | |
90 * | |
91 * filter_coeffs contains coefficients of the positive half of the symmetric | |
92 * interpolation filter. filter_coeffs[0] should the central (unpaired) coefficient. | |
93 * See ff_acelp_interp_filter fot example. | |
94 * | |
95 */ | |
96 void ff_acelp_interpolate( | |
97 int16_t* out, | |
98 const int16_t* in, | |
99 const int16_t* filter_coeffs, | |
100 int precision, | |
101 int pitch_delay_frac, | |
102 int filter_length, | |
103 int length); | |
27 | 104 |
28 /** | 105 /** |
29 * \brief Circularly convolve fixed vector with a phase dispersion impulse | 106 * \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). | 107 * response filter (D.6.2 of G.729 and 6.1.5 of AMR). |
31 * \param fc_out vector with filter applied | 108 * \param fc_out vector with filter applied |