[FFmpeg-devel] [PATCH 08/12] WMA: use a table instead of pow() in decode_exp_vlc

Mans Rullgard mans
Sun Sep 27 12:49:24 CEST 2009


FIXME: is the table big enough
---
 libavcodec/wmadec.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index 52ea7a3..8bd8982 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -243,6 +243,25 @@ static void decode_exp_lsp(WMACodecContext *s, int ch)
                      s->block_len, lsp_coefs);
 }
 
+static const float pow_tab[64] = {
+       1.00000000,    1.15478198,    1.33352143,    1.53992653,
+       1.77827941,    2.05352503,    2.37137371,    2.73841963,
+       3.16227766,    3.65174127,    4.21696503,    4.86967525,
+       5.62341325,    6.49381632,    7.49894209,    8.65964323,
+      10.00000000,   11.54781985,   13.33521432,   15.39926526,
+      17.78279410,   20.53525026,   23.71373706,   27.38419634,
+      31.62277660,   36.51741273,   42.16965034,   48.69675252,
+      56.23413252,   64.93816316,   74.98942093,   86.59643234,
+     100.00000000,  115.47819847,  133.35214322,  153.99265261,
+     177.82794100,  205.35250265,  237.13737057,  273.84196343,
+     316.22776602,  365.17412725,  421.69650343,  486.96752517,
+     562.34132519,  649.38163158,  749.89420933,  865.96432336,
+    1000.00000000, 1154.78198469, 1333.52143216, 1539.92652606,
+    1778.27941004, 2053.52502646, 2371.37370566, 2738.41963426,
+    3162.27766017, 3651.74127255, 4216.96503429, 4869.67525166,
+    5623.41325190, 6493.81631576, 7498.94209332, 8659.64323360,
+};
+
 /**
  * decode exponents coded with VLC codes
  */
@@ -258,8 +277,7 @@ static int decode_exp_vlc(WMACodecContext *s, int ch)
     max_scale = 0;
     if (s->version == 1) {
         last_exp = get_bits(&s->gb, 5) + 10;
-        /* XXX: use a table */
-        v = pow(10, last_exp * (1.0 / 16.0));
+        v = pow_tab[last_exp];
         max_scale = v;
         n = *ptr++;
         s->dsp.fill_float(q, v, n);
@@ -273,9 +291,7 @@ static int decode_exp_vlc(WMACodecContext *s, int ch)
             return -1;
         /* NOTE: this offset is the same as MPEG4 AAC ! */
         last_exp += code - 60;
-        /* XXX: use a table */
-        av_log(NULL, AV_LOG_ERROR, "exp= %d\n", last_exp);
-        v = pow(10, last_exp * (1.0 / 16.0));
+        v = pow_tab[last_exp];
         if (v > max_scale)
             max_scale = v;
         n = *ptr++;
-- 
1.6.4.4




More information about the ffmpeg-devel mailing list