Mercurial > libavcodec.hg
annotate celp_filters.h @ 11000:6d22c964c601 libavcodec
Fix decoding ATI VCR2 codec, sample in
samples/V-codecs/ATI-VCR12/ATI/VCR2test.avi
Software decoding was broken since r8865, when two new context variables
were added, but not initialized in vcr2_init_sequence().
Another such context variable was added in r18381.
author | cehoyos |
---|---|
date | Sun, 24 Jan 2010 22:47:50 +0000 |
parents | 63451af5f8f9 |
children | 0885e7a93ed4 |
rev | line source |
---|---|
8049
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
1 /* |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
2 * various filters for CELP-based codecs |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
3 * |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
4 * Copyright (c) 2008 Vladimir Voroshilov |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
5 * |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
6 * This file is part of FFmpeg. |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
7 * |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
10 * License as published by the Free Software Foundation; either |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
12 * |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
16 * Lesser General Public License for more details. |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
17 * |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
21 */ |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
22 |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
23 #ifndef AVCODEC_CELP_FILTERS_H |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
24 #define AVCODEC_CELP_FILTERS_H |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
25 |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
26 #include <stdint.h> |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
27 |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
28 /** |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
29 * Circularly convolve fixed vector with a phase dispersion impulse |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
30 * response filter (D.6.2 of G.729 and 6.1.5 of AMR). |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
31 * @param fc_out vector with filter applied |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
32 * @param fc_in source vector |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
33 * @param filter phase filter coefficients |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
34 * |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
35 * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] } |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
36 * |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
37 * \note fc_in and fc_out should not overlap! |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
38 */ |
10690
63451af5f8f9
Cosmetics: make celp_filters.* formatting more consistent with the rest of
vitor
parents:
10689
diff
changeset
|
39 void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in, |
63451af5f8f9
Cosmetics: make celp_filters.* formatting more consistent with the rest of
vitor
parents:
10689
diff
changeset
|
40 const int16_t *filter, int len); |
8049
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
41 |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
42 /** |
10045
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
43 * Add an array to a rotated array. |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
44 * |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
45 * out[k] = in[k] + fac * lagged[k-lag] with wrap-around |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
46 * |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
47 * @param out result vector |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
48 * @param in samples to be added unfiltered |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
49 * @param lagged samples to be rotated, multiplied and added |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
50 * @param lag lagged vector delay in the range [0, n] |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
51 * @param fac scalefactor for lagged samples |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
52 * @param n number of samples |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
53 */ |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
54 void ff_celp_circ_addf(float *out, const float *in, |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
55 const float *lagged, int lag, float fac, int n); |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
56 |
d35904b4fe3f
Add ff_celp_circ_addf() function to be used for sparse vector circular
superdump
parents:
10003
diff
changeset
|
57 /** |
8049
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
58 * LP synthesis filter. |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
59 * @param out [out] pointer to output buffer |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
60 * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000) |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
61 * @param in input signal |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
62 * @param buffer_length amount of data to process |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
63 * @param filter_length filter length (10 for 10th order LP filter) |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
64 * @param stop_on_overflow 1 - return immediately if overflow occurs |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
65 * 0 - ignore overflows |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
66 * @param rounder the amount to add for rounding (usually 0x800 or 0xfff) |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
67 * |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
68 * @return 1 if overflow occurred, 0 - otherwise |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
69 * |
8095
b9678ea8e5fb
Fix numbers in Doxygen comments, patch by Kenan Gillet, kenan.gillet gmail com.
diego
parents:
8093
diff
changeset
|
70 * @note Output buffer must contain filter_length samples of past |
8049
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
71 * speech data before pointer. |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
72 * |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
73 * Routine applies 1/A(z) filter to given speech data. |
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
74 */ |
10690
63451af5f8f9
Cosmetics: make celp_filters.* formatting more consistent with the rest of
vitor
parents:
10689
diff
changeset
|
75 int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs, |
63451af5f8f9
Cosmetics: make celp_filters.* formatting more consistent with the rest of
vitor
parents:
10689
diff
changeset
|
76 const int16_t *in, int buffer_length, |
63451af5f8f9
Cosmetics: make celp_filters.* formatting more consistent with the rest of
vitor
parents:
10689
diff
changeset
|
77 int filter_length, int stop_on_overflow, |
10003 | 78 int rounder); |
8049
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
79 |
8091 | 80 /** |
81 * LP synthesis filter. | |
82 * @param out [out] pointer to output buffer | |
83 * - the array out[-filter_length, -1] must | |
84 * contain the previous result of this filter | |
85 * @param filter_coeffs filter coefficients. | |
86 * @param in input signal | |
87 * @param buffer_length amount of data to process | |
10689
d124d9b688d0
Optimize ff_celp_lp_synthesis_filterf(). 50% faster in my tests.
vitor
parents:
10045
diff
changeset
|
88 * @param filter_length filter length (10 for 10th order LP filter). Must be |
d124d9b688d0
Optimize ff_celp_lp_synthesis_filterf(). 50% faster in my tests.
vitor
parents:
10045
diff
changeset
|
89 * greater than 4 and even. |
8091 | 90 * |
8095
b9678ea8e5fb
Fix numbers in Doxygen comments, patch by Kenan Gillet, kenan.gillet gmail com.
diego
parents:
8093
diff
changeset
|
91 * @note Output buffer must contain filter_length samples of past |
8091 | 92 * speech data before pointer. |
93 * | |
94 * Routine applies 1/A(z) filter to given speech data. | |
95 */ | |
10690
63451af5f8f9
Cosmetics: make celp_filters.* formatting more consistent with the rest of
vitor
parents:
10689
diff
changeset
|
96 void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, |
63451af5f8f9
Cosmetics: make celp_filters.* formatting more consistent with the rest of
vitor
parents:
10689
diff
changeset
|
97 const float *in, int buffer_length, |
10003 | 98 int filter_length); |
8091 | 99 |
9509
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
100 /** |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
101 * LP zero synthesis filter. |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
102 * @param out [out] pointer to output buffer |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
103 * @param filter_coeffs filter coefficients. |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
104 * @param in input signal |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
105 * - the array in[-filter_length, -1] must |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
106 * contain the previous input of this filter |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
107 * @param buffer_length amount of data to process |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
108 * @param filter_length filter length (10 for 10th order LP filter) |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
109 * |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
110 * @note Output buffer must contain filter_length samples of past |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
111 * speech data before pointer. |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
112 * |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
113 * Routine applies A(z) filter to given speech data. |
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
114 */ |
10690
63451af5f8f9
Cosmetics: make celp_filters.* formatting more consistent with the rest of
vitor
parents:
10689
diff
changeset
|
115 void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs, |
63451af5f8f9
Cosmetics: make celp_filters.* formatting more consistent with the rest of
vitor
parents:
10689
diff
changeset
|
116 const float *in, int buffer_length, |
10003 | 117 int filter_length); |
9509
2838045383c5
Add LP zero synthesis filter. Patch by Kenan Gillet.
reynaldo
parents:
8095
diff
changeset
|
118 |
8049
611a21e4b01b
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
diego
parents:
diff
changeset
|
119 #endif /* AVCODEC_CELP_FILTERS_H */ |