[FFmpeg-cvslog] aacenc: Move Q^3/4 calculation to it's own table

Nathan Caldwell git at videolan.org
Tue Jan 24 03:04:45 CET 2012


ffmpeg | branch: master | Nathan Caldwell <saintdev at gmail.com> | Fri Jan  6 14:24:37 2012 -0700| [80d44277e6ae6291a1ddba476939bb394a2ed822] | committer: Alex Converse

aacenc: Move Q^3/4 calculation to it's own table

This should be moved to tablegen at some point.

Signed-off-by: Alex Converse <alex.converse at gmail.com>

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

 libavcodec/aaccoder.c |    7 ++++---
 libavcodec/aacenc.c   |    5 +++++
 libavcodec/aacenc.h   |    2 ++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index ec78acc..72be2a2 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -110,14 +110,15 @@ static av_always_inline float quantize_and_encode_band_cost_template(
                                 int *bits, int BT_ZERO, int BT_UNSIGNED,
                                 int BT_PAIR, int BT_ESC)
 {
-    const float IQ = ff_aac_pow2sf_tab[POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
-    const float  Q = ff_aac_pow2sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
+    const int q_idx = POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512;
+    const float Q   = ff_aac_pow2sf_tab [q_idx];
+    const float Q34 = ff_aac_pow34sf_tab[q_idx];
+    const float IQ  = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
     const float CLIPPED_ESCAPE = 165140.0f*IQ;
     int i, j;
     float cost = 0;
     const int dim = BT_PAIR ? 2 : 4;
     int resbits = 0;
-    const float  Q34 = sqrtf(Q * sqrtf(Q));
     const int range  = aac_cb_range[cb];
     const int maxval = aac_cb_maxval[cb];
     int off;
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 3bd04bf..8356ca8 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -52,6 +52,8 @@
         return AVERROR(EINVAL); \
     }
 
+float ff_aac_pow34sf_tab[428];
+
 static const uint8_t swb_size_1024_96[] = {
     4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8,
     12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44,
@@ -691,6 +693,9 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
 
     ff_aac_tableinit();
 
+    for (i = 0; i < 428; i++)
+        ff_aac_pow34sf_tab[i] = sqrt(ff_aac_pow2sf_tab[i] * sqrt(ff_aac_pow2sf_tab[i]));
+
     return 0;
 fail:
     aac_encode_end(avctx);
diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
index 1f5e650..79d542f 100644
--- a/libavcodec/aacenc.h
+++ b/libavcodec/aacenc.h
@@ -74,4 +74,6 @@ typedef struct AACEncContext {
     DECLARE_ALIGNED(32, float, scoefs)[1024];    ///< scaled coefficients
 } AACEncContext;
 
+extern float ff_aac_pow34sf_tab[428];
+
 #endif /* AVCODEC_AACENC_H */



More information about the ffmpeg-cvslog mailing list