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

Reimar Döffinger Reimar.Doeffinger
Tue Oct 13 12:24:58 CEST 2009


Hello,
at over 128kB this is one of the largest variables in .bss
Since it is in .bss I'm not 100% sure it is worth avoiding, though
it might help compiling on IA64 which currently can't handle .bss > 4 MB
with gcc at least.
Attached patch instead uses pow etc. if CONFIG_SMALL is set.
Which on the other hand might be really silly because the systems where
you'd use CONFIG_SMALL are those that are least likely to have a fast
pow implementation...
I also admit that the pow for the exponent could probably be trivially
replaced by shift and a 4-entry multiplication table for the lower bits.
-------------- next part --------------
Index: libavcodec/mpegaudiodec.c
===================================================================
--- libavcodec/mpegaudiodec.c	(revision 20222)
+++ 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 pow(value, 4.0 / 3.0) * pow(2, exponent*0.25) + 0.5;
+#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 f, fm;
             int e, m;
@@ -419,6 +426,7 @@
             table_4_3_value[i] = m;
             table_4_3_exp[i] = -e;
         }
+#endif
         for(i=0; i<512*16; i++){
             int exponent= (i>>4);
             double f= pow(i&15, 4.0 / 3.0) * pow(2, (exponent-400)*0.25 + FRAC_BITS + 5);



More information about the ffmpeg-devel mailing list