Mercurial > libavcodec.hg
comparison aacpsy.c @ 12161:d34f0f3ac678 libavcodec
aacenc: aac_psy_init(): Factorize line_to_frequency.
author | alexc |
---|---|
date | Wed, 14 Jul 2010 04:10:47 +0000 |
parents | e0bed2f0f9f9 |
children | f948f8cf97db |
comparison
equal
deleted
inserted
replaced
12160:e0bed2f0f9f9 | 12161:d34f0f3ac678 |
---|---|
122 pctx = (Psy3gppContext*) ctx->model_priv_data; | 122 pctx = (Psy3gppContext*) ctx->model_priv_data; |
123 | 123 |
124 minath = ath(3410, ATH_ADD); | 124 minath = ath(3410, ATH_ADD); |
125 for (j = 0; j < 2; j++) { | 125 for (j = 0; j < 2; j++) { |
126 Psy3gppCoeffs *coeffs = &pctx->psy_coef[j]; | 126 Psy3gppCoeffs *coeffs = &pctx->psy_coef[j]; |
127 float line_to_frequency = ctx->avctx->sample_rate / 2048.0f; | |
127 i = 0; | 128 i = 0; |
128 prev = 0.0; | 129 prev = 0.0; |
129 for (g = 0; g < ctx->num_bands[j]; g++) { | 130 for (g = 0; g < ctx->num_bands[j]; g++) { |
130 i += ctx->bands[j][g]; | 131 i += ctx->bands[j][g]; |
131 bark = calc_bark((i-1) * ctx->avctx->sample_rate / 2048.0); | 132 bark = calc_bark((i-1) * line_to_frequency); |
132 coeffs->barks[g] = (bark + prev) / 2.0; | 133 coeffs->barks[g] = (bark + prev) / 2.0; |
133 prev = bark; | 134 prev = bark; |
134 } | 135 } |
135 for (g = 0; g < ctx->num_bands[j] - 1; g++) { | 136 for (g = 0; g < ctx->num_bands[j] - 1; g++) { |
136 coeffs->spread_low[g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_LOW); | 137 coeffs->spread_low[g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_LOW); |
137 coeffs->spread_hi [g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_HI); | 138 coeffs->spread_hi [g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_HI); |
138 } | 139 } |
139 start = 0; | 140 start = 0; |
140 for (g = 0; g < ctx->num_bands[j]; g++) { | 141 for (g = 0; g < ctx->num_bands[j]; g++) { |
141 minscale = ath(ctx->avctx->sample_rate * start / 1024.0 / 2.0, ATH_ADD); | 142 minscale = ath(start * line_to_frequency, ATH_ADD); |
142 for (i = 1; i < ctx->bands[j][g]; i++) | 143 for (i = 1; i < ctx->bands[j][g]; i++) |
143 minscale = FFMIN(minscale, ath(ctx->avctx->sample_rate * (start + i) / 1024.0 / 2.0, ATH_ADD)); | 144 minscale = FFMIN(minscale, ath((start + i) * line_to_frequency, ATH_ADD)); |
144 coeffs->ath[g] = minscale - minath; | 145 coeffs->ath[g] = minscale - minath; |
145 start += ctx->bands[j][g]; | 146 start += ctx->bands[j][g]; |
146 } | 147 } |
147 } | 148 } |
148 | 149 |