[FFmpeg-cvslog] opusenc: remove unused header entries and simplify normalization

Rostislav Pehlivanov git at videolan.org
Sat Apr 8 02:57:25 EEST 2017


ffmpeg | branch: master | Rostislav Pehlivanov <atomnuker at gmail.com> | Mon Apr  3 13:13:14 2017 +0100| [63744d8afd57851479ed2ff3e9a843c70d1b0031] | committer: Rostislav Pehlivanov

opusenc: remove unused header entries and simplify normalization

Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=63744d8afd57851479ed2ff3e9a843c70d1b0031
---

 libavcodec/opus_celt.h |  3 ---
 libavcodec/opusenc.c   | 18 +++++++-----------
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/libavcodec/opus_celt.h b/libavcodec/opus_celt.h
index 23c2089..1ed57f3 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 cecc8f2..a84e51f 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];
 



More information about the ffmpeg-cvslog mailing list