[FFmpeg-devel] [PATCH] hardcoded ff_cos tables

Måns Rullgård mans
Wed Oct 14 10:56:26 CEST 2009


Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:

> On Tue, Oct 13, 2009 at 02:41:33PM +0200, Reimar D?ffinger wrote:
>> On Tue, Oct 13, 2009 at 01:29:39PM +0100, M?ns Rullg?rd wrote:
>> > Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
>> > > attached patch allows hardcoding the ff_cos tables so they are in
>> > > .rodata instead of .bss.
>> > > Not included is the cos_tables.h file as generated by costablegen.c
>> > > since it is > 1.7 MB.
>> > > Which I admit is a bit of an issue, including this file directly into
>> > > SVN is not all that great, but it would be the simplest solution by far...
>> > 
>> > We could generate the tables at build time.
>> 
>> Not with this patch, since that reuses the libavcodec/fft.c code to
>> generate them, which will be disabled with hardcoded tables enabled.
>> It is of course possible to just duplicate the code from
>> libavcodec/fft.c, but that is not that beautiful either...
>
> Ok, so here is the version using that approach.
> I moved the code to libavcodec, I think it works better for handling the
> dependencies and also is better for projects that import libavcodec
> directly.
>
> Index: libavcodec/Makefile
> ===================================================================
> --- libavcodec/Makefile	(revision 20231)
> +++ libavcodec/Makefile	(working copy)
> @@ -27,7 +27,7 @@
>  # parts needed for many different codecs
>  OBJS-$(CONFIG_AANDCT)                  += aandcttab.o
>  OBJS-$(CONFIG_ENCODERS)                += faandct.o jfdctfst.o jfdctint.o
> -OBJS-$(CONFIG_FFT)                     += fft.o
> +OBJS-$(CONFIG_FFT)                     += fft.o cos_tables.h
>  OBJS-$(CONFIG_GOLOMB)                  += golomb.o
>  OBJS-$(CONFIG_MDCT)                    += mdct.o
>  OBJS-$(CONFIG_RDFT)                    += rdft.o

WTF?

> @@ -574,3 +574,5 @@
>  include $(SUBDIR)../subdir.mak
>
>  $(SUBDIR)dct-test$(EXESUF): $(SUBDIR)dctref.o
> +cos_tables.h: costablegen
> +	./costablegen > cos_tables.h

This doesn't work:

- It fails if building from the top level like most people do.
- It fails on systems like mswindows with non-empty EXESUF.
- If fails if cross-compiling.

To fix this:

- Use $(SUBDIR) as in the line before.
- Use $(HOSTCC) and friends as in the rules for tests/videogen etc.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list