[FFmpeg-devel] [PATCH] reduce global data in lavc

Stefan Gehrer stefan.gehrer
Tue Jun 24 22:38:36 CEST 2008

Michael Niedermayer wrote:
> On Tue, Jun 24, 2008 at 08:27:50PM +0200, Stefan Gehrer wrote:
>> Hi,
>> attached patch marks tables as const if they are. It contains
>> changes which I think are obvious like e.g.
>> -static uint8_t last_coeff[3] = {
>> +static const uint8_t last_coeff[3] = {
>> but some which change tables of pointers to declare that
>> the pointed to value also is constant, e.g.
>> -static const int16_t *coeff_tables[32] = {
>> +static const int16_t *const coeff_tables[32] = {
>> I found that only if the pointers and the places
>> they point to are declared as const will the table
>> be placed into the .rodata section instead of the
>> .data section, tested with gcc 4.3.2.
>> Is such a change desired?
> yes
>> After this patch, there are still global variables around
>> which I would categorize as the following:
>> 1. run-length tables that I think can be avoided by using
>>   INIT_VLC_STATIC, but I haven't looked closely.
>>   These can be found in the following files:
>>   msmpeg4data.o (rl_table, mv_tables, wmv2_inter_table)
>>   mpeg12data.o  (ff_rl_mpeg1, ff_rl_mpeg2)
>>   h263.o        (rl_inter, rl_intra_aic, rl_intra,
>>                  rvlc_rl_inter, rvlc_rl_intra)
>>   h261dec.o     (h261_rl_tcoeff)
>> 2. temporary space for compound literals in many files
>> 3. ModeAlphabet in vp3.c, which is written to and thus
>>   should be moved to the context
>> 4. The global *_encoder/_decoder/_parser/_bsf structures.
>>   I guess they could also be read-only?
>> If janitorial work on any of those four categories is desired,
>> please let me know.
> yes it is desired and patch ok

I applied but had one 'const' too much slipped in,
it was in vorbis_enc.c and I reverted it now.
I answered my question to point 4 above the hard way with this
If the codec structures are read-only, register_avcodec()
segfaults as it writes to the 'next' field.

So big apologies, I left SVN broken for a short moment.


More information about the ffmpeg-devel mailing list