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

Reimar Döffinger Reimar.Doeffinger
Thu Oct 22 09:04:08 CEST 2009


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.
Also just using printf does not work if you want the generated file not to
look like a complete mess.

> 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?
Forcing to have at most one table per header by design IMO would very strongly
discourage hardcoding-support for smaller tables which make up a large part
of the overall .bss size, too.
As for making it more generic, I already added a write_uint32_array,
You could then use "tableinit" instead of mpegaudio_tableinit and an
int tablecount;
and
struct tabledesc tables[];
that can be used for the printing.
However I do think this kind of thing would be easier if was clear what
kind of things are actually needed.



More information about the ffmpeg-devel mailing list