[FFmpeg-devel] [PATCH 2/5] avcodec/fft_template: Remove unused fixed-point cosine tables

Michael Niedermayer michael at niedermayer.cc
Sun Jan 10 15:31:53 EET 2021


On Sun, Jan 10, 2021 at 01:56:21AM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > On Thu, Jan 07, 2021 at 12:13:05AM +0100, Andreas Rheinhardt wrote:
> >> There are three types of FFTs: floating-point, 32-bit fixed-point and
> >> 16-bit fixed-point. The latter has exactly one user: The fixed-point
> >> AC-3-encoder; the cosine tables used by it use up to seven bits. The
> >> tables corresponding to eight to seventeen bits are unused, as are the
> >> FFT functions for these bits.
> >>
> >> Therefore this commit removes these tables and functions. This is
> >> especially beneficial when using hardcoded tables as they take up moreFirst,
> >> than 255 KiB. But even without it one saves said unused functions as
> >> well as entries in corresponding tables (this also saves relocations).
> >>
> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> >> ---
> >> Thee changes to ARM assembly are honstely untested. I hope someone can
> >> test them. Btw: It seems that the ARM assembly code wouldn't be able to
> >> deal with an FFT with more than 16 bits (no function for this has been
> >> defined), which only worked because no one ever used that many bits with
> >> the fixed-point FFT.
> >>
> >>  libavcodec/arm/fft_fixed_neon.S | 18 ------------------
> >>  libavcodec/cos_tablegen.c       |  4 ++--
> >>  libavcodec/fft.h                |  4 +++-
> >>  libavcodec/fft_fixed.c          |  1 +
> >>  libavcodec/fft_template.c       | 31 +++++++++++++++++++++++--------
> >>  tests/fate/fft.mak              |  8 ++++++--
> >>  6 files changed, 35 insertions(+), 31 deletions(-)
> > 
> > make -j32 libavcodec/tests/fft-fixed && libavcodec/tests/fft-fixed
> > Segmentation fault (core dumped)
> > 
> > (if you cant repro say so and ill rebuild with debug symbols ...)
> > 
> > thx
> > [...]
> > 
> 1. Lynne has an alternative patchset that makes the only user of
> fft_fixed use fft_fixed_32 instead, so this is not important any more.

> 2. Are you testing the ARM assembly code (for which I ask for a test) or

x86-64

> not? If not, then this surprises me. Did you apply the changes to
> fft.mak (some of the tests have been removed as they tested
> functionality that was unused (apart from the tests) and has therefore
> been removed).

i applied the changes from this patchset up to and including the patch
and also did a make distclean
FFT 512 test
Checking...
==18069== Jump to the invalid address stated on the next line
==18069==    at 0x0: ???
==18069==    by 0x10F5F9: main (fft.c:529)
==18069==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==18069== 
==18069== 
==18069== Process terminating with default action of signal 11 (SIGSEGV)
==18069==  Bad permissions for mapped region at address 0x0
==18069==    at 0x0: ???
==18069==    by 0x10F5F9: main (fft.c:529)

commit 6c532480712d395f5973063adcefce62fc75f2e1 (HEAD)
Author: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
Date:   Thu Jan 7 00:13:05 2021 +0100

    avcodec/fft_template: Remove unused fixed-point cosine tables
    
    There are three types of FFTs: floating-point, 32-bit fixed-point and
    16-bit fixed-point. The latter has exactly one user: The fixed-point
    AC-3-encoder; the cosine tables used by it use up to seven bits. The
    tables corresponding to eight to seventeen bits are unused, as are the
    FFT functions for these bits.
    
    Therefore this commit removes these tables and functions. This is
    especially beneficial when using hardcoded tables as they take up more
    than 255 KiB. But even without it one saves said unused functions as
    well as entries in corresponding tables (this also saves relocations).
    
    Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
    Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

 libavcodec/arm/fft_fixed_neon.S | 18 ------------------
 libavcodec/cos_tablegen.c       |  4 ++--
 libavcodec/fft.h                |  4 +++-
 libavcodec/fft_fixed.c          |  1 +
 libavcodec/fft_template.c       | 31 +++++++++++++++++++++++--------
 tests/fate/fft.mak              |  8 ++++++--
 6 files changed, 35 insertions(+), 31 deletions(-)

commit c592684681700a7d8b41e75a11104f8c1bdd13d9
Author: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
Date:   Thu Jan 7 00:13:04 2021 +0100

    avcodec/tableprint: Don't include mem_internal.h
    
    tableprint.h does not declare anything as aligned; it just prints
    DECLARE_ALIGNED. So it can be removed; in fact, it needs to be removed,
    because mem_internal.h includes config.h which leads to warnings when
    building with hardcoded tables enabled because of redefinitions of
    CONFIG_HARDCODED_TABLES.
    
    (Furthermore, config.h is only valid for the target, not the host,
    so HAVE_LOCAL_ALIGNED might even be wrong here.)
    
    Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
    Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

 libavcodec/tableprint.h | 1 -
 1 file changed, 1 deletion(-)

commit 91e1625db15fe8853ceedca9eed14307aaa514c7 (origin/master, origin/HEAD, refs/bisect/good-91e1625db15fe8853ceedca9eed14307aaa514c7)

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210110/e060ec0b/attachment.sig>


More information about the ffmpeg-devel mailing list