diff options
author | Rostislav Pehlivanov <atomnuker@gmail.com> | 2017-04-03 15:13:14 +0300 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2017-04-08 02:27:33 +0300 |
commit | 63744d8afd57851479ed2ff3e9a843c70d1b0031 (patch) | |
tree | 07901f905ff061a18f82cfc51d9681f719e87b43 /libavcodec/opusenc.c | |
parent | a66121d964558348ffcc2fb820853c9381a6a8d2 (diff) |
opusenc: remove unused header entries and simplify normalization
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/opusenc.c')
-rw-r--r-- | libavcodec/opusenc.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c index cecc8f22ab..a84e51fab3 100644 --- a/libavcodec/opusenc.c +++ b/libavcodec/opusenc.c @@ -255,24 +255,20 @@ static int celt_frame_map_norm_bands(OpusEncContext *s, CeltFrame *f) for (ch = 0; ch < f->channels; ch++) { CeltBlock *block = &f->block[ch]; - float *start = block->coeffs; for (i = 0; i < CELT_MAX_BANDS; i++) { float ener = 0.0f; + int band_offset = ff_celt_freq_bands[i] << f->size; + int band_size = ff_celt_freq_range[i] << f->size; + float *coeffs = &block->coeffs[band_offset]; - /* Calculate band bins */ - block->band_bins[i] = ff_celt_freq_range[i] << f->size; - block->band_coeffs[i] = start; - start += block->band_bins[i]; - - /* Normalize band energy */ - for (j = 0; j < block->band_bins[i]; j++) - ener += block->band_coeffs[i][j]*block->band_coeffs[i][j]; + for (j = 0; j < band_size; j++) + ener += coeffs[j]*coeffs[j]; block->lin_energy[i] = sqrtf(ener) + FLT_EPSILON; ener = 1.0f/block->lin_energy[i]; - for (j = 0; j < block->band_bins[i]; j++) - block->band_coeffs[i][j] *= ener; + for (j = 0; j < band_size; j++) + coeffs[j] *= ener; block->energy[i] = log2f(block->lin_energy[i]) - ff_celt_mean_energy[i]; |