[FFmpeg-devel] [PATCH] support for hardcoded mpegaudiodec tables

Michael Niedermayer michaelni
Thu Oct 22 20:58:32 CEST 2009


On Thu, Oct 22, 2009 at 09:04:08AM +0200, Reimar D?ffinger wrote:
> On Wed, Oct 21, 2009 at 09:44:54PM +0200, Michael Niedermayer wrote:
> > On Wed, Oct 21, 2009 at 08:34:07PM +0200, Reimar D?ffinger wrote:
> > > if it's supposed to be switched by linking using a .h file is not possible.
> > 
> > > Furthermore if those tables are supposed to be compiled and linked separately
> > > that means it will be impossible to hardcode static tables, and it also
> > > means that renaming them to ff_ is a must to hardcode them.
> > 
> > one could use
> > init_mp3_table_foo(uint32_t *table)
> > and pass a static table as argument ...
> 
> I was talking about the files containing the tables themselves, you can't
> have them static and in a separate .c file.
> Also your suggestions means duplicating the static table declaration in
> the main file and the table generator.
> 
> > > and worse we can not use config.h for the host-compiled stuff.
> > > I attached a maybe better patch, but I'll surely be flamed for that as
> > > well because it breaks "make checkheaders" but I don't see a way to avoid
> > > that.
> > 
> > To be honest, i would prefer a more generic solution, not one where every
> > 2nd line in every file depends on a specific array name.
> > 
> > if we take the header with the table generator in it as you suggest but
> > instead of doing
> > array[i]= v;
> > do
> > SET(array, i, v);
> > 
> > then in the hardcoded table generator SET could be a printf() while in
> > mpegaudiodec.c it could be array[i]= v;
> 
> No, that isn't possible, unless you suggest to duplicate the whole loop
> and calculation just to first calculate the values and then the exponents.

you turn every tiny problem into a mountain

        int table_4_3_exp[123];

        PRINT_HARDCODED_PREFIX("static const table_4_3_value[123]={");
        for(i=1;i<TABLE_4_3_SIZE;i++) {
            double f, fm;
            int e, m;
            f = pow((double)(i/4), 4.0 / 3.0) * pow(2, (i&3)*0.25);
            fm = frexp(f, &e);
            m = (uint32_t)(fm*(1LL<<31) + 0.5);
            e+= FRAC_BITS - 31 + 5 - 100;

            /* normalized to FRAC_BITS */
            SET(table_4_3_value, i, m);
            table_4_3_exp[i] = -e;
        }

        PRINT_HARDCODED_PREFIX("static const table_4_3_exp[123]={");
        for(i=1;i<TABLE_4_3_SIZE;i++)
            SET(table_4_3_exp, i, table_4_3_exp[i]);

above is one way, likely not the only ...


> Also just using printf does not work if you want the generated file not to
> look like a complete mess.

IMHO the generated file is not for human consumtion, its just an
intermediate to get the table into the object file
but nothing stops one to do a
if(++x % 8 ==0) printf("\n");
as well


> 
> > in addition to that a
> > PRINT_HARDCODED_REFIX("static const blah[123]={");
> > could be in the header 
> 
> How should that work with more than one table per header?

i really dont see the problem, all these just turn into printfs
printf for the
static const blah[123]={
then the actual values
and then the 
};

wheres the problem with multiple tables?


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091022/ae726750/attachment.pgp>



More information about the ffmpeg-devel mailing list