[FFmpeg-devel] [PATCH] lavc/aacenc_quantization: use cbrt table

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Mar 11 09:05:11 CET 2016


On 11.03.2016, at 03:48, Ganesh Ajjanagadde <gajjanag at gmail.com> wrote:

> On Thu, Mar 10, 2016 at 3:12 AM, Reimar Döffinger
> <Reimar.Doeffinger at gmx.de> wrote:
>> On 10.03.2016, at 00:49, Ganesh Ajjanagadde <gajjanag at gmail.com> wrote:
>> 
>>> There is no reason for computing cbrtf at runtime; we have a table for
>>> this.
>>> 
>>> Cruft needed due to the build system, the people who still like using
>>> hardcoded tables and need for single cbrt_tab across the code.
>> 
>> Could you please explain what exactly the problem is?
>> Why would you need cbrt_table.c for example? You can just conditionally include it from cbrt_data.c for example.
>> Hardcoded tables are meant to only change when the initialization code is run, not where the resulting data is located, i.e. it should only ever replace a
>> int table[size];
>> by
>> const int table[size] = { data };
>> (though with the indirection of placing the second one in a header)
> 
> The data can't go into a header; else one gets multiple copies, see
> above. Please not that I may still be missing something; this
> hardcoded ifdefry and build system is something I am not that familiar
> with.

You just include the header in the C file (and only that one) where you want the data to be.
Obviously if you do not want multiple copies that will be some shared C file, not the encoder or decoder code directly.
But the same applies to the non-hardcoded tables, they also need a shared file or else you get two copies in the bss section.
I really don't see why the issue you describe should need anything other than replacing a
int ff_something[size];
by
#if hardcodec
#include "something_table.h"
#else
ff_something[size];
#endif

hardcoding should _never_ ever require changing the code structure or the .c files compiled in.
It should only consist of
1) generating a table header (can get a bit tricky admittedly, this should be the most difficult step)
2) including that header instead of the code otherwise creating the uninitialised table in .bss
3) disabling the code that initializes the table

Nothing magic beyond that.


More information about the ffmpeg-devel mailing list