[FFmpeg-devel] [RFC] simplify exp_table generation
Reimar Döffinger
Reimar.Doeffinger
Sat Nov 7 16:58:36 CET 2009
On Sat, Nov 07, 2009 at 02:32:30PM +0100, Michael Niedermayer wrote:
> On Fri, Nov 06, 2009 at 08:55:20PM +0100, Reimar D?ffinger wrote:
> > Hello,
> > following patch IMO makes it more obvious that exp_table is just a
> > partial copy of expval_table and avoids the duplicate llrintf.
>
> if you want to split that code out, i would say it could be split
> in 2 loops like
> for(512)
> for(16)
>
> this should be simpler than what you suggest
Alternative suggestion attached.
> > I think I also asked whether it is probably ok to replace the llrintf(f)
> > with f + 0.5, since llrintf is not available everywhere and the
> > libavutil/mathematics.h workaround is difficult to use for the case of
> > hardcoded tables + cross-compiling.
>
> my gut feeling says no, it will cause float exceptions on some platforms
> like the code that that we had prior to llrintf()
Ah, interesting, I thought that was only for speed reasons.
Anyone remember details (grepping svnlog was no help)?
-------------- next part --------------
Index: libavcodec/mpegaudio_tablegen.h
===================================================================
--- libavcodec/mpegaudio_tablegen.h (revision 20469)
+++ libavcodec/mpegaudio_tablegen.h (working copy)
@@ -41,6 +41,7 @@
static void mpegaudio_tableinit(void)
{
int i;
+ int exponent;
for(i=1;i<TABLE_4_3_SIZE;i++) {
double value = i/4;
double f, fm;
@@ -54,13 +55,15 @@
table_4_3_value[i] = m;
table_4_3_exp[i] = -e;
}
- for(i=0; i<512*16; i++){
- double value = i & 15;
- int exponent= (i>>4);
- double f= value * cbrtf(value) * pow(2, (exponent-400)*0.25 + FRAC_BITS + 5);
- expval_table[exponent][i&15]= llrint(f);
- if((i&15)==1)
- exp_table[exponent]= llrint(f);
+ for(exponent=0; exponent<512; exponent++){
+ int value;
+ double exp = pow(2, (exponent-400)*0.25 + FRAC_BITS + 5);
+ expval_table[exponent][0] = 0;
+ expval_table[exponent][1] = exp_table[exponent] = llrint(exp);
+ for (value = 2; value < 16; value++) {
+ double f= value * cbrtf(value) * exp;
+ expval_table[exponent][value]= llrint(f);
+ }
}
}
#endif /* CONFIG_HARDCODED_TABLES */
More information about the ffmpeg-devel
mailing list