comparison aacpsy.c @ 9937:3e39dbd2d9eb libavcodec

cosmetics: prettyprinting, K&R style, break overly long lines
author diego
date Wed, 08 Jul 2009 21:16:06 +0000
parents 7f42ae22c351
children 6c1ac45b3097
comparison
equal deleted inserted replaced
9936:7f42ae22c351 9937:3e39dbd2d9eb
104 * Borrowed from Lame. 104 * Borrowed from Lame.
105 */ 105 */
106 static av_cold float ath(float f, float add) 106 static av_cold float ath(float f, float add)
107 { 107 {
108 f /= 1000.0f; 108 f /= 1000.0f;
109 return 3.64 * pow(f, -0.8) 109 return 3.64 * pow(f, -0.8)
110 - 6.8 * exp(-0.6 * (f - 3.4) * (f - 3.4)) 110 - 6.8 * exp(-0.6 * (f - 3.4) * (f - 3.4))
111 + 6.0 * exp(-0.15 * (f - 8.7) * (f - 8.7)) 111 + 6.0 * exp(-0.15 * (f - 8.7) * (f - 8.7))
112 + (0.6 + 0.04 * add) * 0.001 * f * f * f * f; 112 + (0.6 + 0.04 * add) * 0.001 * f * f * f * f;
113 } 113 }
114 114
179 static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx, 179 static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
180 const int16_t *audio, const int16_t *la, 180 const int16_t *audio, const int16_t *la,
181 int channel, int prev_type) 181 int channel, int prev_type)
182 { 182 {
183 int i, j; 183 int i, j;
184 int br = ctx->avctx->bit_rate / ctx->avctx->channels; 184 int br = ctx->avctx->bit_rate / ctx->avctx->channels;
185 int attack_ratio = br <= 16000 ? 18 : 10; 185 int attack_ratio = br <= 16000 ? 18 : 10;
186 Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data; 186 Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data;
187 Psy3gppChannel *pch = &pctx->ch[channel]; 187 Psy3gppChannel *pch = &pctx->ch[channel];
188 uint8_t grouping = 0; 188 uint8_t grouping = 0;
189 FFPsyWindowInfo wi; 189 FFPsyWindowInfo wi;
190 190
191 memset(&wi, 0, sizeof(wi)); 191 memset(&wi, 0, sizeof(wi));
192 if (la) { 192 if (la) {
193 float s[8], v; 193 float s[8], v;
197 for (i = 0; i < 8; i++) { 197 for (i = 0; i < 8; i++) {
198 for (j = 0; j < 128; j++) { 198 for (j = 0; j < 128; j++) {
199 v = iir_filter(audio[(i*128+j)*ctx->avctx->channels], pch->iir_state); 199 v = iir_filter(audio[(i*128+j)*ctx->avctx->channels], pch->iir_state);
200 sum += v*v; 200 sum += v*v;
201 } 201 }
202 s[i] = sum; 202 s[i] = sum;
203 sum2 += sum; 203 sum2 += sum;
204 } 204 }
205 for (i = 0; i < 8; i++) { 205 for (i = 0; i < 8; i++) {
206 if (s[i] > pch->win_energy * attack_ratio) { 206 if (s[i] > pch->win_energy * attack_ratio) {
207 attack_n = i + 1; 207 attack_n = i + 1;
208 switch_to_eight = 1; 208 switch_to_eight = 1;
209 break; 209 break;
210 } 210 }
211 } 211 }
212 pch->win_energy = pch->win_energy*7/8 + sum2/64; 212 pch->win_energy = pch->win_energy*7/8 + sum2/64;
253 } 253 }
254 254
255 /** 255 /**
256 * Calculate band thresholds as suggested in 3GPP TS26.403 256 * Calculate band thresholds as suggested in 3GPP TS26.403
257 */ 257 */
258 static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, const float *coefs, 258 static void psy_3gpp_analyze(FFPsyContext *ctx, int channel,
259 FFPsyWindowInfo *wi) 259 const float *coefs, FFPsyWindowInfo *wi)
260 { 260 {
261 Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data; 261 Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data;
262 Psy3gppChannel *pch = &pctx->ch[channel]; 262 Psy3gppChannel *pch = &pctx->ch[channel];
263 int start = 0; 263 int start = 0;
264 int i, w, g; 264 int i, w, g;
265 const int num_bands = ctx->num_bands[wi->num_windows == 8]; 265 const int num_bands = ctx->num_bands[wi->num_windows == 8];
266 const uint8_t* band_sizes = ctx->bands[wi->num_windows == 8]; 266 const uint8_t* band_sizes = ctx->bands[wi->num_windows == 8];
267 Psy3gppCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8]; 267 Psy3gppCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8];
268 268
269 //calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation" 269 //calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation"
270 for (w = 0; w < wi->num_windows*16; w += 16) { 270 for (w = 0; w < wi->num_windows*16; w += 16) {
271 for (g = 0; g < num_bands; g++) { 271 for (g = 0; g < num_bands; g++) {
272 Psy3gppBand *band = &pch->band[w+g]; 272 Psy3gppBand *band = &pch->band[w+g];
273 band->energy = 0.0f; 273 band->energy = 0.0f;
274 for (i = 0; i < band_sizes[g]; i++) 274 for (i = 0; i < band_sizes[g]; i++)
275 band->energy += coefs[start+i] * coefs[start+i]; 275 band->energy += coefs[start+i] * coefs[start+i];
276 band->energy *= 1.0f / (512*512); 276 band->energy *= 1.0f / (512*512);
277 band->thr = band->energy * 0.001258925f; 277 band->thr = band->energy * 0.001258925f;
278 start += band_sizes[g]; 278 start += band_sizes[g];
279 279
280 ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].energy = band->energy; 280 ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].energy = band->energy;
281 } 281 }
282 } 282 }
283 //modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation" 283 //modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation"