comparison ra288.c @ 7929:5b81784c5fe6 libavcodec

Simplify: avoid duplication backward_filter()
author vitor
date Fri, 26 Sep 2008 18:42:06 +0000
parents 9dc65bb3bd3f
children 36671e6689c7
comparison
equal deleted inserted replaced
7928:7d897cb94a31 7929:5b81784c5fe6
156 } 156 }
157 157
158 /** 158 /**
159 * Backward synthesis filter, find the LPC coefficients from past speech data. 159 * Backward synthesis filter, find the LPC coefficients from past speech data.
160 */ 160 */
161 static void backward_filter(RA288Context *ractx) 161 static void backward_filter(float *hist, float *rec, const float *window,
162 { 162 float *lpc, const float *tab,
163 float temp1[37]; // RTMP in the spec 163 int order, int n, int non_rec, int move_size)
164 float temp2[11]; // GPTPMP in the spec 164 {
165 165 float temp[order+1];
166 do_hybrid_window(36, 40, 35, temp1, ractx->sp_hist, 166
167 ractx->sp_rec, syn_window); 167 do_hybrid_window(order, n, non_rec, temp, hist, rec, window);
168 168
169 if (!compute_lpc_coefs(temp1, 36, ractx->sp_lpc, 0, 1, 1)) 169 if (!compute_lpc_coefs(temp, order, lpc, 0, 1, 1))
170 apply_window(ractx->sp_lpc, ractx->sp_lpc, syn_bw_tab, 36); 170 apply_window(lpc, lpc, tab, order);
171 171
172 do_hybrid_window(10, 8, 20, temp2, ractx->gain_hist, 172 memmove(hist, hist + n, move_size*sizeof(*hist));
173 ractx->gain_rec, gain_window);
174
175 if (!compute_lpc_coefs(temp2, 10, ractx->gain_lpc, 0, 1, 1))
176 apply_window(ractx->gain_lpc, ractx->gain_lpc, gain_bw_tab, 10);
177
178 memmove(ractx->gain_hist, ractx->gain_hist + 8,
179 28*sizeof(*ractx->gain_hist));
180
181 memmove(ractx->sp_hist , ractx->sp_hist + 40,
182 70*sizeof(*ractx->sp_hist ));
183 } 173 }
184 174
185 static int ra288_decode_frame(AVCodecContext * avctx, void *data, 175 static int ra288_decode_frame(AVCodecContext * avctx, void *data,
186 int *data_size, const uint8_t * buf, 176 int *data_size, const uint8_t * buf,
187 int buf_size) 177 int buf_size)
210 decode(ractx, gain, cb_coef); 200 decode(ractx, gain, cb_coef);
211 201
212 for (j=0; j < 5; j++) 202 for (j=0; j < 5; j++)
213 *(out++) = ractx->sp_hist[70 + 36 + j]; 203 *(out++) = ractx->sp_hist[70 + 36 + j];
214 204
215 if ((i & 7) == 3) 205 if ((i & 7) == 3) {
216 backward_filter(ractx); 206 backward_filter(ractx->sp_hist, ractx->sp_rec, syn_window,
207 ractx->sp_lpc, syn_bw_tab, 36, 40, 35, 70);
208
209 backward_filter(ractx->gain_hist, ractx->gain_rec, gain_window,
210 ractx->gain_lpc, gain_bw_tab, 10, 8, 20, 28);
211 }
217 } 212 }
218 213
219 *data_size = (char *)out - (char *)data; 214 *data_size = (char *)out - (char *)data;
220 return avctx->block_align; 215 return avctx->block_align;
221 } 216 }