[FFmpeg-devel] [RFC] remove table_4_3_value with CONFIG_SMALL
Reimar Döffinger
Reimar.Doeffinger
Tue Oct 13 13:53:06 CEST 2009
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.
-------------- 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 value * cbrtf(value) * exp2f(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,10 +413,12 @@
/* 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;
int e, m;
- f = pow((double)(i/4), 4.0 / 3.0) * pow(2, (i&3)*0.25);
+ f = value * cbrtf(value) * exp2f((i&3)*0.25);
fm = frexp(f, &e);
m = (uint32_t)(fm*(1LL<<31) + 0.5);
e+= FRAC_BITS - 31 + 5 - 100;
@@ -419,9 +427,11 @@
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);
- double f= pow(i&15, 4.0 / 3.0) * pow(2, (exponent-400)*0.25 + FRAC_BITS + 5);
+ double f= value * cbrtf(value) * exp2f((exponent-400)*0.25 + FRAC_BITS + 5);
expval_table[exponent][i&15]= llrint(f);
if((i&15)==1)
exp_table[exponent]= llrint(f);
More information about the ffmpeg-devel
mailing list