Mercurial > libavcodec.hg
comparison ra288.c @ 7438:d9d070ff46bf libavcodec
Rename two context vars: s/sb/sp_block/, s/lhist/gain_block/
author | vitor |
---|---|
date | Mon, 28 Jul 2008 04:53:05 +0000 |
parents | d36ec42eef9c |
children | deea146537af |
comparison
equal
deleted
inserted
replaced
7437:d36ec42eef9c | 7438:d9d070ff46bf |
---|---|
37 float gain_hist[38]; ///< Log-gain history (spec: SBLG) | 37 float gain_hist[38]; ///< Log-gain history (spec: SBLG) |
38 | 38 |
39 /** Recursive part of the gain autocorrelation (spec: REXPLG) */ | 39 /** Recursive part of the gain autocorrelation (spec: REXPLG) */ |
40 float gain_rec[11]; | 40 float gain_rec[11]; |
41 | 41 |
42 float sb[41]; | 42 float sp_block[41]; ///< Speech data of four blocks (spec: STTMP) |
43 float lhist[10]; | 43 float gain_block[10]; ///< Gain data of four blocks (spec: GSTATE) |
44 } RA288Context; | 44 } RA288Context; |
45 | 45 |
46 static inline float scalar_product_float(const float * v1, const float * v2, | 46 static inline float scalar_product_float(const float * v1, const float * v2, |
47 int size) | 47 int size) |
48 { | 48 { |
64 { | 64 { |
65 int x, y; | 65 int x, y; |
66 double sumsum; | 66 double sumsum; |
67 float sum, buffer[5]; | 67 float sum, buffer[5]; |
68 | 68 |
69 memmove(ractx->sb + 5, ractx->sb, 36 * sizeof(*ractx->sb)); | 69 memmove(ractx->sp_block + 5, ractx->sp_block, 36*sizeof(*ractx->sp_block)); |
70 | 70 |
71 for (x=4; x >= 0; x--) | 71 for (x=4; x >= 0; x--) |
72 ractx->sb[x] = -scalar_product_float(ractx->sb + x + 1, | 72 ractx->sp_block[x] = -scalar_product_float(ractx->sp_block + x + 1, |
73 ractx->sp_lpc, 36); | 73 ractx->sp_lpc, 36); |
74 | 74 |
75 /* block 46 of G.728 spec */ | 75 /* block 46 of G.728 spec */ |
76 sum = 32. - scalar_product_float(ractx->gain_lpc, ractx->lhist, 10); | 76 sum = 32. - scalar_product_float(ractx->gain_lpc, ractx->gain_block, 10); |
77 | 77 |
78 /* block 47 of G.728 spec */ | 78 /* block 47 of G.728 spec */ |
79 sum = av_clipf(sum, 0, 60); | 79 sum = av_clipf(sum, 0, 60); |
80 | 80 |
81 /* block 48 of G.728 spec */ | 81 /* block 48 of G.728 spec */ |
87 sum = scalar_product_float(buffer, buffer, 5) / 5; | 87 sum = scalar_product_float(buffer, buffer, 5) / 5; |
88 | 88 |
89 sum = FFMAX(sum, 1); | 89 sum = FFMAX(sum, 1); |
90 | 90 |
91 /* shift and store */ | 91 /* shift and store */ |
92 memmove(ractx->lhist, ractx->lhist - 1, 10 * sizeof(*ractx->lhist)); | 92 memmove(ractx->gain_block, ractx->gain_block - 1, |
93 | 93 10 * sizeof(*ractx->gain_block)); |
94 *ractx->lhist = 10 * log10(sum) - 32; | 94 |
95 *ractx->gain_block = 10 * log10(sum) - 32; | |
95 | 96 |
96 for (x=1; x < 5; x++) | 97 for (x=1; x < 5; x++) |
97 for (y=x-1; y >= 0; y--) | 98 for (y=x-1; y >= 0; y--) |
98 buffer[x] -= ractx->sp_lpc[x-y-1] * buffer[y]; | 99 buffer[x] -= ractx->sp_lpc[x-y-1] * buffer[y]; |
99 | 100 |
100 /* output */ | 101 /* output */ |
101 for (x=0; x < 5; x++) | 102 for (x=0; x < 5; x++) |
102 ractx->sb[4-x] = av_clipf(ractx->sb[4-x] + buffer[x], -4095, 4095); | 103 ractx->sp_block[4-x] = |
104 av_clipf(ractx->sp_block[4-x] + buffer[x], -4095, 4095); | |
103 } | 105 } |
104 | 106 |
105 /** | 107 /** |
106 * Converts autocorrelation coefficients to LPC coefficients using the | 108 * Converts autocorrelation coefficients to LPC coefficients using the |
107 * Levinson-Durbin algorithm. See blocks 37 and 50 of the G.728 specification. | 109 * Levinson-Durbin algorithm. See blocks 37 and 50 of the G.728 specification. |
201 static void backward_filter(RA288Context *ractx) | 203 static void backward_filter(RA288Context *ractx) |
202 { | 204 { |
203 float temp1[37]; // RTMP in the spec | 205 float temp1[37]; // RTMP in the spec |
204 float temp2[11]; // GPTPMP in the spec | 206 float temp2[11]; // GPTPMP in the spec |
205 | 207 |
206 do_hybrid_window(36, 40, 35, ractx->sb, temp1, ractx->sp_hist, | 208 do_hybrid_window(36, 40, 35, ractx->sp_block, temp1, ractx->sp_hist, |
207 ractx->sp_rec, syn_window); | 209 ractx->sp_rec, syn_window); |
208 | 210 |
209 if (!eval_lpc_coeffs(temp1, ractx->sp_lpc, 36)) | 211 if (!eval_lpc_coeffs(temp1, ractx->sp_lpc, 36)) |
210 colmult(ractx->sp_lpc, ractx->sp_lpc, syn_bw_tab, 36); | 212 colmult(ractx->sp_lpc, ractx->sp_lpc, syn_bw_tab, 36); |
211 | 213 |
212 do_hybrid_window(10, 8, 20, ractx->lhist, temp2, ractx->gain_hist, | 214 do_hybrid_window(10, 8, 20, ractx->gain_block, temp2, ractx->gain_hist, |
213 ractx->gain_rec, gain_window); | 215 ractx->gain_rec, gain_window); |
214 | 216 |
215 if (!eval_lpc_coeffs(temp2, ractx->gain_lpc, 10)) | 217 if (!eval_lpc_coeffs(temp2, ractx->gain_lpc, 10)) |
216 colmult(ractx->gain_lpc, ractx->gain_lpc, gain_bw_tab, 10); | 218 colmult(ractx->gain_lpc, ractx->gain_lpc, gain_bw_tab, 10); |
217 } | 219 } |
239 int cb_coef = get_bits(&gb, 6 + (x&1)); | 241 int cb_coef = get_bits(&gb, 6 + (x&1)); |
240 ractx->phase = (x + 4) & 7; | 242 ractx->phase = (x + 4) & 7; |
241 decode(ractx, gain, cb_coef); | 243 decode(ractx, gain, cb_coef); |
242 | 244 |
243 for (y=0; y < 5; y++) | 245 for (y=0; y < 5; y++) |
244 *(out++) = 8 * ractx->sb[4 - y]; | 246 *(out++) = 8 * ractx->sp_block[4 - y]; |
245 | 247 |
246 if (ractx->phase == 7) | 248 if (ractx->phase == 7) |
247 backward_filter(ractx); | 249 backward_filter(ractx); |
248 } | 250 } |
249 | 251 |