[FFmpeg-devel] [RFC] remove table_4_3_value with CONFIG_SMALL

Reimar Döffinger Reimar.Doeffinger
Thu Oct 15 09:29:39 CEST 2009


On Tue, Oct 13, 2009 at 01:53:06PM +0200, Reimar D?ffinger wrote:
> On Tue, Oct 13, 2009 at 01:18:02PM +0200, Michael Niedermayer wrote:
> > > Either way, should the code that generates the tables be updated to use
> > > the same formula?
> > 
> > as you prefer ...
> 
> Ok, I propose then this patch, to be applied in two parts.
> It generally replaces "pow(2," by "exp2f(" and "pow(.., 4.0/3.0)" by
> ".. * cbrtf(..)".
> make test passes on x86_64 at least, with and without --enable-small.

Hm... It didn't play any files right though, attached version plays the
files ok, though the CRC is not the same with and without
--enable-small.
Speed is probably about 4 times slower, though on a regular desktop
system the overall speed difference for mp3 decoding is not measurable
(the usual caveat about benchmarks by me apply).
-------------- next part --------------
Index: libavcodec/mpegaudiodec.c
===================================================================
--- libavcodec/mpegaudiodec.c	(revision 20233)
+++ libavcodec/mpegaudiodec.c	(working copy)
@@ -92,10 +92,12 @@
 };
 /* computed from band_size_long */
 static uint16_t band_index_long[9][23];
+#if !CONFIG_SMALL
 /* XXX: free when all decoders are closed */
 #define TABLE_4_3_SIZE (8191 + 16)*4
 static int8_t  table_4_3_exp[TABLE_4_3_SIZE];
 static uint32_t table_4_3_value[TABLE_4_3_SIZE];
+#endif
 static uint32_t exp_table[512];
 static uint32_t expval_table[512][16];
 /* intensity stereo coef table */
@@ -218,6 +220,9 @@
 /* compute value^(4/3) * 2^(exponent/4). It normalized to FRAC_BITS */
 static inline int l3_unscale(int value, int exponent)
 {
+#if CONFIG_SMALL
+    return value * cbrtf(value) * exp2f(exponent*0.25 + FRAC_BITS + 5 - 100);
+#else
     unsigned int m;
     int e;
 
@@ -230,6 +235,7 @@
     m = (m + (1 << (e-1))) >> e;
 
     return m;
+#endif
 }
 
 /* all integer n^(4/3) computation code */
@@ -407,6 +413,7 @@
         /* compute n ^ (4/3) and store it in mantissa/exp format */
 
         int_pow_init();
+#if !CONFIG_SMALL
         for(i=1;i<TABLE_4_3_SIZE;i++) {
             double value = i/4;
             double f, fm;
@@ -420,6 +427,7 @@
             table_4_3_value[i] = m;
             table_4_3_exp[i] = -e;
         }
+#endif
         for(i=0; i<512*16; i++){
             double value = i & 15;
             int exponent= (i>>4);



More information about the ffmpeg-devel mailing list