aboutsummaryrefslogtreecommitdiff
path: root/libavcodec/aacpsy.c
diff options
context:
space:
mode:
authorAlex Converse2010-07-14 04:10:31 +0000
committerAlex Converse2010-07-14 04:10:31 +0000
commit886385afd626c03099aa9ef7725d2a09c82aa196 (patch)
treeb250983e201a2677dcb6877437c5012c40b4d74c /libavcodec/aacpsy.c
parente3a28ea5a9268f70ccc0b3464b2acb1c3ee38e6f (diff)
aacenc: psy_3gpp_init(): Calculate barks on demand.
Originally committed as revision 24230 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/aacpsy.c')
-rw-r--r--libavcodec/aacpsy.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index 466b0e9a1a..7a2a37f4ae 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -114,15 +114,13 @@ static av_cold float ath(float f, float add)
static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
Psy3gppContext *pctx;
- float barks[1024];
+ float bark;
int i, j, g, start;
float prev, minscale, minath;
ctx->model_priv_data = av_mallocz(sizeof(Psy3gppContext));
pctx = (Psy3gppContext*) ctx->model_priv_data;
- for (i = 0; i < 1024; i++)
- barks[i] = calc_bark(i * ctx->avctx->sample_rate / 2048.0);
minath = ath(3410, ATH_ADD);
for (j = 0; j < 2; j++) {
Psy3gppCoeffs *coeffs = &pctx->psy_coef[j];
@@ -130,8 +128,9 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
prev = 0.0;
for (g = 0; g < ctx->num_bands[j]; g++) {
i += ctx->bands[j][g];
- coeffs->barks[g] = (barks[i - 1] + prev) / 2.0;
- prev = barks[i - 1];
+ bark = calc_bark((i-1) * ctx->avctx->sample_rate / 2048.0);
+ coeffs->barks[g] = (bark + prev) / 2.0;
+ prev = bark;
}
for (g = 0; g < ctx->num_bands[j] - 1; g++) {
coeffs->spread_low[g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_LOW);