Mercurial > libavcodec.hg
comparison ra144.c @ 7162:ad0d9713e953 libavcodec
Use ff_acelp_lp_synthesis_filter() instead of duplicating it
author | vitor |
---|---|
date | Sun, 29 Jun 2008 11:21:06 +0000 |
parents | 7767dc2b0ee6 |
children | ec5bae4d05a2 |
comparison
equal
deleted
inserted
replaced
7161:2b763a495c07 | 7162:ad0d9713e953 |
---|---|
20 */ | 20 */ |
21 | 21 |
22 #include "avcodec.h" | 22 #include "avcodec.h" |
23 #include "bitstream.h" | 23 #include "bitstream.h" |
24 #include "ra144.h" | 24 #include "ra144.h" |
25 #include "acelp_filters.h" | |
25 | 26 |
26 #define NBLOCKS 4 ///< number of subblocks within a block | 27 #define NBLOCKS 4 ///< number of subblocks within a block |
27 #define BLOCKSIZE 40 ///< subblock size in 16-bit words | 28 #define BLOCKSIZE 40 ///< subblock size in 16-bit words |
28 #define BUFFERSIZE 146 ///< the size of the adaptive codebook | 29 #define BUFFERSIZE 146 ///< the size of the adaptive codebook |
29 | 30 |
136 for (i=!skip_first; i<3; i++) | 137 for (i=!skip_first; i<3; i++) |
137 v[i] = (gain_val_tab[n][i] * m[i]) >> (gain_exp_tab[n][i] + 1); | 138 v[i] = (gain_val_tab[n][i] * m[i]) >> (gain_exp_tab[n][i] + 1); |
138 | 139 |
139 for (i=0; i < BLOCKSIZE; i++) | 140 for (i=0; i < BLOCKSIZE; i++) |
140 dest[i] = (s1[i]*v[0] + s2[i]*v[1] + s3[i]*v[2]) >> 12; | 141 dest[i] = (s1[i]*v[0] + s2[i]*v[1] + s3[i]*v[2]) >> 12; |
141 } | |
142 | |
143 /** | |
144 * LPC Filter. Each output value is predicted from the 10 previous computed | |
145 * ones. It overwrites the input with the output. | |
146 * | |
147 * @param in the input of the filter. It should be an array of size len + 10. | |
148 * The 10 first input values are used to evaluate the first filtered one. | |
149 */ | |
150 static void lpc_filter(uint16_t *in, const int16_t *lpc_coefs, int len) | |
151 { | |
152 int x, i; | |
153 int16_t *ptr = in; | |
154 | |
155 for (i=0; i<len; i++) { | |
156 int sum = 0; | |
157 int new_val; | |
158 | |
159 for(x=0; x<10; x++) | |
160 sum += lpc_coefs[9-x] * ptr[x]; | |
161 | |
162 sum >>= 12; | |
163 | |
164 new_val = ptr[10] - sum; | |
165 | |
166 if (new_val < -32768 || new_val > 32767) { | |
167 memset(in, 0, 50*sizeof(*in)); | |
168 return; | |
169 } | |
170 | |
171 ptr[10] = new_val; | |
172 ptr++; | |
173 } | |
174 } | 142 } |
175 | 143 |
176 static unsigned int rescale_rms(unsigned int rms, unsigned int energy) | 144 static unsigned int rescale_rms(unsigned int rms, unsigned int energy) |
177 { | 145 { |
178 return (rms * energy) >> 10; | 146 return (rms * energy) >> 10; |
235 memcpy(ractx->curr_sblock, ractx->curr_sblock + 40, | 203 memcpy(ractx->curr_sblock, ractx->curr_sblock + 40, |
236 10*sizeof(*ractx->curr_sblock)); | 204 10*sizeof(*ractx->curr_sblock)); |
237 memcpy(ractx->curr_sblock + 10, block, | 205 memcpy(ractx->curr_sblock + 10, block, |
238 BLOCKSIZE*sizeof(*ractx->curr_sblock)); | 206 BLOCKSIZE*sizeof(*ractx->curr_sblock)); |
239 | 207 |
240 lpc_filter(ractx->curr_sblock, lpc_coefs, BLOCKSIZE); | 208 if (ff_acelp_lp_synthesis_filter( |
209 ractx->curr_sblock + 10, lpc_coefs -1, | |
210 ractx->curr_sblock + 10, BLOCKSIZE, | |
211 11, 1, 0xfff) | |
212 ) | |
213 memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock)); | |
241 } | 214 } |
242 | 215 |
243 static void int_to_int16(int16_t *out, const int *inp) | 216 static void int_to_int16(int16_t *out, const int *inp) |
244 { | 217 { |
245 int i; | 218 int i; |