diff options
author | Rostislav Pehlivanov <atomnuker@gmail.com> | 2017-04-03 13:13:14 +0100 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2017-04-08 00:27:33 +0100 |
commit | 63744d8afd57851479ed2ff3e9a843c70d1b0031 (patch) | |
tree | 07901f905ff061a18f82cfc51d9681f719e87b43 | |
parent | a66121d964558348ffcc2fb820853c9381a6a8d2 (diff) | |
download | ffmpeg-63744d8afd57851479ed2ff3e9a843c70d1b0031.tar.gz |
opusenc: remove unused header entries and simplify normalization
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
-rw-r--r-- | libavcodec/opus_celt.h | 3 | ||||
-rw-r--r-- | libavcodec/opusenc.c | 18 |
2 files changed, 7 insertions, 14 deletions
diff --git a/libavcodec/opus_celt.h b/libavcodec/opus_celt.h index 23c20891cd..1ed57f3651 100644 --- a/libavcodec/opus_celt.h +++ b/libavcodec/opus_celt.h @@ -67,9 +67,6 @@ typedef struct CeltBlock { uint8_t collapse_masks[CELT_MAX_BANDS]; - int band_bins[CELT_MAX_BANDS]; /* MDCT bins per band */ - float *band_coeffs[CELT_MAX_BANDS]; - /* buffer for mdct output + postfilter */ DECLARE_ALIGNED(32, float, buf)[2048]; DECLARE_ALIGNED(32, float, coeffs)[CELT_MAX_FRAME_SIZE]; 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]; |