Mercurial > libavcodec.hg
comparison aacdec.c @ 12259:97db3c60fb9c libavcodec
aacdec: 4% faster main profile decoding.
author | alexc |
---|---|
date | Sat, 24 Jul 2010 02:41:47 +0000 |
parents | 7f8b11d9c831 |
children | 65619c2230e7 |
comparison
equal
deleted
inserted
replaced
12258:86d6c00756cc | 12259:97db3c60fb9c |
---|---|
1229 pun.f = pf; | 1229 pun.f = pf; |
1230 pun.i &= 0xFFFF0000U; | 1230 pun.i &= 0xFFFF0000U; |
1231 return pun.f; | 1231 return pun.f; |
1232 } | 1232 } |
1233 | 1233 |
1234 static av_always_inline void predict(AACContext *ac, PredictorState *ps, float *coef, | 1234 static av_always_inline void predict(PredictorState *ps, float *coef, |
1235 float sf_scale, float inv_sf_scale, | |
1235 int output_enable) | 1236 int output_enable) |
1236 { | 1237 { |
1237 const float a = 0.953125; // 61.0 / 64 | 1238 const float a = 0.953125; // 61.0 / 64 |
1238 const float alpha = 0.90625; // 29.0 / 32 | 1239 const float alpha = 0.90625; // 29.0 / 32 |
1239 float e0, e1; | 1240 float e0, e1; |
1243 k1 = ps->var0 > 1 ? ps->cor0 * flt16_even(a / ps->var0) : 0; | 1244 k1 = ps->var0 > 1 ? ps->cor0 * flt16_even(a / ps->var0) : 0; |
1244 k2 = ps->var1 > 1 ? ps->cor1 * flt16_even(a / ps->var1) : 0; | 1245 k2 = ps->var1 > 1 ? ps->cor1 * flt16_even(a / ps->var1) : 0; |
1245 | 1246 |
1246 pv = flt16_round(k1 * ps->r0 + k2 * ps->r1); | 1247 pv = flt16_round(k1 * ps->r0 + k2 * ps->r1); |
1247 if (output_enable) | 1248 if (output_enable) |
1248 *coef += pv * ac->sf_scale; | 1249 *coef += pv * sf_scale; |
1249 | 1250 |
1250 e0 = *coef / ac->sf_scale; | 1251 e0 = *coef * inv_sf_scale; |
1251 e1 = e0 - k1 * ps->r0; | 1252 e1 = e0 - k1 * ps->r0; |
1252 | 1253 |
1253 ps->cor1 = flt16_trunc(alpha * ps->cor1 + ps->r1 * e1); | 1254 ps->cor1 = flt16_trunc(alpha * ps->cor1 + ps->r1 * e1); |
1254 ps->var1 = flt16_trunc(alpha * ps->var1 + 0.5f * (ps->r1 * ps->r1 + e1 * e1)); | 1255 ps->var1 = flt16_trunc(alpha * ps->var1 + 0.5f * (ps->r1 * ps->r1 + e1 * e1)); |
1255 ps->cor0 = flt16_trunc(alpha * ps->cor0 + ps->r0 * e0); | 1256 ps->cor0 = flt16_trunc(alpha * ps->cor0 + ps->r0 * e0); |
1263 * Apply AAC-Main style frequency domain prediction. | 1264 * Apply AAC-Main style frequency domain prediction. |
1264 */ | 1265 */ |
1265 static void apply_prediction(AACContext *ac, SingleChannelElement *sce) | 1266 static void apply_prediction(AACContext *ac, SingleChannelElement *sce) |
1266 { | 1267 { |
1267 int sfb, k; | 1268 int sfb, k; |
1269 float sf_scale = ac->sf_scale, inv_sf_scale = 1 / ac->sf_scale; | |
1268 | 1270 |
1269 if (!sce->ics.predictor_initialized) { | 1271 if (!sce->ics.predictor_initialized) { |
1270 reset_all_predictors(sce->predictor_state); | 1272 reset_all_predictors(sce->predictor_state); |
1271 sce->ics.predictor_initialized = 1; | 1273 sce->ics.predictor_initialized = 1; |
1272 } | 1274 } |
1273 | 1275 |
1274 if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { | 1276 if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { |
1275 for (sfb = 0; sfb < ff_aac_pred_sfb_max[ac->m4ac.sampling_index]; sfb++) { | 1277 for (sfb = 0; sfb < ff_aac_pred_sfb_max[ac->m4ac.sampling_index]; sfb++) { |
1276 for (k = sce->ics.swb_offset[sfb]; k < sce->ics.swb_offset[sfb + 1]; k++) { | 1278 for (k = sce->ics.swb_offset[sfb]; k < sce->ics.swb_offset[sfb + 1]; k++) { |
1277 predict(ac, &sce->predictor_state[k], &sce->coeffs[k], | 1279 predict(&sce->predictor_state[k], &sce->coeffs[k], |
1280 sf_scale, inv_sf_scale, | |
1278 sce->ics.predictor_present && sce->ics.prediction_used[sfb]); | 1281 sce->ics.predictor_present && sce->ics.prediction_used[sfb]); |
1279 } | 1282 } |
1280 } | 1283 } |
1281 if (sce->ics.predictor_reset_group) | 1284 if (sce->ics.predictor_reset_group) |
1282 reset_predictor_group(sce->predictor_state, sce->ics.predictor_reset_group); | 1285 reset_predictor_group(sce->predictor_state, sce->ics.predictor_reset_group); |