---
 libavcodec/aac_tablegen.c      |    3 +++
 libavcodec/aac_tablegen.h      |    9 ++++++++-
 libavcodec/aac_tablegen_decl.h |    6 ++++++
 libavcodec/aaccoder.c          |    7 ++++---
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/libavcodec/aac_tablegen.c b/libavcodec/aac_tablegen.c
index b2c6c95..a1b6864 100644
--- a/libavcodec/aac_tablegen.c
+++ b/libavcodec/aac_tablegen.c
@@ -32,6 +32,9 @@ int main(void)
     write_fileheader();
 
     WRITE_ARRAY("const", float, ff_aac_pow2sf_tab);
+#if CONFIG_AAC_ENCODER
+    WRITE_ARRAY("const", float, ff_aac_pow34sf_tab);
+#endif /* CONFIG_AAC_ENCODER */
 
     return 0;
 }
diff --git a/libavcodec/aac_tablegen.h b/libavcodec/aac_tablegen.h
index 8773d9b..15e13fd 100644
--- a/libavcodec/aac_tablegen.h
+++ b/libavcodec/aac_tablegen.h
@@ -31,12 +31,19 @@
 #include "libavutil/mathematics.h"
 #include "aac.h"
 float ff_aac_pow2sf_tab[428];
+#if CONFIG_AAC_ENCODER
+float ff_aac_pow34sf_tab[428];
+#endif /* CONFIG_AAC_ENCODER */
 
 void ff_aac_tableinit(void)
 {
     int i;
-    for (i = 0; i < 428; i++)
+    for (i = 0; i < 428; i++) {
         ff_aac_pow2sf_tab[i] = pow(2, (i - POW_SF2_ZERO) / 4.);
+#if CONFIG_AAC_ENCODER
+        ff_aac_pow34sf_tab[i] = sqrt(ff_aac_pow2sf_tab[i] * 
sqrt(ff_aac_pow2sf_tab[i]));
+#endif /* CONFIG_AAC_ENCODER */
+    }
 }
 #endif /* CONFIG_HARDCODED_TABLES */
 
diff --git a/libavcodec/aac_tablegen_decl.h b/libavcodec/aac_tablegen_decl.h
index 496ca0c..d0cdadf 100644
--- a/libavcodec/aac_tablegen_decl.h
+++ b/libavcodec/aac_tablegen_decl.h
@@ -26,9 +26,15 @@
 #if CONFIG_HARDCODED_TABLES
 #define ff_aac_tableinit()
 extern const float ff_aac_pow2sf_tab[428];
+#if CONFIG_AAC_ENCODER
+extern const float ff_aac_pow34sf_tab[428];
+#endif /* CONFIG_AAC_ENCODER */
 #else
 void ff_aac_tableinit(void);
 extern       float ff_aac_pow2sf_tab[428];
+#if CONFIG_AAC_ENCODER
+extern       float ff_aac_pow34sf_tab[428];
+#endif /* CONFIG_AAC_ENCODER */
 #endif /* CONFIG_HARDCODED_TABLES */
 
 #endif /* AVCODEC_AAC_TABLEGEN_DECL_H */
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;
-- 
1.7.5.4

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to