History

avcodec: Remove DCT, FFT, MDCT and RDFT

They were replaced by TX from libavutil; the tremendous work to get to this point (both creating TX as well as porting the users of the components removed in this commit) was completely performed by Lynne alone. Removing the subsystems from configure may break some command lines, because the --disable-fft etc. options are no longer recognized.

Andreas Rheinhardt committed 3 years ago

Commit 6f7bf641 parent d9464f352 files · +2 −8799Browse files

Unified · Split

52 files
  1. configure +0 −11
  2. doc/mips.txt +0 −8
  3. libavcodec/Makefile +1 −15
  4. libavcodec/aarch64/Makefile +0 −3
  5. libavcodec/aarch64/asm-offsets.h +0 −25
  6. libavcodec/aarch64/fft_init_aarch64.c +0 −52
  7. libavcodec/aarch64/fft_neon.S +0 −447
  8. libavcodec/aarch64/mdct_neon.S +0 −326
  9. libavcodec/aarch64/synth_filter_init.c +0 −7
  10. libavcodec/aarch64/synth_filter_neon.S +0 −2
  11. libavcodec/arm/Makefile +0 −7
  12. libavcodec/arm/fft_init_arm.c +0 −63
  13. libavcodec/arm/fft_neon.S +0 −375
  14. libavcodec/arm/fft_vfp.S +0 −530
  15. libavcodec/arm/mdct_neon.S +0 −301
  16. libavcodec/arm/mdct_vfp.S +0 −347
  17. libavcodec/arm/rdft_init_arm.c +0 −33
  18. libavcodec/arm/rdft_neon.S +0 −155
  19. libavcodec/arm/synth_filter_init_arm.c +0 −1
  20. libavcodec/cos_tablegen.c +0 −80
  21. libavcodec/dct.c +0 −228
  22. libavcodec/dct.h +1 −26
  23. libavcodec/fft-internal.h +0 −62
  24. libavcodec/fft.h +0 −160
  25. libavcodec/fft_fixed_32.c +0 −51
  26. libavcodec/fft_float.c +0 −20
  27. libavcodec/fft_init_table.c +0 −344
  28. libavcodec/fft_table.h +0 −66
  29. libavcodec/fft_template.c +0 −628
  30. libavcodec/mdct_fixed_32.c +0 −51
  31. libavcodec/mdct_float.c +0 −20
  32. libavcodec/mdct_template.c +0 −209
  33. libavcodec/mips/Makefile +0 −1
  34. libavcodec/mips/fft_mips.c +0 −516
  35. libavcodec/ppc/Makefile +0 −3
  36. libavcodec/ppc/fft_altivec.S +0 −458
  37. libavcodec/ppc/fft_init.c +0 −168
  38. libavcodec/ppc/fft_vsx.c +0 −226
  39. libavcodec/ppc/fft_vsx.h +0 −829
  40. libavcodec/rdft.c +0 −120
  41. libavcodec/rdft.h +0 −52
  42. libavcodec/tests/.gitignore +0 −3
  43. libavcodec/tests/avfft.c +0 −25
  44. libavcodec/tests/fft-fixed32.c +0 −21
  45. libavcodec/tests/fft.c +0 −683
  46. libavcodec/x86/Makefile +0 −4
  47. libavcodec/x86/dct_init.c +0 −36
  48. libavcodec/x86/fft.asm +0 −838
  49. libavcodec/x86/fft.h +0 −32
  50. libavcodec/x86/fft_init.c +0 −47
  51. tests/Makefile +0 −1
  52. tests/fate/fft.mak +0 −83
configure+0−11
@@ -136,13 +136,9 @@ Component options: · 135 unmodified lines
136 --disable-w32threads disable Win32 threads [autodetect]136 --disable-w32threads disable Win32 threads [autodetect]
137 --disable-os2threads disable OS/2 threads [autodetect]137 --disable-os2threads disable OS/2 threads [autodetect]
138 --disable-network disable network support [no]138 --disable-network disable network support [no]
139 --disable-dct disable DCT code
140 --disable-dwt disable DWT code139 --disable-dwt disable DWT code
141 --disable-error-resilience disable error resilience code140 --disable-error-resilience disable error resilience code
142 --disable-lsp disable LSP code141 --disable-lsp disable LSP code
143 --disable-mdct disable MDCT code
144 --disable-rdft disable RDFT code
145 --disable-fft disable FFT code
146 --disable-faan disable floating point AAN (I)DCT code142 --disable-faan disable floating point AAN (I)DCT code
147 --disable-pixelutils disable pixel utils in libavutil143 --disable-pixelutils disable pixel utils in libavutil
148 144
@@ -2004,17 +2000,13 @@ PROGRAM_LIST=" · 1855 unmodified lines
2004"2000"
2005 2001
2006SUBSYSTEM_LIST="2002SUBSYSTEM_LIST="
2007 dct
2008 dwt2003 dwt
2009 error_resilience2004 error_resilience
2010 faan2005 faan
2011 fast_unaligned2006 fast_unaligned
2012 fft
2013 lsp2007 lsp
2014 mdct
2015 pixelutils2008 pixelutils
2016 network2009 network
2017 rdft
2018"2010"
2019 2011
2020# COMPONENT_LIST needs to come last to ensure correct dependency checking2012# COMPONENT_LIST needs to come last to ensure correct dependency checking
@@ -2766,7 +2758,6 @@ cbs_h266_select="cbs" · 745 unmodified lines
2766cbs_jpeg_select="cbs"2758cbs_jpeg_select="cbs"
2767cbs_mpeg2_select="cbs"2759cbs_mpeg2_select="cbs"
2768cbs_vp9_select="cbs"2760cbs_vp9_select="cbs"
2769dct_select="rdft"
2770deflate_wrapper_deps="zlib"2761deflate_wrapper_deps="zlib"
2771dirac_parse_select="golomb"2762dirac_parse_select="golomb"
2772dovi_rpu_select="golomb"2763dovi_rpu_select="golomb"
@@ -2786,7 +2777,6 @@ frame_thread_encoder_deps="encoders threads" · 13 unmodified lines
2786inflate_wrapper_deps="zlib"2777inflate_wrapper_deps="zlib"
2787intrax8_select="blockdsp wmv2dsp"2778intrax8_select="blockdsp wmv2dsp"
2788iso_media_select="mpeg4audio"2779iso_media_select="mpeg4audio"
2789mdct_select="fft"
2790me_cmp_select="idctdsp"2780me_cmp_select="idctdsp"
2791mpeg_er_select="error_resilience"2781mpeg_er_select="error_resilience"
2792mpegaudio_select="mpegaudiodsp mpegaudioheader"2782mpegaudio_select="mpegaudiodsp mpegaudioheader"
@@ -2796,7 +2786,6 @@ mpegvideoenc_select="aandcttables fdctdsp me_cmp mpegvideo pixblockdsp" · 3 unmodified lines
2796msmpeg4dec_select="h263_decoder"2786msmpeg4dec_select="h263_decoder"
2797msmpeg4enc_select="h263_encoder"2787msmpeg4enc_select="h263_encoder"
2798vc1dsp_select="h264chroma qpeldsp startcode"2788vc1dsp_select="h264chroma qpeldsp startcode"
2799rdft_select="fft"
2800 2789
2801# decoders / encoders2790# decoders / encoders
2802aac_decoder_select="adts_header mpeg4audio sinewin"2791aac_decoder_select="adts_header mpeg4audio sinewin"
doc/mips.txt+0−8
@@ -48,11 +48,6 @@ Files that have MIPS copyright notice in them: · 47 unmodified lines
48 float_dsp_mips.c48 float_dsp_mips.c
49 libm_mips.h49 libm_mips.h
50 softfloat_tables.h50 softfloat_tables.h
51* libavcodec/
52 fft_fixed_32.c
53 fft_init_table.c
54 fft_table.h
55 mdct_fixed_32.c
56* libavcodec/mips/51* libavcodec/mips/
57 aacdec_fixed.c52 aacdec_fixed.c
58 aacsbr_fixed.c53 aacsbr_fixed.c
@@ -70,9 +65,6 @@ Files that have MIPS copyright notice in them: · 11 unmodified lines
70 compute_antialias_float.h65 compute_antialias_float.h
71 lsp_mips.h66 lsp_mips.h
72 dsputil_mips.c67 dsputil_mips.c
73 fft_mips.c
74 fft_table.h
75 fft_init_table.c
76 fmtconvert_mips.c68 fmtconvert_mips.c
77 iirfilter_mips.c69 iirfilter_mips.c
78 mpegaudiodsp_mips_fixed.c70 mpegaudiodsp_mips_fixed.c
libavcodec/Makefile+1−15
@@ -32,6 +32,7 @@ OBJS = ac3_parser.o \ · 31 unmodified lines
32 allcodecs.o \32 allcodecs.o \
33 avcodec.o \33 avcodec.o \
34 avdct.o \34 avdct.o \
35 avfft.o \
35 avpacket.o \36 avpacket.o \
36 bitstream.o \37 bitstream.o \
37 bitstream_filters.o \38 bitstream_filters.o \
@@ -81,7 +82,6 @@ OBJS-$(CONFIG_CBS_JPEG) += cbs_jpeg.o · 43 unmodified lines
81OBJS-$(CONFIG_CBS_MPEG2) += cbs_mpeg2.o82OBJS-$(CONFIG_CBS_MPEG2) += cbs_mpeg2.o
82OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o83OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
83OBJS-$(CONFIG_CRYSTALHD) += crystalhd.o84OBJS-$(CONFIG_CRYSTALHD) += crystalhd.o
84OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
85OBJS-$(CONFIG_DEFLATE_WRAPPER) += zlib_wrapper.o85OBJS-$(CONFIG_DEFLATE_WRAPPER) += zlib_wrapper.o
86OBJS-$(CONFIG_DOVI_RPU) += dovi_rpu.o86OBJS-$(CONFIG_DOVI_RPU) += dovi_rpu.o
87OBJS-$(CONFIG_ERROR_RESILIENCE) += error_resilience.o87OBJS-$(CONFIG_ERROR_RESILIENCE) += error_resilience.o
@@ -90,9 +90,6 @@ OBJS-$(CONFIG_EXIF) += exif.o tiff_common.o · 2 unmodified lines
90OBJS-$(CONFIG_FAANDCT) += faandct.o90OBJS-$(CONFIG_FAANDCT) += faandct.o
91OBJS-$(CONFIG_FAANIDCT) += faanidct.o91OBJS-$(CONFIG_FAANIDCT) += faanidct.o
92OBJS-$(CONFIG_FDCTDSP) += fdctdsp.o jfdctfst.o jfdctint.o92OBJS-$(CONFIG_FDCTDSP) += fdctdsp.o jfdctfst.o jfdctint.o
93FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o
94OBJS-$(CONFIG_FFT) += avfft.o fft_float.o fft_fixed_32.o \
95 fft_init_table.o $(FFT-OBJS-yes)
96OBJS-$(CONFIG_FMTCONVERT) += fmtconvert.o93OBJS-$(CONFIG_FMTCONVERT) += fmtconvert.o
97OBJS-$(CONFIG_GOLOMB) += golomb.o94OBJS-$(CONFIG_GOLOMB) += golomb.o
98OBJS-$(CONFIG_H263DSP) += h263dsp.o95OBJS-$(CONFIG_H263DSP) += h263dsp.o
@@ -125,7 +122,6 @@ OBJS-$(CONFIG_LLVIDENCDSP) += lossless_videoencdsp.o · 26 unmodified lines
125OBJS-$(CONFIG_LPC) += lpc.o122OBJS-$(CONFIG_LPC) += lpc.o
126OBJS-$(CONFIG_LSP) += lsp.o123OBJS-$(CONFIG_LSP) += lsp.o
127OBJS-$(CONFIG_LZF) += lzf.o124OBJS-$(CONFIG_LZF) += lzf.o
128OBJS-$(CONFIG_MDCT) += mdct_float.o mdct_fixed_32.o
129OBJS-$(CONFIG_ME_CMP) += me_cmp.o125OBJS-$(CONFIG_ME_CMP) += me_cmp.o
130OBJS-$(CONFIG_MEDIACODEC) += mediacodecdec_common.o mediacodec_surface.o mediacodec_wrapper.o mediacodec_sw_buffer.o126OBJS-$(CONFIG_MEDIACODEC) += mediacodecdec_common.o mediacodec_surface.o mediacodec_wrapper.o mediacodec_sw_buffer.o
131OBJS-$(CONFIG_MPEG_ER) += mpeg_er.o127OBJS-$(CONFIG_MPEG_ER) += mpeg_er.o
@@ -157,7 +153,6 @@ OBJS-$(CONFIG_QSV) += qsv.o · 25 unmodified lines
157OBJS-$(CONFIG_QSVDEC) += qsvdec.o153OBJS-$(CONFIG_QSVDEC) += qsvdec.o
158OBJS-$(CONFIG_QSVENC) += qsvenc.o154OBJS-$(CONFIG_QSVENC) += qsvenc.o
159OBJS-$(CONFIG_RANGECODER) += rangecoder.o155OBJS-$(CONFIG_RANGECODER) += rangecoder.o
160OBJS-$(CONFIG_RDFT) += rdft.o
161OBJS-$(CONFIG_RV34DSP) += rv34dsp.o156OBJS-$(CONFIG_RV34DSP) += rv34dsp.o
162OBJS-$(CONFIG_SINEWIN) += sinewin.o157OBJS-$(CONFIG_SINEWIN) += sinewin.o
163OBJS-$(CONFIG_SNAPPY) += snappy.o158OBJS-$(CONFIG_SNAPPY) += snappy.o
@@ -1326,8 +1321,6 @@ TESTPROGS = avcodec \ · 1162 unmodified lines
1326 1321
1327TESTPROGS-$(CONFIG_AV1_VAAPI_ENCODER) += av1_levels1322TESTPROGS-$(CONFIG_AV1_VAAPI_ENCODER) += av1_levels
1328TESTPROGS-$(CONFIG_CABAC) += cabac1323TESTPROGS-$(CONFIG_CABAC) += cabac
1329TESTPROGS-$(CONFIG_DCT) += avfft
1330TESTPROGS-$(CONFIG_FFT) += fft fft-fixed32
1331TESTPROGS-$(CONFIG_GOLOMB) += golomb1324TESTPROGS-$(CONFIG_GOLOMB) += golomb
1332TESTPROGS-$(CONFIG_IDCTDSP) += dct1325TESTPROGS-$(CONFIG_IDCTDSP) += dct
1333TESTPROGS-$(CONFIG_IIRFILTER) += iirfilter1326TESTPROGS-$(CONFIG_IIRFILTER) += iirfilter
@@ -1347,7 +1340,6 @@ HOSTPROGS = aacps_tablegen \ · 13 unmodified lines
1347 aacps_fixed_tablegen \1340 aacps_fixed_tablegen \
1348 cbrt_tablegen \1341 cbrt_tablegen \
1349 cbrt_fixed_tablegen \1342 cbrt_fixed_tablegen \
1350 cos_tablegen \
1351 dv_tablegen \1343 dv_tablegen \
1352 motionpixels_tablegen \1344 motionpixels_tablegen \
1353 mpegaudio_tablegen \1345 mpegaudio_tablegen \
@@ -1362,12 +1354,6 @@ CLEANFILES = *_tables.c *_tables.h *_tablegen$(HOSTEXESUF) · 8 unmodified lines
1362$(SUBDIR)tests/dct$(EXESUF): $(SUBDIR)dctref.o $(SUBDIR)aandcttab.o1354$(SUBDIR)tests/dct$(EXESUF): $(SUBDIR)dctref.o $(SUBDIR)aandcttab.o
1363$(SUBDIR)dv_tablegen$(HOSTEXESUF): $(SUBDIR)dvdata_host.o1355$(SUBDIR)dv_tablegen$(HOSTEXESUF): $(SUBDIR)dvdata_host.o
1364 1356
1365TRIG_TABLES = cos cos_fixed sin
1366TRIG_TABLES := $(TRIG_TABLES:%=$(SUBDIR)%_tables.c)
1367
1368$(TRIG_TABLES): $(SUBDIR)%_tables.c: $(SUBDIR)cos_tablegen$(HOSTEXESUF)
1369 $(M)./$< $* > $@
1370
1371ifdef CONFIG_SMALL1357ifdef CONFIG_SMALL
1372$(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=11358$(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=1
1373else1359else
libavcodec/aarch64/Makefile+0−3
@@ -1,5 +1,4 @@
1# subsystems1# subsystems
2OBJS-$(CONFIG_FFT) += aarch64/fft_init_aarch64.o
3OBJS-$(CONFIG_FMTCONVERT) += aarch64/fmtconvert_init.o2OBJS-$(CONFIG_FMTCONVERT) += aarch64/fmtconvert_init.o
4OBJS-$(CONFIG_H264CHROMA) += aarch64/h264chroma_init_aarch64.o3OBJS-$(CONFIG_H264CHROMA) += aarch64/h264chroma_init_aarch64.o
5OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o4OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o
@@ -36,7 +35,6 @@ ARMV8-OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp.o · 30 unmodified lines
36 35
37# subsystems36# subsystems
38NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/sbrdsp_neon.o37NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/sbrdsp_neon.o
39NEON-OBJS-$(CONFIG_FFT) += aarch64/fft_neon.o
40NEON-OBJS-$(CONFIG_FMTCONVERT) += aarch64/fmtconvert_neon.o38NEON-OBJS-$(CONFIG_FMTCONVERT) += aarch64/fmtconvert_neon.o
41NEON-OBJS-$(CONFIG_H264CHROMA) += aarch64/h264cmc_neon.o39NEON-OBJS-$(CONFIG_H264CHROMA) += aarch64/h264cmc_neon.o
42NEON-OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_neon.o \40NEON-OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_neon.o \
@@ -47,7 +45,6 @@ NEON-OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_neon.o \ · 4 unmodified lines
47NEON-OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_neon.o45NEON-OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_neon.o
48NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_neon.o \46NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_neon.o \
49 aarch64/simple_idct_neon.o47 aarch64/simple_idct_neon.o
50NEON-OBJS-$(CONFIG_MDCT) += aarch64/mdct_neon.o
51NEON-OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_neon.o48NEON-OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_neon.o
52NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o49NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o
53NEON-OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_neon.o50NEON-OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_neon.o
libavcodec/aarch64/asm-offsets.h+0−25
@@ -1,25 +0,0 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVCODEC_AARCH64_ASM_OFFSETS_H
20#define AVCODEC_AARCH64_ASM_OFFSETS_H
21
22/* FFTContext */
23#define IMDCT_HALF 0x48
24
25#endif /* AVCODEC_AARCH64_ASM_OFFSETS_H */
libavcodec/aarch64/fft_init_aarch64.c+0−52
@@ -1,52 +0,0 @@
1/*
2 * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "config.h"
22
23#include "libavutil/attributes.h"
24#include "libavutil/cpu.h"
25#include "libavutil/aarch64/cpu.h"
26
27#include "libavcodec/fft.h"
28
29void ff_fft_permute_neon(FFTContext *s, FFTComplex *z);
30void ff_fft_calc_neon(FFTContext *s, FFTComplex *z);
31
32void ff_imdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input);
33void ff_imdct_half_neon(FFTContext *s, FFTSample *output, const FFTSample *input);
34void ff_mdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input);
35
36av_cold void ff_fft_init_aarch64(FFTContext *s)
37{
38 int cpu_flags = av_get_cpu_flags();
39
40 if (have_neon(cpu_flags)) {
41 if (s->nbits < 17) {
42 s->fft_permute = ff_fft_permute_neon;
43 s->fft_calc = ff_fft_calc_neon;
44 }
45#if CONFIG_MDCT
46 s->imdct_calc = ff_imdct_calc_neon;
47 s->imdct_half = ff_imdct_half_neon;
48 s->mdct_calc = ff_mdct_calc_neon;
49 s->mdct_permutation = FF_MDCT_PERM_INTERLEAVE;
50#endif
51 }
52}
libavcodec/aarch64/fft_neon.S+0−447
@@ -1,447 +0,0 @@
1/*
2 * ARM NEON optimised FFT
3 *
4 * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
5 * Copyright (c) 2009 Naotoshi Nojiri
6 * Copyright (c) 2014 Janne Grunau <janne-libav@jannau.net>
7 *
8 * This algorithm (though not any of the implementation details) is
9 * based on libdjbfft by D. J. Bernstein.
10 *
11 * This file is part of FFmpeg.
12 *
13 * FFmpeg is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
17 *
18 * FFmpeg is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with FFmpeg; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 */
27
28#include "libavutil/aarch64/asm.S"
29
30#define M_SQRT1_2 0.70710678118654752440
31
32.macro transpose d0, d1, s0, s1
33 trn1 \d0, \s0, \s1
34 trn2 \d1, \s0, \s1
35.endm
36
37
38function fft4_neon
39 AARCH64_VALID_JUMP_TARGET
40 ld1 {v0.2s,v1.2s,v2.2s,v3.2s}, [x0]
41
42 fadd v4.2s, v0.2s, v1.2s // r0+r1,i0+i1
43 fsub v6.2s, v0.2s, v1.2s // r0-r1,i0-i1
44
45 ext v16.8b, v2.8b, v3.8b, #4
46 ext v17.8b, v3.8b, v2.8b, #4
47
48 fadd v5.2s, v2.2s, v3.2s // i2+i3,r2+r3
49 fsub v7.2s, v16.2s, v17.2s // r3-r2,i2-i3
50
51 fadd v0.2s, v4.2s, v5.2s
52 fsub v2.2s, v4.2s, v5.2s
53 fadd v1.2s, v6.2s, v7.2s
54 fsub v3.2s, v6.2s, v7.2s
55
56 st1 {v0.2s,v1.2s,v2.2s,v3.2s}, [x0]
57
58 ret
59endfunc
60
61function fft8_neon
62 AARCH64_VALID_JUMP_TARGET
63 mov x1, x0
64 ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32
65 ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0]
66 ext v22.8b, v2.8b, v3.8b, #4
67 ext v23.8b, v3.8b, v2.8b, #4
68 fadd v4.2s, v16.2s, v17.2s // r4+r5,i4+i5
69 fadd v5.2s, v18.2s, v19.2s // r6+r7,i6+i7
70 fsub v17.2s, v16.2s, v17.2s // r4-r5,i4-i5
71 fsub v19.2s, v18.2s, v19.2s // r6-r7,i6-i7
72 rev64 v27.2s, v28.2s // ???
73 fadd v20.2s, v0.2s, v1.2s // r0+r1,i0+i1
74 fadd v21.2s, v2.2s, v3.2s // r2+r3,i2+i3
75 fmul v26.2s, v17.2s, v28.2s // -a2r*w,a2i*w
76 ext v6.8b, v4.8b, v5.8b, #4
77 ext v7.8b, v5.8b, v4.8b, #4
78 fmul v27.2s, v19.2s, v27.2s // a3r*w,-a3i*w
79 fsub v23.2s, v22.2s, v23.2s // i2-i3,r3-r2
80 fsub v22.2s, v0.2s, v1.2s // r0-r1,i0-i1
81 fmul v24.2s, v17.2s, v28.s[1] // a2r*w,a2i*w
82 fmul v25.2s, v19.2s, v28.s[1] // a3r*w,a3i*w
83 fadd v0.2s, v20.2s, v21.2s
84 fsub v2.2s, v20.2s, v21.2s
85 fadd v1.2s, v22.2s, v23.2s
86 rev64 v26.2s, v26.2s
87 rev64 v27.2s, v27.2s
88 fsub v3.2s, v22.2s, v23.2s
89 fsub v6.2s, v6.2s, v7.2s
90 fadd v24.2s, v24.2s, v26.2s // a2r+a2i,a2i-a2r t1,t2
91 fadd v25.2s, v25.2s, v27.2s // a3r-a3i,a3i+a3r t5,t6
92 fadd v7.2s, v4.2s, v5.2s
93 fsub v18.2s, v2.2s, v6.2s
94 ext v26.8b, v24.8b, v25.8b, #4
95 ext v27.8b, v25.8b, v24.8b, #4
96 fadd v2.2s, v2.2s, v6.2s
97 fsub v16.2s, v0.2s, v7.2s
98 fadd v5.2s, v25.2s, v24.2s
99 fsub v4.2s, v26.2s, v27.2s
100 fadd v0.2s, v0.2s, v7.2s
101 fsub v17.2s, v1.2s, v5.2s
102 fsub v19.2s, v3.2s, v4.2s
103 fadd v3.2s, v3.2s, v4.2s
104 fadd v1.2s, v1.2s, v5.2s
105
106 st1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0]
107 st1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x1]
108
109 ret
110endfunc
111
112function fft16_neon
113 AARCH64_VALID_JUMP_TARGET
114 mov x1, x0
115 ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32
116 ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0], #32
117 ext v22.8b, v2.8b, v3.8b, #4
118 ext v23.8b, v3.8b, v2.8b, #4
119 fadd v4.2s, v16.2s, v17.2s // r4+r5,i4+i5
120 fadd v5.2s, v18.2s, v19.2s // r6+r7,i6+i7
121 fsub v17.2s, v16.2s, v17.2s // r4-r5,i4-i5
122 fsub v19.2s, v18.2s, v19.2s // r6-r7,i6-i7
123 rev64 v27.2s, v28.2s // ???
124 fadd v20.2s, v0.2s, v1.2s // r0+r1,i0+i1
125 fadd v21.2s, v2.2s, v3.2s // r2+r3,i2+i3
126 fmul v26.2s, v17.2s, v28.2s // -a2r*w,a2i*w
127 ext v6.8b, v4.8b, v5.8b, #4
128 ext v7.8b, v5.8b, v4.8b, #4
129 fmul v27.2s, v19.2s, v27.2s // a3r*w,-a3i*w
130 fsub v23.2s, v22.2s, v23.2s // i2-i3,r3-r2
131 fsub v22.2s, v0.2s, v1.2s // r0-r1,i0-i1
132 fmul v24.2s, v17.2s, v28.s[1] // a2r*w,a2i*w
133 fmul v25.2s, v19.2s, v28.s[1] // a3r*w,a3i*w
134 fadd v0.2s, v20.2s, v21.2s
135 fsub v2.2s, v20.2s, v21.2s
136 fadd v1.2s, v22.2s, v23.2s
137 rev64 v26.2s, v26.2s
138 rev64 v27.2s, v27.2s
139 fsub v3.2s, v22.2s, v23.2s
140 fsub v6.2s, v6.2s, v7.2s
141 fadd v24.2s, v24.2s, v26.2s // a2r+a2i,a2i-a2r t1,t2
142 fadd v25.2s, v25.2s, v27.2s // a3r-a3i,a3i+a3r t5,t6
143 fadd v7.2s, v4.2s, v5.2s
144 fsub v18.2s, v2.2s, v6.2s
145 ld1 {v20.4s,v21.4s}, [x0], #32
146 ld1 {v22.4s,v23.4s}, [x0], #32
147 ext v26.8b, v24.8b, v25.8b, #4
148 ext v27.8b, v25.8b, v24.8b, #4
149 fadd v2.2s, v2.2s, v6.2s
150 fsub v16.2s, v0.2s, v7.2s
151 fadd v5.2s, v25.2s, v24.2s
152 fsub v4.2s, v26.2s, v27.2s
153 transpose v24.2d, v25.2d, v20.2d, v22.2d
154 transpose v26.2d, v27.2d, v21.2d, v23.2d
155 fadd v0.2s, v0.2s, v7.2s
156 fsub v17.2s, v1.2s, v5.2s
157 fsub v19.2s, v3.2s, v4.2s
158 fadd v3.2s, v3.2s, v4.2s
159 fadd v1.2s, v1.2s, v5.2s
160 ext v20.16b, v21.16b, v21.16b, #4
161 ext v21.16b, v23.16b, v23.16b, #4
162
163 zip1 v0.2d, v0.2d, v1.2d // {z[0], z[1]}
164 zip1 v1.2d, v2.2d, v3.2d // {z[2], z[3]}
165 zip1 v2.2d, v16.2d, v17.2d // {z[o1], z[o1+1]}
166 zip1 v3.2d, v18.2d, v19.2d // {z[o1+2],z[o1+3]}
167
168 // 2 x fft4
169 transpose v22.2d, v23.2d, v20.2d, v21.2d
170
171 fadd v4.4s, v24.4s, v25.4s
172 fadd v5.4s, v26.4s, v27.4s
173 fsub v6.4s, v24.4s, v25.4s
174 fsub v7.4s, v22.4s, v23.4s
175
176 ld1 {v23.4s}, [x14]
177
178 fadd v24.4s, v4.4s, v5.4s // {z[o2+0],z[o2+1]}
179 fsub v26.4s, v4.4s, v5.4s // {z[o2+2],z[o2+3]}
180 fadd v25.4s, v6.4s, v7.4s // {z[o3+0],z[o3+1]}
181 fsub v27.4s, v6.4s, v7.4s // {z[o3+2],z[o3+3]}
182
183 //fft_pass_neon_16
184 rev64 v7.4s, v25.4s
185 fmul v25.4s, v25.4s, v23.s[1]
186 fmul v7.4s, v7.4s, v29.4s
187 fmla v25.4s, v7.4s, v23.s[3] // {t1a,t2a,t5a,t6a}
188
189 zip1 v20.4s, v24.4s, v25.4s
190 zip2 v21.4s, v24.4s, v25.4s
191 fneg v22.4s, v20.4s
192 fadd v4.4s, v21.4s, v20.4s
193 fsub v6.4s, v20.4s, v21.4s // just the second half
194 fadd v5.4s, v21.4s, v22.4s // just the first half
195
196 tbl v4.16b, {v4.16b}, v30.16b // trans4_float
197 tbl v5.16b, {v5.16b,v6.16b}, v31.16b // trans8_float
198
199 fsub v20.4s, v0.4s, v4.4s // {z[o2],z[o2+1]}
200 fadd v16.4s, v0.4s, v4.4s // {z[0], z[1]}
201 fsub v22.4s, v2.4s, v5.4s // {z[o3],z[o3+1]}
202 fadd v18.4s, v2.4s, v5.4s // {z[o1],z[o1+1]}
203
204//second half
205 rev64 v6.4s, v26.4s
206 fmul v26.4s, v26.4s, v23.s[2]
207 rev64 v7.4s, v27.4s
208 fmul v27.4s, v27.4s, v23.s[3]
209 fmul v6.4s, v6.4s, v29.4s
210 fmul v7.4s, v7.4s, v29.4s
211 fmla v26.4s, v6.4s, v23.s[2] // {t1,t2,t5,t6}
212 fmla v27.4s, v7.4s, v23.s[1] // {t1a,t2a,t5a,t6a}
213
214 zip1 v24.4s, v26.4s, v27.4s
215 zip2 v25.4s, v26.4s, v27.4s
216 fneg v26.4s, v24.4s
217 fadd v4.4s, v25.4s, v24.4s
218 fsub v6.4s, v24.4s, v25.4s // just the second half
219 fadd v5.4s, v25.4s, v26.4s // just the first half
220
221 tbl v4.16b, {v4.16b}, v30.16b // trans4_float
222 tbl v5.16b, {v5.16b,v6.16b}, v31.16b // trans8_float
223
224 fadd v17.4s, v1.4s, v4.4s // {z[2], z[3]}
225 fsub v21.4s, v1.4s, v4.4s // {z[o2+2],z[o2+3]}
226 fadd v19.4s, v3.4s, v5.4s // {z[o1+2],z[o1+3]}
227 fsub v23.4s, v3.4s, v5.4s // {z[o3+2],z[o3+3]}
228
229 st1 {v16.4s,v17.4s}, [x1], #32
230 st1 {v18.4s,v19.4s}, [x1], #32
231 st1 {v20.4s,v21.4s}, [x1], #32
232 st1 {v22.4s,v23.4s}, [x1], #32
233
234 ret
235endfunc
236
237
238const trans4_float, align=4
239 .byte 0, 1, 2, 3
240 .byte 8, 9, 10, 11
241 .byte 4, 5, 6, 7
242 .byte 12, 13, 14, 15
243endconst
244
245const trans8_float, align=4
246 .byte 24, 25, 26, 27
247 .byte 0, 1, 2, 3
248 .byte 28, 29, 30, 31
249 .byte 4, 5, 6, 7
250endconst
251
252function fft_pass_neon
253 sub x6, x2, #1 // n - 1, loop counter
254 lsl x5, x2, #3 // 2 * n * sizeof FFTSample
255 lsl x1, x2, #4 // 2 * n * sizeof FFTComplex
256 add x5, x4, x5 // wim
257 add x3, x1, x2, lsl #5 // 4 * n * sizeof FFTComplex
258 add x2, x0, x2, lsl #5 // &z[o2]
259 add x3, x0, x3 // &z[o3]
260 add x1, x0, x1 // &z[o1]
261 ld1 {v20.4s},[x2] // {z[o2],z[o2+1]}
262 ld1 {v22.4s},[x3] // {z[o3],z[o3+1]}
263 ld1 {v4.2s}, [x4], #8 // {wre[0],wre[1]}
264 trn2 v25.2d, v20.2d, v22.2d
265 sub x5, x5, #4 // wim--
266 trn1 v24.2d, v20.2d, v22.2d
267 ld1 {v5.s}[0], [x5], x7 // d5[0] = wim[-1]
268 rev64 v7.4s, v25.4s
269 fmul v25.4s, v25.4s, v4.s[1]
270 ld1 {v16.4s}, [x0] // {z[0],z[1]}
271 fmul v7.4s, v7.4s, v29.4s
272 ld1 {v17.4s}, [x1] // {z[o1],z[o1+1]}
273 prfm pldl1keep, [x2, #16]
274 prfm pldl1keep, [x3, #16]
275 fmla v25.4s, v7.4s, v5.s[0] // {t1a,t2a,t5a,t6a}
276 prfm pldl1keep, [x0, #16]
277 prfm pldl1keep, [x1, #16]
278
279 zip1 v20.4s, v24.4s, v25.4s
280 zip2 v21.4s, v24.4s, v25.4s
281 fneg v22.4s, v20.4s
282 fadd v4.4s, v21.4s, v20.4s
283 fsub v6.4s, v20.4s, v21.4s // just the second half
284 fadd v5.4s, v21.4s, v22.4s // just the first half
285
286 tbl v4.16b, {v4.16b}, v30.16b // trans4_float
287 tbl v5.16b, {v5.16b,v6.16b}, v31.16b // trans8_float
288
289 fadd v20.4s, v16.4s, v4.4s
290 fsub v22.4s, v16.4s, v4.4s
291 fadd v21.4s, v17.4s, v5.4s
292 st1 {v20.4s}, [x0], #16 // {z[0], z[1]}
293 fsub v23.4s, v17.4s, v5.4s
294
295 st1 {v21.4s}, [x1], #16 // {z[o1],z[o1+1]}
296 st1 {v22.4s}, [x2], #16 // {z[o2],z[o2+1]}
297 st1 {v23.4s}, [x3], #16 // {z[o3],z[o3+1]}
2981:
299 ld1 {v20.4s},[x2] // {z[o2],z[o2+1]}
300 ld1 {v22.4s},[x3] // {z[o3],z[o3+1]}
301 ld1 {v4.2s}, [x4], #8 // {wre[0],wre[1]}
302 transpose v26.2d, v27.2d, v20.2d, v22.2d
303 ld1 {v5.2s}, [x5], x7 // {wim[-1],wim[0]}
304 rev64 v6.4s, v26.4s
305 fmul v26.4s, v26.4s, v4.s[0]
306 rev64 v7.4s, v27.4s
307 fmul v27.4s, v27.4s, v4.s[1]
308 fmul v6.4s, v6.4s, v29.4s
309 fmul v7.4s, v7.4s, v29.4s
310 ld1 {v16.4s},[x0] // {z[0],z[1]}
311 fmla v26.4s, v6.4s, v5.s[1] // {t1,t2,t5,t6}
312 fmla v27.4s, v7.4s, v5.s[0] // {t1a,t2a,t5a,t6a}
313 ld1 {v17.4s},[x1] // {z[o1],z[o1+1]}
314
315 subs x6, x6, #1 // n--
316
317 zip1 v20.4s, v26.4s, v27.4s
318 zip2 v21.4s, v26.4s, v27.4s
319 fneg v22.4s, v20.4s
320 fadd v4.4s, v21.4s, v20.4s
321 fsub v6.4s, v20.4s, v21.4s // just the second half
322 fadd v5.4s, v21.4s, v22.4s // just the first half
323
324 tbl v4.16b, {v4.16b}, v30.16b // trans4_float
325 tbl v5.16b, {v5.16b,v6.16b}, v31.16b // trans8_float
326
327 fadd v20.4s, v16.4s, v4.4s
328 fsub v22.4s, v16.4s, v4.4s
329 fadd v21.4s, v17.4s, v5.4s
330 st1 {v20.4s}, [x0], #16 // {z[0], z[1]}
331 fsub v23.4s, v17.4s, v5.4s
332
333 st1 {v21.4s}, [x1], #16 // {z[o1],z[o1+1]}
334 st1 {v22.4s}, [x2], #16 // {z[o2],z[o2+1]}
335 st1 {v23.4s}, [x3], #16 // {z[o3],z[o3+1]}
336 b.ne 1b
337
338 ret
339endfunc
340
341.macro def_fft n, n2, n4
342function fft\n\()_neon, align=6
343 AARCH64_VALID_JUMP_TARGET
344 AARCH64_SIGN_LINK_REGISTER
345 stp x28, x30, [sp, #-16]!
346 add x28, x0, #\n4*2*8
347 bl fft\n2\()_neon
348 mov x0, x28
349 bl fft\n4\()_neon
350 add x0, x28, #\n4*1*8
351 bl fft\n4\()_neon
352 sub x0, x28, #\n4*2*8
353 ldp x28, x30, [sp], #16
354 AARCH64_VALIDATE_LINK_REGISTER
355 movrel x4, X(ff_cos_\n)
356 mov x2, #\n4>>1
357 b fft_pass_neon
358endfunc
359.endm
360
361 def_fft 32, 16, 8
362 def_fft 64, 32, 16
363 def_fft 128, 64, 32
364 def_fft 256, 128, 64
365 def_fft 512, 256, 128
366 def_fft 1024, 512, 256
367 def_fft 2048, 1024, 512
368 def_fft 4096, 2048, 1024
369 def_fft 8192, 4096, 2048
370 def_fft 16384, 8192, 4096
371 def_fft 32768, 16384, 8192
372 def_fft 65536, 32768, 16384
373
374function ff_fft_calc_neon, export=1
375 prfm pldl1keep, [x1]
376 movrel x10, trans4_float
377 ldr w2, [x0]
378 movrel x11, trans8_float
379 sub w2, w2, #2
380 movrel x3, fft_tab_neon
381 ld1 {v30.16b}, [x10]
382 mov x7, #-8
383 movrel x12, pmmp
384 ldr x3, [x3, x2, lsl #3]
385 movrel x13, mppm
386 movrel x14, X(ff_cos_16)
387 ld1 {v31.16b}, [x11]
388 mov x0, x1
389 ld1 {v29.4s}, [x12] // pmmp
390 ld1 {v28.4s}, [x13]
391 br x3
392endfunc
393
394function ff_fft_permute_neon, export=1
395 mov x6, #1
396 ldr w2, [x0] // nbits
397 ldr x3, [x0, #16] // tmp_buf
398 ldr x0, [x0, #8] // revtab
399 lsl x6, x6, x2
400 mov x2, x6
4011:
402 ld1 {v0.2s,v1.2s}, [x1], #16
403 ldr w4, [x0], #4
404 uxth w5, w4
405 lsr w4, w4, #16
406 add x5, x3, x5, lsl #3
407 add x4, x3, x4, lsl #3
408 st1 {v0.2s}, [x5]
409 st1 {v1.2s}, [x4]
410 subs x6, x6, #2
411 b.gt 1b
412
413 sub x1, x1, x2, lsl #3
4141:
415 ld1 {v0.4s,v1.4s}, [x3], #32
416 st1 {v0.4s,v1.4s}, [x1], #32
417 subs x2, x2, #4
418 b.gt 1b
419
420 ret
421endfunc
422
423const fft_tab_neon, relocate=1
424 .quad fft4_neon
425 .quad fft8_neon
426 .quad fft16_neon
427 .quad fft32_neon
428 .quad fft64_neon
429 .quad fft128_neon
430 .quad fft256_neon
431 .quad fft512_neon
432 .quad fft1024_neon
433 .quad fft2048_neon
434 .quad fft4096_neon
435 .quad fft8192_neon
436 .quad fft16384_neon
437 .quad fft32768_neon
438 .quad fft65536_neon
439endconst
440
441const pmmp, align=4
442 .float +1.0, -1.0, -1.0, +1.0
443endconst
444
445const mppm, align=4
446 .float -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2
447endconst
libavcodec/aarch64/mdct_neon.S+0−326
@@ -1,326 +0,0 @@
1/*
2 * AArch64 NEON optimised MDCT
3 * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
4 * Copyright (c) 2014 Janne Grunau <janne-libav@jannau.net>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include "libavutil/aarch64/asm.S"
24
25function ff_imdct_half_neon, export=1
26 stp x19, x20, [sp, #-32]!
27 AARCH64_SIGN_LINK_REGISTER
28 str x30, [sp, #16]
29 mov x12, #1
30 ldr w14, [x0, #28] // mdct_bits
31 ldr x4, [x0, #32] // tcos
32 ldr x3, [x0, #8] // revtab
33 lsl x12, x12, x14 // n = 1 << nbits
34 lsr x14, x12, #2 // n4 = n >> 2
35 add x7, x2, x12, lsl #1
36 mov x12, #-16
37 sub x7, x7, #16
38
39 ld2 {v16.2s,v17.2s}, [x7], x12 // d16=x,n1 d17=x,n0
40 ld2 {v0.2s,v1.2s}, [x2], #16 // d0 =m0,x d1 =m1,x
41 rev64 v17.2s, v17.2s
42 ld2 {v2.2s,v3.2s}, [x4], #16 // d2=c0,c1 d3=s0,s2
43 fmul v6.2s, v17.2s, v2.2s
44 fmul v7.2s, v0.2s, v2.2s
451:
46 subs x14, x14, #2
47 ldr w6, [x3], #4
48 fmul v4.2s, v0.2s, v3.2s
49 fmul v5.2s, v17.2s, v3.2s
50 fsub v4.2s, v6.2s, v4.2s
51 fadd v5.2s, v5.2s, v7.2s
52 ubfm x8, x6, #16, #31
53 ubfm x6, x6, #0, #15
54 add x8, x1, x8, lsl #3
55 add x6, x1, x6, lsl #3
56 b.eq 2f
57 ld2 {v16.2s,v17.2s}, [x7], x12
58 ld2 {v0.2s,v1.2s}, [x2], #16
59 rev64 v17.2s, v17.2s
60 ld2 {v2.2s,v3.2s}, [x4], #16 // d2=c0,c1 d3=s0,s2
61 fmul v6.2s, v17.2s, v2.2s
62 fmul v7.2s, v0.2s, v2.2s
63 st2 {v4.s,v5.s}[0], [x6]
64 st2 {v4.s,v5.s}[1], [x8]
65 b 1b
662:
67 st2 {v4.s,v5.s}[0], [x6]
68 st2 {v4.s,v5.s}[1], [x8]
69
70 mov x19, x0
71 mov x20, x1
72 bl X(ff_fft_calc_neon)
73
74 mov x12, #1
75 ldr w14, [x19, #28] // mdct_bits
76 ldr x4, [x19, #32] // tcos
77 lsl x12, x12, x14 // n = 1 << nbits
78 lsr x14, x12, #3 // n8 = n >> 3
79
80 add x4, x4, x14, lsl #3
81 add x6, x20, x14, lsl #3
82 sub x1, x4, #16
83 sub x3, x6, #16
84
85 mov x7, #-16
86 mov x8, x6
87 mov x0, x3
88
89 ld2 {v0.2s,v1.2s}, [x3], x7 // d0 =i1,r1 d1 =i0,r0
90 ld2 {v20.2s,v21.2s},[x6], #16 // d20=i2,r2 d21=i3,r3
91 ld2 {v16.2s,v17.2s},[x1], x7 // d16=c1,c0 d18=s1,s0
923:
93 subs x14, x14, #2
94 fmul v7.2s, v0.2s, v17.2s
95 ld2 {v18.2s,v19.2s},[x4], #16 // d17=c2,c3 d19=s2,s3
96 fmul v4.2s, v1.2s, v17.2s
97 fmul v6.2s, v21.2s, v19.2s
98 fmul v5.2s, v20.2s, v19.2s
99 fmul v22.2s, v1.2s, v16.2s
100 fmul v23.2s, v21.2s, v18.2s
101 fmul v24.2s, v0.2s, v16.2s
102 fmul v25.2s, v20.2s, v18.2s
103 fadd v7.2s, v7.2s, v22.2s
104 fadd v5.2s, v5.2s, v23.2s
105 fsub v4.2s, v4.2s, v24.2s
106 fsub v6.2s, v6.2s, v25.2s
107 b.eq 4f
108 ld2 {v0.2s,v1.2s}, [x3], x7
109 ld2 {v20.2s,v21.2s},[x6], #16
110 ld2 {v16.2s,v17.2s},[x1], x7 // d16=c1,c0 d18=s1,s0
111 rev64 v5.2s, v5.2s
112 rev64 v7.2s, v7.2s
113 st2 {v4.2s,v5.2s}, [x0], x7
114 st2 {v6.2s,v7.2s}, [x8], #16
115 b 3b
1164:
117 rev64 v5.2s, v5.2s
118 rev64 v7.2s, v7.2s
119 st2 {v4.2s,v5.2s}, [x0]
120 st2 {v6.2s,v7.2s}, [x8]
121
122 ldr x30, [sp, #16]
123 AARCH64_VALIDATE_LINK_REGISTER
124 ldp x19, x20, [sp], #32
125
126 ret
127endfunc
128
129function ff_imdct_calc_neon, export=1
130 stp x19, x20, [sp, #-32]!
131 AARCH64_SIGN_LINK_REGISTER
132 str x30, [sp, #16]
133 ldr w3, [x0, #28] // mdct_bits
134 mov x19, #1
135 mov x20, x1
136 lsl x19, x19, x3
137 add x1, x1, x19
138
139 bl X(ff_imdct_half_neon)
140
141 add x0, x20, x19, lsl #2
142 add x1, x20, x19, lsl #1
143 sub x0, x0, #8
144 sub x2, x1, #16
145 mov x3, #-16
146 mov x6, #-8
1471:
148 ld1 {v0.4s}, [x2], x3
149 prfum pldl1keep, [x0, #-16]
150 rev64 v0.4s, v0.4s
151 ld1 {v2.2s,v3.2s}, [x1], #16
152 fneg v4.4s, v0.4s
153 prfum pldl1keep, [x2, #-16]
154 rev64 v2.2s, v2.2s
155 rev64 v3.2s, v3.2s
156 ext v4.16b, v4.16b, v4.16b, #8
157 st1 {v2.2s}, [x0], x6
158 st1 {v3.2s}, [x0], x6
159 st1 {v4.4s}, [x20], #16
160 subs x19, x19, #16
161 b.gt 1b
162
163 ldr x30, [sp, #16]
164 AARCH64_VALIDATE_LINK_REGISTER
165 ldp x19, x20, [sp], #32
166
167 ret
168endfunc
169
170
171function ff_mdct_calc_neon, export=1
172 stp x19, x20, [sp, #-32]!
173 AARCH64_SIGN_LINK_REGISTER
174 str x30, [sp, #16]
175
176 mov x12, #1
177 ldr w14, [x0, #28] // mdct_bits
178 ldr x4, [x0, #32] // tcos
179 ldr x3, [x0, #8] // revtab
180 lsl x14, x12, x14 // n = 1 << nbits
181 add x7, x2, x14 // in4u
182 sub x9, x7, #16 // in4d
183 add x2, x7, x14, lsl #1 // in3u
184 add x8, x9, x14, lsl #1 // in3d
185 add x5, x4, x14, lsl #1
186 sub x5, x5, #16
187 sub x3, x3, #4
188 mov x12, #-16
189 lsr x13, x14, #1
190
191 ld2 {v16.2s,v17.2s}, [x9], x12 // in0u0,in0u1 in4d1,in4d0
192 ld2 {v18.2s,v19.2s}, [x8], x12 // in2u0,in2u1 in3d1,in3d0
193 ld2 {v0.2s, v1.2s}, [x7], #16 // in4u0,in4u1 in2d1,in2d0
194 rev64 v17.2s, v17.2s // in4d0,in4d1 in3d0,in3d1
195 rev64 v19.2s, v19.2s // in4d0,in4d1 in3d0,in3d1
196 ld2 {v2.2s, v3.2s}, [x2], #16 // in3u0,in3u1 in1d1,in1d0
197 fsub v0.2s, v17.2s, v0.2s // in4d-in4u I
198 ld2 {v20.2s,v21.2s}, [x4], #16 // c0,c1 s0,s1
199 rev64 v1.2s, v1.2s // in2d0,in2d1 in1d0,in1d1
200 rev64 v3.2s, v3.2s // in2d0,in2d1 in1d0,in1d1
201 ld2 {v30.2s,v31.2s}, [x5], x12 // c2,c3 s2,s3
202 fadd v2.2s, v2.2s, v19.2s // in3u+in3d -R
203 fsub v16.2s, v16.2s, v1.2s // in0u-in2d R
204 fadd v18.2s, v18.2s, v3.2s // in2u+in1d -I
2051:
206 fmul v7.2s, v0.2s, v21.2s // I*s
207 ldr w10, [x3, x13]
208 fmul v6.2s, v2.2s, v20.2s // -R*c
209 ldr w6, [x3, #4]!
210 fmul v4.2s, v2.2s, v21.2s // -R*s
211 fmul v5.2s, v0.2s, v20.2s // I*c
212 fmul v24.2s, v16.2s, v30.2s // R*c
213 fmul v25.2s, v18.2s, v31.2s // -I*s
214 fmul v22.2s, v16.2s, v31.2s // R*s
215 fmul v23.2s, v18.2s, v30.2s // I*c
216 subs x14, x14, #16
217 subs x13, x13, #8
218 fsub v6.2s, v6.2s, v7.2s // -R*c-I*s
219 fadd v7.2s, v4.2s, v5.2s // -R*s+I*c
220 fsub v24.2s, v25.2s, v24.2s // I*s-R*c
221 fadd v25.2s, v22.2s, v23.2s // R*s-I*c
222 b.eq 1f
223 mov x12, #-16
224 ld2 {v16.2s,v17.2s}, [x9], x12 // in0u0,in0u1 in4d1,in4d0
225 ld2 {v18.2s,v19.2s}, [x8], x12 // in2u0,in2u1 in3d1,in3d0
226 fneg v7.2s, v7.2s // R*s-I*c
227 ld2 {v0.2s, v1.2s}, [x7], #16 // in4u0,in4u1 in2d1,in2d0
228 rev64 v17.2s, v17.2s // in4d0,in4d1 in3d0,in3d1
229 rev64 v19.2s, v19.2s // in4d0,in4d1 in3d0,in3d1
230 ld2 {v2.2s, v3.2s}, [x2], #16 // in3u0,in3u1 in1d1,in1d0
231 fsub v0.2s, v17.2s, v0.2s // in4d-in4u I
232 ld2 {v20.2s,v21.2s}, [x4], #16 // c0,c1 s0,s1
233 rev64 v1.2s, v1.2s // in2d0,in2d1 in1d0,in1d1
234 rev64 v3.2s, v3.2s // in2d0,in2d1 in1d0,in1d1
235 ld2 {v30.2s,v31.2s}, [x5], x12 // c2,c3 s2,s3
236 fadd v2.2s, v2.2s, v19.2s // in3u+in3d -R
237 fsub v16.2s, v16.2s, v1.2s // in0u-in2d R
238 fadd v18.2s, v18.2s, v3.2s // in2u+in1d -I
239 ubfm x12, x6, #16, #31
240 ubfm x6, x6, #0, #15
241 add x12, x1, x12, lsl #3
242 add x6, x1, x6, lsl #3
243 st2 {v6.s,v7.s}[0], [x6]
244 st2 {v6.s,v7.s}[1], [x12]
245 ubfm x6, x10, #16, #31
246 ubfm x10, x10, #0, #15
247 add x6 , x1, x6, lsl #3
248 add x10, x1, x10, lsl #3
249 st2 {v24.s,v25.s}[0], [x10]
250 st2 {v24.s,v25.s}[1], [x6]
251 b 1b
2521:
253 fneg v7.2s, v7.2s // R*s-I*c
254 ubfm x12, x6, #16, #31
255 ubfm x6, x6, #0, #15
256 add x12, x1, x12, lsl #3
257 add x6, x1, x6, lsl #3
258 st2 {v6.s,v7.s}[0], [x6]
259 st2 {v6.s,v7.s}[1], [x12]
260 ubfm x6, x10, #16, #31
261 ubfm x10, x10, #0, #15
262 add x6 , x1, x6, lsl #3
263 add x10, x1, x10, lsl #3
264 st2 {v24.s,v25.s}[0], [x10]
265 st2 {v24.s,v25.s}[1], [x6]
266
267 mov x19, x0
268 mov x20, x1
269 bl X(ff_fft_calc_neon)
270
271 mov x12, #1
272 ldr w14, [x19, #28] // mdct_bits
273 ldr x4, [x19, #32] // tcos
274 lsl x12, x12, x14 // n = 1 << nbits
275 lsr x14, x12, #3 // n8 = n >> 3
276
277 add x4, x4, x14, lsl #3
278 add x6, x20, x14, lsl #3
279 sub x1, x4, #16
280 sub x3, x6, #16
281
282 mov x7, #-16
283 mov x8, x6
284 mov x0, x3
285
286 ld2 {v0.2s,v1.2s}, [x3], x7 // d0 =r1,i1 d1 =r0,i0
287 ld2 {v20.2s,v21.2s}, [x6], #16 // d20=r2,i2 d21=r3,i3
288 ld2 {v16.2s,v17.2s}, [x1], x7 // c1,c0 s1,s0
2891:
290 subs x14, x14, #2
291 fmul v7.2s, v0.2s, v17.2s // r1*s1,r0*s0
292 ld2 {v18.2s,v19.2s}, [x4], #16 // c2,c3 s2,s3
293 fmul v4.2s, v1.2s, v17.2s // i1*s1,i0*s0
294 fmul v6.2s, v21.2s, v19.2s // i2*s2,i3*s3
295 fmul v5.2s, v20.2s, v19.2s // r2*s2,r3*s3
296 fmul v24.2s, v0.2s, v16.2s // r1*c1,r0*c0
297 fmul v25.2s, v20.2s, v18.2s // r2*c2,r3*c3
298 fmul v22.2s, v21.2s, v18.2s // i2*c2,i3*c3
299 fmul v23.2s, v1.2s, v16.2s // i1*c1,i0*c0
300 fadd v4.2s, v4.2s, v24.2s // i1*s1+r1*c1,i0*s0+r0*c0
301 fadd v6.2s, v6.2s, v25.2s // i2*s2+r2*c2,i3*s3+r3*c3
302 fsub v5.2s, v22.2s, v5.2s // i2*c2-r2*s2,i3*c3-r3*s3
303 fsub v7.2s, v23.2s, v7.2s // i1*c1-r1*s1,i0*c0-r0*s0
304 fneg v4.2s, v4.2s
305 fneg v6.2s, v6.2s
306 b.eq 1f
307 ld2 {v0.2s, v1.2s}, [x3], x7
308 ld2 {v20.2s,v21.2s}, [x6], #16
309 ld2 {v16.2s,v17.2s}, [x1], x7 // c1,c0 s1,s0
310 rev64 v5.2s, v5.2s
311 rev64 v7.2s, v7.2s
312 st2 {v4.2s,v5.2s}, [x0], x7
313 st2 {v6.2s,v7.2s}, [x8], #16
314 b 1b
3151:
316 rev64 v5.2s, v5.2s
317 rev64 v7.2s, v7.2s
318 st2 {v4.2s,v5.2s}, [x0]
319 st2 {v6.2s,v7.2s}, [x8]
320
321 ldr x30, [sp, #16]
322 AARCH64_VALIDATE_LINK_REGISTER
323 ldp x19, x20, [sp], #32
324
325 ret
326endfunc
libavcodec/aarch64/synth_filter_init.c+0−7
@@ -23,15 +23,8 @@ · 22 unmodified lines
23#include "libavutil/aarch64/cpu.h"23#include "libavutil/aarch64/cpu.h"
24#include "libavutil/attributes.h"24#include "libavutil/attributes.h"
25#include "libavutil/internal.h"25#include "libavutil/internal.h"
26#include "libavcodec/fft.h"
27#include "libavcodec/synth_filter.h"26#include "libavcodec/synth_filter.h"
28 27
29#include "asm-offsets.h"
30
31#if HAVE_NEON
32AV_CHECK_OFFSET(FFTContext, imdct_half, IMDCT_HALF);
33#endif
34
35void ff_synth_filter_float_neon(AVTXContext *imdct,28void ff_synth_filter_float_neon(AVTXContext *imdct,
36 float *synth_buf_ptr, int *synth_buf_offset,29 float *synth_buf_ptr, int *synth_buf_offset,
37 float synth_buf2[32], const float window[512],30 float synth_buf2[32], const float window[512],
libavcodec/aarch64/synth_filter_neon.S+0−2
@@ -19,8 +19,6 @@ · 18 unmodified lines
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */20 */
21 21
22#include "asm-offsets.h"
23
24#include "libavutil/aarch64/asm.S"22#include "libavutil/aarch64/asm.S"
25 23
26.macro inner_loop24.macro inner_loop
libavcodec/arm/Makefile+0−7
@@ -5,7 +5,6 @@ OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_init_arm.o \ · 4 unmodified lines
5 arm/ac3dsp_arm.o5 arm/ac3dsp_arm.o
6OBJS-$(CONFIG_AUDIODSP) += arm/audiodsp_init_arm.o6OBJS-$(CONFIG_AUDIODSP) += arm/audiodsp_init_arm.o
7OBJS-$(CONFIG_BLOCKDSP) += arm/blockdsp_init_arm.o7OBJS-$(CONFIG_BLOCKDSP) += arm/blockdsp_init_arm.o
8OBJS-$(CONFIG_FFT) += arm/fft_init_arm.o
9OBJS-$(CONFIG_FMTCONVERT) += arm/fmtconvert_init_arm.o8OBJS-$(CONFIG_FMTCONVERT) += arm/fmtconvert_init_arm.o
10OBJS-$(CONFIG_G722DSP) += arm/g722dsp_init_arm.o9OBJS-$(CONFIG_G722DSP) += arm/g722dsp_init_arm.o
11OBJS-$(CONFIG_H264CHROMA) += arm/h264chroma_init_arm.o10OBJS-$(CONFIG_H264CHROMA) += arm/h264chroma_init_arm.o
@@ -25,7 +24,6 @@ OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_arm.o · 13 unmodified lines
25OBJS-$(CONFIG_MPEGVIDEOENC) += arm/mpegvideoencdsp_init_arm.o24OBJS-$(CONFIG_MPEGVIDEOENC) += arm/mpegvideoencdsp_init_arm.o
26OBJS-$(CONFIG_NEON_CLOBBER_TEST) += arm/neontest.o25OBJS-$(CONFIG_NEON_CLOBBER_TEST) += arm/neontest.o
27OBJS-$(CONFIG_PIXBLOCKDSP) += arm/pixblockdsp_init_arm.o26OBJS-$(CONFIG_PIXBLOCKDSP) += arm/pixblockdsp_init_arm.o
28OBJS-$(CONFIG_RDFT) += arm/rdft_init_arm.o
29OBJS-$(CONFIG_RV34DSP) += arm/rv34dsp_init_arm.o27OBJS-$(CONFIG_RV34DSP) += arm/rv34dsp_init_arm.o
30OBJS-$(CONFIG_VC1DSP) += arm/vc1dsp_init_arm.o28OBJS-$(CONFIG_VC1DSP) += arm/vc1dsp_init_arm.o
31OBJS-$(CONFIG_VIDEODSP) += arm/videodsp_init_arm.o29OBJS-$(CONFIG_VIDEODSP) += arm/videodsp_init_arm.o
@@ -90,9 +88,7 @@ ARMV6-OBJS-$(CONFIG_TRUEHD_DECODER) += arm/mlpdsp_armv6.o · 58 unmodified lines
90# VFP optimizations88# VFP optimizations
91 89
92# subsystems90# subsystems
93VFP-OBJS-$(CONFIG_FFT) += arm/fft_vfp.o
94VFP-OBJS-$(CONFIG_FMTCONVERT) += arm/fmtconvert_vfp.o91VFP-OBJS-$(CONFIG_FMTCONVERT) += arm/fmtconvert_vfp.o
95VFP-OBJS-$(CONFIG_MDCT) += arm/mdct_vfp.o
96 92
97# decoders/encoders93# decoders/encoders
98VFP-OBJS-$(CONFIG_DCA_DECODER) += arm/synth_filter_vfp.o94VFP-OBJS-$(CONFIG_DCA_DECODER) += arm/synth_filter_vfp.o
@@ -107,7 +103,6 @@ NEON-OBJS-$(CONFIG_AUDIODSP) += arm/audiodsp_init_neon.o \ · 8 unmodified lines
107 arm/int_neon.o103 arm/int_neon.o
108NEON-OBJS-$(CONFIG_BLOCKDSP) += arm/blockdsp_init_neon.o \104NEON-OBJS-$(CONFIG_BLOCKDSP) += arm/blockdsp_init_neon.o \
109 arm/blockdsp_neon.o105 arm/blockdsp_neon.o
110NEON-OBJS-$(CONFIG_FFT) += arm/fft_neon.o
111NEON-OBJS-$(CONFIG_FMTCONVERT) += arm/fmtconvert_neon.o106NEON-OBJS-$(CONFIG_FMTCONVERT) += arm/fmtconvert_neon.o
112NEON-OBJS-$(CONFIG_G722DSP) += arm/g722dsp_neon.o107NEON-OBJS-$(CONFIG_G722DSP) += arm/g722dsp_neon.o
113NEON-OBJS-$(CONFIG_H264CHROMA) += arm/h264cmc_neon.o108NEON-OBJS-$(CONFIG_H264CHROMA) += arm/h264cmc_neon.o
@@ -121,10 +116,8 @@ NEON-OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_neon.o \ · 7 unmodified lines
121NEON-OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_neon.o \116NEON-OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_neon.o \
122 arm/idctdsp_neon.o \117 arm/idctdsp_neon.o \
123 arm/simple_idct_neon.o118 arm/simple_idct_neon.o
124NEON-OBJS-$(CONFIG_MDCT) += arm/mdct_neon.o
125NEON-OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_neon.o119NEON-OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_neon.o
126NEON-OBJS-$(CONFIG_PIXBLOCKDSP) += arm/pixblockdsp_neon.o120NEON-OBJS-$(CONFIG_PIXBLOCKDSP) += arm/pixblockdsp_neon.o
127NEON-OBJS-$(CONFIG_RDFT) += arm/rdft_neon.o
128NEON-OBJS-$(CONFIG_VC1DSP) += arm/vc1dsp_init_neon.o \121NEON-OBJS-$(CONFIG_VC1DSP) += arm/vc1dsp_init_neon.o \
129 arm/vc1dsp_neon.o122 arm/vc1dsp_neon.o
130NEON-OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_neon.o123NEON-OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_neon.o
libavcodec/arm/fft_init_arm.c+0−63
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "libavutil/attributes.h"
22#include "libavutil/cpu.h"
23#include "libavutil/arm/cpu.h"
24
25#include "libavcodec/fft.h"
26
27void ff_fft_calc_vfp(FFTContext *s, FFTComplex *z);
28
29void ff_fft_permute_neon(FFTContext *s, FFTComplex *z);
30void ff_fft_calc_neon(FFTContext *s, FFTComplex *z);
31
32void ff_imdct_half_vfp(FFTContext *s, FFTSample *output, const FFTSample *input);
33
34void ff_imdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input);
35void ff_imdct_half_neon(FFTContext *s, FFTSample *output, const FFTSample *input);
36void ff_mdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input);
37
38av_cold void ff_fft_init_arm(FFTContext *s)
39{
40 int cpu_flags = av_get_cpu_flags();
41
42 if (have_vfp_vm(cpu_flags)) {
43 s->fft_calc = ff_fft_calc_vfp;
44#if CONFIG_MDCT
45 s->imdct_half = ff_imdct_half_vfp;
46#endif
47 }
48
49 if (have_neon(cpu_flags)) {
50#if CONFIG_FFT
51 if (s->nbits < 17) {
52 s->fft_permute = ff_fft_permute_neon;
53 s->fft_calc = ff_fft_calc_neon;
54 }
55#endif
56#if CONFIG_MDCT
57 s->imdct_calc = ff_imdct_calc_neon;
58 s->imdct_half = ff_imdct_half_neon;
59 s->mdct_calc = ff_mdct_calc_neon;
60 s->mdct_permutation = FF_MDCT_PERM_INTERLEAVE;
61#endif
62 }
63}
libavcodec/arm/fft_neon.S+0−375
@@ -1,375 +0,0 @@
1/*
2 * ARM NEON optimised FFT
3 *
4 * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
5 * Copyright (c) 2009 Naotoshi Nojiri
6 *
7 * This algorithm (though not any of the implementation details) is
8 * based on libdjbfft by D. J. Bernstein.
9 *
10 * This file is part of FFmpeg.
11 *
12 * FFmpeg is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * FFmpeg is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with FFmpeg; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27#include "libavutil/arm/asm.S"
28
29#define M_SQRT1_2 0.70710678118654752440
30
31
32function fft4_neon
33 vld1.32 {d0-d3}, [r0,:128]
34
35 vext.32 q8, q1, q1, #1 @ i2,r3 d3=i3,r2
36 vsub.f32 d6, d0, d1 @ r0-r1,i0-i1
37 vsub.f32 d7, d16, d17 @ r3-r2,i2-i3
38 vadd.f32 d4, d0, d1 @ r0+r1,i0+i1
39 vadd.f32 d5, d2, d3 @ i2+i3,r2+r3
40 vadd.f32 d1, d6, d7
41 vsub.f32 d3, d6, d7
42 vadd.f32 d0, d4, d5
43 vsub.f32 d2, d4, d5
44
45 vst1.32 {d0-d3}, [r0,:128]
46
47 bx lr
48endfunc
49
50function fft8_neon
51 mov r1, r0
52 vld1.32 {d0-d3}, [r1,:128]!
53 vld1.32 {d16-d19}, [r1,:128]
54
55 movw r2, #0x04f3 @ sqrt(1/2)
56 movt r2, #0x3f35
57 eor r3, r2, #1<<31
58 vdup.32 d31, r2
59
60 vext.32 q11, q1, q1, #1 @ i2,r3,i3,r2
61 vadd.f32 d4, d16, d17 @ r4+r5,i4+i5
62 vmov d28, r3, r2
63 vadd.f32 d5, d18, d19 @ r6+r7,i6+i7
64 vsub.f32 d17, d16, d17 @ r4-r5,i4-i5
65 vsub.f32 d19, d18, d19 @ r6-r7,i6-i7
66 vrev64.32 d29, d28
67 vadd.f32 d20, d0, d1 @ r0+r1,i0+i1
68 vadd.f32 d21, d2, d3 @ r2+r3,i2+i3
69 vmul.f32 d26, d17, d28 @ -a2r*w,a2i*w
70 vext.32 q3, q2, q2, #1
71 vmul.f32 d27, d19, d29 @ a3r*w,-a3i*w
72 vsub.f32 d23, d22, d23 @ i2-i3,r3-r2
73 vsub.f32 d22, d0, d1 @ r0-r1,i0-i1
74 vmul.f32 d24, d17, d31 @ a2r*w,a2i*w
75 vmul.f32 d25, d19, d31 @ a3r*w,a3i*w
76 vadd.f32 d0, d20, d21
77 vsub.f32 d2, d20, d21
78 vadd.f32 d1, d22, d23
79 vrev64.32 q13, q13
80 vsub.f32 d3, d22, d23
81 vsub.f32 d6, d6, d7
82 vadd.f32 d24, d24, d26 @ a2r+a2i,a2i-a2r t1,t2
83 vadd.f32 d25, d25, d27 @ a3r-a3i,a3i+a3r t5,t6
84 vadd.f32 d7, d4, d5
85 vsub.f32 d18, d2, d6
86 vext.32 q13, q12, q12, #1
87 vadd.f32 d2, d2, d6
88 vsub.f32 d16, d0, d7
89 vadd.f32 d5, d25, d24
90 vsub.f32 d4, d26, d27
91 vadd.f32 d0, d0, d7
92 vsub.f32 d17, d1, d5
93 vsub.f32 d19, d3, d4
94 vadd.f32 d3, d3, d4
95 vadd.f32 d1, d1, d5
96
97 vst1.32 {d16-d19}, [r1,:128]
98 vst1.32 {d0-d3}, [r0,:128]
99
100 bx lr
101endfunc
102
103function fft16_neon
104 movrel r1, mppm
105 vld1.32 {d16-d19}, [r0,:128]! @ q8{r0,i0,r1,i1} q9{r2,i2,r3,i3}
106 pld [r0, #32]
107 vld1.32 {d2-d3}, [r1,:128]
108 vext.32 q13, q9, q9, #1
109 vld1.32 {d22-d25}, [r0,:128]! @ q11{r4,i4,r5,i5} q12{r6,i5,r7,i7}
110 vadd.f32 d4, d16, d17
111 vsub.f32 d5, d16, d17
112 vadd.f32 d18, d18, d19
113 vsub.f32 d19, d26, d27
114
115 vadd.f32 d20, d22, d23
116 vsub.f32 d22, d22, d23
117 vsub.f32 d23, d24, d25
118 vadd.f32 q8, q2, q9 @ {r0,i0,r1,i1}
119 vadd.f32 d21, d24, d25
120 vmul.f32 d24, d22, d2
121 vsub.f32 q9, q2, q9 @ {r2,i2,r3,i3}
122 vmul.f32 d25, d23, d3
123 vuzp.32 d16, d17 @ {r0,r1,i0,i1}
124 vmul.f32 q1, q11, d2[1]
125 vuzp.32 d18, d19 @ {r2,r3,i2,i3}
126 vrev64.32 q12, q12
127 vadd.f32 q11, q12, q1 @ {t1a,t2a,t5,t6}
128 vld1.32 {d24-d27}, [r0,:128]! @ q12{r8,i8,r9,i9} q13{r10,i10,r11,i11}
129 vzip.32 q10, q11
130 vld1.32 {d28-d31}, [r0,:128] @ q14{r12,i12,r13,i13} q15{r14,i14,r15,i15}
131 vadd.f32 d0, d22, d20
132 vadd.f32 d1, d21, d23
133 vsub.f32 d2, d21, d23
134 vsub.f32 d3, d22, d20
135 sub r0, r0, #96
136 vext.32 q13, q13, q13, #1
137 vsub.f32 q10, q8, q0 @ {r4,r5,i4,i5}
138 vadd.f32 q8, q8, q0 @ {r0,r1,i0,i1}
139 vext.32 q15, q15, q15, #1
140 vsub.f32 q11, q9, q1 @ {r6,r7,i6,i7}
141 vswp d25, d26 @ q12{r8,i8,i10,r11} q13{r9,i9,i11,r10}
142 vadd.f32 q9, q9, q1 @ {r2,r3,i2,i3}
143 vswp d29, d30 @ q14{r12,i12,i14,r15} q15{r13,i13,i15,r14}
144 vadd.f32 q0, q12, q13 @ {t1,t2,t5,t6}
145 vadd.f32 q1, q14, q15 @ {t1a,t2a,t5a,t6a}
146 movrelx r2, X(ff_cos_16)
147 vsub.f32 q13, q12, q13 @ {t3,t4,t7,t8}
148 vrev64.32 d1, d1
149 vsub.f32 q15, q14, q15 @ {t3a,t4a,t7a,t8a}
150 vrev64.32 d3, d3
151 movrel r3, pmmp
152 vswp d1, d26 @ q0{t1,t2,t3,t4} q13{t6,t5,t7,t8}
153 vswp d3, d30 @ q1{t1a,t2a,t3a,t4a} q15{t6a,t5a,t7a,t8a}
154 vadd.f32 q12, q0, q13 @ {r8,i8,r9,i9}
155 vadd.f32 q14, q1, q15 @ {r12,i12,r13,i13}
156 vld1.32 {d4-d5}, [r2,:64]
157 vsub.f32 q13, q0, q13 @ {r10,i10,r11,i11}
158 vsub.f32 q15, q1, q15 @ {r14,i14,r15,i15}
159 vswp d25, d28 @ q12{r8,i8,r12,i12} q14{r9,i9,r13,i13}
160 vld1.32 {d6-d7}, [r3,:128]
161 vrev64.32 q1, q14
162 vmul.f32 q14, q14, d4[1]
163 vmul.f32 q1, q1, q3
164 vmla.f32 q14, q1, d5[1] @ {t1a,t2a,t5a,t6a}
165 vswp d27, d30 @ q13{r10,i10,r14,i14} q15{r11,i11,r15,i15}
166 vzip.32 q12, q14
167 vadd.f32 d0, d28, d24
168 vadd.f32 d1, d25, d29
169 vsub.f32 d2, d25, d29
170 vsub.f32 d3, d28, d24
171 vsub.f32 q12, q8, q0 @ {r8,r9,i8,i9}
172 vadd.f32 q8, q8, q0 @ {r0,r1,i0,i1}
173 vsub.f32 q14, q10, q1 @ {r12,r13,i12,i13}
174 mov r1, #32
175 vadd.f32 q10, q10, q1 @ {r4,r5,i4,i5}
176 vrev64.32 q0, q13
177 vmul.f32 q13, q13, d5[0]
178 vrev64.32 q1, q15
179 vmul.f32 q15, q15, d5[1]
180 vst2.32 {d16-d17},[r0,:128], r1
181 vmul.f32 q0, q0, q3
182 vst2.32 {d20-d21},[r0,:128], r1
183 vmul.f32 q1, q1, q3
184 vmla.f32 q13, q0, d5[0] @ {t1,t2,t5,t6}
185 vmla.f32 q15, q1, d4[1] @ {t1a,t2a,t5a,t6a}
186 vst2.32 {d24-d25},[r0,:128], r1
187 vst2.32 {d28-d29},[r0,:128]
188 vzip.32 q13, q15
189 sub r0, r0, #80
190 vadd.f32 d0, d30, d26
191 vadd.f32 d1, d27, d31
192 vsub.f32 d2, d27, d31
193 vsub.f32 d3, d30, d26
194 vsub.f32 q13, q9, q0 @ {r10,r11,i10,i11}
195 vadd.f32 q9, q9, q0 @ {r2,r3,i2,i3}
196 vsub.f32 q15, q11, q1 @ {r14,r15,i14,i15}
197 vadd.f32 q11, q11, q1 @ {r6,r7,i6,i7}
198 vst2.32 {d18-d19},[r0,:128], r1
199 vst2.32 {d22-d23},[r0,:128], r1
200 vst2.32 {d26-d27},[r0,:128], r1
201 vst2.32 {d30-d31},[r0,:128]
202 bx lr
203endfunc
204
205function fft_pass_neon
206 push {r4-r6,lr}
207 mov r6, r2 @ n
208 lsl r5, r2, #3 @ 2 * n * sizeof FFTSample
209 lsl r4, r2, #4 @ 2 * n * sizeof FFTComplex
210 lsl r2, r2, #5 @ 4 * n * sizeof FFTComplex
211 add r3, r2, r4
212 add r4, r4, r0 @ &z[o1]
213 add r2, r2, r0 @ &z[o2]
214 add r3, r3, r0 @ &z[o3]
215 vld1.32 {d20-d21},[r2,:128] @ {z[o2],z[o2+1]}
216 movrel r12, pmmp
217 vld1.32 {d22-d23},[r3,:128] @ {z[o3],z[o3+1]}
218 add r5, r5, r1 @ wim
219 vld1.32 {d6-d7}, [r12,:128] @ pmmp
220 vswp d21, d22
221 vld1.32 {d4}, [r1,:64]! @ {wre[0],wre[1]}
222 sub r5, r5, #4 @ wim--
223 vrev64.32 q1, q11
224 vmul.f32 q11, q11, d4[1]
225 vmul.f32 q1, q1, q3
226 vld1.32 {d5[0]}, [r5,:32] @ d5[0] = wim[-1]
227 vmla.f32 q11, q1, d5[0] @ {t1a,t2a,t5a,t6a}
228 vld2.32 {d16-d17},[r0,:128] @ {z[0],z[1]}
229 sub r6, r6, #1 @ n--
230 vld2.32 {d18-d19},[r4,:128] @ {z[o1],z[o1+1]}
231 vzip.32 q10, q11
232 vadd.f32 d0, d22, d20
233 vadd.f32 d1, d21, d23
234 vsub.f32 d2, d21, d23
235 vsub.f32 d3, d22, d20
236 vsub.f32 q10, q8, q0
237 vadd.f32 q8, q8, q0
238 vsub.f32 q11, q9, q1
239 vadd.f32 q9, q9, q1
240 vst2.32 {d20-d21},[r2,:128]! @ {z[o2],z[o2+1]}
241 vst2.32 {d16-d17},[r0,:128]! @ {z[0],z[1]}
242 vst2.32 {d22-d23},[r3,:128]! @ {z[o3],z[o3+1]}
243 vst2.32 {d18-d19},[r4,:128]! @ {z[o1],z[o1+1]}
244 sub r5, r5, #8 @ wim -= 2
2451:
246 vld1.32 {d20-d21},[r2,:128] @ {z[o2],z[o2+1]}
247 vld1.32 {d22-d23},[r3,:128] @ {z[o3],z[o3+1]}
248 vswp d21, d22
249 vld1.32 {d4}, [r1]! @ {wre[0],wre[1]}
250 vrev64.32 q0, q10
251 vmul.f32 q10, q10, d4[0]
252 vrev64.32 q1, q11
253 vmul.f32 q11, q11, d4[1]
254 vld1.32 {d5}, [r5] @ {wim[-1],wim[0]}
255 vmul.f32 q0, q0, q3
256 sub r5, r5, #8 @ wim -= 2
257 vmul.f32 q1, q1, q3
258 vmla.f32 q10, q0, d5[1] @ {t1,t2,t5,t6}
259 vmla.f32 q11, q1, d5[0] @ {t1a,t2a,t5a,t6a}
260 vld2.32 {d16-d17},[r0,:128] @ {z[0],z[1]}
261 subs r6, r6, #1 @ n--
262 vld2.32 {d18-d19},[r4,:128] @ {z[o1],z[o1+1]}
263 vzip.32 q10, q11
264 vadd.f32 d0, d22, d20
265 vadd.f32 d1, d21, d23
266 vsub.f32 d2, d21, d23
267 vsub.f32 d3, d22, d20
268 vsub.f32 q10, q8, q0
269 vadd.f32 q8, q8, q0
270 vsub.f32 q11, q9, q1
271 vadd.f32 q9, q9, q1
272 vst2.32 {d20-d21}, [r2,:128]! @ {z[o2],z[o2+1]}
273 vst2.32 {d16-d17}, [r0,:128]! @ {z[0],z[1]}
274 vst2.32 {d22-d23}, [r3,:128]! @ {z[o3],z[o3+1]}
275 vst2.32 {d18-d19}, [r4,:128]! @ {z[o1],z[o1+1]}
276 bne 1b
277
278 pop {r4-r6,pc}
279endfunc
280
281.macro def_fft n, n2, n4
282 .align 6
283function fft\n\()_neon
284 push {r4, lr}
285 mov r4, r0
286 bl fft\n2\()_neon
287 add r0, r4, #\n4*2*8
288 bl fft\n4\()_neon
289 add r0, r4, #\n4*3*8
290 bl fft\n4\()_neon
291 mov r0, r4
292 pop {r4, lr}
293 movrelx r1, X(ff_cos_\n)
294 mov r2, #\n4/2
295 b fft_pass_neon
296endfunc
297.endm
298
299 def_fft 32, 16, 8
300 def_fft 64, 32, 16
301 def_fft 128, 64, 32
302 def_fft 256, 128, 64
303 def_fft 512, 256, 128
304 def_fft 1024, 512, 256
305 def_fft 2048, 1024, 512
306 def_fft 4096, 2048, 1024
307 def_fft 8192, 4096, 2048
308 def_fft 16384, 8192, 4096
309 def_fft 32768, 16384, 8192
310 def_fft 65536, 32768, 16384
311
312function ff_fft_calc_neon, export=1
313 ldr r2, [r0]
314 sub r2, r2, #2
315 movrel r3, fft_tab_neon
316 ldr r3, [r3, r2, lsl #2]
317 mov r0, r1
318 bx r3
319endfunc
320
321function ff_fft_permute_neon, export=1
322 push {r4,lr}
323 mov r12, #1
324 ldr r2, [r0] @ nbits
325 ldr r3, [r0, #12] @ tmp_buf
326 ldr r0, [r0, #8] @ revtab
327 lsl r12, r12, r2
328 mov r2, r12
3291:
330 vld1.32 {d0-d1}, [r1,:128]!
331 ldr r4, [r0], #4
332 uxth lr, r4
333 uxth r4, r4, ror #16
334 add lr, r3, lr, lsl #3
335 add r4, r3, r4, lsl #3
336 vst1.32 {d0}, [lr,:64]
337 vst1.32 {d1}, [r4,:64]
338 subs r12, r12, #2
339 bgt 1b
340
341 sub r1, r1, r2, lsl #3
3421:
343 vld1.32 {d0-d3}, [r3,:128]!
344 vst1.32 {d0-d3}, [r1,:128]!
345 subs r2, r2, #4
346 bgt 1b
347
348 pop {r4,pc}
349endfunc
350
351const fft_tab_neon, relocate=1
352 .word fft4_neon
353 .word fft8_neon
354 .word fft16_neon
355 .word fft32_neon
356 .word fft64_neon
357 .word fft128_neon
358 .word fft256_neon
359 .word fft512_neon
360 .word fft1024_neon
361 .word fft2048_neon
362 .word fft4096_neon
363 .word fft8192_neon
364 .word fft16384_neon
365 .word fft32768_neon
366 .word fft65536_neon
367endconst
368
369const pmmp, align=4
370 .float +1.0, -1.0, -1.0, +1.0
371endconst
372
373const mppm, align=4
374 .float -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2
375endconst
libavcodec/arm/fft_vfp.S+0−530
@@ -1,530 +0,0 @@
1/*
2 * Copyright (c) 2013 RISC OS Open Ltd
3 * Author: Ben Avison <bavison@riscosopen.org>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include "libavutil/arm/asm.S"
23
24@ The fftx_internal_vfp versions of the functions obey a modified AAPCS:
25@ VFP is in RunFast mode, vector length 4, stride 1 thoroughout, and
26@ all single-precision VFP registers may be corrupted on exit. The a2
27@ register may not be clobbered in these functions, as it holds the
28@ stored original FPSCR.
29
30function ff_fft_calc_vfp, export=1
31 ldr ip, [a1, #0] @ nbits
32 mov a1, a2
33 movrel a2, (fft_tab_vfp - 8)
34 ldr pc, [a2, ip, lsl #2]
35endfunc
36const fft_tab_vfp, relocate=1
37 .word fft4_vfp
38 .word fft8_vfp
39 .word X(ff_fft16_vfp) @ this one alone is exported
40 .word fft32_vfp
41 .word fft64_vfp
42 .word fft128_vfp
43 .word fft256_vfp
44 .word fft512_vfp
45 .word fft1024_vfp
46 .word fft2048_vfp
47 .word fft4096_vfp
48 .word fft8192_vfp
49 .word fft16384_vfp
50 .word fft32768_vfp
51 .word fft65536_vfp
52endconst
53
54function fft4_vfp
55 vldr d0, [a1, #0*2*4] @ s0,s1 = z[0]
56 vldr d4, [a1, #1*2*4] @ s8,s9 = z[1]
57 vldr d1, [a1, #2*2*4] @ s2,s3 = z[2]
58 vldr d5, [a1, #3*2*4] @ s10,s11 = z[3]
59 @ stall
60 vadd.f s12, s0, s8 @ i0
61 vadd.f s13, s1, s9 @ i1
62 vadd.f s14, s2, s10 @ i2
63 vadd.f s15, s3, s11 @ i3
64 vsub.f s8, s0, s8 @ i4
65 vsub.f s9, s1, s9 @ i5
66 vsub.f s10, s2, s10 @ i6
67 vsub.f s11, s3, s11 @ i7
68 @ stall
69 @ stall
70 vadd.f s0, s12, s14 @ z[0].re
71 vsub.f s4, s12, s14 @ z[2].re
72 vadd.f s1, s13, s15 @ z[0].im
73 vsub.f s5, s13, s15 @ z[2].im
74 vadd.f s7, s9, s10 @ z[3].im
75 vsub.f s3, s9, s10 @ z[1].im
76 vadd.f s2, s8, s11 @ z[1].re
77 vsub.f s6, s8, s11 @ z[3].re
78 @ stall
79 @ stall
80 vstr d0, [a1, #0*2*4]
81 vstr d2, [a1, #2*2*4]
82 @ stall
83 @ stall
84 vstr d1, [a1, #1*2*4]
85 vstr d3, [a1, #3*2*4]
86
87 bx lr
88endfunc
89
90.macro macro_fft8_head
91 @ FFT4
92 vldr d4, [a1, #0 * 2*4]
93 vldr d6, [a1, #1 * 2*4]
94 vldr d5, [a1, #2 * 2*4]
95 vldr d7, [a1, #3 * 2*4]
96 @ BF
97 vldr d12, [a1, #4 * 2*4]
98 vadd.f s16, s8, s12 @ vector op
99 vldr d14, [a1, #5 * 2*4]
100 vldr d13, [a1, #6 * 2*4]
101 vldr d15, [a1, #7 * 2*4]
102 vsub.f s20, s8, s12 @ vector op
103 vadd.f s0, s16, s18
104 vsub.f s2, s16, s18
105 vadd.f s1, s17, s19
106 vsub.f s3, s17, s19
107 vadd.f s7, s21, s22
108 vsub.f s5, s21, s22
109 vadd.f s4, s20, s23
110 vsub.f s6, s20, s23
111 vsub.f s20, s24, s28 @ vector op
112 vstr d0, [a1, #0 * 2*4] @ transfer s0-s7 to s24-s31 via memory
113 vstr d1, [a1, #1 * 2*4]
114 vldr s0, cos1pi4
115 vadd.f s16, s24, s28 @ vector op
116 vstr d2, [a1, #2 * 2*4]
117 vstr d3, [a1, #3 * 2*4]
118 vldr d12, [a1, #0 * 2*4]
119 @ TRANSFORM
120 vmul.f s20, s20, s0 @ vector x scalar op
121 vldr d13, [a1, #1 * 2*4]
122 vldr d14, [a1, #2 * 2*4]
123 vldr d15, [a1, #3 * 2*4]
124 @ BUTTERFLIES
125 vadd.f s0, s18, s16
126 vadd.f s1, s17, s19
127 vsub.f s2, s17, s19
128 vsub.f s3, s18, s16
129 vadd.f s4, s21, s20
130 vsub.f s5, s21, s20
131 vadd.f s6, s22, s23
132 vsub.f s7, s22, s23
133 vadd.f s8, s0, s24 @ vector op
134 vstr d0, [a1, #0 * 2*4] @ transfer s0-s3 to s12-s15 via memory
135 vstr d1, [a1, #1 * 2*4]
136 vldr d6, [a1, #0 * 2*4]
137 vldr d7, [a1, #1 * 2*4]
138 vadd.f s1, s5, s6
139 vadd.f s0, s7, s4
140 vsub.f s2, s5, s6
141 vsub.f s3, s7, s4
142 vsub.f s12, s24, s12 @ vector op
143 vsub.f s5, s29, s1
144 vsub.f s4, s28, s0
145 vsub.f s6, s30, s2
146 vsub.f s7, s31, s3
147 vadd.f s16, s0, s28 @ vector op
148 vstr d6, [a1, #4 * 2*4]
149 vstr d7, [a1, #6 * 2*4]
150 vstr d4, [a1, #0 * 2*4]
151 vstr d5, [a1, #2 * 2*4]
152 vstr d2, [a1, #5 * 2*4]
153 vstr d3, [a1, #7 * 2*4]
154.endm
155
156.macro macro_fft8_tail
157 vstr d8, [a1, #1 * 2*4]
158 vstr d9, [a1, #3 * 2*4]
159.endm
160
161function .Lfft8_internal_vfp
162 macro_fft8_head
163 macro_fft8_tail
164 bx lr
165endfunc
166
167function fft8_vfp
168 ldr a3, =0x03030000 @ RunFast mode, vector length 4, stride 1
169 fmrx a2, FPSCR
170 fmxr FPSCR, a3
171 vpush {s16-s31}
172 mov ip, lr
173 bl .Lfft8_internal_vfp
174 vpop {s16-s31}
175 fmxr FPSCR, a2
176 bx ip
177endfunc
178
179.align 3
180cos1pi4: @ cos(1*pi/4) = sqrt(2)
181 .float 0.707106769084930419921875
182cos1pi8: @ cos(1*pi/8) = sqrt(2+sqrt(2))/2
183 .float 0.92387950420379638671875
184cos3pi8: @ cos(2*pi/8) = sqrt(2-sqrt(2))/2
185 .float 0.3826834261417388916015625
186
187function .Lfft16_internal_vfp
188 macro_fft8_head
189 @ FFT4(z+8)
190 vldr d10, [a1, #8 * 2*4]
191 vldr d12, [a1, #9 * 2*4]
192 vldr d11, [a1, #10 * 2*4]
193 vldr d13, [a1, #11 * 2*4]
194 macro_fft8_tail
195 vadd.f s16, s20, s24 @ vector op
196 @ FFT4(z+12)
197 vldr d4, [a1, #12 * 2*4]
198 vldr d6, [a1, #13 * 2*4]
199 vldr d5, [a1, #14 * 2*4]
200 vsub.f s20, s20, s24 @ vector op
201 vldr d7, [a1, #15 * 2*4]
202 vadd.f s0, s16, s18
203 vsub.f s4, s16, s18
204 vadd.f s1, s17, s19
205 vsub.f s5, s17, s19
206 vadd.f s7, s21, s22
207 vsub.f s3, s21, s22
208 vadd.f s2, s20, s23
209 vsub.f s6, s20, s23
210 vadd.f s16, s8, s12 @ vector op
211 vstr d0, [a1, #8 * 2*4]
212 vstr d2, [a1, #10 * 2*4]
213 vstr d1, [a1, #9 * 2*4]
214 vsub.f s20, s8, s12
215 vstr d3, [a1, #11 * 2*4]
216 @ TRANSFORM(z[2],z[6],z[10],z[14],cos1pi4,cos1pi4)
217 vldr d12, [a1, #10 * 2*4]
218 vadd.f s0, s16, s18
219 vadd.f s1, s17, s19
220 vsub.f s6, s16, s18
221 vsub.f s7, s17, s19
222 vsub.f s3, s21, s22
223 vadd.f s2, s20, s23
224 vadd.f s5, s21, s22
225 vsub.f s4, s20, s23
226 vstr d0, [a1, #12 * 2*4]
227 vmov s0, s6
228 @ TRANSFORM(z[1],z[5],z[9],z[13],cos1pi8,cos3pi8)
229 vldr d6, [a1, #9 * 2*4]
230 vstr d1, [a1, #13 * 2*4]
231 vldr d1, cos1pi4 @ s2 = cos1pi4, s3 = cos1pi8
232 vstr d2, [a1, #15 * 2*4]
233 vldr d7, [a1, #13 * 2*4]
234 vadd.f s4, s25, s24
235 vsub.f s5, s25, s24
236 vsub.f s6, s0, s7
237 vadd.f s7, s0, s7
238 vmul.f s20, s12, s3 @ vector op
239 @ TRANSFORM(z[3],z[7],z[11],z[15],cos3pi8,cos1pi8)
240 vldr d4, [a1, #11 * 2*4]
241 vldr d5, [a1, #15 * 2*4]
242 vldr s1, cos3pi8
243 vmul.f s24, s4, s2 @ vector * scalar op
244 vmul.f s28, s12, s1 @ vector * scalar op
245 vmul.f s12, s8, s1 @ vector * scalar op
246 vadd.f s4, s20, s29
247 vsub.f s5, s21, s28
248 vsub.f s6, s22, s31
249 vadd.f s7, s23, s30
250 vmul.f s8, s8, s3 @ vector * scalar op
251 vldr d8, [a1, #1 * 2*4]
252 vldr d9, [a1, #5 * 2*4]
253 vldr d10, [a1, #3 * 2*4]
254 vldr d11, [a1, #7 * 2*4]
255 vldr d14, [a1, #2 * 2*4]
256 vadd.f s0, s6, s4
257 vadd.f s1, s5, s7
258 vsub.f s2, s5, s7
259 vsub.f s3, s6, s4
260 vadd.f s4, s12, s9
261 vsub.f s5, s13, s8
262 vsub.f s6, s14, s11
263 vadd.f s7, s15, s10
264 vadd.f s12, s0, s16 @ vector op
265 vstr d0, [a1, #1 * 2*4]
266 vstr d1, [a1, #5 * 2*4]
267 vldr d4, [a1, #1 * 2*4]
268 vldr d5, [a1, #5 * 2*4]
269 vadd.f s0, s6, s4
270 vadd.f s1, s5, s7
271 vsub.f s2, s5, s7
272 vsub.f s3, s6, s4
273 vsub.f s8, s16, s8 @ vector op
274 vstr d6, [a1, #1 * 2*4]
275 vstr d7, [a1, #5 * 2*4]
276 vldr d15, [a1, #6 * 2*4]
277 vsub.f s4, s20, s0
278 vsub.f s5, s21, s1
279 vsub.f s6, s22, s2
280 vsub.f s7, s23, s3
281 vadd.f s20, s0, s20 @ vector op
282 vstr d4, [a1, #9 * 2*4]
283 @ TRANSFORM_ZERO(z[0],z[4],z[8],z[12])
284 vldr d6, [a1, #8 * 2*4]
285 vstr d5, [a1, #13 * 2*4]
286 vldr d7, [a1, #12 * 2*4]
287 vstr d2, [a1, #11 * 2*4]
288 vldr d8, [a1, #0 * 2*4]
289 vstr d3, [a1, #15 * 2*4]
290 vldr d9, [a1, #4 * 2*4]
291 vadd.f s0, s26, s24
292 vadd.f s1, s25, s27
293 vsub.f s2, s25, s27
294 vsub.f s3, s26, s24
295 vadd.f s4, s14, s12
296 vadd.f s5, s13, s15
297 vsub.f s6, s13, s15
298 vsub.f s7, s14, s12
299 vadd.f s8, s0, s28 @ vector op
300 vstr d0, [a1, #3 * 2*4]
301 vstr d1, [a1, #7 * 2*4]
302 vldr d6, [a1, #3 * 2*4]
303 vldr d7, [a1, #7 * 2*4]
304 vsub.f s0, s16, s4
305 vsub.f s1, s17, s5
306 vsub.f s2, s18, s6
307 vsub.f s3, s19, s7
308 vsub.f s12, s28, s12 @ vector op
309 vadd.f s16, s4, s16 @ vector op
310 vstr d10, [a1, #3 * 2*4]
311 vstr d11, [a1, #7 * 2*4]
312 vstr d4, [a1, #2 * 2*4]
313 vstr d5, [a1, #6 * 2*4]
314 vstr d0, [a1, #8 * 2*4]
315 vstr d1, [a1, #12 * 2*4]
316 vstr d6, [a1, #10 * 2*4]
317 vstr d7, [a1, #14 * 2*4]
318 vstr d8, [a1, #0 * 2*4]
319 vstr d9, [a1, #4 * 2*4]
320
321 bx lr
322endfunc
323
324function ff_fft16_vfp, export=1
325 ldr a3, =0x03030000 @ RunFast mode, vector length 4, stride 1
326 fmrx a2, FPSCR
327 fmxr FPSCR, a3
328 vpush {s16-s31}
329 mov ip, lr
330 bl .Lfft16_internal_vfp
331 vpop {s16-s31}
332 fmxr FPSCR, a2
333 bx ip
334endfunc
335
336.macro pass n, z0, z1, z2, z3
337 add v6, v5, #4*2*\n
338 @ TRANSFORM_ZERO(z[0],z[o1],z[o2],z[o3])
339 @ TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1])
340 @ TRANSFORM(z[0],z[o1],z[o2],z[o3],wre[0],wim[0])
341 @ TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1])
342 vldr d8, [\z2, #8*(o2+1)] @ s16,s17
343 vldmdb v6!, {s2}
344 vldr d9, [\z3, #8*(o3+1)] @ s18,s19
345 vldmia v5!, {s0,s1} @ s0 is unused
346 vldr s7, [\z2, #8*o2] @ t1
347 vmul.f s20, s16, s2 @ vector * scalar
348 vldr s0, [\z3, #8*o3] @ t5
349 vldr s6, [\z2, #8*o2+4] @ t2
350 vldr s3, [\z3, #8*o3+4] @ t6
351 vmul.f s16, s16, s1 @ vector * scalar
352 ldr a4, =\n-1
3531: add \z0, \z0, #8*2
354 .if \n*4*2 >= 512
355 add \z1, \z1, #8*2
356 .endif
357 .if \n*4*2 >= 256
358 add \z2, \z2, #8*2
359 .endif
360 .if \n*4*2 >= 512
361 add \z3, \z3, #8*2
362 .endif
363 @ up to 2 stalls (VFP vector issuing / waiting for s0)
364 @ depending upon whether this is the first iteration and
365 @ how many add instructions are inserted above
366 vadd.f s4, s0, s7 @ t5
367 vadd.f s5, s6, s3 @ t6
368 vsub.f s6, s6, s3 @ t4
369 vsub.f s7, s0, s7 @ t3
370 vldr d6, [\z0, #8*0-8*2] @ s12,s13
371 vadd.f s0, s16, s21 @ t1
372 vldr d7, [\z1, #8*o1-8*2] @ s14,s15
373 vsub.f s1, s18, s23 @ t5
374 vadd.f s8, s4, s12 @ vector + vector
375 @ stall (VFP vector issuing)
376 @ stall (VFP vector issuing)
377 @ stall (VFP vector issuing)
378 vsub.f s4, s12, s4
379 vsub.f s5, s13, s5
380 vsub.f s6, s14, s6
381 vsub.f s7, s15, s7
382 vsub.f s2, s17, s20 @ t2
383 vadd.f s3, s19, s22 @ t6
384 vstr d4, [\z0, #8*0-8*2] @ s8,s9
385 vstr d5, [\z1, #8*o1-8*2] @ s10,s11
386 @ stall (waiting for s5)
387 vstr d2, [\z2, #8*o2-8*2] @ s4,s5
388 vadd.f s4, s1, s0 @ t5
389 vstr d3, [\z3, #8*o3-8*2] @ s6,s7
390 vsub.f s7, s1, s0 @ t3
391 vadd.f s5, s2, s3 @ t6
392 vsub.f s6, s2, s3 @ t4
393 vldr d6, [\z0, #8*1-8*2] @ s12,s13
394 vldr d7, [\z1, #8*(o1+1)-8*2] @ s14,s15
395 vldr d4, [\z2, #8*o2] @ s8,s9
396 vldmdb v6!, {s2,s3}
397 vldr d5, [\z3, #8*o3] @ s10,s11
398 vadd.f s20, s4, s12 @ vector + vector
399 vldmia v5!, {s0,s1}
400 vldr d8, [\z2, #8*(o2+1)] @ s16,s17
401 @ stall (VFP vector issuing)
402 vsub.f s4, s12, s4
403 vsub.f s5, s13, s5
404 vsub.f s6, s14, s6
405 vsub.f s7, s15, s7
406 vmul.f s12, s8, s3 @ vector * scalar
407 vstr d10, [\z0, #8*1-8*2] @ s20,s21
408 vldr d9, [\z3, #8*(o3+1)] @ s18,s19
409 vstr d11, [\z1, #8*(o1+1)-8*2] @ s22,s23
410 vmul.f s8, s8, s0 @ vector * scalar
411 vstr d2, [\z2, #8*(o2+1)-8*2] @ s4,s5
412 @ stall (waiting for s7)
413 vstr d3, [\z3, #8*(o3+1)-8*2] @ s6,s7
414 vmul.f s20, s16, s2 @ vector * scalar
415 @ stall (VFP vector issuing)
416 @ stall (VFP vector issuing)
417 @ stall (VFP vector issuing)
418 vadd.f s7, s8, s13 @ t1
419 vsub.f s6, s9, s12 @ t2
420 vsub.f s0, s10, s15 @ t5
421 vadd.f s3, s11, s14 @ t6
422 vmul.f s16, s16, s1 @ vector * scalar
423 subs a4, a4, #1
424 bne 1b
425 @ What remains is identical to the first two indentations of
426 @ the above, but without the increment of z
427 vadd.f s4, s0, s7 @ t5
428 vadd.f s5, s6, s3 @ t6
429 vsub.f s6, s6, s3 @ t4
430 vsub.f s7, s0, s7 @ t3
431 vldr d6, [\z0, #8*0] @ s12,s13
432 vadd.f s0, s16, s21 @ t1
433 vldr d7, [\z1, #8*o1] @ s14,s15
434 vsub.f s1, s18, s23 @ t5
435 vadd.f s8, s4, s12 @ vector + vector
436 vsub.f s4, s12, s4
437 vsub.f s5, s13, s5
438 vsub.f s6, s14, s6
439 vsub.f s7, s15, s7
440 vsub.f s2, s17, s20 @ t2
441 vadd.f s3, s19, s22 @ t6
442 vstr d4, [\z0, #8*0] @ s8,s9
443 vstr d5, [\z1, #8*o1] @ s10,s11
444 vstr d2, [\z2, #8*o2] @ s4,s5
445 vadd.f s4, s1, s0 @ t5
446 vstr d3, [\z3, #8*o3] @ s6,s7
447 vsub.f s7, s1, s0 @ t3
448 vadd.f s5, s2, s3 @ t6
449 vsub.f s6, s2, s3 @ t4
450 vldr d6, [\z0, #8*1] @ s12,s13
451 vldr d7, [\z1, #8*(o1+1)] @ s14,s15
452 vadd.f s20, s4, s12 @ vector + vector
453 vsub.f s4, s12, s4
454 vsub.f s5, s13, s5
455 vsub.f s6, s14, s6
456 vsub.f s7, s15, s7
457 vstr d10, [\z0, #8*1] @ s20,s21
458 vstr d11, [\z1, #8*(o1+1)] @ s22,s23
459 vstr d2, [\z2, #8*(o2+1)] @ s4,s5
460 vstr d3, [\z3, #8*(o3+1)] @ s6,s7
461.endm
462
463.macro def_fft n, n2, n4
464function .Lfft\n\()_internal_vfp
465 .if \n >= 512
466 push {v1-v6,lr}
467 .elseif \n >= 256
468 push {v1-v2,v5-v6,lr}
469 .else
470 push {v1,v5-v6,lr}
471 .endif
472 mov v1, a1
473 bl .Lfft\n2\()_internal_vfp
474 add a1, v1, #8*(\n/4)*2
475 bl .Lfft\n4\()_internal_vfp
476 movrelx v5, X(ff_cos_\n), a1
477 add a1, v1, #8*(\n/4)*3
478 bl .Lfft\n4\()_internal_vfp
479 .if \n >= 512
480 .set o1, 0*(\n/4/2)
481 .set o2, 0*(\n/4/2)
482 .set o3, 0*(\n/4/2)
483 add v2, v1, #8*2*(\n/4/2)
484 add v3, v1, #8*4*(\n/4/2)
485 add v4, v1, #8*6*(\n/4/2)
486 pass (\n/4/2), v1, v2, v3, v4
487 pop {v1-v6,pc}
488 .elseif \n >= 256
489 .set o1, 2*(\n/4/2)
490 .set o2, 0*(\n/4/2)
491 .set o3, 2*(\n/4/2)
492 add v2, v1, #8*4*(\n/4/2)
493 pass (\n/4/2), v1, v1, v2, v2
494 pop {v1-v2,v5-v6,pc}
495 .else
496 .set o1, 2*(\n/4/2)
497 .set o2, 4*(\n/4/2)
498 .set o3, 6*(\n/4/2)
499 pass (\n/4/2), v1, v1, v1, v1
500 pop {v1,v5-v6,pc}
501 .endif
502endfunc
503
504function fft\n\()_vfp
505 ldr a3, =0x03030000 /* RunFast mode, vector length 4, stride 1 */
506 fmrx a2, FPSCR
507 fmxr FPSCR, a3
508 vpush {s16-s31}
509 mov ip, lr
510 bl .Lfft\n\()_internal_vfp
511 vpop {s16-s31}
512 fmxr FPSCR, a2
513 bx ip
514endfunc
515
516.ltorg
517.endm
518
519 def_fft 32, 16, 8
520 def_fft 64, 32, 16
521 def_fft 128, 64, 32
522 def_fft 256, 128, 64
523 def_fft 512, 256, 128
524 def_fft 1024, 512, 256
525 def_fft 2048, 1024, 512
526 def_fft 4096, 2048, 1024
527 def_fft 8192, 4096, 2048
528 def_fft 16384, 8192, 4096
529 def_fft 32768, 16384, 8192
530 def_fft 65536, 32768, 16384
libavcodec/arm/mdct_neon.S+0−301
@@ -1,301 +0,0 @@
1/*
2 * ARM NEON optimised MDCT
3 * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include "libavutil/arm/asm.S"
23
24#define ff_fft_calc_neon X(ff_fft_calc_neon)
25
26function ff_imdct_half_neon, export=1
27 push {r4-r8,lr}
28
29 mov r12, #1
30 ldr lr, [r0, #20] @ mdct_bits
31 ldr r4, [r0, #24] @ tcos
32 ldr r3, [r0, #8] @ revtab
33 lsl r12, r12, lr @ n = 1 << nbits
34 lsr lr, r12, #2 @ n4 = n >> 2
35 add r7, r2, r12, lsl #1
36 mov r12, #-16
37 sub r7, r7, #16
38
39 vld2.32 {d16-d17},[r7,:128],r12 @ d16=x,n1 d17=x,n0
40 vld2.32 {d0-d1}, [r2,:128]! @ d0 =m0,x d1 =m1,x
41 vrev64.32 d17, d17
42 vld2.32 {d2,d3}, [r4,:128]! @ d2=c0,c1 d3=s0,s2
43 vmul.f32 d6, d17, d2
44 vmul.f32 d7, d0, d2
451:
46 subs lr, lr, #2
47 ldr r6, [r3], #4
48 vmul.f32 d4, d0, d3
49 vmul.f32 d5, d17, d3
50 vsub.f32 d4, d6, d4
51 vadd.f32 d5, d5, d7
52 uxth r8, r6, ror #16
53 uxth r6, r6
54 add r8, r1, r8, lsl #3
55 add r6, r1, r6, lsl #3
56 beq 1f
57 vld2.32 {d16-d17},[r7,:128],r12
58 vld2.32 {d0-d1}, [r2,:128]!
59 vrev64.32 d17, d17
60 vld2.32 {d2,d3}, [r4,:128]! @ d2=c0,c1 d3=s0,s2
61 vmul.f32 d6, d17, d2
62 vmul.f32 d7, d0, d2
63 vst2.32 {d4[0],d5[0]}, [r6,:64]
64 vst2.32 {d4[1],d5[1]}, [r8,:64]
65 b 1b
661:
67 vst2.32 {d4[0],d5[0]}, [r6,:64]
68 vst2.32 {d4[1],d5[1]}, [r8,:64]
69
70 mov r4, r0
71 mov r6, r1
72 bl ff_fft_calc_neon
73
74 mov r12, #1
75 ldr lr, [r4, #20] @ mdct_bits
76 ldr r4, [r4, #24] @ tcos
77 lsl r12, r12, lr @ n = 1 << nbits
78 lsr lr, r12, #3 @ n8 = n >> 3
79
80 add r4, r4, lr, lsl #3
81 add r6, r6, lr, lsl #3
82 sub r1, r4, #16
83 sub r3, r6, #16
84
85 mov r7, #-16
86 mov r8, r6
87 mov r0, r3
88
89 vld2.32 {d0-d1}, [r3,:128], r7 @ d0 =i1,r1 d1 =i0,r0
90 vld2.32 {d20-d21},[r6,:128]! @ d20=i2,r2 d21=i3,r3
91 vld2.32 {d16,d18},[r1,:128], r7 @ d16=c1,c0 d18=s1,s0
921:
93 subs lr, lr, #2
94 vmul.f32 d7, d0, d18
95 vld2.32 {d17,d19},[r4,:128]! @ d17=c2,c3 d19=s2,s3
96 vmul.f32 d4, d1, d18
97 vmul.f32 d5, d21, d19
98 vmul.f32 d6, d20, d19
99 vmul.f32 d22, d1, d16
100 vmul.f32 d23, d21, d17
101 vmul.f32 d24, d0, d16
102 vmul.f32 d25, d20, d17
103 vadd.f32 d7, d7, d22
104 vadd.f32 d6, d6, d23
105 vsub.f32 d4, d4, d24
106 vsub.f32 d5, d5, d25
107 beq 1f
108 vld2.32 {d0-d1}, [r3,:128], r7
109 vld2.32 {d20-d21},[r6,:128]!
110 vld2.32 {d16,d18},[r1,:128], r7 @ d16=c1,c0 d18=s1,s0
111 vrev64.32 q3, q3
112 vst2.32 {d4,d6}, [r0,:128], r7
113 vst2.32 {d5,d7}, [r8,:128]!
114 b 1b
1151:
116 vrev64.32 q3, q3
117 vst2.32 {d4,d6}, [r0,:128]
118 vst2.32 {d5,d7}, [r8,:128]
119
120 pop {r4-r8,pc}
121endfunc
122
123function ff_imdct_calc_neon, export=1
124 push {r4-r6,lr}
125
126 ldr r3, [r0, #20]
127 mov r4, #1
128 mov r5, r1
129 lsl r4, r4, r3
130 add r1, r1, r4
131
132 bl X(ff_imdct_half_neon)
133
134 add r0, r5, r4, lsl #2
135 add r1, r5, r4, lsl #1
136 sub r0, r0, #8
137 sub r2, r1, #16
138 mov r3, #-16
139 mov r6, #-8
140 vmov.i32 d30, #1<<31
1411:
142 vld1.32 {d0-d1}, [r2,:128], r3
143 pld [r0, #-16]
144 vrev64.32 q0, q0
145 vld1.32 {d2-d3}, [r1,:128]!
146 veor d4, d1, d30
147 pld [r2, #-16]
148 vrev64.32 q1, q1
149 veor d5, d0, d30
150 vst1.32 {d2}, [r0,:64], r6
151 vst1.32 {d3}, [r0,:64], r6
152 vst1.32 {d4-d5}, [r5,:128]!
153 subs r4, r4, #16
154 bgt 1b
155
156 pop {r4-r6,pc}
157endfunc
158
159function ff_mdct_calc_neon, export=1
160 push {r4-r10,lr}
161
162 mov r12, #1
163 ldr lr, [r0, #20] @ mdct_bits
164 ldr r4, [r0, #24] @ tcos
165 ldr r3, [r0, #8] @ revtab
166 lsl lr, r12, lr @ n = 1 << nbits
167 add r7, r2, lr @ in4u
168 sub r9, r7, #16 @ in4d
169 add r2, r7, lr, lsl #1 @ in3u
170 add r8, r9, lr, lsl #1 @ in3d
171 add r5, r4, lr, lsl #1
172 sub r5, r5, #16
173 sub r3, r3, #4
174 mov r12, #-16
175
176 vld2.32 {d16,d18},[r9,:128],r12 @ in0u0,in0u1 in4d1,in4d0
177 vld2.32 {d17,d19},[r8,:128],r12 @ in2u0,in2u1 in3d1,in3d0
178 vld2.32 {d0, d2}, [r7,:128]! @ in4u0,in4u1 in2d1,in2d0
179 vrev64.32 q9, q9 @ in4d0,in4d1 in3d0,in3d1
180 vld2.32 {d1, d3}, [r2,:128]! @ in3u0,in3u1 in1d1,in1d0
181 vsub.f32 d0, d18, d0 @ in4d-in4u I
182 vld2.32 {d20,d21},[r4,:128]! @ c0,c1 s0,s1
183 vrev64.32 q1, q1 @ in2d0,in2d1 in1d0,in1d1
184 vld2.32 {d30,d31},[r5,:128],r12 @ c2,c3 s2,s3
185 vadd.f32 d1, d1, d19 @ in3u+in3d -R
186 vsub.f32 d16, d16, d2 @ in0u-in2d R
187 vadd.f32 d17, d17, d3 @ in2u+in1d -I
1881:
189 vmul.f32 d7, d0, d21 @ I*s
190A ldr r10, [r3, lr, lsr #1]
191T lsr r10, lr, #1
192T ldr r10, [r3, r10]
193 vmul.f32 d6, d1, d20 @ -R*c
194 ldr r6, [r3, #4]!
195 vmul.f32 d4, d1, d21 @ -R*s
196 vmul.f32 d5, d0, d20 @ I*c
197 vmul.f32 d24, d16, d30 @ R*c
198 vmul.f32 d25, d17, d31 @ -I*s
199 vmul.f32 d22, d16, d31 @ R*s
200 vmul.f32 d23, d17, d30 @ I*c
201 subs lr, lr, #16
202 vsub.f32 d6, d6, d7 @ -R*c-I*s
203 vadd.f32 d7, d4, d5 @ -R*s+I*c
204 vsub.f32 d24, d25, d24 @ I*s-R*c
205 vadd.f32 d25, d22, d23 @ R*s-I*c
206 beq 1f
207 mov r12, #-16
208 vld2.32 {d16,d18},[r9,:128],r12 @ in0u0,in0u1 in4d1,in4d0
209 vld2.32 {d17,d19},[r8,:128],r12 @ in2u0,in2u1 in3d1,in3d0
210 vneg.f32 d7, d7 @ R*s-I*c
211 vld2.32 {d0, d2}, [r7,:128]! @ in4u0,in4u1 in2d1,in2d0
212 vrev64.32 q9, q9 @ in4d0,in4d1 in3d0,in3d1
213 vld2.32 {d1, d3}, [r2,:128]! @ in3u0,in3u1 in1d1,in1d0
214 vsub.f32 d0, d18, d0 @ in4d-in4u I
215 vld2.32 {d20,d21},[r4,:128]! @ c0,c1 s0,s1
216 vrev64.32 q1, q1 @ in2d0,in2d1 in1d0,in1d1
217 vld2.32 {d30,d31},[r5,:128],r12 @ c2,c3 s2,s3
218 vadd.f32 d1, d1, d19 @ in3u+in3d -R
219 vsub.f32 d16, d16, d2 @ in0u-in2d R
220 vadd.f32 d17, d17, d3 @ in2u+in1d -I
221 uxth r12, r6, ror #16
222 uxth r6, r6
223 add r12, r1, r12, lsl #3
224 add r6, r1, r6, lsl #3
225 vst2.32 {d6[0],d7[0]}, [r6,:64]
226 vst2.32 {d6[1],d7[1]}, [r12,:64]
227 uxth r6, r10, ror #16
228 uxth r10, r10
229 add r6 , r1, r6, lsl #3
230 add r10, r1, r10, lsl #3
231 vst2.32 {d24[0],d25[0]},[r10,:64]
232 vst2.32 {d24[1],d25[1]},[r6,:64]
233 b 1b
2341:
235 vneg.f32 d7, d7 @ R*s-I*c
236 uxth r12, r6, ror #16
237 uxth r6, r6
238 add r12, r1, r12, lsl #3
239 add r6, r1, r6, lsl #3
240 vst2.32 {d6[0],d7[0]}, [r6,:64]
241 vst2.32 {d6[1],d7[1]}, [r12,:64]
242 uxth r6, r10, ror #16
243 uxth r10, r10
244 add r6 , r1, r6, lsl #3
245 add r10, r1, r10, lsl #3
246 vst2.32 {d24[0],d25[0]},[r10,:64]
247 vst2.32 {d24[1],d25[1]},[r6,:64]
248
249 mov r4, r0
250 mov r6, r1
251 bl ff_fft_calc_neon
252
253 mov r12, #1
254 ldr lr, [r4, #20] @ mdct_bits
255 ldr r4, [r4, #24] @ tcos
256 lsl r12, r12, lr @ n = 1 << nbits
257 lsr lr, r12, #3 @ n8 = n >> 3
258
259 add r4, r4, lr, lsl #3
260 add r6, r6, lr, lsl #3
261 sub r1, r4, #16
262 sub r3, r6, #16
263
264 mov r7, #-16
265 mov r8, r6
266 mov r0, r3
267
268 vld2.32 {d0-d1}, [r3,:128], r7 @ d0 =r1,i1 d1 =r0,i0
269 vld2.32 {d20-d21},[r6,:128]! @ d20=r2,i2 d21=r3,i3
270 vld2.32 {d16,d18},[r1,:128], r7 @ c1,c0 s1,s0
2711:
272 subs lr, lr, #2
273 vmul.f32 d7, d0, d18 @ r1*s1,r0*s0
274 vld2.32 {d17,d19},[r4,:128]! @ c2,c3 s2,s3
275 vmul.f32 d4, d1, d18 @ i1*s1,i0*s0
276 vmul.f32 d5, d21, d19 @ i2*s2,i3*s3
277 vmul.f32 d6, d20, d19 @ r2*s2,r3*s3
278 vmul.f32 d24, d0, d16 @ r1*c1,r0*c0
279 vmul.f32 d25, d20, d17 @ r2*c2,r3*c3
280 vmul.f32 d22, d21, d17 @ i2*c2,i3*c3
281 vmul.f32 d23, d1, d16 @ i1*c1,i0*c0
282 vadd.f32 d4, d4, d24 @ i1*s1+r1*c1,i0*s0+r0*c0
283 vadd.f32 d5, d5, d25 @ i2*s2+r2*c2,i3*s3+r3*c3
284 vsub.f32 d6, d22, d6 @ i2*c2-r2*s2,i3*c3-r3*s3
285 vsub.f32 d7, d23, d7 @ i1*c1-r1*s1,i0*c0-r0*s0
286 vneg.f32 q2, q2
287 beq 1f
288 vld2.32 {d0-d1}, [r3,:128], r7
289 vld2.32 {d20-d21},[r6,:128]!
290 vld2.32 {d16,d18},[r1,:128], r7 @ c1,c0 s1,s0
291 vrev64.32 q3, q3
292 vst2.32 {d4,d6}, [r0,:128], r7
293 vst2.32 {d5,d7}, [r8,:128]!
294 b 1b
2951:
296 vrev64.32 q3, q3
297 vst2.32 {d4,d6}, [r0,:128]
298 vst2.32 {d5,d7}, [r8,:128]
299
300 pop {r4-r10,pc}
301endfunc
libavcodec/arm/mdct_vfp.S+0−347
@@ -1,347 +0,0 @@
1/*
2 * Copyright (c) 2013 RISC OS Open Ltd
3 * Author: Ben Avison <bavison@riscosopen.org>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include "libavutil/arm/asm.S"
23
24CONTEXT .req a1
25ORIGOUT .req a2
26IN .req a3
27OUT .req v1
28REVTAB .req v2
29TCOS .req v3
30TSIN .req v4
31OLDFPSCR .req v5
32J0 .req a2
33J1 .req a4
34J2 .req ip
35J3 .req lr
36REVTAB_HI .req v5
37IN_HI .req v6
38OUT_HI .req v6
39TCOS_HI .req sl
40TSIN_HI .req fp
41
42.macro prerotation_innerloop
43 .set trig_lo, k
44 .set trig_hi, n4 - k - 2
45 .set in_lo, trig_lo * 2
46 .set in_hi, trig_hi * 2
47 vldr d8, [TCOS, #trig_lo*4] @ s16,s17
48 vldr d9, [TCOS, #trig_hi*4] @ s18,s19
49 vldr s0, [IN, #in_hi*4 + 12]
50 vldr s1, [IN, #in_hi*4 + 4]
51 vldr s2, [IN, #in_lo*4 + 12]
52 vldr s3, [IN, #in_lo*4 + 4]
53 vmul.f s8, s0, s16 @ vector operation
54 vldr d10, [TSIN, #trig_lo*4] @ s20,s21
55 vldr d11, [TSIN, #trig_hi*4] @ s22,s23
56 vldr s4, [IN, #in_lo*4]
57 vldr s5, [IN, #in_lo*4 + 8]
58 vldr s6, [IN, #in_hi*4]
59 vldr s7, [IN, #in_hi*4 + 8]
60 ldr J0, [REVTAB, #trig_lo*2]
61 vmul.f s12, s0, s20 @ vector operation
62 ldr J2, [REVTAB, #trig_hi*2]
63 mov J1, J0, lsr #16
64 and J0, J0, #255 @ halfword value will be < n4
65 vmls.f s8, s4, s20 @ vector operation
66 mov J3, J2, lsr #16
67 and J2, J2, #255 @ halfword value will be < n4
68 add J0, OUT, J0, lsl #3
69 vmla.f s12, s4, s16 @ vector operation
70 add J1, OUT, J1, lsl #3
71 add J2, OUT, J2, lsl #3
72 add J3, OUT, J3, lsl #3
73 vstr s8, [J0]
74 vstr s9, [J1]
75 vstr s10, [J2]
76 vstr s11, [J3]
77 vstr s12, [J0, #4]
78 vstr s13, [J1, #4]
79 vstr s14, [J2, #4]
80 vstr s15, [J3, #4]
81 .set k, k + 2
82.endm
83
84.macro prerotation_innerloop_rolled
85 vldmia TCOS!, {s16,s17}
86 vldmdb TCOS_HI!, {s18,s19}
87 vldr s0, [IN_HI, #-4]
88 vldr s1, [IN_HI, #-12]
89 vldr s2, [IN, #12]
90 vldr s3, [IN, #4]
91 vmul.f s8, s0, s16 @ vector operation
92 vldmia TSIN!, {s20,s21}
93 vldmdb TSIN_HI!, {s22,s23}
94 vldr s4, [IN]
95 vldr s5, [IN, #8]
96 vldr s6, [IN_HI, #-16]
97 vldr s7, [IN_HI, #-8]
98 vmul.f s12, s0, s20 @ vector operation
99 add IN, IN, #16
100 sub IN_HI, IN_HI, #16
101 ldrh J0, [REVTAB], #2
102 ldrh J1, [REVTAB], #2
103 vmls.f s8, s4, s20 @ vector operation
104 ldrh J3, [REVTAB_HI, #-2]!
105 ldrh J2, [REVTAB_HI, #-2]!
106 add J0, OUT, J0, lsl #3
107 vmla.f s12, s4, s16 @ vector operation
108 add J1, OUT, J1, lsl #3
109 add J2, OUT, J2, lsl #3
110 add J3, OUT, J3, lsl #3
111 vstr s8, [J0]
112 vstr s9, [J1]
113 vstr s10, [J2]
114 vstr s11, [J3]
115 vstr s12, [J0, #4]
116 vstr s13, [J1, #4]
117 vstr s14, [J2, #4]
118 vstr s15, [J3, #4]
119.endm
120
121.macro postrotation_innerloop tail, head
122 .set trig_lo_head, n8 - k - 2
123 .set trig_hi_head, n8 + k
124 .set out_lo_head, trig_lo_head * 2
125 .set out_hi_head, trig_hi_head * 2
126 .set trig_lo_tail, n8 - (k - 2) - 2
127 .set trig_hi_tail, n8 + (k - 2)
128 .set out_lo_tail, trig_lo_tail * 2
129 .set out_hi_tail, trig_hi_tail * 2
130 .if (k & 2) == 0
131 TCOS_D0_HEAD .req d10 @ s20,s21
132 TCOS_D1_HEAD .req d11 @ s22,s23
133 TCOS_S0_TAIL .req s24
134 .else
135 TCOS_D0_HEAD .req d12 @ s24,s25
136 TCOS_D1_HEAD .req d13 @ s26,s27
137 TCOS_S0_TAIL .req s20
138 .endif
139 .ifnc "\tail",""
140 vmls.f s8, s0, TCOS_S0_TAIL @ vector operation
141 .endif
142 .ifnc "\head",""
143 vldr d8, [TSIN, #trig_lo_head*4] @ s16,s17
144 vldr d9, [TSIN, #trig_hi_head*4] @ s18,s19
145 vldr TCOS_D0_HEAD, [TCOS, #trig_lo_head*4]
146 .endif
147 .ifnc "\tail",""
148 vmla.f s12, s4, TCOS_S0_TAIL @ vector operation
149 .endif
150 .ifnc "\head",""
151 vldr s0, [OUT, #out_lo_head*4]
152 vldr s1, [OUT, #out_lo_head*4 + 8]
153 vldr s2, [OUT, #out_hi_head*4]
154 vldr s3, [OUT, #out_hi_head*4 + 8]
155 vldr s4, [OUT, #out_lo_head*4 + 4]
156 vldr s5, [OUT, #out_lo_head*4 + 12]
157 vldr s6, [OUT, #out_hi_head*4 + 4]
158 vldr s7, [OUT, #out_hi_head*4 + 12]
159 .endif
160 .ifnc "\tail",""
161 vstr s8, [OUT, #out_lo_tail*4]
162 vstr s9, [OUT, #out_lo_tail*4 + 8]
163 vstr s10, [OUT, #out_hi_tail*4]
164 vstr s11, [OUT, #out_hi_tail*4 + 8]
165 .endif
166 .ifnc "\head",""
167 vmul.f s8, s4, s16 @ vector operation
168 .endif
169 .ifnc "\tail",""
170 vstr s12, [OUT, #out_hi_tail*4 + 12]
171 vstr s13, [OUT, #out_hi_tail*4 + 4]
172 vstr s14, [OUT, #out_lo_tail*4 + 12]
173 vstr s15, [OUT, #out_lo_tail*4 + 4]
174 .endif
175 .ifnc "\head",""
176 vmul.f s12, s0, s16 @ vector operation
177 vldr TCOS_D1_HEAD, [TCOS, #trig_hi_head*4]
178 .endif
179 .unreq TCOS_D0_HEAD
180 .unreq TCOS_D1_HEAD
181 .unreq TCOS_S0_TAIL
182 .ifnc "\head",""
183 .set k, k + 2
184 .endif
185.endm
186
187.macro postrotation_innerloop_rolled tail, head, tcos_s0_head, tcos_s1_head, tcos_s2_head, tcos_s3_head, tcos_s0_tail, out_offset_head, out_offset_tail
188 .ifnc "\tail",""
189 vmls.f s8, s0, \tcos_s0_tail @ vector operation
190 .endif
191 .ifnc "\head",""
192 vldmia TSIN!, {s16,s17}
193 vldmdb TSIN_HI!, {s18,s19}
194 vldmia TCOS!, {\tcos_s0_head,\tcos_s1_head}
195 .endif
196 .ifnc "\tail",""
197 vmla.f s12, s4, \tcos_s0_tail @ vector operation
198 .endif
199 .ifnc "\head",""
200 vldr s0, [OUT, #+\out_offset_head+0]
201 vldr s1, [OUT, #+\out_offset_head+8]
202 vldr s2, [OUT_HI, #-\out_offset_head-16]
203 vldr s3, [OUT_HI, #-\out_offset_head-8]
204 vldr s4, [OUT, #+\out_offset_head+4]
205 vldr s5, [OUT, #+\out_offset_head+12]
206 vldr s6, [OUT_HI, #-\out_offset_head-12]
207 vldr s7, [OUT_HI, #-\out_offset_head-4]
208 .endif
209 .ifnc "\tail",""
210 vstr s8, [OUT, #+\out_offset_tail+0]
211 vstr s9, [OUT, #+\out_offset_tail+8]
212 vstr s10, [OUT_HI, #-\out_offset_tail-16]
213 vstr s11, [OUT_HI, #-\out_offset_tail-8]
214 .endif
215 .ifnc "\head",""
216 vmul.f s8, s4, s16 @ vector operation
217 .endif
218 .ifnc "\tail",""
219 vstr s12, [OUT_HI, #-\out_offset_tail-4]
220 vstr s13, [OUT_HI, #-\out_offset_tail-12]
221 vstr s14, [OUT, #+\out_offset_tail+12]
222 vstr s15, [OUT, #+\out_offset_tail+4]
223 .endif
224 .ifnc "\head",""
225 vmul.f s12, s0, s16 @ vector operation
226 vldmdb TCOS_HI!, {\tcos_s2_head,\tcos_s3_head}
227 .endif
228.endm
229
230
231/* void ff_imdct_half_vfp(FFTContext *s,
232 * FFTSample *output,
233 * const FFTSample *input)
234 */
235function ff_imdct_half_vfp, export=1
236 ldr ip, [CONTEXT, #5*4] @ mdct_bits
237 teq ip, #6
238 bne 10f
239
240 .set n, 1<<6
241 .set n2, n/2
242 .set n4, n/4
243 .set n8, n/8
244
245 push {v1-v5,lr}
246 vpush {s16-s27}
247 fmrx OLDFPSCR, FPSCR
248 ldr lr, =0x03030000 @ RunFast mode, short vectors of length 4, stride 1
249 fmxr FPSCR, lr
250 mov OUT, ORIGOUT
251 ldr REVTAB, [CONTEXT, #2*4]
252 ldr TCOS, [CONTEXT, #6*4]
253 ldr TSIN, [CONTEXT, #7*4]
254
255 .set k, 0
256 .rept n8/2
257 prerotation_innerloop
258 .endr
259
260 fmxr FPSCR, OLDFPSCR
261 mov a1, OUT
262 bl X(ff_fft16_vfp)
263 ldr lr, =0x03030000 @ RunFast mode, short vectors of length 4, stride 1
264 fmxr FPSCR, lr
265
266 .set k, 0
267 postrotation_innerloop , head
268 .rept n8/2 - 1
269 postrotation_innerloop tail, head
270 .endr
271 postrotation_innerloop tail
272
273 fmxr FPSCR, OLDFPSCR
274 vpop {s16-s27}
275 pop {v1-v5,pc}
276
27710:
278 push {v1-v6,sl,fp,lr}
279 vpush {s16-s27}
280 fmrx OLDFPSCR, FPSCR
281 ldr lr, =0x03030000 @ RunFast mode, short vectors of length 4, stride 1
282 fmxr FPSCR, lr
283 mov lr, #1
284 mov OUT, ORIGOUT
285 ldr REVTAB, [CONTEXT, #2*4]
286 ldr TCOS, [CONTEXT, #6*4]
287 ldr TSIN, [CONTEXT, #7*4]
288 mov lr, lr, lsl ip
289
290 push {CONTEXT,OLDFPSCR}
291 add IN_HI, IN, lr, lsl #1
292 add REVTAB_HI, REVTAB, lr, lsr #1
293 add TCOS_HI, TCOS, lr
294 add TSIN_HI, TSIN, lr
2950: prerotation_innerloop_rolled
296 teq IN, IN_HI
297 bne 0b
298 ldmia sp, {CONTEXT,OLDFPSCR}
299
300 mov ORIGOUT, OUT
301 fmxr FPSCR, OLDFPSCR
302 ldr ip, [CONTEXT, #9*4]
303 blx ip @ s->fft_calc(s, output)
304
305 pop {CONTEXT,OLDFPSCR}
306 ldr lr, =0x03030000 @ RunFast mode, short vectors of length 4, stride 1
307 ldr ip, [CONTEXT, #5*4] @ mdct_bits
308 fmxr FPSCR, lr
309 mov lr, #1
310 mov lr, lr, lsl ip
311 sub TCOS, TCOS, lr, lsr #1
312 sub TSIN, TSIN, lr, lsr #1
313 add OUT_HI, OUT, lr, lsl #1
314 add TCOS_HI, TCOS, lr
315 add TSIN_HI, TSIN, lr
316 postrotation_innerloop_rolled , head, s20, s21, s22, s23,, 0
317 b 1f
3180: add OUT, OUT, #32
319 sub OUT_HI, OUT_HI, #32
320 postrotation_innerloop_rolled tail, head, s20, s21, s22, s23, s24, 0, -16
3211: postrotation_innerloop_rolled tail, head, s24, s25, s26, s27, s20, 16, 0
322 teq TSIN, TSIN_HI
323 bne 0b
324 postrotation_innerloop_rolled tail,,,,,, s24,, 16
325
326 fmxr FPSCR, OLDFPSCR
327 vpop {s16-s27}
328 pop {v1-v6,sl,fp,pc}
329endfunc
330
331 .unreq CONTEXT
332 .unreq ORIGOUT
333 .unreq IN
334 .unreq OUT
335 .unreq REVTAB
336 .unreq TCOS
337 .unreq TSIN
338 .unreq OLDFPSCR
339 .unreq J0
340 .unreq J1
341 .unreq J2
342 .unreq J3
343 .unreq REVTAB_HI
344 .unreq IN_HI
345 .unreq OUT_HI
346 .unreq TCOS_HI
347 .unreq TSIN_HI
libavcodec/arm/rdft_init_arm.c+0−33
@@ -1,33 +0,0 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "libavutil/attributes.h"
20#include "libavutil/cpu.h"
21#include "libavutil/arm/cpu.h"
22
23#include "libavcodec/rdft.h"
24
25void ff_rdft_calc_neon(struct RDFTContext *s, FFTSample *z);
26
27av_cold void ff_rdft_init_arm(RDFTContext *s)
28{
29 int cpu_flags = av_get_cpu_flags();
30
31 if (have_neon(cpu_flags))
32 s->rdft_calc = ff_rdft_calc_neon;
33}
libavcodec/arm/rdft_neon.S+0−155
@@ -1,155 +0,0 @@
1/*
2 * ARM NEON optimised RDFT
3 * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include "libavutil/arm/asm.S"
23
24function ff_rdft_calc_neon, export=1
25 push {r4-r8,lr}
26
27 ldr r6, [r0, #4] @ inverse
28 mov r4, r0
29 mov r5, r1
30
31 lsls r6, r6, #31
32 bne 1f
33 add r0, r4, #24
34 bl X(ff_fft_permute_neon)
35 add r0, r4, #24
36 mov r1, r5
37 bl X(ff_fft_calc_neon)
381:
39 ldr r12, [r4, #0] @ nbits
40 mov r2, #1
41 ldr r8, [r4, #20] @ negative_sin
42 lsl r12, r2, r12
43 add r0, r5, #8
44 lsl r8, r8, #31
45 add r1, r5, r12, lsl #2
46 lsr r12, r12, #2
47 vdup.32 d26, r8
48 ldr r2, [r4, #12] @ tcos
49 sub r12, r12, #2
50 ldr r3, [r4, #16] @ tsin
51 mov r7, r0
52 sub r1, r1, #8
53 mov lr, r1
54 mov r8, #-8
55 vld1.32 {d0}, [r0,:64]! @ d1[0,1]
56 vld1.32 {d1}, [r1,:64], r8 @ d2[0,1]
57 vld1.32 {d4}, [r2,:64]! @ tcos[i]
58 vld1.32 {d5}, [r3,:64]! @ tsin[i]
59 vmov.f32 d18, #0.5 @ k1
60 vdup.32 d19, r6
61 veor d5, d26, d5
62 pld [r0, #32]
63 veor d19, d18, d19 @ k2
64 vmov.i32 d16, #0
65 vmov.i32 d17, #1<<31
66 pld [r1, #-32]
67 vtrn.32 d16, d17
68 pld [r2, #32]
69 vrev64.32 d16, d16 @ d16=1,0 d17=0,1
70 pld [r3, #32]
712:
72 veor q1, q0, q8 @ -d1[0],d1[1], d2[0],-d2[1]
73 vld1.32 {d24}, [r0,:64]! @ d1[0,1]
74 vadd.f32 d0, d0, d3 @ d1[0]+d2[0], d1[1]-d2[1]
75 vld1.32 {d25}, [r1,:64], r8 @ d2[0,1]
76 vadd.f32 d1, d2, d1 @ -d1[0]+d2[0], d1[1]+d2[1]
77 veor q3, q12, q8 @ -d1[0],d1[1], d2[0],-d2[1]
78 pld [r0, #32]
79 vmul.f32 q10, q0, q9 @ ev.re, ev.im, od.im, od.re
80 pld [r1, #-32]
81 vadd.f32 d0, d24, d7 @ d1[0]+d2[0], d1[1]-d2[1]
82 vadd.f32 d1, d6, d25 @ -d1[0]+d2[0], d1[1]+d2[1]
83 vmul.f32 q11, q0, q9 @ ev.re, ev.im, od.im, od.re
84 veor d7, d21, d16 @ -od.im, od.re
85 vrev64.32 d3, d21 @ od.re, od.im
86 veor d6, d20, d17 @ ev.re,-ev.im
87 veor d2, d3, d16 @ -od.re, od.im
88 vmla.f32 d20, d3, d4[1]
89 vmla.f32 d20, d7, d5[1]
90 vmla.f32 d6, d2, d4[1]
91 vmla.f32 d6, d21, d5[1]
92 vld1.32 {d4}, [r2,:64]! @ tcos[i]
93 veor d7, d23, d16 @ -od.im, od.re
94 vld1.32 {d5}, [r3,:64]! @ tsin[i]
95 veor d24, d22, d17 @ ev.re,-ev.im
96 vrev64.32 d3, d23 @ od.re, od.im
97 veor d5, d26, d5
98 pld [r2, #32]
99 veor d2, d3, d16 @ -od.re, od.im
100 pld [r3, #32]
101 vmla.f32 d22, d3, d4[0]
102 vmla.f32 d22, d7, d5[0]
103 vmla.f32 d24, d2, d4[0]
104 vmla.f32 d24, d23, d5[0]
105 vld1.32 {d0}, [r0,:64]! @ d1[0,1]
106 vld1.32 {d1}, [r1,:64], r8 @ d2[0,1]
107 vst1.32 {d20}, [r7,:64]!
108 vst1.32 {d6}, [lr,:64], r8
109 vst1.32 {d22}, [r7,:64]!
110 vst1.32 {d24}, [lr,:64], r8
111 subs r12, r12, #2
112 bgt 2b
113
114 veor q1, q0, q8 @ -d1[0],d1[1], d2[0],-d2[1]
115 vadd.f32 d0, d0, d3 @ d1[0]+d2[0], d1[1]-d2[1]
116 vadd.f32 d1, d2, d1 @ -d1[0]+d2[0], d1[1]+d2[1]
117 ldr r2, [r4, #8] @ sign_convention
118 vmul.f32 q10, q0, q9 @ ev.re, ev.im, od.im, od.re
119 add r0, r0, #4
120 bfc r2, #0, #31
121 vld1.32 {d0[0]}, [r0,:32]
122 veor d7, d21, d16 @ -od.im, od.re
123 vrev64.32 d3, d21 @ od.re, od.im
124 veor d6, d20, d17 @ ev.re,-ev.im
125 vld1.32 {d22}, [r5,:64]
126 vdup.32 d1, r2
127 vmov d23, d22
128 veor d2, d3, d16 @ -od.re, od.im
129 vtrn.32 d22, d23
130 veor d0, d0, d1
131 veor d23, d23, d17
132 vmla.f32 d20, d3, d4[1]
133 vmla.f32 d20, d7, d5[1]
134 vmla.f32 d6, d2, d4[1]
135 vmla.f32 d6, d21, d5[1]
136 vadd.f32 d22, d22, d23
137 vst1.32 {d20}, [r7,:64]
138 vst1.32 {d6}, [lr,:64]
139 vst1.32 {d0[0]}, [r0,:32]
140 vst1.32 {d22}, [r5,:64]
141
142 cmp r6, #0
143 it eq
144 popeq {r4-r8,pc}
145
146 vmul.f32 d22, d22, d18
147 vst1.32 {d22}, [r5,:64]
148 add r0, r4, #24
149 mov r1, r5
150 bl X(ff_fft_permute_neon)
151 add r0, r4, #24
152 mov r1, r5
153 pop {r4-r8,lr}
154 b X(ff_fft_calc_neon)
155endfunc
libavcodec/arm/synth_filter_init_arm.c+0−1
@@ -23,7 +23,6 @@ · 22 unmodified lines
23#include "libavutil/arm/cpu.h"23#include "libavutil/arm/cpu.h"
24#include "libavutil/attributes.h"24#include "libavutil/attributes.h"
25#include "libavutil/internal.h"25#include "libavutil/internal.h"
26#include "libavcodec/fft.h"
27#include "libavcodec/synth_filter.h"26#include "libavcodec/synth_filter.h"
28 27
29void ff_synth_filter_float_vfp(AVTXContext *imdct,28void ff_synth_filter_float_vfp(AVTXContext *imdct,
libavcodec/cos_tablegen.c+0−80
@@ -1,80 +0,0 @@
1/*
2 * Generate a header file for hardcoded ff_cos_* tables
3 *
4 * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <stdio.h>
24#include <string.h>
25#include <math.h>
26
27#include "libavutil/mathematics.h"
28
29#define BITS 17
30#define FLOATFMT "%.18e"
31#define FIXEDFMT "%6d"
32
33static int clip_f15(int v)
34{
35 return v < -32767 ? -32767 :
36 v > 32767 ? 32767 :
37 v;
38}
39
40static void printval(double val, int fixed)
41{
42 if (fixed) {
43 /* lrint() isn't always available, so round and cast manually. */
44 double new_val = val * (double) (1 << 15);
45
46 new_val = new_val >= 0 ? floor(new_val + 0.5) : ceil(new_val - 0.5);
47
48 printf(" "FIXEDFMT",", clip_f15((long int) new_val));
49 } else {
50 printf(" "FLOATFMT",", val);
51 }
52}
53
54int main(int argc, char *argv[])
55{
56 int i, j;
57 int do_sin = argc > 1 && !strcmp(argv[1], "sin");
58 int fixed = argc > 1 && strstr(argv[1], "fixed");
59 double (*func)(double) = do_sin ? sin : cos;
60
61 printf("/* This file was automatically generated. */\n");
62 printf("#define FFT_FLOAT %d\n", !fixed);
63 printf("#include \"libavcodec/%s\"\n", do_sin ? "rdft.h" : "fft.h");
64 for (i = 4; i <= BITS; i++) {
65 int m = 1 << i;
66 double freq = 2*M_PI/m;
67 printf("%s(%i) = {\n ", do_sin ? "SINTABLE" : "COSTABLE", m);
68 for (j = 0; j < m/2 - 1; j++) {
69 int idx = j > m/4 ? m/2 - j : j;
70 if (do_sin && j >= m/4)
71 idx = m/4 - j;
72 printval(func(idx*freq), fixed);
73 if ((j & 3) == 3)
74 printf("\n ");
75 }
76 printval(func(do_sin ? -(m/4 - 1)*freq : freq), fixed);
77 printf("\n};\n");
78 }
79 return 0;
80}
libavcodec/dct.c+0−228
@@ -1,228 +0,0 @@
1/*
2 * (I)DCT Transforms
3 * Copyright (c) 2009 Peter Ross <pross@xvid.org>
4 * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
5 * Copyright (c) 2010 Vitor Sessak
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24/**
25 * @file
26 * (Inverse) Discrete Cosine Transforms. These are also known as the
27 * type II and type III DCTs respectively.
28 */
29
30#include <math.h>
31#include <string.h>
32
33#include "libavutil/error.h"
34#include "libavutil/mathematics.h"
35#include "libavutil/mem.h"
36#include "dct.h"
37#include "dct32.h"
38
39/* sin((M_PI * x / (2 * n)) */
40#define SIN(s, n, x) (s->costab[(n) - (x)])
41
42/* cos((M_PI * x / (2 * n)) */
43#define COS(s, n, x) (s->costab[x])
44
45static void dst_calc_I_c(DCTContext *ctx, FFTSample *data)
46{
47 int n = 1 << ctx->nbits;
48 int i;
49
50 data[0] = 0;
51 for (i = 1; i < n / 2; i++) {
52 float tmp1 = data[i ];
53 float tmp2 = data[n - i];
54 float s = SIN(ctx, n, 2 * i);
55
56 s *= tmp1 + tmp2;
57 tmp1 = (tmp1 - tmp2) * 0.5f;
58 data[i] = s + tmp1;
59 data[n - i] = s - tmp1;
60 }
61
62 data[n / 2] *= 2;
63 ctx->rdft.rdft_calc(&ctx->rdft, data);
64
65 data[0] *= 0.5f;
66
67 for (i = 1; i < n - 2; i += 2) {
68 data[i + 1] += data[i - 1];
69 data[i] = -data[i + 2];
70 }
71
72 data[n - 1] = 0;
73}
74
75static void dct_calc_I_c(DCTContext *ctx, FFTSample *data)
76{
77 int n = 1 << ctx->nbits;
78 int i;
79 float next = -0.5f * (data[0] - data[n]);
80
81 for (i = 0; i < n / 2; i++) {
82 float tmp1 = data[i];
83 float tmp2 = data[n - i];
84 float s = SIN(ctx, n, 2 * i);
85 float c = COS(ctx, n, 2 * i);
86
87 c *= tmp1 - tmp2;
88 s *= tmp1 - tmp2;
89
90 next += c;
91
92 tmp1 = (tmp1 + tmp2) * 0.5f;
93 data[i] = tmp1 - s;
94 data[n - i] = tmp1 + s;
95 }
96
97 ctx->rdft.rdft_calc(&ctx->rdft, data);
98 data[n] = data[1];
99 data[1] = next;
100
101 for (i = 3; i <= n; i += 2)
102 data[i] = data[i - 2] - data[i];
103}
104
105static void dct_calc_III_c(DCTContext *ctx, FFTSample *data)
106{
107 int n = 1 << ctx->nbits;
108 int i;
109
110 float next = data[n - 1];
111 float inv_n = 1.0f / n;
112
113 for (i = n - 2; i >= 2; i -= 2) {
114 float val1 = data[i];
115 float val2 = data[i - 1] - data[i + 1];
116 float c = COS(ctx, n, i);
117 float s = SIN(ctx, n, i);
118
119 data[i] = c * val1 + s * val2;
120 data[i + 1] = s * val1 - c * val2;
121 }
122
123 data[1] = 2 * next;
124
125 ctx->rdft.rdft_calc(&ctx->rdft, data);
126
127 for (i = 0; i < n / 2; i++) {
128 float tmp1 = data[i] * inv_n;
129 float tmp2 = data[n - i - 1] * inv_n;
130 float csc = ctx->csc2[i] * (tmp1 - tmp2);
131
132 tmp1 += tmp2;
133 data[i] = tmp1 + csc;
134 data[n - i - 1] = tmp1 - csc;
135 }
136}
137
138static void dct_calc_II_c(DCTContext *ctx, FFTSample *data)
139{
140 int n = 1 << ctx->nbits;
141 int i;
142 float next;
143
144 for (i = 0; i < n / 2; i++) {
145 float tmp1 = data[i];
146 float tmp2 = data[n - i - 1];
147 float s = SIN(ctx, n, 2 * i + 1);
148
149 s *= tmp1 - tmp2;
150 tmp1 = (tmp1 + tmp2) * 0.5f;
151
152 data[i] = tmp1 + s;
153 data[n-i-1] = tmp1 - s;
154 }
155
156 ctx->rdft.rdft_calc(&ctx->rdft, data);
157
158 next = data[1] * 0.5;
159 data[1] *= -1;
160
161 for (i = n - 2; i >= 0; i -= 2) {
162 float inr = data[i ];
163 float ini = data[i + 1];
164 float c = COS(ctx, n, i);
165 float s = SIN(ctx, n, i);
166
167 data[i] = c * inr + s * ini;
168 data[i + 1] = next;
169
170 next += s * inr - c * ini;
171 }
172}
173
174static void dct32_func(DCTContext *ctx, FFTSample *data)
175{
176 ctx->dct32(data, data);
177}
178
179av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
180{
181 int n = 1 << nbits;
182 int i;
183 int ret;
184
185 memset(s, 0, sizeof(*s));
186
187 s->nbits = nbits;
188 s->inverse = inverse;
189
190 if (inverse == DCT_II && nbits == 5) {
191 s->dct_calc = dct32_func;
192 } else {
193 ff_init_ff_cos_tabs(nbits + 2);
194
195 s->costab = ff_cos_tabs[nbits + 2];
196 s->csc2 = av_malloc_array(n / 2, sizeof(FFTSample));
197 if (!s->csc2)
198 return AVERROR(ENOMEM);
199
200 if ((ret = ff_rdft_init(&s->rdft, nbits, inverse == DCT_III)) < 0) {
201 av_freep(&s->csc2);
202 return ret;
203 }
204
205 for (i = 0; i < n / 2; i++)
206 s->csc2[i] = 0.5 / sin((M_PI / (2 * n) * (2 * i + 1)));
207
208 switch (inverse) {
209 case DCT_I : s->dct_calc = dct_calc_I_c; break;
210 case DCT_II : s->dct_calc = dct_calc_II_c; break;
211 case DCT_III: s->dct_calc = dct_calc_III_c; break;
212 case DST_I : s->dct_calc = dst_calc_I_c; break;
213 }
214 }
215
216 s->dct32 = ff_dct32_float;
217#if ARCH_X86
218 ff_dct_init_x86(s);
219#endif
220
221 return 0;
222}
223
224av_cold void ff_dct_end(DCTContext *s)
225{
226 ff_rdft_end(&s->rdft);
227 av_freep(&s->csc2);
228}
libavcodec/dct.h+1−26
@@ -21,37 +21,12 @@ · 20 unmodified lines
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */22 */
23 23
24#if !defined(AVCODEC_DCT_H) && (!defined(FFT_FLOAT) || FFT_FLOAT)24#ifndef AVCODEC_DCT_H
25#define AVCODEC_DCT_H25#define AVCODEC_DCT_H
26 26
27#include <stddef.h>27#include <stddef.h>
28#include <stdint.h>28#include <stdint.h>
29 29
30#include "rdft.h"
31
32struct DCTContext {
33 int nbits;
34 int inverse;
35 RDFTContext rdft;
36 const float *costab;
37 FFTSample *csc2;
38 void (*dct_calc)(struct DCTContext *s, FFTSample *data);
39 void (*dct32)(FFTSample *out, const FFTSample *in);
40};
41
42/**
43 * Set up DCT.
44 * @param nbits size of the input array:
45 * (1 << nbits) for DCT-II, DCT-III and DST-I
46 * (1 << nbits) + 1 for DCT-I
47 *
48 * @note the first element of the input of DST-I is ignored
49 */
50int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type);
51void ff_dct_end (DCTContext *s);
52
53void ff_dct_init_x86(DCTContext *s);
54
55void ff_j_rev_dct(int16_t *data);30void ff_j_rev_dct(int16_t *data);
56void ff_j_rev_dct4(int16_t *data);31void ff_j_rev_dct4(int16_t *data);
57void ff_j_rev_dct2(int16_t *data);32void ff_j_rev_dct2(int16_t *data);
libavcodec/fft-internal.h+0−62
@@ -1,62 +0,0 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVCODEC_FFT_INTERNAL_H
20#define AVCODEC_FFT_INTERNAL_H
21
22#include "libavutil/mathematics.h"
23#include "fft.h"
24
25#if FFT_FLOAT
26
27#define FIX15(v) (v)
28#define sqrthalf (float)M_SQRT1_2
29
30#define BF(x, y, a, b) do { \
31 x = a - b; \
32 y = a + b; \
33 } while (0)
34
35#define CMUL(dre, dim, are, aim, bre, bim) do { \
36 (dre) = (are) * (bre) - (aim) * (bim); \
37 (dim) = (are) * (bim) + (aim) * (bre); \
38 } while (0)
39
40#else /* FFT_FLOAT */
41
42#define CMUL(dre, dim, are, aim, bre, bim) do { \
43 int64_t accu; \
44 (accu) = (int64_t)(bre) * (are); \
45 (accu) -= (int64_t)(bim) * (aim); \
46 (dre) = (int)(((accu) + 0x40000000) >> 31); \
47 (accu) = (int64_t)(bre) * (aim); \
48 (accu) += (int64_t)(bim) * (are); \
49 (dim) = (int)(((accu) + 0x40000000) >> 31); \
50 } while (0)
51
52#endif /* FFT_FLOAT */
53
54#define ff_imdct_calc_c FFT_NAME(ff_imdct_calc_c)
55#define ff_imdct_half_c FFT_NAME(ff_imdct_half_c)
56#define ff_mdct_calc_c FFT_NAME(ff_mdct_calc_c)
57
58void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
59void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input);
60void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
61
62#endif /* AVCODEC_FFT_INTERNAL_H */
libavcodec/fft.h+0−160
@@ -1,160 +0,0 @@
1/*
2 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
3 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef AVCODEC_FFT_H
23#define AVCODEC_FFT_H
24
25#ifndef FFT_FLOAT
26#define FFT_FLOAT 1
27#endif
28
29#include <stdint.h>
30#include "config.h"
31
32#include "libavutil/attributes_internal.h"
33#include "libavutil/mem_internal.h"
34
35#if FFT_FLOAT
36
37#include "avfft.h"
38
39#define FFT_NAME(x) x
40
41typedef float FFTDouble;
42
43#else
44
45#define Q31(x) (int)((x)*2147483648.0 + 0.5)
46#define FFT_NAME(x) x ## _fixed_32
47
48typedef int32_t FFTSample;
49
50typedef struct FFTComplex {
51 FFTSample re, im;
52} FFTComplex;
53
54typedef int FFTDouble;
55typedef struct FFTContext FFTContext;
56
57#endif /* FFT_FLOAT */
58
59typedef struct FFTDComplex {
60 FFTDouble re, im;
61} FFTDComplex;
62
63/* FFT computation */
64
65enum fft_permutation_type {
66 FF_FFT_PERM_DEFAULT,
67 FF_FFT_PERM_SWAP_LSBS,
68 FF_FFT_PERM_AVX,
69};
70
71enum mdct_permutation_type {
72 FF_MDCT_PERM_NONE,
73 FF_MDCT_PERM_INTERLEAVE,
74};
75
76struct FFTContext {
77 int nbits;
78 int inverse;
79 uint16_t *revtab;
80 FFTComplex *tmp_buf;
81 int mdct_size; /* size of MDCT (i.e. number of input data * 2) */
82 int mdct_bits; /* n = 2^nbits */
83 /* pre/post rotation tables */
84 FFTSample *tcos;
85 FFTSample *tsin;
86 /**
87 * Do the permutation needed BEFORE calling fft_calc().
88 */
89 void (*fft_permute)(struct FFTContext *s, FFTComplex *z);
90 /**
91 * Do a complex FFT with the parameters defined in ff_fft_init(). The
92 * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
93 */
94 void (*fft_calc)(struct FFTContext *s, FFTComplex *z);
95 void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
96 void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
97 void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
98 enum fft_permutation_type fft_permutation;
99 enum mdct_permutation_type mdct_permutation;
100 uint32_t *revtab32;
101};
102
103#if CONFIG_HARDCODED_TABLES
104#define COSTABLE_CONST const
105#define ff_init_ff_cos_tabs(index)
106#else
107#define COSTABLE_CONST
108#define ff_init_ff_cos_tabs FFT_NAME(ff_init_ff_cos_tabs)
109
110/**
111 * Initialize the cosine table in ff_cos_tabs[index]
112 * @param index index in ff_cos_tabs array of the table to initialize
113 */
114void ff_init_ff_cos_tabs(int index);
115#endif
116
117#define COSTABLE(size) \
118 COSTABLE_CONST attribute_visibility_hidden DECLARE_ALIGNED(32, FFTSample, FFT_NAME(ff_cos_##size))[size/2]
119
120extern COSTABLE(16);
121extern COSTABLE(32);
122extern COSTABLE(64);
123extern COSTABLE(128);
124extern COSTABLE(256);
125extern COSTABLE(512);
126extern COSTABLE(1024);
127extern COSTABLE(2048);
128extern COSTABLE(4096);
129extern COSTABLE(8192);
130extern COSTABLE(16384);
131extern COSTABLE(32768);
132extern COSTABLE(65536);
133extern COSTABLE(131072);
134extern COSTABLE_CONST FFTSample* const FFT_NAME(ff_cos_tabs)[18];
135
136#define ff_fft_init FFT_NAME(ff_fft_init)
137#define ff_fft_end FFT_NAME(ff_fft_end)
138
139/**
140 * Set up a complex FFT.
141 * @param nbits log2 of the length of the input array
142 * @param inverse if 0 perform the forward transform, if 1 perform the inverse
143 */
144int ff_fft_init(FFTContext *s, int nbits, int inverse);
145
146void ff_fft_init_aarch64(FFTContext *s);
147void ff_fft_init_x86(FFTContext *s);
148void ff_fft_init_arm(FFTContext *s);
149void ff_fft_init_mips(FFTContext *s);
150void ff_fft_init_ppc(FFTContext *s);
151
152void ff_fft_end(FFTContext *s);
153
154#define ff_mdct_init FFT_NAME(ff_mdct_init)
155#define ff_mdct_end FFT_NAME(ff_mdct_end)
156
157int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale);
158void ff_mdct_end(FFTContext *s);
159
160#endif /* AVCODEC_FFT_H */
libavcodec/fft_fixed_32.c+0−51
@@ -1,51 +0,0 @@
1/*
2 * Copyright (c) 2012
3 * MIPS Technologies, Inc., California.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * Authors: Stanislav Ocovaj (socovaj@mips.com)
30 * Goran Cordasic (goran@mips.com)
31 * Djordje Pesut (djordje@mips.com)
32 *
33 * This file is part of FFmpeg.
34 *
35 * FFmpeg is free software; you can redistribute it and/or
36 * modify it under the terms of the GNU Lesser General Public
37 * License as published by the Free Software Foundation; either
38 * version 2.1 of the License, or (at your option) any later version.
39 *
40 * FFmpeg is distributed in the hope that it will be useful,
41 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43 * Lesser General Public License for more details.
44 *
45 * You should have received a copy of the GNU Lesser General Public
46 * License along with FFmpeg; if not, write to the Free Software
47 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
48 */
49
50#define FFT_FLOAT 0
51#include "fft_template.c"
libavcodec/fft_float.c+0−20
@@ -1,20 +0,0 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#define FFT_FLOAT 1
20#include "fft_template.c"
libavcodec/fft_init_table.c+0−344
@@ -1,344 +0,0 @@
1/*
2 * Copyright (c) 2012
3 * MIPS Technologies, Inc., California.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * Authors: Stanislav Ocovaj (socovaj@mips.com)
30 * Goran Cordasic (goran@mips.com)
31 * Djordje Pesut (djordje@mips.com)
32 *
33 * This file is part of FFmpeg.
34 *
35 * FFmpeg is free software; you can redistribute it and/or
36 * modify it under the terms of the GNU Lesser General Public
37 * License as published by the Free Software Foundation; either
38 * version 2.1 of the License, or (at your option) any later version.
39 *
40 * FFmpeg is distributed in the hope that it will be useful,
41 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43 * Lesser General Public License for more details.
44 *
45 * You should have received a copy of the GNU Lesser General Public
46 * License along with FFmpeg; if not, write to the Free Software
47 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
48 */
49
50/**
51 * @file
52 * definitions and initialization of LUT table for FFT
53 */
54#include "libavutil/thread.h"
55
56#include "libavcodec/fft_table.h"
57
58const int32_t ff_w_tab_sr[MAX_FFT_SIZE/(4*16)] = {
592147483647, 2147483016, 2147481121, 2147477963, 2147473542, 2147467857, 2147460908, 2147452697,
602147443222, 2147432484, 2147420483, 2147407218, 2147392690, 2147376899, 2147359845, 2147341527,
612147321946, 2147301102, 2147278995, 2147255625, 2147230991, 2147205094, 2147177934, 2147149511,
622147119825, 2147088876, 2147056664, 2147023188, 2146988450, 2146952448, 2146915184, 2146876656,
632146836866, 2146795813, 2146753497, 2146709917, 2146665076, 2146618971, 2146571603, 2146522973,
642146473080, 2146421924, 2146369505, 2146315824, 2146260881, 2146204674, 2146147205, 2146088474,
652146028480, 2145967224, 2145904705, 2145840924, 2145775880, 2145709574, 2145642006, 2145573176,
662145503083, 2145431729, 2145359112, 2145285233, 2145210092, 2145133690, 2145056025, 2144977098,
672144896910, 2144815460, 2144732748, 2144648774, 2144563539, 2144477042, 2144389283, 2144300264,
682144209982, 2144118439, 2144025635, 2143931570, 2143836244, 2143739656, 2143641807, 2143542697,
692143442326, 2143340694, 2143237802, 2143133648, 2143028234, 2142921559, 2142813624, 2142704427,
702142593971, 2142482254, 2142369276, 2142255039, 2142139541, 2142022783, 2141904764, 2141785486,
712141664948, 2141543150, 2141420092, 2141295774, 2141170197, 2141043360, 2140915264, 2140785908,
722140655293, 2140523418, 2140390284, 2140255892, 2140120240, 2139983329, 2139845159, 2139705730,
732139565043, 2139423097, 2139279892, 2139135429, 2138989708, 2138842728, 2138694490, 2138544994,
742138394240, 2138242228, 2138088958, 2137934430, 2137778644, 2137621601, 2137463301, 2137303743,
752137142927, 2136980855, 2136817525, 2136652938, 2136487095, 2136319994, 2136151637, 2135982023,
762135811153, 2135639026, 2135465642, 2135291003, 2135115107, 2134937956, 2134759548, 2134579885,
772134398966, 2134216791, 2134033361, 2133848675, 2133662734, 2133475538, 2133287087, 2133097381,
782132906420, 2132714204, 2132520734, 2132326009, 2132130030, 2131932796, 2131734309, 2131534567,
792131333572, 2131131322, 2130927819, 2130723062, 2130517052, 2130309789, 2130101272, 2129891502,
802129680480, 2129468204, 2129254676, 2129039895, 2128823862, 2128606576, 2128388038, 2128168248,
812127947206, 2127724913, 2127501367, 2127276570, 2127050522, 2126823222, 2126594672, 2126364870,
822126133817, 2125901514, 2125667960, 2125433155, 2125197100, 2124959795, 2124721240, 2124481435,
832124240380, 2123998076, 2123754522, 2123509718, 2123263666, 2123016364, 2122767814, 2122518015,
842122266967, 2122014670, 2121761126, 2121506333, 2121250292, 2120993003, 2120734467, 2120474683,
852120213651, 2119951372, 2119687847, 2119423074, 2119157054, 2118889788, 2118621275, 2118351516,
862118080511, 2117808259, 2117534762, 2117260020, 2116984031, 2116706797, 2116428319, 2116148595,
872115867626, 2115585412, 2115301954, 2115017252, 2114731305, 2114444114, 2114155680, 2113866001,
882113575080, 2113282914, 2112989506, 2112694855, 2112398960, 2112101824, 2111803444, 2111503822,
892111202959, 2110900853, 2110597505, 2110292916, 2109987085, 2109680013, 2109371700, 2109062146,
902108751352, 2108439317, 2108126041, 2107811526, 2107495770, 2107178775, 2106860540, 2106541065,
912106220352, 2105898399, 2105575208, 2105250778, 2104925109, 2104598202, 2104270057, 2103940674,
922103610054, 2103278196, 2102945101, 2102610768, 2102275199, 2101938393, 2101600350, 2101261071,
932100920556, 2100578805, 2100235819, 2099891596, 2099546139, 2099199446, 2098851519, 2098502357,
942098151960, 2097800329, 2097447464, 2097093365, 2096738032, 2096381466, 2096023667, 2095664635,
952095304370, 2094942872, 2094580142, 2094216179, 2093850985, 2093484559, 2093116901, 2092748012,
962092377892, 2092006541, 2091633960, 2091260147, 2090885105, 2090508833, 2090131331, 2089752599,
972089372638, 2088991448, 2088609029, 2088225381, 2087840505, 2087454400, 2087067068, 2086678508,
982086288720, 2085897705, 2085505463, 2085111994, 2084717298, 2084321376, 2083924228, 2083525854,
992083126254, 2082725429, 2082323379, 2081920103, 2081515603, 2081109879, 2080702930, 2080294757,
1002079885360, 2079474740, 2079062896, 2078649830, 2078235540, 2077820028, 2077403294, 2076985338,
1012076566160, 2076145760, 2075724139, 2075301296, 2074877233, 2074451950, 2074025446, 2073597721,
1022073168777, 2072738614, 2072307231, 2071874629, 2071440808, 2071005769, 2070569511, 2070132035,
1032069693342, 2069253430, 2068812302, 2068369957, 2067926394, 2067481616, 2067035621, 2066588410,
1042066139983, 2065690341, 2065239484, 2064787411, 2064334124, 2063879623, 2063423908, 2062966978,
1052062508835, 2062049479, 2061588910, 2061127128, 2060664133, 2060199927, 2059734508, 2059267877,
1062058800036, 2058330983, 2057860719, 2057389244, 2056916560, 2056442665, 2055967560, 2055491246,
1072055013723, 2054534991, 2054055050, 2053573901, 2053091544, 2052607979, 2052123207, 2051637227,
1082051150040, 2050661647, 2050172048, 2049681242, 2049189231, 2048696014, 2048201592, 2047705965,
1092047209133, 2046711097, 2046211857, 2045711414, 2045209767, 2044706916, 2044202863, 2043697608,
1102043191150, 2042683490, 2042174628, 2041664565, 2041153301, 2040640837, 2040127172, 2039612306,
1112039096241, 2038578976, 2038060512, 2037540850, 2037019988, 2036497928, 2035974670, 2035450215,
1122034924562, 2034397712, 2033869665, 2033340422, 2032809982, 2032278347, 2031745516, 2031211490,
1132030676269, 2030139853, 2029602243, 2029063439, 2028523442, 2027982251, 2027439867, 2026896291,
1142026351522, 2025805561, 2025258408, 2024710064, 2024160529, 2023609803, 2023057887, 2022504780,
1152021950484, 2021394998, 2020838323, 2020280460, 2019721407, 2019161167, 2018599739, 2018037123,
1162017473321, 2016908331, 2016342155, 2015774793, 2015206245, 2014636511, 2014065592, 2013493489,
1172012920201, 2012345729, 2011770073, 2011193233, 2010615210, 2010036005, 2009455617, 2008874047,
1182008291295, 2007707362, 2007122248, 2006535953, 2005948478, 2005359822, 2004769987, 2004178973,
1192003586779, 2002993407, 2002398857, 2001803128, 2001206222, 2000608139, 2000008879, 1999408442,
1201998806829, 1998204040, 1997600076, 1996994937, 1996388622, 1995781134, 1995172471, 1994562635,
1211993951625, 1993339442, 1992726087, 1992111559, 1991495860, 1990878989, 1990260946, 1989641733,
1221989021350, 1988399796, 1987777073, 1987153180, 1986528118, 1985901888, 1985274489, 1984645923,
1231984016189, 1983385288, 1982753220, 1982119985, 1981485585, 1980850019, 1980213288, 1979575392,
1241978936331, 1978296106, 1977654717, 1977012165, 1976368450, 1975723572, 1975077532, 1974430331,
1251973781967, 1973132443, 1972481757, 1971829912, 1971176906, 1970522741, 1969867417, 1969210933,
1261968553292, 1967894492, 1967234535, 1966573420, 1965911148, 1965247720, 1964583136, 1963917396,
1271963250501, 1962582451, 1961913246, 1961242888, 1960571375, 1959898709, 1959224890, 1958549919,
1281957873796, 1957196520, 1956518093, 1955838516, 1955157788, 1954475909, 1953792881, 1953108703,
1291952423377, 1951736902, 1951049279, 1950360508, 1949670589, 1948979524, 1948287312, 1947593954,
1301946899451, 1946203802, 1945507008, 1944809070, 1944109987, 1943409761, 1942708392, 1942005880,
1311941302225, 1940597428, 1939891490, 1939184411, 1938476190, 1937766830, 1937056329, 1936344689,
1321935631910, 1934917992, 1934202936, 1933486742, 1932769411, 1932050943, 1931331338, 1930610597,
1331929888720, 1929165708, 1928441561, 1927716279, 1926989864, 1926262315, 1925533633, 1924803818,
1341924072871, 1923340791, 1922607581, 1921873239, 1921137767, 1920401165, 1919663432, 1918924571,
1351918184581, 1917443462, 1916701216, 1915957841, 1915213340, 1914467712, 1913720958, 1912973078,
1361912224073, 1911473942, 1910722688, 1909970309, 1909216806, 1908462181, 1907706433, 1906949562,
1371906191570, 1905432457, 1904672222, 1903910867, 1903148392, 1902384797, 1901620084, 1900854251,
1381900087301, 1899319232, 1898550047, 1897779744, 1897008325, 1896235790, 1895462140, 1894687374,
1391893911494, 1893134500, 1892356392, 1891577171, 1890796837, 1890015391, 1889232832, 1888449163,
1401887664383, 1886878492, 1886091491, 1885303381, 1884514161, 1883723833, 1882932397, 1882139853,
1411881346202, 1880551444, 1879755580, 1878958610, 1878160535, 1877361354, 1876561070, 1875759681,
1421874957189, 1874153594, 1873348897, 1872543097, 1871736196, 1870928194, 1870119091, 1869308888,
1431868497586, 1867685184, 1866871683, 1866057085, 1865241388, 1864424594, 1863606704, 1862787717,
1441861967634, 1861146456, 1860324183, 1859500816, 1858676355, 1857850800, 1857024153, 1856196413,
1451855367581, 1854537657, 1853706643, 1852874538, 1852041343, 1851207059, 1850371686, 1849535224,
1461848697674, 1847859036, 1847019312, 1846178501, 1845336604, 1844493621, 1843649553, 1842804401,
1471841958164, 1841110844, 1840262441, 1839412956, 1838562388, 1837710739, 1836858008, 1836004197,
1481835149306, 1834293336, 1833436286, 1832578158, 1831718951, 1830858668, 1829997307, 1829134869,
1491828271356, 1827406767, 1826541103, 1825674364, 1824806552, 1823937666, 1823067707, 1822196675,
1501821324572, 1820451397, 1819577151, 1818701835, 1817825449, 1816947994, 1816069469, 1815189877,
1511814309216, 1813427489, 1812544694, 1811660833, 1810775906, 1809889915, 1809002858, 1808114737,
1521807225553, 1806335305, 1805443995, 1804551623, 1803658189, 1802763694, 1801868139, 1800971523,
1531800073849, 1799175115, 1798275323, 1797374472, 1796472565, 1795569601, 1794665580, 1793760504,
1541792854372, 1791947186, 1791038946, 1790129652, 1789219305, 1788307905, 1787395453, 1786481950,
1551785567396, 1784651792, 1783735137, 1782817434, 1781898681, 1780978881, 1780058032, 1779136137,
1561778213194, 1777289206, 1776364172, 1775438094, 1774510970, 1773582803, 1772653593, 1771723340,
1571770792044, 1769859707, 1768926328, 1767991909, 1767056450, 1766119952, 1765182414, 1764243838,
1581763304224, 1762363573, 1761421885, 1760479161, 1759535401, 1758590607, 1757644777, 1756697914,
1591755750017, 1754801087, 1753851126, 1752900132, 1751948107, 1750995052, 1750040966, 1749085851,
1601748129707, 1747172535, 1746214334, 1745255107, 1744294853, 1743333573, 1742371267, 1741407936,
1611740443581, 1739478202, 1738511799, 1737544374, 1736575927, 1735606458, 1734635968, 1733664458,
1621732691928, 1731718378, 1730743810, 1729768224, 1728791620, 1727813999, 1726835361, 1725855708,
1631724875040, 1723893357, 1722910659, 1721926948, 1720942225, 1719956488, 1718969740, 1717981981,
1641716993211, 1716003431, 1715012642, 1714020844, 1713028037, 1712034223, 1711039401, 1710043573,
1651709046739, 1708048900, 1707050055, 1706050207, 1705049355, 1704047500, 1703044642, 1702040783,
1661701035922, 1700030061, 1699023199, 1698015339, 1697006479, 1695996621, 1694985765, 1693973912,
1671692961062, 1691947217, 1690932376, 1689916541, 1688899711, 1687881888, 1686863072, 1685843263,
1681684822463, 1683800672, 1682777890, 1681754118, 1680729357, 1679703608, 1678676870, 1677649144,
1691676620432, 1675590733, 1674560049, 1673528379, 1672495725, 1671462087, 1670427466, 1669391862,
1701668355276, 1667317709, 1666279161, 1665239632, 1664199124, 1663157637, 1662115172, 1661071729,
1711660027308, 1658981911, 1657935539, 1656888190, 1655839867, 1654790570, 1653740300, 1652689057,
1721651636841, 1650583654, 1649529496, 1648474367, 1647418269, 1646361202, 1645303166, 1644244162,
1731643184191, 1642123253, 1641061349, 1639998480, 1638934646, 1637869848, 1636804087, 1635737362,
1741634669676, 1633601027, 1632531418, 1631460848, 1630389319, 1629316830, 1628243383, 1627168978,
1751626093616, 1625017297, 1623940023, 1622861793, 1621782608, 1620702469, 1619621377, 1618539332,
1761617456335, 1616372386, 1615287487, 1614201637, 1613114838, 1612027089, 1610938393, 1609848749,
1771608758157, 1607666620, 1606574136, 1605480708, 1604386335, 1603291018, 1602194758, 1601097555,
1781599999411, 1598900325, 1597800299, 1596699333, 1595597428, 1594494583, 1593390801, 1592286082,
1791591180426, 1590073833, 1588966306, 1587857843, 1586748447, 1585638117, 1584526854, 1583414660,
1801582301533, 1581187476, 1580072489, 1578956572, 1577839726, 1576721952, 1575603251, 1574483623,
1811573363068, 1572241588, 1571119183, 1569995854, 1568871601, 1567746425, 1566620327, 1565493307,
1821564365367, 1563236506, 1562106725, 1560976026, 1559844408, 1558711873, 1557578421, 1556444052,
1831555308768, 1554172569, 1553035455, 1551897428, 1550758488, 1549618636, 1548477872, 1547336197,
1841546193612, 1545050118, 1543905714, 1542760402, 1541614183, 1540467057, 1539319024, 1538170087,
1851537020244, 1535869497, 1534717846, 1533565293, 1532411837, 1531257480, 1530102222, 1528946064,
1861527789007, 1526631051, 1525472197, 1524312445, 1523151797, 1521990252, 1520827813, 1519664478,
1871518500250, 1517335128, 1516169114, 1515002208, 1513834411, 1512665723, 1511496145, 1510325678,
1881509154322, 1507982079, 1506808949, 1505634932, 1504460029, 1503284242, 1502107570, 1500930014,
1891499751576, 1498572255, 1497392053, 1496210969, 1495029006, 1493846163, 1492662441, 1491477842,
1901490292364, 1489106011, 1487918781, 1486730675, 1485541696, 1484351842, 1483161115, 1481969516,
1911480777044, 1479583702, 1478389489, 1477194407, 1475998456, 1474801636, 1473603949, 1472405394,
1921471205974, 1470005688, 1468804538, 1467602523, 1466399645, 1465195904, 1463991302, 1462785838,
1931461579514, 1460372329, 1459164286, 1457955385, 1456745625, 1455535009, 1454323536, 1453111208,
1941451898025, 1450683988, 1449469098, 1448253355, 1447036760, 1445819314, 1444601017, 1443381870,
1951442161874, 1440941030, 1439719338, 1438496799, 1437273414, 1436049184, 1434824109, 1433598189,
1961432371426, 1431143821, 1429915374, 1428686085, 1427455956, 1426224988, 1424993180, 1423760534,
1971422527051, 1421292730, 1420057574, 1418821582, 1417584755, 1416347095, 1415108601, 1413869275,
1981412629117, 1411388129, 1410146309, 1408903661, 1407660183, 1406415878, 1405170745, 1403924785,
1991402678000, 1401430389, 1400181954, 1398932695, 1397682613, 1396431709, 1395179984, 1393927438,
2001392674072, 1391419886, 1390164882, 1388909060, 1387652422, 1386394966, 1385136696, 1383877610,
2011382617710, 1381356997, 1380095472, 1378833134, 1377569986, 1376306026, 1375041258, 1373775680,
2021372509294, 1371242101, 1369974101, 1368705296, 1367435685, 1366165269, 1364894050, 1363622028,
2031362349204, 1361075579, 1359801152, 1358525926, 1357249901, 1355973077, 1354695455, 1353417037,
2041352137822, 1350857812, 1349577007, 1348295409, 1347013017, 1345729833, 1344445857, 1343161090,
2051341875533, 1340589187, 1339302052, 1338014129, 1336725419, 1335435923, 1334145641, 1332854574,
2061331562723, 1330270089, 1328976672, 1327682474, 1326387494, 1325091734, 1323795195, 1322497877,
2071321199781, 1319900907, 1318601257, 1317300832, 1315999631, 1314697657, 1313394909, 1312091388,
2081310787095, 1309482032, 1308176198, 1306869594, 1305562222, 1304254082, 1302945174, 1301635500,
2091300325060, 1299013855, 1297701886, 1296389154, 1295075659, 1293761402, 1292446384, 1291130606,
2101289814068, 1288496772, 1287178717, 1285859905, 1284540337, 1283220013, 1281898935, 1280577102,
2111279254516, 1277931177, 1276607086, 1275282245, 1273956653, 1272630312, 1271303222, 1269975384,
2121268646800, 1267317469, 1265987392, 1264656571, 1263325005, 1261992697, 1260659646, 1259325853,
2131257991320, 1256656047, 1255320034, 1253983283, 1252645794, 1251307568, 1249968606, 1248628909,
2141247288478, 1245947312, 1244605414, 1243262783, 1241919421, 1240575329, 1239230506, 1237884955,
2151236538675, 1235191668, 1233843935, 1232495475, 1231146291, 1229796382, 1228445750, 1227094395,
2161225742318, 1224389521, 1223036002, 1221681765, 1220326809, 1218971135, 1217614743, 1216257636,
2171214899813, 1213541275, 1212182024, 1210822059, 1209461382, 1208099993, 1206737894, 1205375085,
2181204011567, 1202647340, 1201282407, 1199916766, 1198550419, 1197183368, 1195815612, 1194447153,
2191193077991, 1191708127, 1190337562, 1188966297, 1187594332, 1186221669, 1184848308, 1183474250,
2201182099496, 1180724046, 1179347902, 1177971064, 1176593533, 1175215310, 1173836395, 1172456790,
2211171076495, 1169695512, 1168313840, 1166931481, 1165548435, 1164164704, 1162780288, 1161395188,
2221160009405, 1158622939, 1157235792, 1155847964, 1154459456, 1153070269, 1151680403, 1150289860,
2231148898640, 1147506745, 1146114174, 1144720929, 1143327011, 1141932420, 1140537158, 1139141224,
2241137744621, 1136347348, 1134949406, 1133550797, 1132151521, 1130751579, 1129350972, 1127949701,
2251126547765, 1125145168, 1123741908, 1122337987, 1120933406, 1119528166, 1118122267, 1116715710,
2261115308496, 1113900627, 1112492101, 1111082922, 1109673089, 1108262603, 1106851465, 1105439676,
2271104027237, 1102614148, 1101200410, 1099786025, 1098370993, 1096955314, 1095538991, 1094122023,
2281092704411, 1091286156, 1089867259, 1088447722, 1087027544, 1085606726, 1084185270, 1082763176,
2291081340445, 1079917078, 1078493076, 1077068439, 1075643169, 1074217266, 1072790730, 1071363564,
2301069935768, 1068507342, 1067078288, 1065648605, 1064218296, 1062787361, 1061355801, 1059923616,
2311058490808, 1057057377, 1055623324, 1054188651, 1052753357, 1051317443, 1049880912, 1048443763,
2321047005996, 1045567615, 1044128617, 1042689006, 1041248781, 1039807944, 1038366495, 1036924436,
2331035481766, 1034038487, 1032594600, 1031150105, 1029705004, 1028259297, 1026812985, 1025366069,
2341023918550, 1022470428, 1021021705, 1019572382, 1018122458, 1016671936, 1015220816, 1013769098,
2351012316784, 1010863875, 1009410370, 1007956272, 1006501581, 1005046298, 1003590424, 1002133959,
2361000676905, 999219262, 997761031, 996302214, 994842810, 993382821, 991922248, 990461091,
237988999351, 987537030, 986074127, 984610645, 983146583, 981681943, 980216726, 978750932,
238977284562, 975817617, 974350098, 972882006, 971413342, 969944106, 968474300, 967003923,
239965532978, 964061465, 962589385, 961116739, 959643527, 958169751, 956695411, 955220508,
240953745043, 952269017, 950792431, 949315286, 947837582, 946359321, 944880503, 943401129,
241941921200, 940440717, 938959681, 937478092, 935995952, 934513261, 933030021, 931546231,
242930061894, 928577010, 927091579, 925605603, 924119082, 922632018, 921144411, 919656262,
243918167572, 916678342, 915188572, 913698265, 912207419, 910716038, 909224120, 907731667,
244906238681, 904745161, 903251110, 901756526, 900261413, 898765769, 897269597, 895772898,
245894275671, 892777918, 891279640, 889780838, 888281512, 886781663, 885281293, 883780402,
246882278992, 880777062, 879274614, 877771649, 876268167, 874764170, 873259659, 871754633,
247870249095, 868743045, 867236484, 865729413, 864221832, 862713743, 861205147, 859696043,
248858186435, 856676321, 855165703, 853654582, 852142959, 850630835, 849118210, 847605086,
249846091463, 844577343, 843062726, 841547612, 840032004, 838515901, 836999305, 835482217,
250833964638, 832446567, 830928007, 829408958, 827889422, 826369398, 824848888, 823327893,
251821806413, 820284450, 818762005, 817239078, 815715670, 814191782, 812667415, 811142571,
252809617249, 808091450, 806565177, 805038429, 803511207, 801983513, 800455346, 798926709,
253797397602, 795868026, 794337982, 792807470, 791276492, 789745049, 788213141, 786680769,
254785147934, 783614638, 782080880, 780546663, 779011986, 777476851, 775941259, 774405210,
255772868706, 771331747, 769794334, 768256469, 766718151, 765179382, 763640164, 762100496,
256760560380, 759019816, 757478806, 755937350, 754395449, 752853105, 751310318, 749767089,
257748223418, 746679308, 745134758, 743589770, 742044345, 740498483, 738952186, 737405453,
258735858287, 734310688, 732762657, 731214195, 729665303, 728115982, 726566232, 725016055,
259723465451, 721914422, 720362968, 718811090, 717258790, 715706067, 714152924, 712599360,
260711045377, 709490976, 707936158, 706380923, 704825272, 703269207, 701712728, 700155836,
261698598533, 697040818, 695482694, 693924160, 692365218, 690805869, 689246113, 687685952,
262686125387, 684564417, 683003045, 681441272, 679879097, 678316522, 676753549, 675190177,
263673626408, 672062243, 670497682, 668932727, 667367379, 665801638, 664235505, 662668981,
264661102068, 659534766, 657967075, 656398998, 654830535, 653261686, 651692453, 650122837,
265648552838, 646982457, 645411696, 643840556, 642269036, 640697139, 639124865, 637552215,
266635979190, 634405791, 632832018, 631257873, 629683357, 628108471, 626533215, 624957590,
267623381598, 621805239, 620228514, 618651424, 617073971, 615496154, 613917975, 612339436,
268610760536, 609181276, 607601658, 606021683, 604441352, 602860664, 601279623, 599698227,
269598116479, 596534378, 594951927, 593369126, 591785976, 590202477, 588618632, 587034440,
270585449903, 583865021, 582279796, 580694229, 579108320, 577522070, 575935480, 574348552,
271572761285, 571173682, 569585743, 567997469, 566408860, 564819919, 563230645, 561641039,
272560051104, 558460839, 556870245, 555279324, 553688076, 552096502, 550504604, 548912382,
273547319836, 545726969, 544133781, 542540273, 540946445, 539352300, 537757837, 536163058,
274534567963, 532972554, 531376831, 529780796, 528184449, 526587791, 524990824, 523393547,
275521795963, 520198072, 518599875, 517001373, 515402566, 513803457, 512204045, 510604332,
276509004318, 507404005, 505803394, 504202485, 502601279, 500999778, 499397982, 497795892,
277496193509, 494590835, 492987869, 491384614, 489781069, 488177236, 486573117, 484968710,
278483364019, 481759043, 480153784, 478548243, 476942419, 475336316, 473729932, 472123270,
279470516330, 468909114, 467301622, 465693854, 464085813, 462477499, 460868912, 459260055,
280457650927, 456041530, 454431865, 452821933, 451211734, 449601270, 447990541, 446379549,
281444768294, 443156777, 441545000, 439932963, 438320667, 436708113, 435095303, 433482236,
282431868915, 430255339, 428641511, 427027430, 425413098, 423798515, 422183684, 420568604,
283418953276, 417337703, 415721883, 414105819, 412489512, 410872962, 409256170, 407639137,
284406021865, 404404353, 402786604, 401168618, 399550396, 397931939, 396313247, 394694323,
285393075166, 391455778, 389836160, 388216313, 386596237, 384975934, 383355404, 381734649,
286380113669, 378492466, 376871039, 375249392, 373627523, 372005435, 370383128, 368760603,
287367137861, 365514903, 363891730, 362268343, 360644742, 359020930, 357396906, 355772673,
288354148230, 352523578, 350898719, 349273654, 347648383, 346022908, 344397230, 342771348,
289341145265, 339518981, 337892498, 336265816, 334638936, 333011859, 331384586, 329757119,
290328129457, 326501602, 324873555, 323245317, 321616889, 319988272, 318359466, 316730474,
291315101295, 313471930, 311842381, 310212649, 308582734, 306952638, 305322361, 303691904,
292302061269, 300430456, 298799466, 297168301, 295536961, 293905447, 292273760, 290641901,
293289009871, 287377671, 285745302, 284112765, 282480061, 280847190, 279214155, 277580955,
294275947592, 274314066, 272680379, 271046532, 269412525, 267778360, 266144038, 264509558,
295262874923, 261240134, 259605191, 257970095, 256334847, 254699448, 253063900, 251428203,
296249792358, 248156366, 246520228, 244883945, 243247518, 241610947, 239974235, 238337382,
297236700388, 235063255, 233425984, 231788575, 230151030, 228513350, 226875535, 225237587,
298223599506, 221961294, 220322951, 218684479, 217045878, 215407149, 213768293, 212129312,
299210490206, 208850976, 207211624, 205572149, 203932553, 202292838, 200653003, 199013051,
300197372981, 195732795, 194092495, 192452080, 190811551, 189170911, 187530159, 185889297,
301184248325, 182607245, 180966058, 179324764, 177683365, 176041861, 174400254, 172758544,
302171116733, 169474820, 167832808, 166190698, 164548489, 162906184, 161263783, 159621287,
303157978697, 156336015, 154693240, 153050374, 151407418, 149764374, 148121241, 146478021,
304144834714, 143191323, 141547847, 139904288, 138260647, 136616925, 134973122, 133329239,
305131685278, 130041240, 128397125, 126752935, 125108670, 123464332, 121819921, 120175438,
306118530885, 116886262, 115241570, 113596810, 111951983, 110307091, 108662134, 107017112,
307105372028, 103726882, 102081675, 100436408, 98791081, 97145697, 95500255, 93854758,
308 92209205, 90563597, 88917937, 87272224, 85626460, 83980645, 82334782, 80688869,
309 79042909, 77396903, 75750851, 74104755, 72458615, 70812432, 69166208, 67519943,
310 65873638, 64227295, 62580914, 60934496, 59288042, 57641553, 55995030, 54348475,
311 52701887, 51055268, 49408620, 47761942, 46115236, 44468503, 42821744, 41174960,
312 39528151, 37881320, 36234466, 34587590, 32940695, 31293780, 29646846, 27999895,
313 26352928, 24705945, 23058947, 21411936, 19764913, 18117878, 16470832, 14823776,
314 13176712, 11529640, 9882561, 8235476, 6588387, 4941294, 3294197, 1647099
315};
316
317uint16_t ff_fft_offsets_lut[21845];
318
319static void fft_lut_init(uint16_t *table, int off, int size, int *index)
320{
321 if (size < 16) {
322 table[*index] = off >> 2;
323 (*index)++;
324 }
325 else {
326 fft_lut_init(table, off, size >> 1, index);
327 fft_lut_init(table, off + (size >> 1), size >> 2, index);
328 fft_lut_init(table, off + 3 * (size >> 2), size >> 2, index);
329 }
330}
331
332static void fft_lut_init_start(void)
333{
334 int n = 0;
335
336 fft_lut_init(ff_fft_offsets_lut, 0, 1 << 17, &n);
337}
338
339void ff_fft_lut_init(void)
340{
341 static AVOnce init_once = AV_ONCE_INIT;
342
343 ff_thread_once(&init_once, fft_lut_init_start);
344}
libavcodec/fft_table.h+0−66
@@ -1,66 +0,0 @@
1/*
2 * Copyright (c) 2012
3 * MIPS Technologies, Inc., California.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * Authors: Stanislav Ocovaj (socovaj@mips.com)
30 * Goran Cordasic (goran@mips.com)
31 * Djordje Pesut (djordje@mips.com)
32 *
33 * This file is part of FFmpeg.
34 *
35 * FFmpeg is free software; you can redistribute it and/or
36 * modify it under the terms of the GNU Lesser General Public
37 * License as published by the Free Software Foundation; either
38 * version 2.1 of the License, or (at your option) any later version.
39 *
40 * FFmpeg is distributed in the hope that it will be useful,
41 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43 * Lesser General Public License for more details.
44 *
45 * You should have received a copy of the GNU Lesser General Public
46 * License along with FFmpeg; if not, write to the Free Software
47 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
48 */
49
50/**
51 * @file
52 * definitions and tables for FFT
53 */
54#ifndef AVCODEC_FFT_TABLE_H
55#define AVCODEC_FFT_TABLE_H
56
57#include "libavcodec/fft.h"
58
59#define MAX_LOG2_NFFT 17 //!< Specifies maximum allowed fft size
60#define MAX_FFT_SIZE (1 << MAX_LOG2_NFFT)
61
62extern const int32_t ff_w_tab_sr[];
63extern uint16_t ff_fft_offsets_lut[];
64void ff_fft_lut_init(void);
65
66#endif /* AVCODEC_FFT_TABLE_H */
libavcodec/fft_template.c+0−628
@@ -1,628 +0,0 @@
1/*
2 * FFT/IFFT transforms
3 * Copyright (c) 2008 Loren Merritt
4 * Copyright (c) 2002 Fabrice Bellard
5 * Partly based on libdjbfft by D. J. Bernstein
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24/**
25 * @file
26 * FFT/IFFT transforms.
27 */
28
29#include <stdlib.h>
30#include <string.h>
31#include "libavutil/mathematics.h"
32#include "libavutil/thread.h"
33#include "fft.h"
34#include "fft-internal.h"
35
36#if !FFT_FLOAT
37#include "fft_table.h"
38#else /* !FFT_FLOAT */
39
40/* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */
41#if !CONFIG_HARDCODED_TABLES
42COSTABLE(16);
43COSTABLE(32);
44COSTABLE(64);
45COSTABLE(128);
46COSTABLE(256);
47COSTABLE(512);
48COSTABLE(1024);
49COSTABLE(2048);
50COSTABLE(4096);
51COSTABLE(8192);
52COSTABLE(16384);
53COSTABLE(32768);
54COSTABLE(65536);
55COSTABLE(131072);
56
57static av_cold void init_ff_cos_tabs(int index)
58{
59 int i;
60 int m = 1<<index;
61 double freq = 2*M_PI/m;
62 FFTSample *tab = FFT_NAME(ff_cos_tabs)[index];
63 for(i=0; i<=m/4; i++)
64 tab[i] = FIX15(cos(i*freq));
65 for(i=1; i<m/4; i++)
66 tab[m/2-i] = tab[i];
67}
68
69typedef struct CosTabsInitOnce {
70 void (*func)(void);
71 AVOnce control;
72} CosTabsInitOnce;
73
74#define INIT_FF_COS_TABS_FUNC(index, size) \
75static av_cold void init_ff_cos_tabs_ ## size (void)\
76{ \
77 init_ff_cos_tabs(index); \
78}
79
80INIT_FF_COS_TABS_FUNC(4, 16)
81INIT_FF_COS_TABS_FUNC(5, 32)
82INIT_FF_COS_TABS_FUNC(6, 64)
83INIT_FF_COS_TABS_FUNC(7, 128)
84INIT_FF_COS_TABS_FUNC(8, 256)
85INIT_FF_COS_TABS_FUNC(9, 512)
86INIT_FF_COS_TABS_FUNC(10, 1024)
87INIT_FF_COS_TABS_FUNC(11, 2048)
88INIT_FF_COS_TABS_FUNC(12, 4096)
89INIT_FF_COS_TABS_FUNC(13, 8192)
90INIT_FF_COS_TABS_FUNC(14, 16384)
91INIT_FF_COS_TABS_FUNC(15, 32768)
92INIT_FF_COS_TABS_FUNC(16, 65536)
93INIT_FF_COS_TABS_FUNC(17, 131072)
94
95static CosTabsInitOnce cos_tabs_init_once[] = {
96 { NULL },
97 { NULL },
98 { NULL },
99 { NULL },
100 { init_ff_cos_tabs_16, AV_ONCE_INIT },
101 { init_ff_cos_tabs_32, AV_ONCE_INIT },
102 { init_ff_cos_tabs_64, AV_ONCE_INIT },
103 { init_ff_cos_tabs_128, AV_ONCE_INIT },
104 { init_ff_cos_tabs_256, AV_ONCE_INIT },
105 { init_ff_cos_tabs_512, AV_ONCE_INIT },
106 { init_ff_cos_tabs_1024, AV_ONCE_INIT },
107 { init_ff_cos_tabs_2048, AV_ONCE_INIT },
108 { init_ff_cos_tabs_4096, AV_ONCE_INIT },
109 { init_ff_cos_tabs_8192, AV_ONCE_INIT },
110 { init_ff_cos_tabs_16384, AV_ONCE_INIT },
111 { init_ff_cos_tabs_32768, AV_ONCE_INIT },
112 { init_ff_cos_tabs_65536, AV_ONCE_INIT },
113 { init_ff_cos_tabs_131072, AV_ONCE_INIT },
114};
115
116av_cold void ff_init_ff_cos_tabs(int index)
117{
118 ff_thread_once(&cos_tabs_init_once[index].control, cos_tabs_init_once[index].func);
119}
120#endif
121COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = {
122 NULL, NULL, NULL, NULL,
123 FFT_NAME(ff_cos_16),
124 FFT_NAME(ff_cos_32),
125 FFT_NAME(ff_cos_64),
126 FFT_NAME(ff_cos_128),
127 FFT_NAME(ff_cos_256),
128 FFT_NAME(ff_cos_512),
129 FFT_NAME(ff_cos_1024),
130 FFT_NAME(ff_cos_2048),
131 FFT_NAME(ff_cos_4096),
132 FFT_NAME(ff_cos_8192),
133 FFT_NAME(ff_cos_16384),
134 FFT_NAME(ff_cos_32768),
135 FFT_NAME(ff_cos_65536),
136 FFT_NAME(ff_cos_131072),
137};
138
139#endif /* FFT_FLOAT */
140
141static void fft_permute_c(FFTContext *s, FFTComplex *z);
142static void fft_calc_c(FFTContext *s, FFTComplex *z);
143
144static int split_radix_permutation(int i, int n, int inverse)
145{
146 int m;
147 if(n <= 2) return i&1;
148 m = n >> 1;
149 if(!(i&m)) return split_radix_permutation(i, m, inverse)*2;
150 m >>= 1;
151 if(inverse == !(i&m)) return split_radix_permutation(i, m, inverse)*4 + 1;
152 else return split_radix_permutation(i, m, inverse)*4 - 1;
153}
154
155
156static const int avx_tab[] = {
157 0, 4, 1, 5, 8, 12, 9, 13, 2, 6, 3, 7, 10, 14, 11, 15
158};
159
160static int is_second_half_of_fft32(int i, int n)
161{
162 if (n <= 32)
163 return i >= 16;
164 else if (i < n/2)
165 return is_second_half_of_fft32(i, n/2);
166 else if (i < 3*n/4)
167 return is_second_half_of_fft32(i - n/2, n/4);
168 else
169 return is_second_half_of_fft32(i - 3*n/4, n/4);
170}
171
172static av_cold void fft_perm_avx(FFTContext *s)
173{
174 int i;
175 int n = 1 << s->nbits;
176
177 for (i = 0; i < n; i += 16) {
178 int k;
179 if (is_second_half_of_fft32(i, n)) {
180 for (k = 0; k < 16; k++)
181 s->revtab[-split_radix_permutation(i + k, n, s->inverse) & (n - 1)] =
182 i + avx_tab[k];
183
184 } else {
185 for (k = 0; k < 16; k++) {
186 int j = i + k;
187 j = (j & ~7) | ((j >> 1) & 3) | ((j << 2) & 4);
188 s->revtab[-split_radix_permutation(i + k, n, s->inverse) & (n - 1)] = j;
189 }
190 }
191 }
192}
193
194av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
195{
196 int i, j, n;
197
198 s->revtab = NULL;
199 s->revtab32 = NULL;
200
201 if (nbits < 2 || nbits > 17)
202 goto fail;
203 s->nbits = nbits;
204 n = 1 << nbits;
205
206 if (nbits <= 16) {
207 s->revtab = av_malloc(n * sizeof(uint16_t));
208 if (!s->revtab)
209 goto fail;
210 } else {
211 s->revtab32 = av_malloc(n * sizeof(uint32_t));
212 if (!s->revtab32)
213 goto fail;
214 }
215 s->tmp_buf = av_malloc(n * sizeof(FFTComplex));
216 if (!s->tmp_buf)
217 goto fail;
218 s->inverse = inverse;
219 s->fft_permutation = FF_FFT_PERM_DEFAULT;
220
221 s->fft_permute = fft_permute_c;
222 s->fft_calc = fft_calc_c;
223#if CONFIG_MDCT
224 s->imdct_calc = ff_imdct_calc_c;
225 s->imdct_half = ff_imdct_half_c;
226 s->mdct_calc = ff_mdct_calc_c;
227#endif
228
229#if FFT_FLOAT
230#if ARCH_AARCH64
231 ff_fft_init_aarch64(s);
232#elif ARCH_ARM
233 ff_fft_init_arm(s);
234#elif ARCH_PPC
235 ff_fft_init_ppc(s);
236#elif ARCH_X86
237 ff_fft_init_x86(s);
238#endif
239#if HAVE_MIPSFPU
240 ff_fft_init_mips(s);
241#endif
242 for(j=4; j<=nbits; j++) {
243 ff_init_ff_cos_tabs(j);
244 }
245#else /* FFT_FLOAT */
246 ff_fft_lut_init();
247#endif
248
249
250 if (ARCH_X86 && FFT_FLOAT && s->fft_permutation == FF_FFT_PERM_AVX) {
251 fft_perm_avx(s);
252 } else {
253#define PROCESS_FFT_PERM_SWAP_LSBS(num) do {\
254 for(i = 0; i < n; i++) {\
255 int k;\
256 j = i;\
257 j = (j & ~3) | ((j >> 1) & 1) | ((j << 1) & 2);\
258 k = -split_radix_permutation(i, n, s->inverse) & (n - 1);\
259 s->revtab##num[k] = j;\
260 } \
261} while(0);
262
263#define PROCESS_FFT_PERM_DEFAULT(num) do {\
264 for(i = 0; i < n; i++) {\
265 int k;\
266 j = i;\
267 k = -split_radix_permutation(i, n, s->inverse) & (n - 1);\
268 s->revtab##num[k] = j;\
269 } \
270} while(0);
271
272#define SPLIT_RADIX_PERMUTATION(num) do { \
273 if (s->fft_permutation == FF_FFT_PERM_SWAP_LSBS) {\
274 PROCESS_FFT_PERM_SWAP_LSBS(num) \
275 } else {\
276 PROCESS_FFT_PERM_DEFAULT(num) \
277 }\
278} while(0);
279
280 if (s->revtab)
281 SPLIT_RADIX_PERMUTATION()
282 if (s->revtab32)
283 SPLIT_RADIX_PERMUTATION(32)
284
285#undef PROCESS_FFT_PERM_DEFAULT
286#undef PROCESS_FFT_PERM_SWAP_LSBS
287#undef SPLIT_RADIX_PERMUTATION
288 }
289
290 return 0;
291 fail:
292 av_freep(&s->revtab);
293 av_freep(&s->revtab32);
294 av_freep(&s->tmp_buf);
295 return -1;
296}
297
298static void fft_permute_c(FFTContext *s, FFTComplex *z)
299{
300 int j, np;
301 const uint16_t *revtab = s->revtab;
302 const uint32_t *revtab32 = s->revtab32;
303 np = 1 << s->nbits;
304 /* TODO: handle split-radix permute in a more optimal way, probably in-place */
305 if (revtab) {
306 for(j=0;j<np;j++) s->tmp_buf[revtab[j]] = z[j];
307 } else
308 for(j=0;j<np;j++) s->tmp_buf[revtab32[j]] = z[j];
309
310 memcpy(z, s->tmp_buf, np * sizeof(FFTComplex));
311}
312
313av_cold void ff_fft_end(FFTContext *s)
314{
315 av_freep(&s->revtab);
316 av_freep(&s->revtab32);
317 av_freep(&s->tmp_buf);
318}
319
320#if !FFT_FLOAT
321
322static void fft_calc_c(FFTContext *s, FFTComplex *z) {
323
324 int nbits, i, n, num_transforms, offset, step;
325 int n4, n2, n34;
326 unsigned tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
327 FFTComplex *tmpz;
328 const int fft_size = (1 << s->nbits);
329 int64_t accu;
330
331 num_transforms = (0x2aab >> (16 - s->nbits)) | 1;
332
333 for (n=0; n<num_transforms; n++){
334 offset = ff_fft_offsets_lut[n] << 2;
335 tmpz = z + offset;
336
337 tmp1 = tmpz[0].re + (unsigned)tmpz[1].re;
338 tmp5 = tmpz[2].re + (unsigned)tmpz[3].re;
339 tmp2 = tmpz[0].im + (unsigned)tmpz[1].im;
340 tmp6 = tmpz[2].im + (unsigned)tmpz[3].im;
341 tmp3 = tmpz[0].re - (unsigned)tmpz[1].re;
342 tmp8 = tmpz[2].im - (unsigned)tmpz[3].im;
343 tmp4 = tmpz[0].im - (unsigned)tmpz[1].im;
344 tmp7 = tmpz[2].re - (unsigned)tmpz[3].re;
345
346 tmpz[0].re = tmp1 + tmp5;
347 tmpz[2].re = tmp1 - tmp5;
348 tmpz[0].im = tmp2 + tmp6;
349 tmpz[2].im = tmp2 - tmp6;
350 tmpz[1].re = tmp3 + tmp8;
351 tmpz[3].re = tmp3 - tmp8;
352 tmpz[1].im = tmp4 - tmp7;
353 tmpz[3].im = tmp4 + tmp7;
354 }
355
356 if (fft_size < 8)
357 return;
358
359 num_transforms = (num_transforms >> 1) | 1;
360
361 for (n=0; n<num_transforms; n++){
362 offset = ff_fft_offsets_lut[n] << 3;
363 tmpz = z + offset;
364
365 tmp1 = tmpz[4].re + (unsigned)tmpz[5].re;
366 tmp3 = tmpz[6].re + (unsigned)tmpz[7].re;
367 tmp2 = tmpz[4].im + (unsigned)tmpz[5].im;
368 tmp4 = tmpz[6].im + (unsigned)tmpz[7].im;
369 tmp5 = tmp1 + tmp3;
370 tmp7 = tmp1 - tmp3;
371 tmp6 = tmp2 + tmp4;
372 tmp8 = tmp2 - tmp4;
373
374 tmp1 = tmpz[4].re - (unsigned)tmpz[5].re;
375 tmp2 = tmpz[4].im - (unsigned)tmpz[5].im;
376 tmp3 = tmpz[6].re - (unsigned)tmpz[7].re;
377 tmp4 = tmpz[6].im - (unsigned)tmpz[7].im;
378
379 tmpz[4].re = tmpz[0].re - tmp5;
380 tmpz[0].re = tmpz[0].re + tmp5;
381 tmpz[4].im = tmpz[0].im - tmp6;
382 tmpz[0].im = tmpz[0].im + tmp6;
383 tmpz[6].re = tmpz[2].re - tmp8;
384 tmpz[2].re = tmpz[2].re + tmp8;
385 tmpz[6].im = tmpz[2].im + tmp7;
386 tmpz[2].im = tmpz[2].im - tmp7;
387
388 accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp1 + tmp2);
389 tmp5 = (int32_t)((accu + 0x40000000) >> 31);
390 accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp3 - tmp4);
391 tmp7 = (int32_t)((accu + 0x40000000) >> 31);
392 accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp2 - tmp1);
393 tmp6 = (int32_t)((accu + 0x40000000) >> 31);
394 accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp3 + tmp4);
395 tmp8 = (int32_t)((accu + 0x40000000) >> 31);
396 tmp1 = tmp5 + tmp7;
397 tmp3 = tmp5 - tmp7;
398 tmp2 = tmp6 + tmp8;
399 tmp4 = tmp6 - tmp8;
400
401 tmpz[5].re = tmpz[1].re - tmp1;
402 tmpz[1].re = tmpz[1].re + tmp1;
403 tmpz[5].im = tmpz[1].im - tmp2;
404 tmpz[1].im = tmpz[1].im + tmp2;
405 tmpz[7].re = tmpz[3].re - tmp4;
406 tmpz[3].re = tmpz[3].re + tmp4;
407 tmpz[7].im = tmpz[3].im + tmp3;
408 tmpz[3].im = tmpz[3].im - tmp3;
409 }
410
411 step = 1 << ((MAX_LOG2_NFFT-4) - 4);
412 n4 = 4;
413
414 for (nbits=4; nbits<=s->nbits; nbits++){
415 n2 = 2*n4;
416 n34 = 3*n4;
417 num_transforms = (num_transforms >> 1) | 1;
418
419 for (n=0; n<num_transforms; n++){
420 const FFTSample *w_re_ptr = ff_w_tab_sr + step;
421 const FFTSample *w_im_ptr = ff_w_tab_sr + MAX_FFT_SIZE/(4*16) - step;
422 offset = ff_fft_offsets_lut[n] << nbits;
423 tmpz = z + offset;
424
425 tmp5 = tmpz[ n2].re + (unsigned)tmpz[n34].re;
426 tmp1 = tmpz[ n2].re - (unsigned)tmpz[n34].re;
427 tmp6 = tmpz[ n2].im + (unsigned)tmpz[n34].im;
428 tmp2 = tmpz[ n2].im - (unsigned)tmpz[n34].im;
429
430 tmpz[ n2].re = tmpz[ 0].re - tmp5;
431 tmpz[ 0].re = tmpz[ 0].re + tmp5;
432 tmpz[ n2].im = tmpz[ 0].im - tmp6;
433 tmpz[ 0].im = tmpz[ 0].im + tmp6;
434 tmpz[n34].re = tmpz[n4].re - tmp2;
435 tmpz[ n4].re = tmpz[n4].re + tmp2;
436 tmpz[n34].im = tmpz[n4].im + tmp1;
437 tmpz[ n4].im = tmpz[n4].im - tmp1;
438
439 for (i=1; i<n4; i++){
440 FFTSample w_re = w_re_ptr[0];
441 FFTSample w_im = w_im_ptr[0];
442 accu = (int64_t)w_re*tmpz[ n2+i].re;
443 accu += (int64_t)w_im*tmpz[ n2+i].im;
444 tmp1 = (int32_t)((accu + 0x40000000) >> 31);
445 accu = (int64_t)w_re*tmpz[ n2+i].im;
446 accu -= (int64_t)w_im*tmpz[ n2+i].re;
447 tmp2 = (int32_t)((accu + 0x40000000) >> 31);
448 accu = (int64_t)w_re*tmpz[n34+i].re;
449 accu -= (int64_t)w_im*tmpz[n34+i].im;
450 tmp3 = (int32_t)((accu + 0x40000000) >> 31);
451 accu = (int64_t)w_re*tmpz[n34+i].im;
452 accu += (int64_t)w_im*tmpz[n34+i].re;
453 tmp4 = (int32_t)((accu + 0x40000000) >> 31);
454
455 tmp5 = tmp1 + tmp3;
456 tmp1 = tmp1 - tmp3;
457 tmp6 = tmp2 + tmp4;
458 tmp2 = tmp2 - tmp4;
459
460 tmpz[ n2+i].re = tmpz[ i].re - tmp5;
461 tmpz[ i].re = tmpz[ i].re + tmp5;
462 tmpz[ n2+i].im = tmpz[ i].im - tmp6;
463 tmpz[ i].im = tmpz[ i].im + tmp6;
464 tmpz[n34+i].re = tmpz[n4+i].re - tmp2;
465 tmpz[ n4+i].re = tmpz[n4+i].re + tmp2;
466 tmpz[n34+i].im = tmpz[n4+i].im + tmp1;
467 tmpz[ n4+i].im = tmpz[n4+i].im - tmp1;
468
469 w_re_ptr += step;
470 w_im_ptr -= step;
471 }
472 }
473 step >>= 1;
474 n4 <<= 1;
475 }
476}
477
478#else /* !FFT_FLOAT */
479
480#define BUTTERFLIES(a0,a1,a2,a3) {\
481 BF(t3, t5, t5, t1);\
482 BF(a2.re, a0.re, a0.re, t5);\
483 BF(a3.im, a1.im, a1.im, t3);\
484 BF(t4, t6, t2, t6);\
485 BF(a3.re, a1.re, a1.re, t4);\
486 BF(a2.im, a0.im, a0.im, t6);\
487}
488
489// force loading all the inputs before storing any.
490// this is slightly slower for small data, but avoids store->load aliasing
491// for addresses separated by large powers of 2.
492#define BUTTERFLIES_BIG(a0,a1,a2,a3) {\
493 FFTSample r0=a0.re, i0=a0.im, r1=a1.re, i1=a1.im;\
494 BF(t3, t5, t5, t1);\
495 BF(a2.re, a0.re, r0, t5);\
496 BF(a3.im, a1.im, i1, t3);\
497 BF(t4, t6, t2, t6);\
498 BF(a3.re, a1.re, r1, t4);\
499 BF(a2.im, a0.im, i0, t6);\
500}
501
502#define TRANSFORM(a0,a1,a2,a3,wre,wim) {\
503 CMUL(t1, t2, a2.re, a2.im, wre, -wim);\
504 CMUL(t5, t6, a3.re, a3.im, wre, wim);\
505 BUTTERFLIES(a0,a1,a2,a3)\
506}
507
508#define TRANSFORM_ZERO(a0,a1,a2,a3) {\
509 t1 = a2.re;\
510 t2 = a2.im;\
511 t5 = a3.re;\
512 t6 = a3.im;\
513 BUTTERFLIES(a0,a1,a2,a3)\
514}
515
516/* z[0...8n-1], w[1...2n-1] */
517#define PASS(name)\
518static void name(FFTComplex *z, const FFTSample *wre, unsigned int n)\
519{\
520 FFTDouble t1, t2, t3, t4, t5, t6;\
521 int o1 = 2*n;\
522 int o2 = 4*n;\
523 int o3 = 6*n;\
524 const FFTSample *wim = wre+o1;\
525 n--;\
526\
527 TRANSFORM_ZERO(z[0],z[o1],z[o2],z[o3]);\
528 TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
529 do {\
530 z += 2;\
531 wre += 2;\
532 wim -= 2;\
533 TRANSFORM(z[0],z[o1],z[o2],z[o3],wre[0],wim[0]);\
534 TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
535 } while(--n);\
536}
537
538PASS(pass)
539#if !CONFIG_SMALL
540#undef BUTTERFLIES
541#define BUTTERFLIES BUTTERFLIES_BIG
542PASS(pass_big)
543#endif
544
545#define DECL_FFT(n,n2,n4)\
546static void fft##n(FFTComplex *z)\
547{\
548 fft##n2(z);\
549 fft##n4(z+n4*2);\
550 fft##n4(z+n4*3);\
551 pass(z,FFT_NAME(ff_cos_##n),n4/2);\
552}
553
554static void fft4(FFTComplex *z)
555{
556 FFTDouble t1, t2, t3, t4, t5, t6, t7, t8;
557
558 BF(t3, t1, z[0].re, z[1].re);
559 BF(t8, t6, z[3].re, z[2].re);
560 BF(z[2].re, z[0].re, t1, t6);
561 BF(t4, t2, z[0].im, z[1].im);
562 BF(t7, t5, z[2].im, z[3].im);
563 BF(z[3].im, z[1].im, t4, t8);
564 BF(z[3].re, z[1].re, t3, t7);
565 BF(z[2].im, z[0].im, t2, t5);
566}
567
568static void fft8(FFTComplex *z)
569{
570 FFTDouble t1, t2, t3, t4, t5, t6;
571
572 fft4(z);
573
574 BF(t1, z[5].re, z[4].re, -z[5].re);
575 BF(t2, z[5].im, z[4].im, -z[5].im);
576 BF(t5, z[7].re, z[6].re, -z[7].re);
577 BF(t6, z[7].im, z[6].im, -z[7].im);
578
579 BUTTERFLIES(z[0],z[2],z[4],z[6]);
580 TRANSFORM(z[1],z[3],z[5],z[7],sqrthalf,sqrthalf);
581}
582
583#if !CONFIG_SMALL
584static void fft16(FFTComplex *z)
585{
586 FFTDouble t1, t2, t3, t4, t5, t6;
587 FFTSample cos_16_1 = FFT_NAME(ff_cos_16)[1];
588 FFTSample cos_16_3 = FFT_NAME(ff_cos_16)[3];
589
590 fft8(z);
591 fft4(z+8);
592 fft4(z+12);
593
594 TRANSFORM_ZERO(z[0],z[4],z[8],z[12]);
595 TRANSFORM(z[2],z[6],z[10],z[14],sqrthalf,sqrthalf);
596 TRANSFORM(z[1],z[5],z[9],z[13],cos_16_1,cos_16_3);
597 TRANSFORM(z[3],z[7],z[11],z[15],cos_16_3,cos_16_1);
598}
599#else
600DECL_FFT(16,8,4)
601#endif
602DECL_FFT(32,16,8)
603DECL_FFT(64,32,16)
604DECL_FFT(128,64,32)
605DECL_FFT(256,128,64)
606DECL_FFT(512,256,128)
607#if !CONFIG_SMALL
608#define pass pass_big
609#endif
610DECL_FFT(1024,512,256)
611DECL_FFT(2048,1024,512)
612DECL_FFT(4096,2048,1024)
613DECL_FFT(8192,4096,2048)
614DECL_FFT(16384,8192,4096)
615DECL_FFT(32768,16384,8192)
616DECL_FFT(65536,32768,16384)
617DECL_FFT(131072,65536,32768)
618
619static void (* const fft_dispatch[])(FFTComplex*) = {
620 fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512, fft1024,
621 fft2048, fft4096, fft8192, fft16384, fft32768, fft65536, fft131072
622};
623
624static void fft_calc_c(FFTContext *s, FFTComplex *z)
625{
626 fft_dispatch[s->nbits-2](z);
627}
628#endif /* !FFT_FLOAT */
libavcodec/mdct_fixed_32.c+0−51
@@ -1,51 +0,0 @@
1/*
2 * Copyright (c) 2012
3 * MIPS Technologies, Inc., California.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * Authors: Stanislav Ocovaj (socovaj@mips.com)
30 * Goran Cordasic (goran@mips.com)
31 * Djordje Pesut (djordje@mips.com)
32 *
33 * This file is part of FFmpeg.
34 *
35 * FFmpeg is free software; you can redistribute it and/or
36 * modify it under the terms of the GNU Lesser General Public
37 * License as published by the Free Software Foundation; either
38 * version 2.1 of the License, or (at your option) any later version.
39 *
40 * FFmpeg is distributed in the hope that it will be useful,
41 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43 * Lesser General Public License for more details.
44 *
45 * You should have received a copy of the GNU Lesser General Public
46 * License along with FFmpeg; if not, write to the Free Software
47 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
48 */
49
50#define FFT_FLOAT 0
51#include "mdct_template.c"
libavcodec/mdct_float.c+0−20
@@ -1,20 +0,0 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#define FFT_FLOAT 1
20#include "mdct_template.c"
libavcodec/mdct_template.c+0−209
@@ -1,209 +0,0 @@
1/*
2 * MDCT/IMDCT transforms
3 * Copyright (c) 2002 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <stdlib.h>
23#include <string.h>
24#include "libavutil/common.h"
25#include "libavutil/libm.h"
26#include "libavutil/mathematics.h"
27#include "fft.h"
28#include "fft-internal.h"
29
30/**
31 * @file
32 * MDCT/IMDCT transforms.
33 */
34
35#if FFT_FLOAT
36# define RSCALE(x, y) ((x) + (y))
37#else
38# define RSCALE(x, y) ((int)((x) + (unsigned)(y) + 32) >> 6)
39#endif
40
41/**
42 * init MDCT or IMDCT computation.
43 */
44av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
45{
46 int n, n4, i;
47 double alpha, theta;
48 int tstep;
49
50 memset(s, 0, sizeof(*s));
51 n = 1 << nbits;
52 s->mdct_bits = nbits;
53 s->mdct_size = n;
54 n4 = n >> 2;
55 s->mdct_permutation = FF_MDCT_PERM_NONE;
56
57 if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0)
58 goto fail;
59
60 s->tcos = av_malloc_array(n/2, sizeof(FFTSample));
61 if (!s->tcos)
62 goto fail;
63
64 switch (s->mdct_permutation) {
65 case FF_MDCT_PERM_NONE:
66 s->tsin = s->tcos + n4;
67 tstep = 1;
68 break;
69 case FF_MDCT_PERM_INTERLEAVE:
70 s->tsin = s->tcos + 1;
71 tstep = 2;
72 break;
73 default:
74 goto fail;
75 }
76
77 theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0);
78 scale = sqrt(fabs(scale));
79 for(i=0;i<n4;i++) {
80 alpha = 2 * M_PI * (i + theta) / n;
81#if !FFT_FLOAT
82 s->tcos[i*tstep] = lrint(-cos(alpha) * 2147483648.0);
83 s->tsin[i*tstep] = lrint(-sin(alpha) * 2147483648.0);
84#else
85 s->tcos[i*tstep] = FIX15(-cos(alpha) * scale);
86 s->tsin[i*tstep] = FIX15(-sin(alpha) * scale);
87#endif
88 }
89 return 0;
90 fail:
91 ff_mdct_end(s);
92 return -1;
93}
94
95/**
96 * Compute the middle half of the inverse MDCT of size N = 2^nbits,
97 * thus excluding the parts that can be derived by symmetry
98 * @param output N/2 samples
99 * @param input N/2 samples
100 */
101void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input)
102{
103 int k, n8, n4, n2, n, j;
104 const uint16_t *revtab = s->revtab;
105 const FFTSample *tcos = s->tcos;
106 const FFTSample *tsin = s->tsin;
107 const FFTSample *in1, *in2;
108 FFTComplex *z = (FFTComplex *)output;
109
110 n = 1 << s->mdct_bits;
111 n2 = n >> 1;
112 n4 = n >> 2;
113 n8 = n >> 3;
114
115 /* pre rotation */
116 in1 = input;
117 in2 = input + n2 - 1;
118 for(k = 0; k < n4; k++) {
119 j=revtab[k];
120 CMUL(z[j].re, z[j].im, *in2, *in1, tcos[k], tsin[k]);
121 in1 += 2;
122 in2 -= 2;
123 }
124 s->fft_calc(s, z);
125
126 /* post rotation + reordering */
127 for(k = 0; k < n8; k++) {
128 FFTSample r0, i0, r1, i1;
129 CMUL(r0, i1, z[n8-k-1].im, z[n8-k-1].re, tsin[n8-k-1], tcos[n8-k-1]);
130 CMUL(r1, i0, z[n8+k ].im, z[n8+k ].re, tsin[n8+k ], tcos[n8+k ]);
131 z[n8-k-1].re = r0;
132 z[n8-k-1].im = i0;
133 z[n8+k ].re = r1;
134 z[n8+k ].im = i1;
135 }
136}
137
138/**
139 * Compute inverse MDCT of size N = 2^nbits
140 * @param output N samples
141 * @param input N/2 samples
142 */
143void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input)
144{
145 int k;
146 int n = 1 << s->mdct_bits;
147 int n2 = n >> 1;
148 int n4 = n >> 2;
149
150 ff_imdct_half_c(s, output+n4, input);
151
152 for(k = 0; k < n4; k++) {
153 output[k] = -output[n2-k-1];
154 output[n-k-1] = output[n2+k];
155 }
156}
157
158/**
159 * Compute MDCT of size N = 2^nbits
160 * @param input N samples
161 * @param out N/2 samples
162 */
163void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input)
164{
165 int i, j, n, n8, n4, n2, n3;
166 FFTDouble re, im;
167 const uint16_t *revtab = s->revtab;
168 const FFTSample *tcos = s->tcos;
169 const FFTSample *tsin = s->tsin;
170 FFTComplex *x = (FFTComplex *)out;
171
172 n = 1 << s->mdct_bits;
173 n2 = n >> 1;
174 n4 = n >> 2;
175 n8 = n >> 3;
176 n3 = 3 * n4;
177
178 /* pre rotation */
179 for(i=0;i<n8;i++) {
180 re = RSCALE(-input[2*i+n3], - input[n3-1-2*i]);
181 im = RSCALE(-input[n4+2*i], + input[n4-1-2*i]);
182 j = revtab[i];
183 CMUL(x[j].re, x[j].im, re, im, -tcos[i], tsin[i]);
184
185 re = RSCALE( input[2*i] , - input[n2-1-2*i]);
186 im = RSCALE(-input[n2+2*i], - input[ n-1-2*i]);
187 j = revtab[n8 + i];
188 CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]);
189 }
190
191 s->fft_calc(s, x);
192
193 /* post rotation */
194 for(i=0;i<n8;i++) {
195 FFTSample r0, i0, r1, i1;
196 CMUL(i1, r0, x[n8-i-1].re, x[n8-i-1].im, -tsin[n8-i-1], -tcos[n8-i-1]);
197 CMUL(i0, r1, x[n8+i ].re, x[n8+i ].im, -tsin[n8+i ], -tcos[n8+i ]);
198 x[n8-i-1].re = r0;
199 x[n8-i-1].im = i0;
200 x[n8+i ].re = r1;
201 x[n8+i ].im = i1;
202 }
203}
204
205av_cold void ff_mdct_end(FFTContext *s)
206{
207 av_freep(&s->tcos);
208 ff_fft_end(s);
209}
libavcodec/mips/Makefile+0−1
@@ -13,7 +13,6 @@ MIPSFPU-OBJS-$(CONFIG_AMRWB_DECODER) += mips/acelp_filters_mips.o \ · 12 unmodified lines
13 mips/acelp_vectors_mips.o13 mips/acelp_vectors_mips.o
14MIPSFPU-OBJS-$(CONFIG_MPEGAUDIODSP) += mips/mpegaudiodsp_mips_float.o14MIPSFPU-OBJS-$(CONFIG_MPEGAUDIODSP) += mips/mpegaudiodsp_mips_float.o
15MIPSDSP-OBJS-$(CONFIG_MPEGAUDIODSP) += mips/mpegaudiodsp_mips_fixed.o15MIPSDSP-OBJS-$(CONFIG_MPEGAUDIODSP) += mips/mpegaudiodsp_mips_fixed.o
16MIPSFPU-OBJS-$(CONFIG_FFT) += mips/fft_mips.o
17MIPSFPU-OBJS-$(CONFIG_FMTCONVERT) += mips/fmtconvert_mips.o16MIPSFPU-OBJS-$(CONFIG_FMTCONVERT) += mips/fmtconvert_mips.o
18OBJS-$(CONFIG_AC3DSP) += mips/ac3dsp_mips.o17OBJS-$(CONFIG_AC3DSP) += mips/ac3dsp_mips.o
19OBJS-$(CONFIG_AAC_DECODER) += mips/aacdec_mips.o \18OBJS-$(CONFIG_AAC_DECODER) += mips/aacdec_mips.o \
libavcodec/mips/fft_mips.c+0−516
@@ -1,516 +0,0 @@
1/*
2 * Copyright (c) 2012
3 * MIPS Technologies, Inc., California.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * Author: Stanislav Ocovaj (socovaj@mips.com)
30 * Author: Zoran Lukic (zoranl@mips.com)
31 *
32 * Optimized MDCT/IMDCT and FFT transforms
33 *
34 * This file is part of FFmpeg.
35 *
36 * FFmpeg is free software; you can redistribute it and/or
37 * modify it under the terms of the GNU Lesser General Public
38 * License as published by the Free Software Foundation; either
39 * version 2.1 of the License, or (at your option) any later version.
40 *
41 * FFmpeg is distributed in the hope that it will be useful,
42 * but WITHOUT ANY WARRANTY; without even the implied warranty of
43 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44 * Lesser General Public License for more details.
45 *
46 * You should have received a copy of the GNU Lesser General Public
47 * License along with FFmpeg; if not, write to the Free Software
48 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
49 */
50#include "config.h"
51#include "libavutil/attributes.h"
52#include "libavcodec/fft.h"
53#include "libavcodec/fft_table.h"
54#include "libavutil/mips/asmdefs.h"
55
56/**
57 * FFT transform
58 */
59
60#if HAVE_INLINE_ASM
61#if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
62static void ff_fft_calc_mips(FFTContext *s, FFTComplex *z)
63{
64 int nbits, i, n, num_transforms, offset, step;
65 int n4, n2, n34;
66 FFTSample tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
67 FFTComplex *tmpz;
68 float w_re, w_im;
69 float *w_re_ptr, *w_im_ptr;
70 const int fft_size = (1 << s->nbits);
71 float pom, pom1, pom2, pom3;
72 float temp, temp1, temp3, temp4;
73 FFTComplex * tmpz_n2, * tmpz_n34, * tmpz_n4;
74 FFTComplex * tmpz_n2_i, * tmpz_n34_i, * tmpz_n4_i, * tmpz_i;
75 float f1 = 0.7071067812;
76
77 num_transforms = (21845 >> (17 - s->nbits)) | 1;
78
79 for (n=0; n<num_transforms; n++) {
80 offset = ff_fft_offsets_lut[n] << 2;
81 tmpz = z + offset;
82
83 tmp1 = tmpz[0].re + tmpz[1].re;
84 tmp5 = tmpz[2].re + tmpz[3].re;
85 tmp2 = tmpz[0].im + tmpz[1].im;
86 tmp6 = tmpz[2].im + tmpz[3].im;
87 tmp3 = tmpz[0].re - tmpz[1].re;
88 tmp8 = tmpz[2].im - tmpz[3].im;
89 tmp4 = tmpz[0].im - tmpz[1].im;
90 tmp7 = tmpz[2].re - tmpz[3].re;
91
92 tmpz[0].re = tmp1 + tmp5;
93 tmpz[2].re = tmp1 - tmp5;
94 tmpz[0].im = tmp2 + tmp6;
95 tmpz[2].im = tmp2 - tmp6;
96 tmpz[1].re = tmp3 + tmp8;
97 tmpz[3].re = tmp3 - tmp8;
98 tmpz[1].im = tmp4 - tmp7;
99 tmpz[3].im = tmp4 + tmp7;
100
101 }
102
103 if (fft_size < 8)
104 return;
105
106 num_transforms = (num_transforms >> 1) | 1;
107
108 for (n=0; n<num_transforms; n++) {
109 offset = ff_fft_offsets_lut[n] << 3;
110 tmpz = z + offset;
111
112 __asm__ volatile (
113 "lwc1 %[tmp1], 32(%[tmpz]) \n\t"
114 "lwc1 %[pom], 40(%[tmpz]) \n\t"
115 "lwc1 %[tmp3], 48(%[tmpz]) \n\t"
116 "lwc1 %[pom1], 56(%[tmpz]) \n\t"
117 "lwc1 %[tmp2], 36(%[tmpz]) \n\t"
118 "lwc1 %[pom2], 44(%[tmpz]) \n\t"
119 "lwc1 %[pom3], 60(%[tmpz]) \n\t"
120 "lwc1 %[tmp4], 52(%[tmpz]) \n\t"
121 "add.s %[tmp1], %[tmp1], %[pom] \n\t" // tmp1 = tmpz[4].re + tmpz[5].re;
122 "add.s %[tmp3], %[tmp3], %[pom1] \n\t" // tmp3 = tmpz[6].re + tmpz[7].re;
123 "add.s %[tmp2], %[tmp2], %[pom2] \n\t" // tmp2 = tmpz[4].im + tmpz[5].im;
124 "lwc1 %[pom], 40(%[tmpz]) \n\t"
125 "add.s %[tmp4], %[tmp4], %[pom3] \n\t" // tmp4 = tmpz[6].im + tmpz[7].im;
126 "add.s %[tmp5], %[tmp1], %[tmp3] \n\t" // tmp5 = tmp1 + tmp3;
127 "sub.s %[tmp7], %[tmp1], %[tmp3] \n\t" // tmp7 = tmp1 - tmp3;
128 "lwc1 %[tmp1], 32(%[tmpz]) \n\t"
129 "lwc1 %[pom1], 44(%[tmpz]) \n\t"
130 "add.s %[tmp6], %[tmp2], %[tmp4] \n\t" // tmp6 = tmp2 + tmp4;
131 "sub.s %[tmp8], %[tmp2], %[tmp4] \n\t" // tmp8 = tmp2 - tmp4;
132 "lwc1 %[tmp2], 36(%[tmpz]) \n\t"
133 "lwc1 %[pom2], 56(%[tmpz]) \n\t"
134 "lwc1 %[pom3], 60(%[tmpz]) \n\t"
135 "lwc1 %[tmp3], 48(%[tmpz]) \n\t"
136 "lwc1 %[tmp4], 52(%[tmpz]) \n\t"
137 "sub.s %[tmp1], %[tmp1], %[pom] \n\t" // tmp1 = tmpz[4].re - tmpz[5].re;
138 "lwc1 %[pom], 0(%[tmpz]) \n\t"
139 "sub.s %[tmp2], %[tmp2], %[pom1] \n\t" // tmp2 = tmpz[4].im - tmpz[5].im;
140 "sub.s %[tmp3], %[tmp3], %[pom2] \n\t" // tmp3 = tmpz[6].re - tmpz[7].re;
141 "lwc1 %[pom2], 4(%[tmpz]) \n\t"
142 "sub.s %[pom1], %[pom], %[tmp5] \n\t"
143 "sub.s %[tmp4], %[tmp4], %[pom3] \n\t" // tmp4 = tmpz[6].im - tmpz[7].im;
144 "add.s %[pom3], %[pom], %[tmp5] \n\t"
145 "sub.s %[pom], %[pom2], %[tmp6] \n\t"
146 "add.s %[pom2], %[pom2], %[tmp6] \n\t"
147 "swc1 %[pom1], 32(%[tmpz]) \n\t" // tmpz[4].re = tmpz[0].re - tmp5;
148 "swc1 %[pom3], 0(%[tmpz]) \n\t" // tmpz[0].re = tmpz[0].re + tmp5;
149 "swc1 %[pom], 36(%[tmpz]) \n\t" // tmpz[4].im = tmpz[0].im - tmp6;
150 "swc1 %[pom2], 4(%[tmpz]) \n\t" // tmpz[0].im = tmpz[0].im + tmp6;
151 "lwc1 %[pom1], 16(%[tmpz]) \n\t"
152 "lwc1 %[pom3], 20(%[tmpz]) \n\t"
153 "add.s %[temp1],%[tmp1], %[tmp2] \n\t"
154 "sub.s %[temp], %[pom1], %[tmp8] \n\t"
155 "add.s %[pom2], %[pom3], %[tmp7] \n\t"
156 "sub.s %[temp3],%[tmp3], %[tmp4] \n\t"
157 "sub.s %[temp4],%[tmp2], %[tmp1] \n\t"
158 "swc1 %[temp], 48(%[tmpz]) \n\t" // tmpz[6].re = tmpz[2].re - tmp8;
159 "swc1 %[pom2], 52(%[tmpz]) \n\t" // tmpz[6].im = tmpz[2].im + tmp7;
160 "add.s %[pom1], %[pom1], %[tmp8] \n\t"
161 "sub.s %[pom3], %[pom3], %[tmp7] \n\t"
162 "add.s %[tmp3], %[tmp3], %[tmp4] \n\t"
163 "mul.s %[tmp5], %[f1], %[temp1] \n\t" // tmp5 = pom * (tmp1 + tmp2);
164 "mul.s %[tmp7], %[f1], %[temp3] \n\t" // tmp7 = pom * (tmp3 - tmp4);
165 "mul.s %[tmp6], %[f1], %[temp4] \n\t" // tmp6 = pom * (tmp2 - tmp1);
166 "mul.s %[tmp8], %[f1], %[tmp3] \n\t" // tmp8 = pom * (tmp3 + tmp4);
167 "swc1 %[pom1], 16(%[tmpz]) \n\t" // tmpz[2].re = tmpz[2].re + tmp8;
168 "swc1 %[pom3], 20(%[tmpz]) \n\t" // tmpz[2].im = tmpz[2].im - tmp7;
169 "add.s %[tmp1], %[tmp5], %[tmp7] \n\t" // tmp1 = tmp5 + tmp7;
170 "sub.s %[tmp3], %[tmp5], %[tmp7] \n\t" // tmp3 = tmp5 - tmp7;
171 "add.s %[tmp2], %[tmp6], %[tmp8] \n\t" // tmp2 = tmp6 + tmp8;
172 "sub.s %[tmp4], %[tmp6], %[tmp8] \n\t" // tmp4 = tmp6 - tmp8;
173 "lwc1 %[temp], 8(%[tmpz]) \n\t"
174 "lwc1 %[temp1],12(%[tmpz]) \n\t"
175 "lwc1 %[pom], 24(%[tmpz]) \n\t"
176 "lwc1 %[pom2], 28(%[tmpz]) \n\t"
177 "sub.s %[temp4],%[temp], %[tmp1] \n\t"
178 "sub.s %[temp3],%[temp1], %[tmp2] \n\t"
179 "add.s %[temp], %[temp], %[tmp1] \n\t"
180 "add.s %[temp1],%[temp1], %[tmp2] \n\t"
181 "sub.s %[pom1], %[pom], %[tmp4] \n\t"
182 "add.s %[pom3], %[pom2], %[tmp3] \n\t"
183 "add.s %[pom], %[pom], %[tmp4] \n\t"
184 "sub.s %[pom2], %[pom2], %[tmp3] \n\t"
185 "swc1 %[temp4],40(%[tmpz]) \n\t" // tmpz[5].re = tmpz[1].re - tmp1;
186 "swc1 %[temp3],44(%[tmpz]) \n\t" // tmpz[5].im = tmpz[1].im - tmp2;
187 "swc1 %[temp], 8(%[tmpz]) \n\t" // tmpz[1].re = tmpz[1].re + tmp1;
188 "swc1 %[temp1],12(%[tmpz]) \n\t" // tmpz[1].im = tmpz[1].im + tmp2;
189 "swc1 %[pom1], 56(%[tmpz]) \n\t" // tmpz[7].re = tmpz[3].re - tmp4;
190 "swc1 %[pom3], 60(%[tmpz]) \n\t" // tmpz[7].im = tmpz[3].im + tmp3;
191 "swc1 %[pom], 24(%[tmpz]) \n\t" // tmpz[3].re = tmpz[3].re + tmp4;
192 "swc1 %[pom2], 28(%[tmpz]) \n\t" // tmpz[3].im = tmpz[3].im - tmp3;
193 : [tmp1]"=&f"(tmp1), [pom]"=&f"(pom), [pom1]"=&f"(pom1), [pom2]"=&f"(pom2),
194 [tmp3]"=&f"(tmp3), [tmp2]"=&f"(tmp2), [tmp4]"=&f"(tmp4), [tmp5]"=&f"(tmp5), [tmp7]"=&f"(tmp7),
195 [tmp6]"=&f"(tmp6), [tmp8]"=&f"(tmp8), [pom3]"=&f"(pom3),[temp]"=&f"(temp), [temp1]"=&f"(temp1),
196 [temp3]"=&f"(temp3), [temp4]"=&f"(temp4)
197 : [tmpz]"r"(tmpz), [f1]"f"(f1)
198 : "memory"
199 );
200 }
201
202 step = 1 << (MAX_LOG2_NFFT - 4);
203 n4 = 4;
204
205 for (nbits=4; nbits<=s->nbits; nbits++) {
206 num_transforms = (num_transforms >> 1) | 1;
207 n2 = 2 * n4;
208 n34 = 3 * n4;
209
210 for (n=0; n<num_transforms; n++) {
211 offset = ff_fft_offsets_lut[n] << nbits;
212 tmpz = z + offset;
213
214 tmpz_n2 = tmpz + n2;
215 tmpz_n4 = tmpz + n4;
216 tmpz_n34 = tmpz + n34;
217
218 __asm__ volatile (
219 "lwc1 %[pom1], 0(%[tmpz_n2]) \n\t"
220 "lwc1 %[pom], 0(%[tmpz_n34]) \n\t"
221 "lwc1 %[pom2], 4(%[tmpz_n2]) \n\t"
222 "lwc1 %[pom3], 4(%[tmpz_n34]) \n\t"
223 "lwc1 %[temp1],0(%[tmpz]) \n\t"
224 "lwc1 %[temp3],4(%[tmpz]) \n\t"
225 "add.s %[tmp5], %[pom1], %[pom] \n\t" // tmp5 = tmpz[ n2].re + tmpz[n34].re;
226 "sub.s %[tmp1], %[pom1], %[pom] \n\t" // tmp1 = tmpz[ n2].re - tmpz[n34].re;
227 "add.s %[tmp6], %[pom2], %[pom3] \n\t" // tmp6 = tmpz[ n2].im + tmpz[n34].im;
228 "sub.s %[tmp2], %[pom2], %[pom3] \n\t" // tmp2 = tmpz[ n2].im - tmpz[n34].im;
229 "sub.s %[temp], %[temp1], %[tmp5] \n\t"
230 "add.s %[temp1],%[temp1], %[tmp5] \n\t"
231 "sub.s %[temp4],%[temp3], %[tmp6] \n\t"
232 "add.s %[temp3],%[temp3], %[tmp6] \n\t"
233 "swc1 %[temp], 0(%[tmpz_n2]) \n\t" // tmpz[ n2].re = tmpz[ 0].re - tmp5;
234 "swc1 %[temp1],0(%[tmpz]) \n\t" // tmpz[ 0].re = tmpz[ 0].re + tmp5;
235 "lwc1 %[pom1], 0(%[tmpz_n4]) \n\t"
236 "swc1 %[temp4],4(%[tmpz_n2]) \n\t" // tmpz[ n2].im = tmpz[ 0].im - tmp6;
237 "lwc1 %[temp], 4(%[tmpz_n4]) \n\t"
238 "swc1 %[temp3],4(%[tmpz]) \n\t" // tmpz[ 0].im = tmpz[ 0].im + tmp6;
239 "sub.s %[pom], %[pom1], %[tmp2] \n\t"
240 "add.s %[pom1], %[pom1], %[tmp2] \n\t"
241 "add.s %[temp1],%[temp], %[tmp1] \n\t"
242 "sub.s %[temp], %[temp], %[tmp1] \n\t"
243 "swc1 %[pom], 0(%[tmpz_n34]) \n\t" // tmpz[n34].re = tmpz[n4].re - tmp2;
244 "swc1 %[pom1], 0(%[tmpz_n4]) \n\t" // tmpz[ n4].re = tmpz[n4].re + tmp2;
245 "swc1 %[temp1],4(%[tmpz_n34]) \n\t" // tmpz[n34].im = tmpz[n4].im + tmp1;
246 "swc1 %[temp], 4(%[tmpz_n4]) \n\t" // tmpz[ n4].im = tmpz[n4].im - tmp1;
247 : [tmp5]"=&f"(tmp5),
248 [tmp1]"=&f"(tmp1), [pom]"=&f"(pom), [pom1]"=&f"(pom1), [pom2]"=&f"(pom2),
249 [tmp2]"=&f"(tmp2), [tmp6]"=&f"(tmp6), [pom3]"=&f"(pom3),
250 [temp]"=&f"(temp), [temp1]"=&f"(temp1), [temp3]"=&f"(temp3), [temp4]"=&f"(temp4)
251 : [tmpz]"r"(tmpz), [tmpz_n2]"r"(tmpz_n2), [tmpz_n34]"r"(tmpz_n34), [tmpz_n4]"r"(tmpz_n4)
252 : "memory"
253 );
254
255 w_re_ptr = (float*)(ff_cos_131072 + step);
256 w_im_ptr = (float*)(ff_cos_131072 + MAX_FFT_SIZE/4 - step);
257
258 for (i=1; i<n4; i++) {
259 w_re = w_re_ptr[0];
260 w_im = w_im_ptr[0];
261 tmpz_n2_i = tmpz_n2 + i;
262 tmpz_n4_i = tmpz_n4 + i;
263 tmpz_n34_i= tmpz_n34 + i;
264 tmpz_i = tmpz + i;
265
266 __asm__ volatile (
267 "lwc1 %[temp], 0(%[tmpz_n2_i]) \n\t"
268 "lwc1 %[temp1], 4(%[tmpz_n2_i]) \n\t"
269 "lwc1 %[pom], 0(%[tmpz_n34_i]) \n\t"
270 "lwc1 %[pom1], 4(%[tmpz_n34_i]) \n\t"
271 "mul.s %[temp3], %[w_im], %[temp] \n\t"
272 "mul.s %[temp4], %[w_im], %[temp1] \n\t"
273 "mul.s %[pom2], %[w_im], %[pom1] \n\t"
274 "mul.s %[pom3], %[w_im], %[pom] \n\t"
275 "msub.s %[tmp2], %[temp3], %[w_re], %[temp1] \n\t" // tmp2 = w_re * tmpz[ n2+i].im - w_im * tmpz[ n2+i].re;
276 "madd.s %[tmp1], %[temp4], %[w_re], %[temp] \n\t" // tmp1 = w_re * tmpz[ n2+i].re + w_im * tmpz[ n2+i].im;
277 "msub.s %[tmp3], %[pom2], %[w_re], %[pom] \n\t" // tmp3 = w_re * tmpz[n34+i].re - w_im * tmpz[n34+i].im;
278 "madd.s %[tmp4], %[pom3], %[w_re], %[pom1] \n\t" // tmp4 = w_re * tmpz[n34+i].im + w_im * tmpz[n34+i].re;
279 "lwc1 %[temp], 0(%[tmpz_i]) \n\t"
280 "lwc1 %[pom], 4(%[tmpz_i]) \n\t"
281 "add.s %[tmp5], %[tmp1], %[tmp3] \n\t" // tmp5 = tmp1 + tmp3;
282 "sub.s %[tmp1], %[tmp1], %[tmp3] \n\t" // tmp1 = tmp1 - tmp3;
283 "add.s %[tmp6], %[tmp2], %[tmp4] \n\t" // tmp6 = tmp2 + tmp4;
284 "sub.s %[tmp2], %[tmp2], %[tmp4] \n\t" // tmp2 = tmp2 - tmp4;
285 "sub.s %[temp1], %[temp], %[tmp5] \n\t"
286 "add.s %[temp], %[temp], %[tmp5] \n\t"
287 "sub.s %[pom1], %[pom], %[tmp6] \n\t"
288 "add.s %[pom], %[pom], %[tmp6] \n\t"
289 "lwc1 %[temp3], 0(%[tmpz_n4_i]) \n\t"
290 "lwc1 %[pom2], 4(%[tmpz_n4_i]) \n\t"
291 "swc1 %[temp1], 0(%[tmpz_n2_i]) \n\t" // tmpz[ n2+i].re = tmpz[ i].re - tmp5;
292 "swc1 %[temp], 0(%[tmpz_i]) \n\t" // tmpz[ i].re = tmpz[ i].re + tmp5;
293 "swc1 %[pom1], 4(%[tmpz_n2_i]) \n\t" // tmpz[ n2+i].im = tmpz[ i].im - tmp6;
294 "swc1 %[pom] , 4(%[tmpz_i]) \n\t" // tmpz[ i].im = tmpz[ i].im + tmp6;
295 "sub.s %[temp4], %[temp3], %[tmp2] \n\t"
296 "add.s %[pom3], %[pom2], %[tmp1] \n\t"
297 "add.s %[temp3], %[temp3], %[tmp2] \n\t"
298 "sub.s %[pom2], %[pom2], %[tmp1] \n\t"
299 "swc1 %[temp4], 0(%[tmpz_n34_i]) \n\t" // tmpz[n34+i].re = tmpz[n4+i].re - tmp2;
300 "swc1 %[pom3], 4(%[tmpz_n34_i]) \n\t" // tmpz[n34+i].im = tmpz[n4+i].im + tmp1;
301 "swc1 %[temp3], 0(%[tmpz_n4_i]) \n\t" // tmpz[ n4+i].re = tmpz[n4+i].re + tmp2;
302 "swc1 %[pom2], 4(%[tmpz_n4_i]) \n\t" // tmpz[ n4+i].im = tmpz[n4+i].im - tmp1;
303 : [tmp1]"=&f"(tmp1), [tmp2]"=&f" (tmp2), [temp]"=&f"(temp), [tmp3]"=&f"(tmp3),
304 [tmp4]"=&f"(tmp4), [tmp5]"=&f"(tmp5), [tmp6]"=&f"(tmp6),
305 [temp1]"=&f"(temp1), [temp3]"=&f"(temp3), [temp4]"=&f"(temp4),
306 [pom]"=&f"(pom), [pom1]"=&f"(pom1), [pom2]"=&f"(pom2), [pom3]"=&f"(pom3)
307 : [w_re]"f"(w_re), [w_im]"f"(w_im),
308 [tmpz_i]"r"(tmpz_i),[tmpz_n2_i]"r"(tmpz_n2_i),
309 [tmpz_n34_i]"r"(tmpz_n34_i), [tmpz_n4_i]"r"(tmpz_n4_i)
310 : "memory"
311 );
312 w_re_ptr += step;
313 w_im_ptr -= step;
314 }
315 }
316 step >>= 1;
317 n4 <<= 1;
318 }
319}
320
321/**
322 * MDCT/IMDCT transforms.
323 */
324
325static void ff_imdct_half_mips(FFTContext *s, FFTSample *output, const FFTSample *input)
326{
327 int k, n8, n4, n2, n, j;
328 const uint16_t *revtab = s->revtab;
329 const FFTSample *tcos = s->tcos;
330 const FFTSample *tsin = s->tsin;
331 const FFTSample *in1, *in2, *in3, *in4;
332 FFTComplex *z = (FFTComplex *)output;
333
334 int j1;
335 const float *tcos1, *tsin1, *tcos2, *tsin2;
336 float temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8,
337 temp9, temp10, temp11, temp12, temp13, temp14, temp15, temp16;
338 FFTComplex *z1, *z2;
339
340 n = 1 << s->mdct_bits;
341 n2 = n >> 1;
342 n4 = n >> 2;
343 n8 = n >> 3;
344
345 /* pre rotation */
346 in1 = input;
347 in2 = input + n2 - 1;
348 in3 = input + 2;
349 in4 = input + n2 - 3;
350
351 tcos1 = tcos;
352 tsin1 = tsin;
353
354 /* n4 = 64 or 128 */
355 for(k = 0; k < n4; k += 2) {
356 j = revtab[k ];
357 j1 = revtab[k + 1];
358
359 __asm__ volatile (
360 "lwc1 %[temp1], 0(%[in2]) \t\n"
361 "lwc1 %[temp2], 0(%[tcos1]) \t\n"
362 "lwc1 %[temp3], 0(%[tsin1]) \t\n"
363 "lwc1 %[temp4], 0(%[in1]) \t\n"
364 "lwc1 %[temp5], 0(%[in4]) \t\n"
365 "mul.s %[temp9], %[temp1], %[temp2] \t\n"
366 "mul.s %[temp10], %[temp1], %[temp3] \t\n"
367 "lwc1 %[temp6], 4(%[tcos1]) \t\n"
368 "lwc1 %[temp7], 4(%[tsin1]) \t\n"
369 "nmsub.s %[temp9], %[temp9], %[temp4], %[temp3] \t\n"
370 "madd.s %[temp10], %[temp10], %[temp4], %[temp2] \t\n"
371 "mul.s %[temp11], %[temp5], %[temp6] \t\n"
372 "mul.s %[temp12], %[temp5], %[temp7] \t\n"
373 "lwc1 %[temp8], 0(%[in3]) \t\n"
374 PTR_ADDIU " %[tcos1], %[tcos1], 8 \t\n"
375 PTR_ADDIU " %[tsin1], %[tsin1], 8 \t\n"
376 PTR_ADDIU " %[in1], %[in1], 16 \t\n"
377 "nmsub.s %[temp11], %[temp11], %[temp8], %[temp7] \t\n"
378 "madd.s %[temp12], %[temp12], %[temp8], %[temp6] \t\n"
379 PTR_ADDIU " %[in2], %[in2], -16 \t\n"
380 PTR_ADDIU " %[in3], %[in3], 16 \t\n"
381 PTR_ADDIU " %[in4], %[in4], -16 \t\n"
382
383 : [temp1]"=&f"(temp1), [temp2]"=&f"(temp2),
384 [temp3]"=&f"(temp3), [temp4]"=&f"(temp4),
385 [temp5]"=&f"(temp5), [temp6]"=&f"(temp6),
386 [temp7]"=&f"(temp7), [temp8]"=&f"(temp8),
387 [temp9]"=&f"(temp9), [temp10]"=&f"(temp10),
388 [temp11]"=&f"(temp11), [temp12]"=&f"(temp12),
389 [tsin1]"+r"(tsin1), [tcos1]"+r"(tcos1),
390 [in1]"+r"(in1), [in2]"+r"(in2),
391 [in3]"+r"(in3), [in4]"+r"(in4)
392 :
393 : "memory"
394 );
395
396 z[j ].re = temp9;
397 z[j ].im = temp10;
398 z[j1].re = temp11;
399 z[j1].im = temp12;
400 }
401
402 s->fft_calc(s, z);
403
404 /* post rotation + reordering */
405 /* n8 = 32 or 64 */
406 for(k = 0; k < n8; k += 2) {
407 tcos1 = &tcos[n8 - k - 2];
408 tsin1 = &tsin[n8 - k - 2];
409 tcos2 = &tcos[n8 + k];
410 tsin2 = &tsin[n8 + k];
411 z1 = &z[n8 - k - 2];
412 z2 = &z[n8 + k ];
413
414 __asm__ volatile (
415 "lwc1 %[temp1], 12(%[z1]) \t\n"
416 "lwc1 %[temp2], 4(%[tsin1]) \t\n"
417 "lwc1 %[temp3], 4(%[tcos1]) \t\n"
418 "lwc1 %[temp4], 8(%[z1]) \t\n"
419 "lwc1 %[temp5], 4(%[z1]) \t\n"
420 "mul.s %[temp9], %[temp1], %[temp2] \t\n"
421 "mul.s %[temp10], %[temp1], %[temp3] \t\n"
422 "lwc1 %[temp6], 0(%[tsin1]) \t\n"
423 "lwc1 %[temp7], 0(%[tcos1]) \t\n"
424 "nmsub.s %[temp9], %[temp9], %[temp4], %[temp3] \t\n"
425 "madd.s %[temp10], %[temp10], %[temp4], %[temp2] \t\n"
426 "mul.s %[temp11], %[temp5], %[temp6] \t\n"
427 "mul.s %[temp12], %[temp5], %[temp7] \t\n"
428 "lwc1 %[temp8], 0(%[z1]) \t\n"
429 "lwc1 %[temp1], 4(%[z2]) \t\n"
430 "lwc1 %[temp2], 0(%[tsin2]) \t\n"
431 "lwc1 %[temp3], 0(%[tcos2]) \t\n"
432 "nmsub.s %[temp11], %[temp11], %[temp8], %[temp7] \t\n"
433 "madd.s %[temp12], %[temp12], %[temp8], %[temp6] \t\n"
434 "mul.s %[temp13], %[temp1], %[temp2] \t\n"
435 "mul.s %[temp14], %[temp1], %[temp3] \t\n"
436 "lwc1 %[temp4], 0(%[z2]) \t\n"
437 "lwc1 %[temp5], 12(%[z2]) \t\n"
438 "lwc1 %[temp6], 4(%[tsin2]) \t\n"
439 "lwc1 %[temp7], 4(%[tcos2]) \t\n"
440 "nmsub.s %[temp13], %[temp13], %[temp4], %[temp3] \t\n"
441 "madd.s %[temp14], %[temp14], %[temp4], %[temp2] \t\n"
442 "mul.s %[temp15], %[temp5], %[temp6] \t\n"
443 "mul.s %[temp16], %[temp5], %[temp7] \t\n"
444 "lwc1 %[temp8], 8(%[z2]) \t\n"
445 "nmsub.s %[temp15], %[temp15], %[temp8], %[temp7] \t\n"
446 "madd.s %[temp16], %[temp16], %[temp8], %[temp6] \t\n"
447 : [temp1]"=&f"(temp1), [temp2]"=&f"(temp2),
448 [temp3]"=&f"(temp3), [temp4]"=&f"(temp4),
449 [temp5]"=&f"(temp5), [temp6]"=&f"(temp6),
450 [temp7]"=&f"(temp7), [temp8]"=&f"(temp8),
451 [temp9]"=&f"(temp9), [temp10]"=&f"(temp10),
452 [temp11]"=&f"(temp11), [temp12]"=&f"(temp12),
453 [temp13]"=&f"(temp13), [temp14]"=&f"(temp14),
454 [temp15]"=&f"(temp15), [temp16]"=&f"(temp16)
455 : [z1]"r"(z1), [z2]"r"(z2),
456 [tsin1]"r"(tsin1), [tcos1]"r"(tcos1),
457 [tsin2]"r"(tsin2), [tcos2]"r"(tcos2)
458 : "memory"
459 );
460
461 z1[1].re = temp9;
462 z1[1].im = temp14;
463 z2[0].re = temp13;
464 z2[0].im = temp10;
465
466 z1[0].re = temp11;
467 z1[0].im = temp16;
468 z2[1].re = temp15;
469 z2[1].im = temp12;
470 }
471}
472
473/**
474 * Compute inverse MDCT of size N = 2^nbits
475 * @param output N samples
476 * @param input N/2 samples
477 */
478static void ff_imdct_calc_mips(FFTContext *s, FFTSample *output, const FFTSample *input)
479{
480 int k;
481 int n = 1 << s->mdct_bits;
482 int n2 = n >> 1;
483 int n4 = n >> 2;
484
485 ff_imdct_half_mips(s, output+n4, input);
486
487 for(k = 0; k < n4; k+=4) {
488 output[k] = -output[n2-k-1];
489 output[k+1] = -output[n2-k-2];
490 output[k+2] = -output[n2-k-3];
491 output[k+3] = -output[n2-k-4];
492
493 output[n-k-1] = output[n2+k];
494 output[n-k-2] = output[n2+k+1];
495 output[n-k-3] = output[n2+k+2];
496 output[n-k-4] = output[n2+k+3];
497 }
498}
499#endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */
500#endif /* HAVE_INLINE_ASM */
501
502av_cold void ff_fft_init_mips(FFTContext *s)
503{
504 ff_fft_lut_init();
505 ff_init_ff_cos_tabs(17);
506
507#if HAVE_INLINE_ASM
508#if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
509 s->fft_calc = ff_fft_calc_mips;
510#if CONFIG_MDCT
511 s->imdct_calc = ff_imdct_calc_mips;
512 s->imdct_half = ff_imdct_half_mips;
513#endif
514#endif
515#endif
516}
libavcodec/ppc/Makefile+0−3
@@ -1,9 +1,6 @@
1# subsystems1# subsystems
2OBJS-$(CONFIG_AUDIODSP) += ppc/audiodsp.o2OBJS-$(CONFIG_AUDIODSP) += ppc/audiodsp.o
3OBJS-$(CONFIG_BLOCKDSP) += ppc/blockdsp.o3OBJS-$(CONFIG_BLOCKDSP) += ppc/blockdsp.o
4OBJS-$(CONFIG_FFT) += ppc/fft_init.o \
5 ppc/fft_altivec.o \
6 ppc/fft_vsx.o
7OBJS-$(CONFIG_FDCTDSP) += ppc/fdctdsp.o4OBJS-$(CONFIG_FDCTDSP) += ppc/fdctdsp.o
8OBJS-$(CONFIG_FMTCONVERT) += ppc/fmtconvert_altivec.o5OBJS-$(CONFIG_FMTCONVERT) += ppc/fmtconvert_altivec.o
9OBJS-$(CONFIG_H264CHROMA) += ppc/h264chroma_init.o6OBJS-$(CONFIG_H264CHROMA) += ppc/h264chroma_init.o
libavcodec/ppc/fft_altivec.S+0−458
@@ -1,458 +0,0 @@
1/*
2 * FFT transform with Altivec optimizations
3 * Copyright (c) 2009 Loren Merritt
4 *
5 * This algorithm (though not any of the implementation details) is
6 * based on libdjbfft by D. J. Bernstein.
7 *
8 * This file is part of FFmpeg.
9 *
10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25/*
26 * These functions are not individually interchangeable with the C versions.
27 * While C takes arrays of FFTComplex, Altivec leaves intermediate results
28 * in blocks as convenient to the vector size.
29 * i.e. {4x real, 4x imaginary, 4x real, ...}
30 *
31 * I ignore standard calling convention.
32 * Instead, the following registers are treated as global constants:
33 * v14: zero
34 * v15..v18: cosines
35 * v19..v29: permutations
36 * r9: 16
37 * r12: ff_cos_tabs
38 * and the rest are free for local use.
39 */
40
41#include "config.h"
42
43#if HAVE_GNU_AS && HAVE_ALTIVEC && HAVE_BIGENDIAN
44
45#include "asm.S"
46
47.text
48
49.macro addi2 ra, imm // add 32-bit immediate
50.if \imm & 0xffff
51 addi \ra, \ra, \imm@l
52.endif
53.if (\imm+0x8000)>>16
54 addis \ra, \ra, \imm@ha
55.endif
56.endm
57
58.macro FFT4 a0, a1, a2, a3 // in:0-1 out:2-3
59 vperm \a2,\a0,\a1,v20 // vcprm(0,1,s2,s1) // {r0,i0,r3,i2}
60 vperm \a3,\a0,\a1,v21 // vcprm(2,3,s0,s3) // {r1,i1,r2,i3}
61 vaddfp \a0,\a2,\a3 // {t1,t2,t6,t5}
62 vsubfp \a1,\a2,\a3 // {t3,t4,t8,t7}
63 vmrghw \a2,\a0,\a1 // vcprm(0,s0,1,s1) // {t1,t3,t2,t4}
64 vperm \a3,\a0,\a1,v22 // vcprm(2,s3,3,s2) // {t6,t7,t5,t8}
65 vaddfp \a0,\a2,\a3 // {r0,r1,i0,i1}
66 vsubfp \a1,\a2,\a3 // {r2,r3,i2,i3}
67 vperm \a2,\a0,\a1,v23 // vcprm(0,1,s0,s1) // {r0,r1,r2,r3}
68 vperm \a3,\a0,\a1,v24 // vcprm(2,3,s2,s3) // {i0,i1,i2,i3}
69.endm
70
71.macro FFT4x2 a0, a1, b0, b1, a2, a3, b2, b3
72 vperm \a2,\a0,\a1,v20 // vcprm(0,1,s2,s1) // {r0,i0,r3,i2}
73 vperm \a3,\a0,\a1,v21 // vcprm(2,3,s0,s3) // {r1,i1,r2,i3}
74 vperm \b2,\b0,\b1,v20
75 vperm \b3,\b0,\b1,v21
76 vaddfp \a0,\a2,\a3 // {t1,t2,t6,t5}
77 vsubfp \a1,\a2,\a3 // {t3,t4,t8,t7}
78 vaddfp \b0,\b2,\b3
79 vsubfp \b1,\b2,\b3
80 vmrghw \a2,\a0,\a1 // vcprm(0,s0,1,s1) // {t1,t3,t2,t4}
81 vperm \a3,\a0,\a1,v22 // vcprm(2,s3,3,s2) // {t6,t7,t5,t8}
82 vmrghw \b2,\b0,\b1
83 vperm \b3,\b0,\b1,v22
84 vaddfp \a0,\a2,\a3 // {r0,r1,i0,i1}
85 vsubfp \a1,\a2,\a3 // {r2,r3,i2,i3}
86 vaddfp \b0,\b2,\b3
87 vsubfp \b1,\b2,\b3
88 vperm \a2,\a0,\a1,v23 // vcprm(0,1,s0,s1) // {r0,r1,r2,r3}
89 vperm \a3,\a0,\a1,v24 // vcprm(2,3,s2,s3) // {i0,i1,i2,i3}
90 vperm \b2,\b0,\b1,v23
91 vperm \b3,\b0,\b1,v24
92.endm
93
94.macro FFT8 a0, a1, b0, b1, a2, a3, b2, b3, b4 // in,out:a0-b1
95 vmrghw \b2,\b0,\b1 // vcprm(0,s0,1,s1) // {r4,r6,i4,i6}
96 vmrglw \b3,\b0,\b1 // vcprm(2,s2,3,s3) // {r5,r7,i5,i7}
97 vperm \a2,\a0,\a1,v20 // FFT4 ...
98 vperm \a3,\a0,\a1,v21
99 vaddfp \b0,\b2,\b3 // {t1,t3,t2,t4}
100 vsubfp \b1,\b2,\b3 // {r5,r7,i5,i7}
101 vperm \b4,\b1,\b1,v25 // vcprm(2,3,0,1) // {i5,i7,r5,r7}
102 vaddfp \a0,\a2,\a3
103 vsubfp \a1,\a2,\a3
104 vmaddfp \b1,\b1,v17,v14 // * {-1,1,1,-1}/sqrt(2)
105 vmaddfp \b1,\b4,v18,\b1 // * { 1,1,1,1 }/sqrt(2) // {t8,ta,t7,t9}
106 vmrghw \a2,\a0,\a1
107 vperm \a3,\a0,\a1,v22
108 vperm \b2,\b0,\b1,v26 // vcprm(1,2,s3,s0) // {t3,t2,t9,t8}
109 vperm \b3,\b0,\b1,v27 // vcprm(0,3,s2,s1) // {t1,t4,t7,ta}
110 vaddfp \a0,\a2,\a3
111 vsubfp \a1,\a2,\a3
112 vaddfp \b0,\b2,\b3 // {t1,t2,t9,ta}
113 vsubfp \b1,\b2,\b3 // {t6,t5,tc,tb}
114 vperm \a2,\a0,\a1,v23
115 vperm \a3,\a0,\a1,v24
116 vperm \b2,\b0,\b1,v28 // vcprm(0,2,s1,s3) // {t1,t9,t5,tb}
117 vperm \b3,\b0,\b1,v29 // vcprm(1,3,s0,s2) // {t2,ta,t6,tc}
118 vsubfp \b0,\a2,\b2 // {r4,r5,r6,r7}
119 vsubfp \b1,\a3,\b3 // {i4,i5,i6,i7}
120 vaddfp \a0,\a2,\b2 // {r0,r1,r2,r3}
121 vaddfp \a1,\a3,\b3 // {i0,i1,i2,i3}
122.endm
123
124.macro BF d0,d1,s0,s1
125 vsubfp \d1,\s0,\s1
126 vaddfp \d0,\s0,\s1
127.endm
128
129.macro zip d0,d1,s0,s1
130 vmrghw \d0,\s0,\s1
131 vmrglw \d1,\s0,\s1
132.endm
133
134.macro def_fft4 interleave
135fft4\interleave\()_altivec:
136 lvx v0, 0,r3
137 lvx v1,r9,r3
138 FFT4 v0,v1,v2,v3
139.ifnb \interleave
140 zip v0,v1,v2,v3
141 stvx v0, 0,r3
142 stvx v1,r9,r3
143.else
144 stvx v2, 0,r3
145 stvx v3,r9,r3
146.endif
147 blr
148.endm
149
150.macro def_fft8 interleave
151fft8\interleave\()_altivec:
152 addi r4,r3,32
153 lvx v0, 0,r3
154 lvx v1,r9,r3
155 lvx v2, 0,r4
156 lvx v3,r9,r4
157 FFT8 v0,v1,v2,v3,v4,v5,v6,v7,v8
158.ifnb \interleave
159 zip v4,v5,v0,v1
160 zip v6,v7,v2,v3
161 stvx v4, 0,r3
162 stvx v5,r9,r3
163 stvx v6, 0,r4
164 stvx v7,r9,r4
165.else
166 stvx v0, 0,r3
167 stvx v1,r9,r3
168 stvx v2, 0,r4
169 stvx v3,r9,r4
170.endif
171 blr
172.endm
173
174.macro def_fft16 interleave
175fft16\interleave\()_altivec:
176 addi r5,r3,64
177 addi r6,r3,96
178 addi r4,r3,32
179 lvx v0, 0,r5
180 lvx v1,r9,r5
181 lvx v2, 0,r6
182 lvx v3,r9,r6
183 FFT4x2 v0,v1,v2,v3,v4,v5,v6,v7
184 lvx v0, 0,r3
185 lvx v1,r9,r3
186 lvx v2, 0,r4
187 lvx v3,r9,r4
188 FFT8 v0,v1,v2,v3,v8,v9,v10,v11,v12
189 vmaddfp v8,v4,v15,v14 // r2*wre
190 vmaddfp v9,v5,v15,v14 // i2*wre
191 vmaddfp v10,v6,v15,v14 // r3*wre
192 vmaddfp v11,v7,v15,v14 // i3*wre
193 vmaddfp v8,v5,v16,v8 // i2*wim
194 vnmsubfp v9,v4,v16,v9 // r2*wim
195 vnmsubfp v10,v7,v16,v10 // i3*wim
196 vmaddfp v11,v6,v16,v11 // r3*wim
197 BF v10,v12,v10,v8
198 BF v11,v13,v9,v11
199 BF v0,v4,v0,v10
200 BF v3,v7,v3,v12
201 BF v1,v5,v1,v11
202 BF v2,v6,v2,v13
203.ifnb \interleave
204 zip v8, v9,v0,v1
205 zip v10,v11,v2,v3
206 zip v12,v13,v4,v5
207 zip v14,v15,v6,v7
208 stvx v8, 0,r3
209 stvx v9,r9,r3
210 stvx v10, 0,r4
211 stvx v11,r9,r4
212 stvx v12, 0,r5
213 stvx v13,r9,r5
214 stvx v14, 0,r6
215 stvx v15,r9,r6
216.else
217 stvx v0, 0,r3
218 stvx v4, 0,r5
219 stvx v3,r9,r4
220 stvx v7,r9,r6
221 stvx v1,r9,r3
222 stvx v5,r9,r5
223 stvx v2, 0,r4
224 stvx v6, 0,r6
225.endif
226 blr
227.endm
228
229// void pass(float *z, float *wre, int n)
230.macro PASS interleave, suffix
231fft_pass\suffix\()_altivec:
232 mtctr r5
233 slwi r0,r5,4
234 slwi r7,r5,6 // o2
235 slwi r5,r5,5 // o1
236 add r10,r5,r7 // o3
237 add r0,r4,r0 // wim
238 addi r6,r5,16 // o1+16
239 addi r8,r7,16 // o2+16
240 addi r11,r10,16 // o3+16
2411:
242 lvx v8, 0,r4 // wre
243 lvx v10, 0,r0 // wim
244 sub r0,r0,r9
245 lvx v9, 0,r0
246 vperm v9,v9,v10,v19 // vcprm(s0,3,2,1) => wim[0 .. -3]
247 lvx v4,r3,r7 // r2 = z[o2]
248 lvx v5,r3,r8 // i2 = z[o2+16]
249 lvx v6,r3,r10 // r3 = z[o3]
250 lvx v7,r3,r11 // i3 = z[o3+16]
251 vmaddfp v10,v4,v8,v14 // r2*wre
252 vmaddfp v11,v5,v8,v14 // i2*wre
253 vmaddfp v12,v6,v8,v14 // r3*wre
254 vmaddfp v13,v7,v8,v14 // i3*wre
255 lvx v0, 0,r3 // r0 = z[0]
256 lvx v3,r3,r6 // i1 = z[o1+16]
257 vmaddfp v10,v5,v9,v10 // i2*wim
258 vnmsubfp v11,v4,v9,v11 // r2*wim
259 vnmsubfp v12,v7,v9,v12 // i3*wim
260 vmaddfp v13,v6,v9,v13 // r3*wim
261 lvx v1,r3,r9 // i0 = z[16]
262 lvx v2,r3,r5 // r1 = z[o1]
263 BF v12,v8,v12,v10
264 BF v13,v9,v11,v13
265 BF v0,v4,v0,v12
266 BF v3,v7,v3,v8
267.if !\interleave
268 stvx v0, 0,r3
269 stvx v4,r3,r7
270 stvx v3,r3,r6
271 stvx v7,r3,r11
272.endif
273 BF v1,v5,v1,v13
274 BF v2,v6,v2,v9
275.if !\interleave
276 stvx v1,r3,r9
277 stvx v2,r3,r5
278 stvx v5,r3,r8
279 stvx v6,r3,r10
280.else
281 vmrghw v8,v0,v1
282 vmrglw v9,v0,v1
283 stvx v8, 0,r3
284 stvx v9,r3,r9
285 vmrghw v8,v2,v3
286 vmrglw v9,v2,v3
287 stvx v8,r3,r5
288 stvx v9,r3,r6
289 vmrghw v8,v4,v5
290 vmrglw v9,v4,v5
291 stvx v8,r3,r7
292 stvx v9,r3,r8
293 vmrghw v8,v6,v7
294 vmrglw v9,v6,v7
295 stvx v8,r3,r10
296 stvx v9,r3,r11
297.endif
298 addi r3,r3,32
299 addi r4,r4,16
300 bdnz 1b
301 sub r3,r3,r5
302 blr
303.endm
304
305#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
306
307#define WORD_0 0x00,0x01,0x02,0x03
308#define WORD_1 0x04,0x05,0x06,0x07
309#define WORD_2 0x08,0x09,0x0a,0x0b
310#define WORD_3 0x0c,0x0d,0x0e,0x0f
311#define WORD_s0 0x10,0x11,0x12,0x13
312#define WORD_s1 0x14,0x15,0x16,0x17
313#define WORD_s2 0x18,0x19,0x1a,0x1b
314#define WORD_s3 0x1c,0x1d,0x1e,0x1f
315
316#define vcprm(a, b, c, d) .byte WORD_##a, WORD_##b, WORD_##c, WORD_##d
317
318 .rodata
319 .align 4
320fft_data:
321 .float 0, 0, 0, 0
322 .float 1, 0.92387953, M_SQRT1_2, 0.38268343
323 .float 0, 0.38268343, M_SQRT1_2, 0.92387953
324 .float -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2,-M_SQRT1_2
325 .float M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2
326 vcprm(s0,3,2,1)
327 vcprm(0,1,s2,s1)
328 vcprm(2,3,s0,s3)
329 vcprm(2,s3,3,s2)
330 vcprm(0,1,s0,s1)
331 vcprm(2,3,s2,s3)
332 vcprm(2,3,0,1)
333 vcprm(1,2,s3,s0)
334 vcprm(0,3,s2,s1)
335 vcprm(0,2,s1,s3)
336 vcprm(1,3,s0,s2)
337
338.macro lvm b, r, regs:vararg
339 lvx \r, 0, \b
340 addi \b, \b, 16
341 .ifnb \regs
342 lvm \b, \regs
343 .endif
344.endm
345
346.macro stvm b, r, regs:vararg
347 stvx \r, 0, \b
348 addi \b, \b, 16
349 .ifnb \regs
350 stvm \b, \regs
351 .endif
352.endm
353
354.macro fft_calc interleave
355extfunc ff_fft_calc\interleave\()_altivec
356 mflr r0
357 stp r0, 2*PS(R(1))
358 stpu r1, -(160+16*PS)(R(1))
359 get_got r11
360 addi r6, r1, 16*PS
361 stvm r6, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29
362 mfvrsave r0
363 stw r0, 15*PS(R(1))
364#if __APPLE__
365 li r6, 0xfffffffc
366#else
367 li r6, -4
368#endif
369 mtvrsave r6
370
371 movrel r6, fft_data, r11
372 lvm r6, v14, v15, v16, v17, v18, v19, v20, v21
373 lvm r6, v22, v23, v24, v25, v26, v27, v28, v29
374
375 li r9, 16
376 movrel r12, X(ff_cos_tabs), r11
377
378 movrel r6, fft_dispatch_tab\interleave\()_altivec, r11
379 lwz r3, 0(R(3))
380 subi r3, r3, 2
381 slwi r3, r3, 2+ARCH_PPC64
382 lpx r3, r3, r6
383 mtctr r3
384 mr r3, r4
385 bctrl
386
387 addi r6, r1, 16*PS
388 lvm r6, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29
389 lwz r6, 15*PS(R(1))
390 mtvrsave r6
391 lp r1, 0(R(1))
392 lp r0, 2*PS(R(1))
393 mtlr r0
394 blr
395.endm
396
397.macro DECL_FFT suffix, bits, n, n2, n4
398fft\n\suffix\()_altivec:
399 mflr r0
400 stp r0,PS*(\bits-3)(R(1))
401 bl fft\n2\()_altivec
402 addi2 r3,\n*4
403 bl fft\n4\()_altivec
404 addi2 r3,\n*2
405 bl fft\n4\()_altivec
406 addi2 r3,\n*-6
407 lp r0,PS*(\bits-3)(R(1))
408 lp r4,\bits*PS(R(12))
409 mtlr r0
410 li r5,\n/16
411 b fft_pass\suffix\()_altivec
412.endm
413
414.macro DECL_FFTS interleave, suffix
415 .text
416 def_fft4 \suffix
417 def_fft8 \suffix
418 def_fft16 \suffix
419 PASS \interleave, \suffix
420 DECL_FFT \suffix, 5, 32, 16, 8
421 DECL_FFT \suffix, 6, 64, 32, 16
422 DECL_FFT \suffix, 7, 128, 64, 32
423 DECL_FFT \suffix, 8, 256, 128, 64
424 DECL_FFT \suffix, 9, 512, 256, 128
425 DECL_FFT \suffix,10, 1024, 512, 256
426 DECL_FFT \suffix,11, 2048, 1024, 512
427 DECL_FFT \suffix,12, 4096, 2048, 1024
428 DECL_FFT \suffix,13, 8192, 4096, 2048
429 DECL_FFT \suffix,14,16384, 8192, 4096
430 DECL_FFT \suffix,15,32768,16384, 8192
431 DECL_FFT \suffix,16,65536,32768,16384
432
433 fft_calc \suffix
434
435 .rodata
436 .align 3
437fft_dispatch_tab\suffix\()_altivec:
438 PTR fft4\suffix\()_altivec
439 PTR fft8\suffix\()_altivec
440 PTR fft16\suffix\()_altivec
441 PTR fft32\suffix\()_altivec
442 PTR fft64\suffix\()_altivec
443 PTR fft128\suffix\()_altivec
444 PTR fft256\suffix\()_altivec
445 PTR fft512\suffix\()_altivec
446 PTR fft1024\suffix\()_altivec
447 PTR fft2048\suffix\()_altivec
448 PTR fft4096\suffix\()_altivec
449 PTR fft8192\suffix\()_altivec
450 PTR fft16384\suffix\()_altivec
451 PTR fft32768\suffix\()_altivec
452 PTR fft65536\suffix\()_altivec
453.endm
454
455DECL_FFTS 0
456DECL_FFTS 1, _interleave
457
458#endif /* HAVE_GNU_AS && HAVE_ALTIVEC && HAVE_BIGENDIAN */
libavcodec/ppc/fft_init.c+0−168
@@ -1,168 +0,0 @@
1/*
2 * FFT/IFFT transforms
3 * AltiVec-enabled
4 * Copyright (c) 2009 Loren Merritt
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include "config.h"
24#include "libavutil/attributes.h"
25#include "libavutil/cpu.h"
26#include "libavutil/ppc/cpu.h"
27#include "libavutil/ppc/util_altivec.h"
28#include "libavcodec/fft.h"
29
30/**
31 * Do a complex FFT with the parameters defined in ff_fft_init().
32 * The input data must be permuted before with s->revtab table.
33 * No 1.0 / sqrt(n) normalization is done.
34 * AltiVec-enabled:
35 * This code assumes that the 'z' pointer is 16 bytes-aligned.
36 * It also assumes all FFTComplex are 8 bytes-aligned pairs of floats.
37 */
38
39#if HAVE_VSX
40#include "fft_vsx.h"
41#else
42void ff_fft_calc_altivec(FFTContext *s, FFTComplex *z);
43void ff_fft_calc_interleave_altivec(FFTContext *s, FFTComplex *z);
44#endif
45
46#if HAVE_GNU_AS && HAVE_ALTIVEC && (HAVE_BIGENDIAN || HAVE_VSX)
47static void imdct_half_altivec(FFTContext *s, FFTSample *output, const FFTSample *input)
48{
49 int j, k;
50 int n = 1 << s->mdct_bits;
51 int n4 = n >> 2;
52 int n8 = n >> 3;
53 int n32 = n >> 5;
54 const uint16_t *revtabj = s->revtab;
55 const uint16_t *revtabk = s->revtab+n4;
56 const vec_f *tcos = (const vec_f*)(s->tcos+n8);
57 const vec_f *tsin = (const vec_f*)(s->tsin+n8);
58 const vec_f *pin = (const vec_f*)(input+n4);
59 vec_f *pout = (vec_f*)(output+n4);
60
61 /* pre rotation */
62 k = n32-1;
63 do {
64 vec_f cos,sin,cos0,sin0,cos1,sin1,re,im,r0,i0,r1,i1,a,b,c,d;
65#define CMULA(p,o0,o1,o2,o3)\
66 a = pin[ k*2+p]; /* { z[k].re, z[k].im, z[k+1].re, z[k+1].im } */\
67 b = pin[-k*2-p-1]; /* { z[-k-2].re, z[-k-2].im, z[-k-1].re, z[-k-1].im } */\
68 re = vec_perm(a, b, vcprm(0,2,s0,s2)); /* { z[k].re, z[k+1].re, z[-k-2].re, z[-k-1].re } */\
69 im = vec_perm(a, b, vcprm(s3,s1,3,1)); /* { z[-k-1].im, z[-k-2].im, z[k+1].im, z[k].im } */\
70 cos = vec_perm(cos0, cos1, vcprm(o0,o1,s##o2,s##o3)); /* { cos[k], cos[k+1], cos[-k-2], cos[-k-1] } */\
71 sin = vec_perm(sin0, sin1, vcprm(o0,o1,s##o2,s##o3));\
72 r##p = im*cos - re*sin;\
73 i##p = re*cos + im*sin;
74#define STORE2(v,dst)\
75 j = dst;\
76 vec_ste(v, 0, output+j*2);\
77 vec_ste(v, 4, output+j*2);
78#define STORE8(p)\
79 a = vec_perm(r##p, i##p, vcprm(0,s0,0,s0));\
80 b = vec_perm(r##p, i##p, vcprm(1,s1,1,s1));\
81 c = vec_perm(r##p, i##p, vcprm(2,s2,2,s2));\
82 d = vec_perm(r##p, i##p, vcprm(3,s3,3,s3));\
83 STORE2(a, revtabk[ p*2-4]);\
84 STORE2(b, revtabk[ p*2-3]);\
85 STORE2(c, revtabj[-p*2+2]);\
86 STORE2(d, revtabj[-p*2+3]);
87
88 cos0 = tcos[k];
89 sin0 = tsin[k];
90 cos1 = tcos[-k-1];
91 sin1 = tsin[-k-1];
92 CMULA(0, 0,1,2,3);
93 CMULA(1, 2,3,0,1);
94 STORE8(0);
95 STORE8(1);
96 revtabj += 4;
97 revtabk -= 4;
98 k--;
99 } while(k >= 0);
100
101#if HAVE_VSX
102 ff_fft_calc_vsx(s, (FFTComplex*)output);
103#else
104 ff_fft_calc_altivec(s, (FFTComplex*)output);
105#endif
106
107 /* post rotation + reordering */
108 j = -n32;
109 k = n32-1;
110 do {
111 vec_f cos,sin,re,im,a,b,c,d;
112#define CMULB(d0,d1,o)\
113 re = pout[o*2];\
114 im = pout[o*2+1];\
115 cos = tcos[o];\
116 sin = tsin[o];\
117 d0 = im*sin - re*cos;\
118 d1 = re*sin + im*cos;
119
120 CMULB(a,b,j);
121 CMULB(c,d,k);
122 pout[2*j] = vec_perm(a, d, vcprm(0,s3,1,s2));
123 pout[2*j+1] = vec_perm(a, d, vcprm(2,s1,3,s0));
124 pout[2*k] = vec_perm(c, b, vcprm(0,s3,1,s2));
125 pout[2*k+1] = vec_perm(c, b, vcprm(2,s1,3,s0));
126 j++;
127 k--;
128 } while(k >= 0);
129}
130
131static void imdct_calc_altivec(FFTContext *s, FFTSample *output, const FFTSample *input)
132{
133 int k;
134 int n = 1 << s->mdct_bits;
135 int n4 = n >> 2;
136 int n16 = n >> 4;
137 vec_u32 sign = {1U<<31,1U<<31,1U<<31,1U<<31};
138 vec_u32 *p0 = (vec_u32*)(output+n4);
139 vec_u32 *p1 = (vec_u32*)(output+n4*3);
140
141 imdct_half_altivec(s, output + n4, input);
142
143 for (k = 0; k < n16; k++) {
144 vec_u32 a = p0[k] ^ sign;
145 vec_u32 b = p1[-k-1];
146 p0[-k-1] = vec_perm(a, a, vcprm(3,2,1,0));
147 p1[k] = vec_perm(b, b, vcprm(3,2,1,0));
148 }
149}
150#endif /* HAVE_GNU_AS && HAVE_ALTIVEC && (HAVE_BIGENDIAN || HAVE_VSX) */
151
152av_cold void ff_fft_init_ppc(FFTContext *s)
153{
154#if HAVE_GNU_AS && HAVE_ALTIVEC && (HAVE_BIGENDIAN || HAVE_VSX)
155 if (!PPC_ALTIVEC(av_get_cpu_flags()))
156 return;
157
158#if HAVE_VSX
159 s->fft_calc = ff_fft_calc_interleave_vsx;
160#else
161 s->fft_calc = ff_fft_calc_interleave_altivec;
162#endif
163 if (s->mdct_bits >= 5) {
164 s->imdct_calc = imdct_calc_altivec;
165 s->imdct_half = imdct_half_altivec;
166 }
167#endif /* HAVE_GNU_AS && HAVE_ALTIVEC && HAVE_BIGENDIAN */
168}
libavcodec/ppc/fft_vsx.c+0−226
@@ -1,226 +0,0 @@
1/*
2 * FFT transform, optimized with VSX built-in functions
3 * Copyright (c) 2014 Rong Yan
4 *
5 * This algorithm (though not any of the implementation details) is
6 * based on libdjbfft by D. J. Bernstein.
7 *
8 * This file is part of FFmpeg.
9 *
10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25
26#include "config.h"
27#include "libavutil/cpu.h"
28#include "libavutil/ppc/util_altivec.h"
29#include "libavcodec/fft.h"
30#include "libavcodec/fft-internal.h"
31#include "fft_vsx.h"
32
33#if HAVE_VSX
34
35static void fft32_vsx_interleave(FFTComplex *z)
36{
37 fft16_vsx_interleave(z);
38 fft8_vsx_interleave(z+16);
39 fft8_vsx_interleave(z+24);
40 pass_vsx_interleave(z,ff_cos_32,4);
41}
42
43static void fft64_vsx_interleave(FFTComplex *z)
44{
45 fft32_vsx_interleave(z);
46 fft16_vsx_interleave(z+32);
47 fft16_vsx_interleave(z+48);
48 pass_vsx_interleave(z,ff_cos_64, 8);
49}
50static void fft128_vsx_interleave(FFTComplex *z)
51{
52 fft64_vsx_interleave(z);
53 fft32_vsx_interleave(z+64);
54 fft32_vsx_interleave(z+96);
55 pass_vsx_interleave(z,ff_cos_128,16);
56}
57static void fft256_vsx_interleave(FFTComplex *z)
58{
59 fft128_vsx_interleave(z);
60 fft64_vsx_interleave(z+128);
61 fft64_vsx_interleave(z+192);
62 pass_vsx_interleave(z,ff_cos_256,32);
63}
64static void fft512_vsx_interleave(FFTComplex *z)
65{
66 fft256_vsx_interleave(z);
67 fft128_vsx_interleave(z+256);
68 fft128_vsx_interleave(z+384);
69 pass_vsx_interleave(z,ff_cos_512,64);
70}
71static void fft1024_vsx_interleave(FFTComplex *z)
72{
73 fft512_vsx_interleave(z);
74 fft256_vsx_interleave(z+512);
75 fft256_vsx_interleave(z+768);
76 pass_vsx_interleave(z,ff_cos_1024,128);
77
78}
79static void fft2048_vsx_interleave(FFTComplex *z)
80{
81 fft1024_vsx_interleave(z);
82 fft512_vsx_interleave(z+1024);
83 fft512_vsx_interleave(z+1536);
84 pass_vsx_interleave(z,ff_cos_2048,256);
85}
86static void fft4096_vsx_interleave(FFTComplex *z)
87{
88 fft2048_vsx_interleave(z);
89 fft1024_vsx_interleave(z+2048);
90 fft1024_vsx_interleave(z+3072);
91 pass_vsx_interleave(z,ff_cos_4096, 512);
92}
93static void fft8192_vsx_interleave(FFTComplex *z)
94{
95 fft4096_vsx_interleave(z);
96 fft2048_vsx_interleave(z+4096);
97 fft2048_vsx_interleave(z+6144);
98 pass_vsx_interleave(z,ff_cos_8192,1024);
99}
100static void fft16384_vsx_interleave(FFTComplex *z)
101{
102 fft8192_vsx_interleave(z);
103 fft4096_vsx_interleave(z+8192);
104 fft4096_vsx_interleave(z+12288);
105 pass_vsx_interleave(z,ff_cos_16384,2048);
106}
107static void fft32768_vsx_interleave(FFTComplex *z)
108{
109 fft16384_vsx_interleave(z);
110 fft8192_vsx_interleave(z+16384);
111 fft8192_vsx_interleave(z+24576);
112 pass_vsx_interleave(z,ff_cos_32768,4096);
113}
114static void fft65536_vsx_interleave(FFTComplex *z)
115{
116 fft32768_vsx_interleave(z);
117 fft16384_vsx_interleave(z+32768);
118 fft16384_vsx_interleave(z+49152);
119 pass_vsx_interleave(z,ff_cos_65536,8192);
120}
121
122static void fft32_vsx(FFTComplex *z)
123{
124 fft16_vsx(z);
125 fft8_vsx(z+16);
126 fft8_vsx(z+24);
127 pass_vsx(z,ff_cos_32,4);
128}
129
130static void fft64_vsx(FFTComplex *z)
131{
132 fft32_vsx(z);
133 fft16_vsx(z+32);
134 fft16_vsx(z+48);
135 pass_vsx(z,ff_cos_64, 8);
136}
137static void fft128_vsx(FFTComplex *z)
138{
139 fft64_vsx(z);
140 fft32_vsx(z+64);
141 fft32_vsx(z+96);
142 pass_vsx(z,ff_cos_128,16);
143}
144static void fft256_vsx(FFTComplex *z)
145{
146 fft128_vsx(z);
147 fft64_vsx(z+128);
148 fft64_vsx(z+192);
149 pass_vsx(z,ff_cos_256,32);
150}
151static void fft512_vsx(FFTComplex *z)
152{
153 fft256_vsx(z);
154 fft128_vsx(z+256);
155 fft128_vsx(z+384);
156 pass_vsx(z,ff_cos_512,64);
157}
158static void fft1024_vsx(FFTComplex *z)
159{
160 fft512_vsx(z);
161 fft256_vsx(z+512);
162 fft256_vsx(z+768);
163 pass_vsx(z,ff_cos_1024,128);
164
165}
166static void fft2048_vsx(FFTComplex *z)
167{
168 fft1024_vsx(z);
169 fft512_vsx(z+1024);
170 fft512_vsx(z+1536);
171 pass_vsx(z,ff_cos_2048,256);
172}
173static void fft4096_vsx(FFTComplex *z)
174{
175 fft2048_vsx(z);
176 fft1024_vsx(z+2048);
177 fft1024_vsx(z+3072);
178 pass_vsx(z,ff_cos_4096, 512);
179}
180static void fft8192_vsx(FFTComplex *z)
181{
182 fft4096_vsx(z);
183 fft2048_vsx(z+4096);
184 fft2048_vsx(z+6144);
185 pass_vsx(z,ff_cos_8192,1024);
186}
187static void fft16384_vsx(FFTComplex *z)
188{
189 fft8192_vsx(z);
190 fft4096_vsx(z+8192);
191 fft4096_vsx(z+12288);
192 pass_vsx(z,ff_cos_16384,2048);
193}
194static void fft32768_vsx(FFTComplex *z)
195{
196 fft16384_vsx(z);
197 fft8192_vsx(z+16384);
198 fft8192_vsx(z+24576);
199 pass_vsx(z,ff_cos_32768,4096);
200}
201static void fft65536_vsx(FFTComplex *z)
202{
203 fft32768_vsx(z);
204 fft16384_vsx(z+32768);
205 fft16384_vsx(z+49152);
206 pass_vsx(z,ff_cos_65536,8192);
207}
208
209static void (* const fft_dispatch_vsx[])(FFTComplex*) = {
210 fft4_vsx, fft8_vsx, fft16_vsx, fft32_vsx, fft64_vsx, fft128_vsx, fft256_vsx, fft512_vsx, fft1024_vsx,
211 fft2048_vsx, fft4096_vsx, fft8192_vsx, fft16384_vsx, fft32768_vsx, fft65536_vsx,
212};
213static void (* const fft_dispatch_vsx_interleave[])(FFTComplex*) = {
214 fft4_vsx_interleave, fft8_vsx_interleave, fft16_vsx_interleave, fft32_vsx_interleave, fft64_vsx_interleave,
215 fft128_vsx_interleave, fft256_vsx_interleave, fft512_vsx_interleave, fft1024_vsx_interleave,
216 fft2048_vsx_interleave, fft4096_vsx_interleave, fft8192_vsx_interleave, fft16384_vsx_interleave, fft32768_vsx_interleave, fft65536_vsx_interleave,
217};
218void ff_fft_calc_interleave_vsx(FFTContext *s, FFTComplex *z)
219{
220 fft_dispatch_vsx_interleave[s->nbits-2](z);
221}
222void ff_fft_calc_vsx(FFTContext *s, FFTComplex *z)
223{
224 fft_dispatch_vsx[s->nbits-2](z);
225}
226#endif /* HAVE_VSX */
libavcodec/ppc/fft_vsx.h+0−829
@@ -1,829 +0,0 @@
1#ifndef AVCODEC_PPC_FFT_VSX_H
2#define AVCODEC_PPC_FFT_VSX_H
3/*
4 * FFT transform, optimized with VSX built-in functions
5 * Copyright (c) 2014 Rong Yan Copyright (c) 2009 Loren Merritt
6 *
7 * This algorithm (though not any of the implementation details) is
8 * based on libdjbfft by D. J. Bernstein, and fft_altivec_s.S.
9 *
10 * This file is part of FFmpeg.
11 *
12 * FFmpeg is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * FFmpeg is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with FFmpeg; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27
28#include "config.h"
29#include "libavutil/cpu.h"
30#include "libavutil/ppc/util_altivec.h"
31#include "libavcodec/fft.h"
32#include "libavcodec/fft-internal.h"
33
34#if HAVE_VSX
35
36void ff_fft_calc_interleave_vsx(FFTContext *s, FFTComplex *z);
37void ff_fft_calc_vsx(FFTContext *s, FFTComplex *z);
38
39
40#define byte_2complex (2*sizeof(FFTComplex))
41#define byte_4complex (4*sizeof(FFTComplex))
42#define byte_6complex (6*sizeof(FFTComplex))
43#define byte_8complex (8*sizeof(FFTComplex))
44#define byte_10complex (10*sizeof(FFTComplex))
45#define byte_12complex (12*sizeof(FFTComplex))
46#define byte_14complex (14*sizeof(FFTComplex))
47
48inline static void pass_vsx_interleave(FFTComplex *z, const FFTSample *wre, unsigned int n)
49{
50 int o1 = n<<1;
51 int o2 = n<<2;
52 int o3 = o1+o2;
53 int i1, i2, i3;
54 FFTSample* out = (FFTSample*)z;
55 const FFTSample *wim = wre+o1;
56 vec_f vz0, vzo1, vzo2, vzo3;
57 vec_f x0, x1, x2, x3;
58 vec_f x4, x5, x6, x7;
59 vec_f x8, x9, x10, x11;
60 vec_f x12, x13, x14, x15;
61 vec_f x16, x17, x18, x19;
62 vec_f x20, x21, x22, x23;
63 vec_f vz0plus1, vzo1plus1, vzo2plus1, vzo3plus1;
64 vec_f y0, y1, y2, y3;
65 vec_f y4, y5, y8, y9;
66 vec_f y10, y13, y14, y15;
67 vec_f y16, y17, y18, y19;
68 vec_f y20, y21, y22, y23;
69 vec_f wr1, wi1, wr0, wi0;
70 vec_f wr2, wi2, wr3, wi3;
71 vec_f xmulwi0, xmulwi1, ymulwi2, ymulwi3;
72
73 n = n-2;
74 i1 = o1*sizeof(FFTComplex);
75 i2 = o2*sizeof(FFTComplex);
76 i3 = o3*sizeof(FFTComplex);
77 vzo2 = vec_ld(i2, &(out[0])); // zo2.r zo2.i z(o2+1).r z(o2+1).i
78 vzo2plus1 = vec_ld(i2+16, &(out[0]));
79 vzo3 = vec_ld(i3, &(out[0])); // zo3.r zo3.i z(o3+1).r z(o3+1).i
80 vzo3plus1 = vec_ld(i3+16, &(out[0]));
81 vz0 = vec_ld(0, &(out[0])); // z0.r z0.i z1.r z1.i
82 vz0plus1 = vec_ld(16, &(out[0]));
83 vzo1 = vec_ld(i1, &(out[0])); // zo1.r zo1.i z(o1+1).r z(o1+1).i
84 vzo1plus1 = vec_ld(i1+16, &(out[0]));
85
86 x0 = vec_add(vzo2, vzo3);
87 x1 = vec_sub(vzo2, vzo3);
88 y0 = vec_add(vzo2plus1, vzo3plus1);
89 y1 = vec_sub(vzo2plus1, vzo3plus1);
90
91 wr1 = vec_splats(wre[1]);
92 wi1 = vec_splats(wim[-1]);
93 wi2 = vec_splats(wim[-2]);
94 wi3 = vec_splats(wim[-3]);
95 wr2 = vec_splats(wre[2]);
96 wr3 = vec_splats(wre[3]);
97
98 x2 = vec_perm(x0, x1, vcprm(2,s2,3,s3));
99 x3 = vec_perm(x0, x1, vcprm(s3,3,s2,2));
100
101 y4 = vec_perm(y0, y1, vcprm(s1,1,s0,0));
102 y5 = vec_perm(y0, y1, vcprm(s3,3,s2,2));
103 y2 = vec_perm(y0, y1, vcprm(0,s0,1,s1));
104 y3 = vec_perm(y0, y1, vcprm(2,s2,3,s3));
105
106 ymulwi2 = vec_mul(y4, wi2);
107 ymulwi3 = vec_mul(y5, wi3);
108 x4 = vec_mul(x2, wr1);
109 x5 = vec_mul(x3, wi1);
110 y8 = vec_madd(y2, wr2, ymulwi2);
111 y9 = vec_msub(y2, wr2, ymulwi2);
112 x6 = vec_add(x4, x5);
113 x7 = vec_sub(x4, x5);
114 y13 = vec_madd(y3, wr3, ymulwi3);
115 y14 = vec_msub(y3, wr3, ymulwi3);
116
117 x8 = vec_perm(x6, x7, vcprm(0,1,s2,s3));
118 y10 = vec_perm(y8, y9, vcprm(0,1,s2,s3));
119 y15 = vec_perm(y13, y14, vcprm(0,1,s2,s3));
120
121 x9 = vec_perm(x0, x8, vcprm(0,1,s0,s2));
122 x10 = vec_perm(x1, x8, vcprm(1,0,s3,s1));
123
124 y16 = vec_perm(y10, y15, vcprm(0,2,s0,s2));
125 y17 = vec_perm(y10, y15, vcprm(3,1,s3,s1));
126
127 x11 = vec_add(vz0, x9);
128 x12 = vec_sub(vz0, x9);
129 x13 = vec_add(vzo1, x10);
130 x14 = vec_sub(vzo1, x10);
131
132 y18 = vec_add(vz0plus1, y16);
133 y19 = vec_sub(vz0plus1, y16);
134 y20 = vec_add(vzo1plus1, y17);
135 y21 = vec_sub(vzo1plus1, y17);
136
137 x15 = vec_perm(x13, x14, vcprm(0,s1,2,s3));
138 x16 = vec_perm(x13, x14, vcprm(s0,1,s2,3));
139 y22 = vec_perm(y20, y21, vcprm(0,s1,2,s3));
140 y23 = vec_perm(y20, y21, vcprm(s0,1,s2,3));
141
142
143 vec_st(x11, 0, &(out[0]));
144 vec_st(y18, 16, &(out[0]));
145 vec_st(x15, i1, &(out[0]));
146 vec_st(y22, i1+16, &(out[0]));
147 vec_st(x12, i2, &(out[0]));
148 vec_st(y19, i2+16, &(out[0]));
149 vec_st(x16, i3, &(out[0]));
150 vec_st(y23, i3+16, &(out[0]));
151
152 do {
153 out += 8;
154 wre += 4;
155 wim -= 4;
156 wr0 = vec_splats(wre[0]);
157 wr1 = vec_splats(wre[1]);
158 wi0 = vec_splats(wim[0]);
159 wi1 = vec_splats(wim[-1]);
160
161 wr2 = vec_splats(wre[2]);
162 wr3 = vec_splats(wre[3]);
163 wi2 = vec_splats(wim[-2]);
164 wi3 = vec_splats(wim[-3]);
165
166 vzo2 = vec_ld(i2, &(out[0])); // zo2.r zo2.i z(o2+1).r z(o2+1).i
167 vzo2plus1 = vec_ld(i2+16, &(out[0]));
168 vzo3 = vec_ld(i3, &(out[0])); // zo3.r zo3.i z(o3+1).r z(o3+1).i
169 vzo3plus1 = vec_ld(i3+16, &(out[0]));
170 vz0 = vec_ld(0, &(out[0])); // z0.r z0.i z1.r z1.i
171 vz0plus1 = vec_ld(16, &(out[0]));
172 vzo1 = vec_ld(i1, &(out[0])); // zo1.r zo1.i z(o1+1).r z(o1+1).i
173 vzo1plus1 = vec_ld(i1+16, &(out[0]));
174
175 x0 = vec_add(vzo2, vzo3);
176 x1 = vec_sub(vzo2, vzo3);
177
178 y0 = vec_add(vzo2plus1, vzo3plus1);
179 y1 = vec_sub(vzo2plus1, vzo3plus1);
180
181 x4 = vec_perm(x0, x1, vcprm(s1,1,s0,0));
182 x5 = vec_perm(x0, x1, vcprm(s3,3,s2,2));
183 x2 = vec_perm(x0, x1, vcprm(0,s0,1,s1));
184 x3 = vec_perm(x0, x1, vcprm(2,s2,3,s3));
185
186 y2 = vec_perm(y0, y1, vcprm(0,s0,1,s1));
187 y3 = vec_perm(y0, y1, vcprm(2,s2,3,s3));
188 xmulwi0 = vec_mul(x4, wi0);
189 xmulwi1 = vec_mul(x5, wi1);
190
191 y4 = vec_perm(y0, y1, vcprm(s1,1,s0,0));
192 y5 = vec_perm(y0, y1, vcprm(s3,3,s2,2));
193
194 x8 = vec_madd(x2, wr0, xmulwi0);
195 x9 = vec_msub(x2, wr0, xmulwi0);
196 ymulwi2 = vec_mul(y4, wi2);
197 ymulwi3 = vec_mul(y5, wi3);
198
199 x13 = vec_madd(x3, wr1, xmulwi1);
200 x14 = vec_msub(x3, wr1, xmulwi1);
201
202 y8 = vec_madd(y2, wr2, ymulwi2);
203 y9 = vec_msub(y2, wr2, ymulwi2);
204 y13 = vec_madd(y3, wr3, ymulwi3);
205 y14 = vec_msub(y3, wr3, ymulwi3);
206
207 x10 = vec_perm(x8, x9, vcprm(0,1,s2,s3));
208 x15 = vec_perm(x13, x14, vcprm(0,1,s2,s3));
209
210 y10 = vec_perm(y8, y9, vcprm(0,1,s2,s3));
211 y15 = vec_perm(y13, y14, vcprm(0,1,s2,s3));
212
213 x16 = vec_perm(x10, x15, vcprm(0,2,s0,s2));
214 x17 = vec_perm(x10, x15, vcprm(3,1,s3,s1));
215
216 y16 = vec_perm(y10, y15, vcprm(0,2,s0,s2));
217 y17 = vec_perm(y10, y15, vcprm(3,1,s3,s1));
218
219 x18 = vec_add(vz0, x16);
220 x19 = vec_sub(vz0, x16);
221 x20 = vec_add(vzo1, x17);
222 x21 = vec_sub(vzo1, x17);
223
224 y18 = vec_add(vz0plus1, y16);
225 y19 = vec_sub(vz0plus1, y16);
226 y20 = vec_add(vzo1plus1, y17);
227 y21 = vec_sub(vzo1plus1, y17);
228
229 x22 = vec_perm(x20, x21, vcprm(0,s1,2,s3));
230 x23 = vec_perm(x20, x21, vcprm(s0,1,s2,3));
231
232 y22 = vec_perm(y20, y21, vcprm(0,s1,2,s3));
233 y23 = vec_perm(y20, y21, vcprm(s0,1,s2,3));
234
235 vec_st(x18, 0, &(out[0]));
236 vec_st(y18, 16, &(out[0]));
237 vec_st(x22, i1, &(out[0]));
238 vec_st(y22, i1+16, &(out[0]));
239 vec_st(x19, i2, &(out[0]));
240 vec_st(y19, i2+16, &(out[0]));
241 vec_st(x23, i3, &(out[0]));
242 vec_st(y23, i3+16, &(out[0]));
243 } while (n-=2);
244}
245
246inline static void fft2_vsx_interleave(FFTComplex *z)
247{
248 FFTSample r1, i1;
249
250 r1 = z[0].re - z[1].re;
251 z[0].re += z[1].re;
252 z[1].re = r1;
253
254 i1 = z[0].im - z[1].im;
255 z[0].im += z[1].im;
256 z[1].im = i1;
257 }
258
259inline static void fft4_vsx_interleave(FFTComplex *z)
260{
261 vec_f a, b, c, d;
262 float* out= (float*)z;
263 a = vec_ld(0, &(out[0]));
264 b = vec_ld(byte_2complex, &(out[0]));
265
266 c = vec_perm(a, b, vcprm(0,1,s2,s1));
267 d = vec_perm(a, b, vcprm(2,3,s0,s3));
268 a = vec_add(c, d);
269 b = vec_sub(c, d);
270
271 c = vec_perm(a, b, vcprm(0,1,s0,s1));
272 d = vec_perm(a, b, vcprm(2,3,s3,s2));
273
274 a = vec_add(c, d);
275 b = vec_sub(c, d);
276 vec_st(a, 0, &(out[0]));
277 vec_st(b, byte_2complex, &(out[0]));
278}
279
280inline static void fft8_vsx_interleave(FFTComplex *z)
281{
282 vec_f vz0, vz1, vz2, vz3;
283 vec_f x0, x1, x2, x3;
284 vec_f x4, x5, x6, x7;
285 vec_f x8, x9, x10, x11;
286 vec_f x12, x13, x14, x15;
287 vec_f x16, x17, x18, x19;
288 vec_f x20, x21, x22, x23;
289 vec_f x24, x25, x26, x27;
290 vec_f x28, x29, x30, x31;
291 vec_f x32, x33, x34;
292
293 float* out= (float*)z;
294 vec_f vc1 = {sqrthalf, sqrthalf, sqrthalf, sqrthalf};
295
296 vz0 = vec_ld(0, &(out[0]));
297 vz1 = vec_ld(byte_2complex, &(out[0]));
298 vz2 = vec_ld(byte_4complex, &(out[0]));
299 vz3 = vec_ld(byte_6complex, &(out[0]));
300
301 x0 = vec_perm(vz0, vz1, vcprm(0,1,s2,s1));
302 x1 = vec_perm(vz0, vz1, vcprm(2,3,s0,s3));
303 x2 = vec_perm(vz2, vz3, vcprm(2,1,s0,s1));
304 x3 = vec_perm(vz2, vz3, vcprm(0,3,s2,s3));
305
306 x4 = vec_add(x0, x1);
307 x5 = vec_sub(x0, x1);
308 x6 = vec_add(x2, x3);
309 x7 = vec_sub(x2, x3);
310
311 x8 = vec_perm(x4, x5, vcprm(0,1,s0,s1));
312 x9 = vec_perm(x4, x5, vcprm(2,3,s3,s2));
313 x10 = vec_perm(x6, x7, vcprm(2,1,s2,s1));
314 x11 = vec_perm(x6, x7, vcprm(0,3,s0,s3));
315
316 x12 = vec_add(x8, x9);
317 x13 = vec_sub(x8, x9);
318 x14 = vec_add(x10, x11);
319 x15 = vec_sub(x10, x11);
320 x16 = vec_perm(x12, x13, vcprm(0,s0,1,s1));
321 x17 = vec_perm(x14, x15, vcprm(0,s0,1,s1));
322 x18 = vec_perm(x16, x17, vcprm(s0,s3,s2,s1));
323 x19 = vec_add(x16, x18); // z0.r z2.r z0.i z2.i
324 x20 = vec_sub(x16, x18); // z4.r z6.r z4.i z6.i
325
326 x21 = vec_perm(x12, x13, vcprm(2,s2,3,s3));
327 x22 = vec_perm(x14, x15, vcprm(2,3,s2,s3));
328 x23 = vec_perm(x14, x15, vcprm(3,2,s3,s2));
329 x24 = vec_add(x22, x23);
330 x25 = vec_sub(x22, x23);
331 x26 = vec_mul( vec_perm(x24, x25, vcprm(2,s2,0,s0)), vc1);
332
333 x27 = vec_add(x21, x26); // z1.r z7.r z1.i z3.i
334 x28 = vec_sub(x21, x26); //z5.r z3.r z5.i z7.i
335
336 x29 = vec_perm(x19, x27, vcprm(0,2,s0,s2)); // z0.r z0.i z1.r z1.i
337 x30 = vec_perm(x19, x27, vcprm(1,3,s1,s3)); // z2.r z2.i z7.r z3.i
338 x31 = vec_perm(x20, x28, vcprm(0,2,s0,s2)); // z4.r z4.i z5.r z5.i
339 x32 = vec_perm(x20, x28, vcprm(1,3,s1,s3)); // z6.r z6.i z3.r z7.i
340 x33 = vec_perm(x30, x32, vcprm(0,1,s2,3)); // z2.r z2.i z3.r z3.i
341 x34 = vec_perm(x30, x32, vcprm(s0,s1,2,s3)); // z6.r z6.i z7.r z7.i
342
343 vec_st(x29, 0, &(out[0]));
344 vec_st(x33, byte_2complex, &(out[0]));
345 vec_st(x31, byte_4complex, &(out[0]));
346 vec_st(x34, byte_6complex, &(out[0]));
347}
348
349inline static void fft16_vsx_interleave(FFTComplex *z)
350{
351 float* out= (float*)z;
352 vec_f vc0 = {sqrthalf, sqrthalf, sqrthalf, sqrthalf};
353 vec_f vc1 = {ff_cos_16[1], ff_cos_16[1], ff_cos_16[1], ff_cos_16[1]};
354 vec_f vc2 = {ff_cos_16[3], ff_cos_16[3], ff_cos_16[3], ff_cos_16[3]};
355 vec_f vz0, vz1, vz2, vz3;
356 vec_f vz4, vz5, vz6, vz7;
357 vec_f x0, x1, x2, x3;
358 vec_f x4, x5, x6, x7;
359 vec_f x8, x9, x10, x11;
360 vec_f x12, x13, x14, x15;
361 vec_f x16, x17, x18, x19;
362 vec_f x20, x21, x22, x23;
363 vec_f x24, x25, x26, x27;
364 vec_f x28, x29, x30, x31;
365 vec_f x32, x33, x34, x35;
366 vec_f x36, x37, x38, x39;
367 vec_f x40, x41, x42, x43;
368 vec_f x44, x45, x46, x47;
369 vec_f x48, x49, x50, x51;
370 vec_f x52, x53, x54, x55;
371 vec_f x56, x57, x58, x59;
372 vec_f x60, x61, x62, x63;
373 vec_f x64, x65, x66, x67;
374 vec_f x68, x69, x70, x71;
375 vec_f x72, x73, x74, x75;
376 vec_f x76, x77, x78, x79;
377 vec_f x80, x81, x82, x83;
378 vec_f x84, x85, x86;
379
380 vz0 = vec_ld(0, &(out[0]));
381 vz1 = vec_ld(byte_2complex, &(out[0]));
382 vz2 = vec_ld(byte_4complex, &(out[0]));
383 vz3 = vec_ld(byte_6complex, &(out[0]));
384 vz4 = vec_ld(byte_8complex, &(out[0]));
385 vz5 = vec_ld(byte_10complex, &(out[0]));
386 vz6 = vec_ld(byte_12complex, &(out[0]));
387 vz7 = vec_ld(byte_14complex, &(out[0]));
388
389 x0 = vec_perm(vz0, vz1, vcprm(0,1,s2,s1));
390 x1 = vec_perm(vz0, vz1, vcprm(2,3,s0,s3));
391 x2 = vec_perm(vz2, vz3, vcprm(0,1,s0,s1));
392 x3 = vec_perm(vz2, vz3, vcprm(2,3,s2,s3));
393
394 x4 = vec_perm(vz4, vz5, vcprm(0,1,s2,s1));
395 x5 = vec_perm(vz4, vz5, vcprm(2,3,s0,s3));
396 x6 = vec_perm(vz6, vz7, vcprm(0,1,s2,s1));
397 x7 = vec_perm(vz6, vz7, vcprm(2,3,s0,s3));
398
399 x8 = vec_add(x0, x1);
400 x9 = vec_sub(x0, x1);
401 x10 = vec_add(x2, x3);
402 x11 = vec_sub(x2, x3);
403
404 x12 = vec_add(x4, x5);
405 x13 = vec_sub(x4, x5);
406 x14 = vec_add(x6, x7);
407 x15 = vec_sub(x6, x7);
408
409 x16 = vec_perm(x8, x9, vcprm(0,1,s0,s1));
410 x17 = vec_perm(x8, x9, vcprm(2,3,s3,s2));
411 x18 = vec_perm(x10, x11, vcprm(2,1,s1,s2));
412 x19 = vec_perm(x10, x11, vcprm(0,3,s0,s3));
413 x20 = vec_perm(x12, x14, vcprm(0,1,s0, s1));
414 x21 = vec_perm(x12, x14, vcprm(2,3,s2,s3));
415 x22 = vec_perm(x13, x15, vcprm(0,1,s0,s1));
416 x23 = vec_perm(x13, x15, vcprm(3,2,s3,s2));
417
418 x24 = vec_add(x16, x17);
419 x25 = vec_sub(x16, x17);
420 x26 = vec_add(x18, x19);
421 x27 = vec_sub(x18, x19);
422 x28 = vec_add(x20, x21);
423 x29 = vec_sub(x20, x21);
424 x30 = vec_add(x22, x23);
425 x31 = vec_sub(x22, x23);
426
427 x32 = vec_add(x24, x26);
428 x33 = vec_sub(x24, x26);
429 x34 = vec_perm(x32, x33, vcprm(0,1,s0,s1));
430
431 x35 = vec_perm(x28, x29, vcprm(2,1,s1,s2));
432 x36 = vec_perm(x28, x29, vcprm(0,3,s0,s3));
433 x37 = vec_add(x35, x36);
434 x38 = vec_sub(x35, x36);
435 x39 = vec_perm(x37, x38, vcprm(0,1,s1,s0));
436
437 x40 = vec_perm(x27, x38, vcprm(3,2,s2,s3));
438 x41 = vec_perm(x26, x37, vcprm(2,3,s3,s2));
439 x42 = vec_add(x40, x41);
440 x43 = vec_sub(x40, x41);
441 x44 = vec_mul(x42, vc0);
442 x45 = vec_mul(x43, vc0);
443
444 x46 = vec_add(x34, x39); // z0.r z0.i z4.r z4.i
445 x47 = vec_sub(x34, x39); // z8.r z8.i z12.r z12.i
446
447 x48 = vec_perm(x30, x31, vcprm(2,1,s1,s2));
448 x49 = vec_perm(x30, x31, vcprm(0,3,s3,s0));
449 x50 = vec_add(x48, x49);
450 x51 = vec_sub(x48, x49);
451 x52 = vec_mul(x50, vc1);
452 x53 = vec_mul(x50, vc2);
453 x54 = vec_mul(x51, vc1);
454 x55 = vec_mul(x51, vc2);
455
456 x56 = vec_perm(x24, x25, vcprm(2,3,s2,s3));
457 x57 = vec_perm(x44, x45, vcprm(0,1,s1,s0));
458 x58 = vec_add(x56, x57);
459 x59 = vec_sub(x56, x57);
460
461 x60 = vec_perm(x54, x55, vcprm(1,0,3,2));
462 x61 = vec_perm(x54, x55, vcprm(s1,s0,s3,s2));
463 x62 = vec_add(x52, x61);
464 x63 = vec_sub(x52, x61);
465 x64 = vec_add(x60, x53);
466 x65 = vec_sub(x60, x53);
467 x66 = vec_perm(x62, x64, vcprm(0,1,s3,s2));
468 x67 = vec_perm(x63, x65, vcprm(s0,s1,3,2));
469
470 x68 = vec_add(x58, x66); // z1.r z1.i z3.r z3.i
471 x69 = vec_sub(x58, x66); // z9.r z9.i z11.r z11.i
472 x70 = vec_add(x59, x67); // z5.r z5.i z15.r z15.i
473 x71 = vec_sub(x59, x67); // z13.r z13.i z7.r z7.i
474
475 x72 = vec_perm(x25, x27, vcprm(s1,s0,s2,s3));
476 x73 = vec_add(x25, x72);
477 x74 = vec_sub(x25, x72);
478 x75 = vec_perm(x73, x74, vcprm(0,1,s0,s1));
479 x76 = vec_perm(x44, x45, vcprm(3,2,s2,s3));
480 x77 = vec_add(x75, x76); // z2.r z2.i z6.r z6.i
481 x78 = vec_sub(x75, x76); // z10.r z10.i z14.r z14.i
482
483 x79 = vec_perm(x46, x68, vcprm(0,1,s0,s1)); // z0.r z0.i z1.r z1.i
484 x80 = vec_perm(x77, x68, vcprm(0,1,s2,s3)); // z2.r z2.i z3.r z3.i
485 x81 = vec_perm(x46, x70, vcprm(2,3,s0,s1)); // z4.r z4.i z5.r z5.i
486 x82 = vec_perm(x71, x77, vcprm(s2,s3,2,3)); // z6.r z6.i z7.r z7.i
487 vec_st(x79, 0, &(out[0]));
488 vec_st(x80, byte_2complex, &(out[0]));
489 vec_st(x81, byte_4complex, &(out[0]));
490 vec_st(x82, byte_6complex, &(out[0]));
491 x83 = vec_perm(x47, x69, vcprm(0,1,s0,s1)); // z8.r z8.i z9.r z9.i
492 x84 = vec_perm(x78, x69, vcprm(0,1,s2,s3)); // z10.r z10.i z11.r z11.i
493 x85 = vec_perm(x47, x71, vcprm(2,3,s0,s1)); // z12.r z12.i z13.r z13.i
494 x86 = vec_perm(x70, x78, vcprm(s2,s3,2,3)); // z14.r z14.i z15.r z15.i
495 vec_st(x83, byte_8complex, &(out[0]));
496 vec_st(x84, byte_10complex, &(out[0]));
497 vec_st(x85, byte_12complex, &(out[0]));
498 vec_st(x86, byte_14complex, &(out[0]));
499}
500
501inline static void fft4_vsx(FFTComplex *z)
502{
503 vec_f a, b, c, d;
504 float* out= (float*)z;
505 a = vec_ld(0, &(out[0]));
506 b = vec_ld(byte_2complex, &(out[0]));
507
508 c = vec_perm(a, b, vcprm(0,1,s2,s1));
509 d = vec_perm(a, b, vcprm(2,3,s0,s3));
510 a = vec_add(c, d);
511 b = vec_sub(c, d);
512
513 c = vec_perm(a,b, vcprm(0,s0,1,s1));
514 d = vec_perm(a, b, vcprm(2,s3,3,s2));
515
516 a = vec_add(c, d);
517 b = vec_sub(c, d);
518
519 c = vec_perm(a, b, vcprm(0,1,s0,s1));
520 d = vec_perm(a, b, vcprm(2,3,s2,s3));
521
522 vec_st(c, 0, &(out[0]));
523 vec_st(d, byte_2complex, &(out[0]));
524 return;
525}
526
527inline static void fft8_vsx(FFTComplex *z)
528{
529 vec_f vz0, vz1, vz2, vz3;
530 vec_f vz4, vz5, vz6, vz7, vz8;
531
532 float* out= (float*)z;
533 vec_f vc0 = {0.0, 0.0, 0.0, 0.0};
534 vec_f vc1 = {-sqrthalf, sqrthalf, sqrthalf, -sqrthalf};
535 vec_f vc2 = {sqrthalf, sqrthalf, sqrthalf, sqrthalf};
536
537 vz0 = vec_ld(0, &(out[0]));
538 vz1 = vec_ld(byte_2complex, &(out[0]));
539 vz2 = vec_ld(byte_4complex, &(out[0]));
540 vz3 = vec_ld(byte_6complex, &(out[0]));
541
542 vz6 = vec_perm(vz2, vz3, vcprm(0,s0,1,s1));
543 vz7 = vec_perm(vz2, vz3, vcprm(2,s2,3,s3));
544 vz4 = vec_perm(vz0, vz1, vcprm(0,1,s2,s1));
545 vz5 = vec_perm(vz0, vz1, vcprm(2,3,s0,s3));
546
547 vz2 = vec_add(vz6, vz7);
548 vz3 = vec_sub(vz6, vz7);
549 vz8 = vec_perm(vz3, vz3, vcprm(2,3,0,1));
550
551 vz0 = vec_add(vz4, vz5);
552 vz1 = vec_sub(vz4, vz5);
553
554 vz3 = vec_madd(vz3, vc1, vc0);
555 vz3 = vec_madd(vz8, vc2, vz3);
556
557 vz4 = vec_perm(vz0, vz1, vcprm(0,s0,1,s1));
558 vz5 = vec_perm(vz0, vz1, vcprm(2,s3,3,s2));
559 vz6 = vec_perm(vz2, vz3, vcprm(1,2,s3,s0));
560 vz7 = vec_perm(vz2, vz3, vcprm(0,3,s2,s1));
561
562 vz0 = vec_add(vz4, vz5);
563 vz1 = vec_sub(vz4, vz5);
564 vz2 = vec_add(vz6, vz7);
565 vz3 = vec_sub(vz6, vz7);
566
567 vz4 = vec_perm(vz0, vz1, vcprm(0,1,s0,s1));
568 vz5 = vec_perm(vz0, vz1, vcprm(2,3,s2,s3));
569 vz6 = vec_perm(vz2, vz3, vcprm(0,2,s1,s3));
570 vz7 = vec_perm(vz2, vz3, vcprm(1,3,s0,s2));
571
572
573 vz2 = vec_sub(vz4, vz6);
574 vz3 = vec_sub(vz5, vz7);
575
576 vz0 = vec_add(vz4, vz6);
577 vz1 = vec_add(vz5, vz7);
578
579 vec_st(vz0, 0, &(out[0]));
580 vec_st(vz1, byte_2complex, &(out[0]));
581 vec_st(vz2, byte_4complex, &(out[0]));
582 vec_st(vz3, byte_6complex, &(out[0]));
583 return;
584}
585
586inline static void fft16_vsx(FFTComplex *z)
587{
588 float* out= (float*)z;
589 vec_f vc0 = {0.0, 0.0, 0.0, 0.0};
590 vec_f vc1 = {-sqrthalf, sqrthalf, sqrthalf, -sqrthalf};
591 vec_f vc2 = {sqrthalf, sqrthalf, sqrthalf, sqrthalf};
592 vec_f vc3 = {1.0, 0.92387953, sqrthalf, 0.38268343};
593 vec_f vc4 = {0.0, 0.38268343, sqrthalf, 0.92387953};
594 vec_f vc5 = {-0.0, -0.38268343, -sqrthalf, -0.92387953};
595
596 vec_f vz0, vz1, vz2, vz3;
597 vec_f vz4, vz5, vz6, vz7;
598 vec_f vz8, vz9, vz10, vz11;
599 vec_f vz12, vz13;
600
601 vz0 = vec_ld(byte_8complex, &(out[0]));
602 vz1 = vec_ld(byte_10complex, &(out[0]));
603 vz2 = vec_ld(byte_12complex, &(out[0]));
604 vz3 = vec_ld(byte_14complex, &(out[0]));
605
606 vz4 = vec_perm(vz0, vz1, vcprm(0,1,s2,s1));
607 vz5 = vec_perm(vz0, vz1, vcprm(2,3,s0,s3));
608 vz6 = vec_perm(vz2, vz3, vcprm(0,1,s2,s1));
609 vz7 = vec_perm(vz2, vz3, vcprm(2,3,s0,s3));
610
611 vz0 = vec_add(vz4, vz5);
612 vz1= vec_sub(vz4, vz5);
613 vz2 = vec_add(vz6, vz7);
614 vz3 = vec_sub(vz6, vz7);
615
616 vz4 = vec_perm(vz0, vz1, vcprm(0,s0,1,s1));
617 vz5 = vec_perm(vz0, vz1, vcprm(2,s3,3,s2));
618 vz6 = vec_perm(vz2, vz3, vcprm(0,s0,1,s1));
619 vz7 = vec_perm(vz2, vz3, vcprm(2,s3,3,s2));
620
621 vz0 = vec_add(vz4, vz5);
622 vz1 = vec_sub(vz4, vz5);
623 vz2 = vec_add(vz6, vz7);
624 vz3 = vec_sub(vz6, vz7);
625
626 vz4 = vec_perm(vz0, vz1, vcprm(0,1,s0,s1));
627 vz5 = vec_perm(vz0, vz1, vcprm(2,3,s2,s3));
628
629 vz6 = vec_perm(vz2, vz3, vcprm(0,1,s0,s1));
630 vz7 = vec_perm(vz2, vz3, vcprm(2,3,s2,s3));
631
632 vz0 = vec_ld(0, &(out[0]));
633 vz1 = vec_ld(byte_2complex, &(out[0]));
634 vz2 = vec_ld(byte_4complex, &(out[0]));
635 vz3 = vec_ld(byte_6complex, &(out[0]));
636 vz10 = vec_perm(vz2, vz3, vcprm(0,s0,1,s1));
637 vz11 = vec_perm(vz2, vz3, vcprm(2,s2,3,s3));
638 vz8 = vec_perm(vz0, vz1, vcprm(0,1,s2,s1));
639 vz9 = vec_perm(vz0, vz1, vcprm(2,3,s0,s3));
640
641 vz2 = vec_add(vz10, vz11);
642 vz3 = vec_sub(vz10, vz11);
643 vz12 = vec_perm(vz3, vz3, vcprm(2,3,0,1));
644 vz0 = vec_add(vz8, vz9);
645 vz1 = vec_sub(vz8, vz9);
646
647 vz3 = vec_madd(vz3, vc1, vc0);
648 vz3 = vec_madd(vz12, vc2, vz3);
649 vz8 = vec_perm(vz0, vz1, vcprm(0,s0,1,s1));
650 vz9 = vec_perm(vz0, vz1, vcprm(2,s3,3,s2));
651 vz10 = vec_perm(vz2, vz3, vcprm(1,2,s3,s0));
652 vz11 = vec_perm(vz2, vz3, vcprm(0,3,s2,s1));
653
654 vz0 = vec_add(vz8, vz9);
655 vz1 = vec_sub(vz8, vz9);
656 vz2 = vec_add(vz10, vz11);
657 vz3 = vec_sub(vz10, vz11);
658
659 vz8 = vec_perm(vz0, vz1, vcprm(0,1,s0,s1));
660 vz9 = vec_perm(vz0, vz1, vcprm(2,3,s2,s3));
661 vz10 = vec_perm(vz2, vz3, vcprm(0,2,s1,s3));
662 vz11 = vec_perm(vz2, vz3, vcprm(1,3,s0,s2));
663
664 vz2 = vec_sub(vz8, vz10);
665 vz3 = vec_sub(vz9, vz11);
666 vz0 = vec_add(vz8, vz10);
667 vz1 = vec_add(vz9, vz11);
668
669 vz8 = vec_madd(vz4, vc3, vc0);
670 vz9 = vec_madd(vz5, vc3, vc0);
671 vz10 = vec_madd(vz6, vc3, vc0);
672 vz11 = vec_madd(vz7, vc3, vc0);
673
674 vz8 = vec_madd(vz5, vc4, vz8);
675 vz9 = vec_madd(vz4, vc5, vz9);
676 vz10 = vec_madd(vz7, vc5, vz10);
677 vz11 = vec_madd(vz6, vc4, vz11);
678
679 vz12 = vec_sub(vz10, vz8);
680 vz10 = vec_add(vz10, vz8);
681
682 vz13 = vec_sub(vz9, vz11);
683 vz11 = vec_add(vz9, vz11);
684
685 vz4 = vec_sub(vz0, vz10);
686 vz0 = vec_add(vz0, vz10);
687
688 vz7= vec_sub(vz3, vz12);
689 vz3= vec_add(vz3, vz12);
690
691 vz5 = vec_sub(vz1, vz11);
692 vz1 = vec_add(vz1, vz11);
693
694 vz6 = vec_sub(vz2, vz13);
695 vz2 = vec_add(vz2, vz13);
696
697 vec_st(vz0, 0, &(out[0]));
698 vec_st(vz1, byte_2complex, &(out[0]));
699 vec_st(vz2, byte_4complex, &(out[0]));
700 vec_st(vz3, byte_6complex, &(out[0]));
701 vec_st(vz4, byte_8complex, &(out[0]));
702 vec_st(vz5, byte_10complex, &(out[0]));
703 vec_st(vz6, byte_12complex, &(out[0]));
704 vec_st(vz7, byte_14complex, &(out[0]));
705 return;
706
707}
708inline static void pass_vsx(FFTComplex * z, const FFTSample * wre, unsigned int n)
709{
710 int o1 = n<<1;
711 int o2 = n<<2;
712 int o3 = o1+o2;
713 int i1, i2, i3;
714 FFTSample* out = (FFTSample*)z;
715 const FFTSample *wim = wre+o1;
716 vec_f v0, v1, v2, v3;
717 vec_f v4, v5, v6, v7;
718 vec_f v8, v9, v10, v11;
719 vec_f v12, v13;
720
721 n = n-2;
722 i1 = o1*sizeof(FFTComplex);
723 i2 = o2*sizeof(FFTComplex);
724 i3 = o3*sizeof(FFTComplex);
725
726 v8 = vec_ld(0, &(wre[0]));
727 v10 = vec_ld(0, &(wim[0]));
728 v9 = vec_ld(0, &(wim[-4]));
729 v9 = vec_perm(v9, v10, vcprm(s0,3,2,1));
730
731 v4 = vec_ld(i2, &(out[0]));
732 v5 = vec_ld(i2+16, &(out[0]));
733 v6 = vec_ld(i3, &(out[0]));
734 v7 = vec_ld(i3+16, &(out[0]));
735 v10 = vec_mul(v4, v8); // r2*wre
736 v11 = vec_mul(v5, v8); // i2*wre
737 v12 = vec_mul(v6, v8); // r3*wre
738 v13 = vec_mul(v7, v8); // i3*wre
739
740 v0 = vec_ld(0, &(out[0])); // r0
741 v3 = vec_ld(i1+16, &(out[0])); // i1
742 v10 = vec_madd(v5, v9, v10); // r2*wim
743 v11 = vec_nmsub(v4, v9, v11); // i2*wim
744 v12 = vec_nmsub(v7, v9, v12); // r3*wim
745 v13 = vec_madd(v6, v9, v13); // i3*wim
746
747 v1 = vec_ld(16, &(out[0])); // i0
748 v2 = vec_ld(i1, &(out[0])); // r1
749 v8 = vec_sub(v12, v10);
750 v12 = vec_add(v12, v10);
751 v9 = vec_sub(v11, v13);
752 v13 = vec_add(v11, v13);
753 v4 = vec_sub(v0, v12);
754 v0 = vec_add(v0, v12);
755 v7 = vec_sub(v3, v8);
756 v3 = vec_add(v3, v8);
757
758 vec_st(v0, 0, &(out[0])); // r0
759 vec_st(v3, i1+16, &(out[0])); // i1
760 vec_st(v4, i2, &(out[0])); // r2
761 vec_st(v7, i3+16, &(out[0]));// i3
762
763 v5 = vec_sub(v1, v13);
764 v1 = vec_add(v1, v13);
765 v6 = vec_sub(v2, v9);
766 v2 = vec_add(v2, v9);
767
768 vec_st(v1, 16, &(out[0])); // i0
769 vec_st(v2, i1, &(out[0])); // r1
770 vec_st(v5, i2+16, &(out[0])); // i2
771 vec_st(v6, i3, &(out[0])); // r3
772
773 do {
774 out += 8;
775 wre += 4;
776 wim -= 4;
777
778 v8 = vec_ld(0, &(wre[0]));
779 v10 = vec_ld(0, &(wim[0]));
780 v9 = vec_ld(0, &(wim[-4]));
781 v9 = vec_perm(v9, v10, vcprm(s0,3,2,1));
782
783 v4 = vec_ld(i2, &(out[0])); // r2
784 v5 = vec_ld(i2+16, &(out[0])); // i2
785 v6 = vec_ld(i3, &(out[0])); // r3
786 v7 = vec_ld(i3+16, &(out[0]));// i3
787 v10 = vec_mul(v4, v8); // r2*wre
788 v11 = vec_mul(v5, v8); // i2*wre
789 v12 = vec_mul(v6, v8); // r3*wre
790 v13 = vec_mul(v7, v8); // i3*wre
791
792 v0 = vec_ld(0, &(out[0])); // r0
793 v3 = vec_ld(i1+16, &(out[0])); // i1
794 v10 = vec_madd(v5, v9, v10); // r2*wim
795 v11 = vec_nmsub(v4, v9, v11); // i2*wim
796 v12 = vec_nmsub(v7, v9, v12); // r3*wim
797 v13 = vec_madd(v6, v9, v13); // i3*wim
798
799 v1 = vec_ld(16, &(out[0])); // i0
800 v2 = vec_ld(i1, &(out[0])); // r1
801 v8 = vec_sub(v12, v10);
802 v12 = vec_add(v12, v10);
803 v9 = vec_sub(v11, v13);
804 v13 = vec_add(v11, v13);
805 v4 = vec_sub(v0, v12);
806 v0 = vec_add(v0, v12);
807 v7 = vec_sub(v3, v8);
808 v3 = vec_add(v3, v8);
809
810 vec_st(v0, 0, &(out[0])); // r0
811 vec_st(v3, i1+16, &(out[0])); // i1
812 vec_st(v4, i2, &(out[0])); // r2
813 vec_st(v7, i3+16, &(out[0])); // i3
814
815 v5 = vec_sub(v1, v13);
816 v1 = vec_add(v1, v13);
817 v6 = vec_sub(v2, v9);
818 v2 = vec_add(v2, v9);
819
820 vec_st(v1, 16, &(out[0])); // i0
821 vec_st(v2, i1, &(out[0])); // r1
822 vec_st(v5, i2+16, &(out[0])); // i2
823 vec_st(v6, i3, &(out[0])); // r3
824 } while (n-=2);
825}
826
827#endif
828
829#endif /* AVCODEC_PPC_FFT_VSX_H */
libavcodec/rdft.c+0−120
@@ -1,120 +0,0 @@
1/*
2 * (I)RDFT transforms
3 * Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21#include <stdlib.h>
22#include <math.h>
23#include "libavutil/error.h"
24#include "libavutil/mathematics.h"
25#include "rdft.h"
26
27/**
28 * @file
29 * (Inverse) Real Discrete Fourier Transforms.
30 */
31
32/** Map one real FFT into two parallel real even and odd FFTs. Then interleave
33 * the two real FFTs into one complex FFT. Unmangle the results.
34 * ref: http://www.engineeringproductivitytools.com/stuff/T0001/PT10.HTM
35 */
36static void rdft_calc_c(RDFTContext *s, FFTSample *data)
37{
38 int i, i1, i2;
39 FFTComplex ev, od, odsum;
40 const int n = 1 << s->nbits;
41 const float k1 = 0.5;
42 const float k2 = 0.5 - s->inverse;
43 const FFTSample *tcos = s->tcos;
44 const FFTSample *tsin = s->tsin;
45
46 if (!s->inverse) {
47 s->fft.fft_permute(&s->fft, (FFTComplex*)data);
48 s->fft.fft_calc(&s->fft, (FFTComplex*)data);
49 }
50 /* i=0 is a special case because of packing, the DC term is real, so we
51 are going to throw the N/2 term (also real) in with it. */
52 ev.re = data[0];
53 data[0] = ev.re+data[1];
54 data[1] = ev.re-data[1];
55
56#define RDFT_UNMANGLE(sign0, sign1) \
57 for (i = 1; i < (n>>2); i++) { \
58 i1 = 2*i; \
59 i2 = n-i1; \
60 /* Separate even and odd FFTs */ \
61 ev.re = k1*(data[i1 ]+data[i2 ]); \
62 od.im = k2*(data[i2 ]-data[i1 ]); \
63 ev.im = k1*(data[i1+1]-data[i2+1]); \
64 od.re = k2*(data[i1+1]+data[i2+1]); \
65 /* Apply twiddle factors to the odd FFT and add to the even FFT */ \
66 odsum.re = od.re*tcos[i] sign0 od.im*tsin[i]; \
67 odsum.im = od.im*tcos[i] sign1 od.re*tsin[i]; \
68 data[i1 ] = ev.re + odsum.re; \
69 data[i1+1] = ev.im + odsum.im; \
70 data[i2 ] = ev.re - odsum.re; \
71 data[i2+1] = odsum.im - ev.im; \
72 }
73
74 if (s->negative_sin) {
75 RDFT_UNMANGLE(+,-)
76 } else {
77 RDFT_UNMANGLE(-,+)
78 }
79
80 data[2*i+1]=s->sign_convention*data[2*i+1];
81 if (s->inverse) {
82 data[0] *= k1;
83 data[1] *= k1;
84 s->fft.fft_permute(&s->fft, (FFTComplex*)data);
85 s->fft.fft_calc(&s->fft, (FFTComplex*)data);
86 }
87}
88
89av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
90{
91 int n = 1 << nbits;
92 int ret;
93
94 s->nbits = nbits;
95 s->inverse = trans == IDFT_C2R || trans == DFT_C2R;
96 s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;
97 s->negative_sin = trans == DFT_C2R || trans == DFT_R2C;
98
99 if (nbits < 4 || nbits > 16)
100 return AVERROR(EINVAL);
101
102 if ((ret = ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C)) < 0)
103 return ret;
104
105 ff_init_ff_cos_tabs(nbits);
106 s->tcos = ff_cos_tabs[nbits];
107 s->tsin = ff_cos_tabs[nbits] + (n >> 2);
108 s->rdft_calc = rdft_calc_c;
109
110#if ARCH_ARM
111 ff_rdft_init_arm(s);
112#endif
113
114 return 0;
115}
116
117av_cold void ff_rdft_end(RDFTContext *s)
118{
119 ff_fft_end(&s->fft);
120}
libavcodec/rdft.h+0−52
@@ -1,52 +0,0 @@
1/*
2 * (I)RDFT transforms
3 * Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#if !defined(AVCODEC_RDFT_H) && (!defined(FFT_FLOAT) || FFT_FLOAT)
23#define AVCODEC_RDFT_H
24
25#include "config.h"
26#include "fft.h"
27
28struct RDFTContext {
29 int nbits;
30 int inverse;
31 int sign_convention;
32
33 /* pre/post rotation tables */
34 const FFTSample *tcos;
35 const FFTSample *tsin;
36 int negative_sin;
37 FFTContext fft;
38 void (*rdft_calc)(struct RDFTContext *s, FFTSample *z);
39};
40
41/**
42 * Set up a real FFT.
43 * @param nbits log2 of the length of the input array
44 * @param trans the type of transform
45 */
46int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans);
47void ff_rdft_end(RDFTContext *s);
48
49void ff_rdft_init_arm(RDFTContext *s);
50
51
52#endif /* AVCODEC_RDFT_H */
libavcodec/tests/.gitignore+0−3
@@ -1,6 +1,5 @@
1/av1_levels1/av1_levels
2/avcodec2/avcodec
3/avfft
4/avpacket3/avpacket
5/bitstream_be4/bitstream_be
6/bitstream_le5/bitstream_le
@@ -8,8 +7,6 @@ · 1 unmodified line
8/celp_math7/celp_math
9/codec_desc8/codec_desc
10/dct9/dct
11/fft
12/fft-fixed32
13/golomb10/golomb
14/h264_levels11/h264_levels
15/h265_levels12/h265_levels
libavcodec/tests/avfft.c+0−25
@@ -1,25 +0,0 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19/*
20 * This test is similar to fft-fixed.c or fft-fixed32.c
21 */
22
23#define AVFFT 1
24#define FFT_FLOAT 1
25#include "fft.c"
libavcodec/tests/fft-fixed32.c+0−21
@@ -1,21 +0,0 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#define FFT_FLOAT 0
20#define AVFFT 0
21#include "fft.c"
libavcodec/tests/fft.c+0−683
@@ -1,683 +0,0 @@
1/*
2 * (c) 2002 Fabrice Bellard
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "libavutil/internal.h"
22
23FF_DISABLE_DEPRECATION_WARNINGS
24
25/**
26 * @file
27 * FFT and MDCT tests.
28 */
29
30#include "config.h"
31
32#ifndef AVFFT
33#define AVFFT 0
34#endif
35
36#include <math.h>
37#if HAVE_UNISTD_H
38#include <unistd.h>
39#endif
40#include <stdio.h>
41#include <stdlib.h>
42#include <string.h>
43
44#include "libavutil/cpu.h"
45#include "libavutil/error.h"
46#include "libavutil/lfg.h"
47#include "libavutil/log.h"
48#include "libavutil/mathematics.h"
49#include "libavutil/time.h"
50
51#if AVFFT
52#include "libavcodec/avfft.h"
53#else
54#include "libavcodec/fft.h"
55#endif
56
57#if FFT_FLOAT
58#include "libavcodec/dct.h"
59#include "libavcodec/rdft.h"
60#endif
61
62/* reference fft */
63
64#define MUL16(a, b) ((a) * (b))
65
66#define CMAC(pre, pim, are, aim, bre, bim) \
67 { \
68 pre += (MUL16(are, bre) - MUL16(aim, bim)); \
69 pim += (MUL16(are, bim) + MUL16(bre, aim)); \
70 }
71
72#if FFT_FLOAT || AVFFT
73#define RANGE 1.0
74#define REF_SCALE(x, bits) (x)
75#define FMT "%10.6f"
76#else
77#define RANGE 8388608
78#define REF_SCALE(x, bits) (x)
79#define FMT "%6d"
80#endif
81
82static struct {
83 float re, im;
84} *exptab;
85
86static int fft_ref_init(int nbits, int inverse)
87{
88 int i, n = 1 << nbits;
89
90 exptab = av_malloc_array((n / 2), sizeof(*exptab));
91 if (!exptab)
92 return AVERROR(ENOMEM);
93
94 for (i = 0; i < (n / 2); i++) {
95 double alpha = 2 * M_PI * (float) i / (float) n;
96 double c1 = cos(alpha), s1 = sin(alpha);
97 if (!inverse)
98 s1 = -s1;
99 exptab[i].re = c1;
100 exptab[i].im = s1;
101 }
102 return 0;
103}
104
105static void fft_ref(FFTComplex *tabr, FFTComplex *tab, int nbits)
106{
107 int i, j;
108 int n = 1 << nbits;
109 int n2 = n >> 1;
110
111 for (i = 0; i < n; i++) {
112 double tmp_re = 0, tmp_im = 0;
113 FFTComplex *q = tab;
114 for (j = 0; j < n; j++) {
115 double s, c;
116 int k = (i * j) & (n - 1);
117 if (k >= n2) {
118 c = -exptab[k - n2].re;
119 s = -exptab[k - n2].im;
120 } else {
121 c = exptab[k].re;
122 s = exptab[k].im;
123 }
124 CMAC(tmp_re, tmp_im, c, s, q->re, q->im);
125 q++;
126 }
127 tabr[i].re = REF_SCALE(tmp_re, nbits);
128 tabr[i].im = REF_SCALE(tmp_im, nbits);
129 }
130}
131
132#if CONFIG_MDCT
133static void imdct_ref(FFTSample *out, FFTSample *in, int nbits)
134{
135 int i, k, n = 1 << nbits;
136
137 for (i = 0; i < n; i++) {
138 double sum = 0;
139 for (k = 0; k < n / 2; k++) {
140 int a = (2 * i + 1 + (n / 2)) * (2 * k + 1);
141 double f = cos(M_PI * a / (double) (2 * n));
142 sum += f * in[k];
143 }
144 out[i] = REF_SCALE(-sum, nbits - 2);
145 }
146}
147
148/* NOTE: no normalisation by 1 / N is done */
149static void mdct_ref(FFTSample *output, FFTSample *input, int nbits)
150{
151 int i, k, n = 1 << nbits;
152
153 /* do it by hand */
154 for (k = 0; k < n / 2; k++) {
155 double s = 0;
156 for (i = 0; i < n; i++) {
157 double a = (2 * M_PI * (2 * i + 1 + n / 2) * (2 * k + 1) / (4 * n));
158 s += input[i] * cos(a);
159 }
160 output[k] = REF_SCALE(s, nbits - 1);
161 }
162}
163#endif /* CONFIG_MDCT */
164
165#if FFT_FLOAT
166#if CONFIG_DCT
167static void idct_ref(FFTSample *output, FFTSample *input, int nbits)
168{
169 int i, k, n = 1 << nbits;
170
171 /* do it by hand */
172 for (i = 0; i < n; i++) {
173 double s = 0.5 * input[0];
174 for (k = 1; k < n; k++) {
175 double a = M_PI * k * (i + 0.5) / n;
176 s += input[k] * cos(a);
177 }
178 output[i] = 2 * s / n;
179 }
180}
181
182static void dct_ref(FFTSample *output, FFTSample *input, int nbits)
183{
184 int i, k, n = 1 << nbits;
185
186 /* do it by hand */
187 for (k = 0; k < n; k++) {
188 double s = 0;
189 for (i = 0; i < n; i++) {
190 double a = M_PI * k * (i + 0.5) / n;
191 s += input[i] * cos(a);
192 }
193 output[k] = s;
194 }
195}
196#endif /* CONFIG_DCT */
197#endif /* FFT_FLOAT */
198
199static FFTSample frandom(AVLFG *prng)
200{
201 return (int16_t) av_lfg_get(prng) / 32768.0 * RANGE;
202}
203
204static int check_diff(FFTSample *tab1, FFTSample *tab2, int n, double scale)
205{
206 int i, err = 0;
207 double error = 0, max = 0;
208
209 for (i = 0; i < n; i++) {
210 double e = fabs(tab1[i] - (tab2[i] / scale)) / RANGE;
211 if (e >= 1e-3) {
212 av_log(NULL, AV_LOG_ERROR, "ERROR %5d: "FMT" "FMT"\n",
213 i, tab1[i], tab2[i]);
214 err = 1;
215 }
216 error += e * e;
217 if (e > max)
218 max = e;
219 }
220 av_log(NULL, AV_LOG_INFO, "max:%f e:%g\n", max, sqrt(error / n));
221 return err;
222}
223
224static inline void fft_init(FFTContext **s, int nbits, int inverse)
225{
226#if AVFFT
227 *s = av_fft_init(nbits, inverse);
228#else
229 ff_fft_init(*s, nbits, inverse);
230#endif
231}
232
233#if CONFIG_MDCT
234static inline void mdct_init(FFTContext **s, int nbits, int inverse, double scale)
235{
236#if AVFFT
237 *s = av_mdct_init(nbits, inverse, scale);
238#else
239 ff_mdct_init(*s, nbits, inverse, scale);
240#endif
241}
242
243static inline void mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
244{
245#if AVFFT
246 av_mdct_calc(s, output, input);
247#else
248 s->mdct_calc(s, output, input);
249#endif
250}
251
252static inline void imdct_calc(struct FFTContext *s, FFTSample *output, const FFTSample *input)
253{
254#if AVFFT
255 av_imdct_calc(s, output, input);
256#else
257 s->imdct_calc(s, output, input);
258#endif
259}
260#endif
261
262static inline void fft_permute(FFTContext *s, FFTComplex *z)
263{
264#if AVFFT
265 av_fft_permute(s, z);
266#else
267 s->fft_permute(s, z);
268#endif
269}
270
271static inline void fft_calc(FFTContext *s, FFTComplex *z)
272{
273#if AVFFT
274 av_fft_calc(s, z);
275#else
276 s->fft_calc(s, z);
277#endif
278}
279
280static inline void mdct_end(FFTContext *s)
281{
282#if AVFFT
283 av_mdct_end(s);
284#else
285 ff_mdct_end(s);
286#endif
287}
288
289static inline void fft_end(FFTContext *s)
290{
291#if AVFFT
292 av_fft_end(s);
293#else
294 ff_fft_end(s);
295#endif
296}
297
298#if FFT_FLOAT
299static inline void rdft_init(RDFTContext **r, int nbits, enum RDFTransformType trans)
300{
301#if AVFFT
302 *r = av_rdft_init(nbits, trans);
303#else
304 ff_rdft_init(*r, nbits, trans);
305#endif
306}
307
308static inline void dct_init(DCTContext **d, int nbits, enum DCTTransformType trans)
309{
310#if AVFFT
311 *d = av_dct_init(nbits, trans);
312#else
313 ff_dct_init(*d, nbits, trans);
314#endif
315}
316
317static inline void rdft_calc(RDFTContext *r, FFTSample *tab)
318{
319#if AVFFT
320 av_rdft_calc(r, tab);
321#else
322 r->rdft_calc(r, tab);
323#endif
324}
325
326static inline void dct_calc(DCTContext *d, FFTSample *data)
327{
328#if AVFFT
329 av_dct_calc(d, data);
330#else
331 d->dct_calc(d, data);
332#endif
333}
334
335static inline void rdft_end(RDFTContext *r)
336{
337#if AVFFT
338 av_rdft_end(r);
339#else
340 ff_rdft_end(r);
341#endif
342}
343
344static inline void dct_end(DCTContext *d)
345{
346#if AVFFT
347 av_dct_end(d);
348#else
349 ff_dct_end(d);
350#endif
351}
352#endif /* FFT_FLOAT */
353
354static void help(void)
355{
356 av_log(NULL, AV_LOG_INFO,
357 "usage: fft-test [-h] [-s] [-i] [-n b]\n"
358 "-h print this help\n"
359 "-s speed test\n"
360 "-m (I)MDCT test\n"
361 "-d (I)DCT test\n"
362 "-r (I)RDFT test\n"
363 "-i inverse transform test\n"
364 "-n b set the transform size to 2^b\n"
365 "-f x set scale factor for output data of (I)MDCT to x\n");
366}
367
368enum tf_transform {
369 TRANSFORM_FFT,
370 TRANSFORM_MDCT,
371 TRANSFORM_RDFT,
372 TRANSFORM_DCT,
373};
374
375#if !HAVE_GETOPT
376#include "compat/getopt.c"
377#endif
378
379int main(int argc, char **argv)
380{
381 FFTComplex *tab, *tab1, *tab_ref;
382 FFTSample *tab2;
383 enum tf_transform transform = TRANSFORM_FFT;
384 FFTContext *m, *s;
385#if FFT_FLOAT
386 RDFTContext *r;
387 DCTContext *d;
388#endif /* FFT_FLOAT */
389 int it, i, err = 1;
390 int do_speed = 0, do_inverse = 0;
391 int fft_nbits = 9, fft_size;
392 double scale = 1.0;
393 AVLFG prng;
394
395#if !AVFFT
396 s = av_mallocz(sizeof(*s));
397 m = av_mallocz(sizeof(*m));
398#endif
399
400#if !AVFFT && FFT_FLOAT
401 r = av_mallocz(sizeof(*r));
402 d = av_mallocz(sizeof(*d));
403#endif
404
405 av_lfg_init(&prng, 1);
406
407 for (;;) {
408 int c = getopt(argc, argv, "hsimrdn:f:c:");
409 if (c == -1)
410 break;
411 switch (c) {
412 case 'h':
413 help();
414 return 1;
415 case 's':
416 do_speed = 1;
417 break;
418 case 'i':
419 do_inverse = 1;
420 break;
421 case 'm':
422 transform = TRANSFORM_MDCT;
423 break;
424 case 'r':
425 transform = TRANSFORM_RDFT;
426 break;
427 case 'd':
428 transform = TRANSFORM_DCT;
429 break;
430 case 'n':
431 fft_nbits = atoi(optarg);
432 break;
433 case 'f':
434 scale = atof(optarg);
435 break;
436 case 'c':
437 {
438 unsigned cpuflags = av_get_cpu_flags();
439
440 if (av_parse_cpu_caps(&cpuflags, optarg) < 0)
441 return 1;
442
443 av_force_cpu_flags(cpuflags);
444 break;
445 }
446 }
447 }
448
449 fft_size = 1 << fft_nbits;
450 tab = av_malloc_array(fft_size, sizeof(FFTComplex));
451 tab1 = av_malloc_array(fft_size, sizeof(FFTComplex));
452 tab_ref = av_malloc_array(fft_size, sizeof(FFTComplex));
453 tab2 = av_malloc_array(fft_size, sizeof(FFTSample));
454
455 if (!(tab && tab1 && tab_ref && tab2))
456 goto cleanup;
457
458 switch (transform) {
459#if CONFIG_MDCT
460 case TRANSFORM_MDCT:
461 av_log(NULL, AV_LOG_INFO, "Scale factor is set to %f\n", scale);
462 if (do_inverse)
463 av_log(NULL, AV_LOG_INFO, "IMDCT");
464 else
465 av_log(NULL, AV_LOG_INFO, "MDCT");
466 mdct_init(&m, fft_nbits, do_inverse, scale);
467 break;
468#endif /* CONFIG_MDCT */
469 case TRANSFORM_FFT:
470 if (do_inverse)
471 av_log(NULL, AV_LOG_INFO, "IFFT");
472 else
473 av_log(NULL, AV_LOG_INFO, "FFT");
474 fft_init(&s, fft_nbits, do_inverse);
475 if ((err = fft_ref_init(fft_nbits, do_inverse)) < 0)
476 goto cleanup;
477 break;
478#if FFT_FLOAT
479# if CONFIG_RDFT
480 case TRANSFORM_RDFT:
481 if (do_inverse)
482 av_log(NULL, AV_LOG_INFO, "IDFT_C2R");
483 else
484 av_log(NULL, AV_LOG_INFO, "DFT_R2C");
485 rdft_init(&r, fft_nbits, do_inverse ? IDFT_C2R : DFT_R2C);
486 if ((err = fft_ref_init(fft_nbits, do_inverse)) < 0)
487 goto cleanup;
488 break;
489# endif /* CONFIG_RDFT */
490# if CONFIG_DCT
491 case TRANSFORM_DCT:
492 if (do_inverse)
493 av_log(NULL, AV_LOG_INFO, "DCT_III");
494 else
495 av_log(NULL, AV_LOG_INFO, "DCT_II");
496 dct_init(&d, fft_nbits, do_inverse ? DCT_III : DCT_II);
497 break;
498# endif /* CONFIG_DCT */
499#endif /* FFT_FLOAT */
500 default:
501 av_log(NULL, AV_LOG_ERROR, "Requested transform not supported\n");
502 goto cleanup;
503 }
504 av_log(NULL, AV_LOG_INFO, " %d test\n", fft_size);
505
506 /* generate random data */
507
508 for (i = 0; i < fft_size; i++) {
509 tab1[i].re = frandom(&prng);
510 tab1[i].im = frandom(&prng);
511 }
512
513 /* checking result */
514 av_log(NULL, AV_LOG_INFO, "Checking...\n");
515
516 switch (transform) {
517#if CONFIG_MDCT
518 case TRANSFORM_MDCT:
519 if (do_inverse) {
520 imdct_ref(&tab_ref->re, &tab1->re, fft_nbits);
521 imdct_calc(m, tab2, &tab1->re);
522 err = check_diff(&tab_ref->re, tab2, fft_size, scale);
523 } else {
524 mdct_ref(&tab_ref->re, &tab1->re, fft_nbits);
525 mdct_calc(m, tab2, &tab1->re);
526 err = check_diff(&tab_ref->re, tab2, fft_size / 2, scale);
527 }
528 break;
529#endif /* CONFIG_MDCT */
530 case TRANSFORM_FFT:
531 memcpy(tab, tab1, fft_size * sizeof(FFTComplex));
532 fft_permute(s, tab);
533 fft_calc(s, tab);
534
535 fft_ref(tab_ref, tab1, fft_nbits);
536 err = check_diff(&tab_ref->re, &tab->re, fft_size * 2, 1.0);
537 break;
538#if FFT_FLOAT
539#if CONFIG_RDFT
540 case TRANSFORM_RDFT:
541 {
542 int fft_size_2 = fft_size >> 1;
543 if (do_inverse) {
544 tab1[0].im = 0;
545 tab1[fft_size_2].im = 0;
546 for (i = 1; i < fft_size_2; i++) {
547 tab1[fft_size_2 + i].re = tab1[fft_size_2 - i].re;
548 tab1[fft_size_2 + i].im = -tab1[fft_size_2 - i].im;
549 }
550
551 memcpy(tab2, tab1, fft_size * sizeof(FFTSample));
552 tab2[1] = tab1[fft_size_2].re;
553
554 rdft_calc(r, tab2);
555 fft_ref(tab_ref, tab1, fft_nbits);
556 for (i = 0; i < fft_size; i++) {
557 tab[i].re = tab2[i];
558 tab[i].im = 0;
559 }
560 err = check_diff(&tab_ref->re, &tab->re, fft_size * 2, 0.5);
561 } else {
562 for (i = 0; i < fft_size; i++) {
563 tab2[i] = tab1[i].re;
564 tab1[i].im = 0;
565 }
566 rdft_calc(r, tab2);
567 fft_ref(tab_ref, tab1, fft_nbits);
568 tab_ref[0].im = tab_ref[fft_size_2].re;
569 err = check_diff(&tab_ref->re, tab2, fft_size, 1.0);
570 }
571 break;
572 }
573#endif /* CONFIG_RDFT */
574#if CONFIG_DCT
575 case TRANSFORM_DCT:
576 memcpy(tab, tab1, fft_size * sizeof(FFTComplex));
577 dct_calc(d, &tab->re);
578 if (do_inverse)
579 idct_ref(&tab_ref->re, &tab1->re, fft_nbits);
580 else
581 dct_ref(&tab_ref->re, &tab1->re, fft_nbits);
582 err = check_diff(&tab_ref->re, &tab->re, fft_size, 1.0);
583 break;
584#endif /* CONFIG_DCT */
585#endif /* FFT_FLOAT */
586 }
587
588 /* do a speed test */
589
590 if (do_speed) {
591 int64_t time_start, duration;
592 int nb_its;
593
594 av_log(NULL, AV_LOG_INFO, "Speed test...\n");
595 /* we measure during about 1 seconds */
596 nb_its = 1;
597 for (;;) {
598 time_start = av_gettime_relative();
599 for (it = 0; it < nb_its; it++) {
600 switch (transform) {
601#if CONFIG_MDCT
602 case TRANSFORM_MDCT:
603 if (do_inverse)
604 imdct_calc(m, &tab->re, &tab1->re);
605 else
606 mdct_calc(m, &tab->re, &tab1->re);
607 break;
608#endif
609 case TRANSFORM_FFT:
610 memcpy(tab, tab1, fft_size * sizeof(FFTComplex));
611 fft_calc(s, tab);
612 break;
613#if FFT_FLOAT
614 case TRANSFORM_RDFT:
615 memcpy(tab2, tab1, fft_size * sizeof(FFTSample));
616 rdft_calc(r, tab2);
617 break;
618 case TRANSFORM_DCT:
619 memcpy(tab2, tab1, fft_size * sizeof(FFTSample));
620 dct_calc(d, tab2);
621 break;
622#endif /* FFT_FLOAT */
623 }
624 }
625 duration = av_gettime_relative() - time_start;
626 if (duration >= 1000000)
627 break;
628 nb_its *= 2;
629 }
630 av_log(NULL, AV_LOG_INFO,
631 "time: %0.1f us/transform [total time=%0.2f s its=%d]\n",
632 (double) duration / nb_its,
633 (double) duration / 1000000.0,
634 nb_its);
635 }
636
637 switch (transform) {
638#if CONFIG_MDCT
639 case TRANSFORM_MDCT:
640 mdct_end(m);
641 break;
642#endif /* CONFIG_MDCT */
643 case TRANSFORM_FFT:
644 fft_end(s);
645 break;
646#if FFT_FLOAT
647# if CONFIG_RDFT
648 case TRANSFORM_RDFT:
649 rdft_end(r);
650 break;
651# endif /* CONFIG_RDFT */
652# if CONFIG_DCT
653 case TRANSFORM_DCT:
654 dct_end(d);
655 break;
656# endif /* CONFIG_DCT */
657#endif /* FFT_FLOAT */
658 }
659
660cleanup:
661 av_free(tab);
662 av_free(tab1);
663 av_free(tab2);
664 av_free(tab_ref);
665 av_free(exptab);
666
667#if !AVFFT
668 av_free(s);
669 av_free(m);
670#endif
671
672#if !AVFFT && FFT_FLOAT
673 av_free(r);
674 av_free(d);
675#endif
676
677 if (err)
678 printf("Error: %d.\n", err);
679
680 return !!err;
681}
682
683FF_ENABLE_DEPRECATION_WARNINGS
libavcodec/x86/Makefile+0−4
@@ -5,11 +5,9 @@ OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp_init.o · 4 unmodified lines
5OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp_init.o5OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp_init.o
6OBJS-$(CONFIG_BLOCKDSP) += x86/blockdsp_init.o6OBJS-$(CONFIG_BLOCKDSP) += x86/blockdsp_init.o
7OBJS-$(CONFIG_BSWAPDSP) += x86/bswapdsp_init.o7OBJS-$(CONFIG_BSWAPDSP) += x86/bswapdsp_init.o
8OBJS-$(CONFIG_DCT) += x86/dct_init.o
9OBJS-$(CONFIG_DIRAC_DECODER) += x86/diracdsp_init.o \8OBJS-$(CONFIG_DIRAC_DECODER) += x86/diracdsp_init.o \
10 x86/dirac_dwt_init.o9 x86/dirac_dwt_init.o
11OBJS-$(CONFIG_FDCTDSP) += x86/fdctdsp_init.o10OBJS-$(CONFIG_FDCTDSP) += x86/fdctdsp_init.o
12OBJS-$(CONFIG_FFT) += x86/fft_init.o
13OBJS-$(CONFIG_FMTCONVERT) += x86/fmtconvert_init.o11OBJS-$(CONFIG_FMTCONVERT) += x86/fmtconvert_init.o
14OBJS-$(CONFIG_H263DSP) += x86/h263dsp_init.o12OBJS-$(CONFIG_H263DSP) += x86/h263dsp_init.o
15OBJS-$(CONFIG_H264CHROMA) += x86/h264chroma_init.o13OBJS-$(CONFIG_H264CHROMA) += x86/h264chroma_init.o
@@ -98,8 +96,6 @@ X86ASM-OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp.o \ · 82 unmodified lines
98X86ASM-OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp.o96X86ASM-OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp.o
99X86ASM-OBJS-$(CONFIG_BLOCKDSP) += x86/blockdsp.o97X86ASM-OBJS-$(CONFIG_BLOCKDSP) += x86/blockdsp.o
100X86ASM-OBJS-$(CONFIG_BSWAPDSP) += x86/bswapdsp.o98X86ASM-OBJS-$(CONFIG_BSWAPDSP) += x86/bswapdsp.o
101X86ASM-OBJS-$(CONFIG_DCT) += x86/dct32.o
102X86ASM-OBJS-$(CONFIG_FFT) += x86/fft.o
103X86ASM-OBJS-$(CONFIG_FMTCONVERT) += x86/fmtconvert.o99X86ASM-OBJS-$(CONFIG_FMTCONVERT) += x86/fmtconvert.o
104X86ASM-OBJS-$(CONFIG_H263DSP) += x86/h263_loopfilter.o100X86ASM-OBJS-$(CONFIG_H263DSP) += x86/h263_loopfilter.o
105X86ASM-OBJS-$(CONFIG_H264CHROMA) += x86/h264_chromamc.o \101X86ASM-OBJS-$(CONFIG_H264CHROMA) += x86/h264_chromamc.o \
libavcodec/x86/dct_init.c+0−36
@@ -1,36 +0,0 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "config.h"
20#include "libavutil/attributes.h"
21#include "libavutil/cpu.h"
22#include "libavutil/x86/cpu.h"
23#include "libavcodec/dct.h"
24
25void ff_dct32_float_sse2(FFTSample *out, const FFTSample *in);
26void ff_dct32_float_avx(FFTSample *out, const FFTSample *in);
27
28av_cold void ff_dct_init_x86(DCTContext *s)
29{
30 int cpu_flags = av_get_cpu_flags();
31
32 if (EXTERNAL_SSE2(cpu_flags))
33 s->dct32 = ff_dct32_float_sse2;
34 if (EXTERNAL_AVX_FAST(cpu_flags))
35 s->dct32 = ff_dct32_float_avx;
36}
libavcodec/x86/fft.asm+0−838
@@ -1,838 +0,0 @@
1;******************************************************************************
2;* FFT transform with SSE/AVX optimizations
3;* Copyright (c) 2008 Loren Merritt
4;* Copyright (c) 2011 Vitor Sessak
5;*
6;* This algorithm (though not any of the implementation details) is
7;* based on libdjbfft by D. J. Bernstein.
8;*
9;* This file is part of FFmpeg.
10;*
11;* FFmpeg is free software; you can redistribute it and/or
12;* modify it under the terms of the GNU Lesser General Public
13;* License as published by the Free Software Foundation; either
14;* version 2.1 of the License, or (at your option) any later version.
15;*
16;* FFmpeg is distributed in the hope that it will be useful,
17;* but WITHOUT ANY WARRANTY; without even the implied warranty of
18;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19;* Lesser General Public License for more details.
20;*
21;* You should have received a copy of the GNU Lesser General Public
22;* License along with FFmpeg; if not, write to the Free Software
23;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24;******************************************************************************
25
26; These functions are not individually interchangeable with the C versions.
27; While C takes arrays of FFTComplex, SSE/3DNow leave intermediate results
28; in blocks as conventient to the vector size.
29; i.e. {4x real, 4x imaginary, 4x real, ...} (or 2x respectively)
30
31%include "libavutil/x86/x86util.asm"
32
33%if ARCH_X86_64
34%define pointer resq
35%else
36%define pointer resd
37%endif
38
39struc FFTContext
40 .nbits: resd 1
41 .reverse: resd 1
42 .revtab: pointer 1
43 .tmpbuf: pointer 1
44 .mdctsize: resd 1
45 .mdctbits: resd 1
46 .tcos: pointer 1
47 .tsin: pointer 1
48 .fftperm: pointer 1
49 .fftcalc: pointer 1
50 .imdctcalc:pointer 1
51 .imdcthalf:pointer 1
52endstruc
53
54SECTION_RODATA 32
55
56%define M_SQRT1_2 0.70710678118654752440
57%define M_COS_PI_1_8 0.923879532511287
58%define M_COS_PI_3_8 0.38268343236509
59
60ps_cos16_1: dd 1.0, M_COS_PI_1_8, M_SQRT1_2, M_COS_PI_3_8, 1.0, M_COS_PI_1_8, M_SQRT1_2, M_COS_PI_3_8
61ps_cos16_2: dd 0, M_COS_PI_3_8, M_SQRT1_2, M_COS_PI_1_8, 0, -M_COS_PI_3_8, -M_SQRT1_2, -M_COS_PI_1_8
62
63ps_root2: times 8 dd M_SQRT1_2
64ps_root2mppm: dd -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2, -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2
65ps_p1p1m1p1: dd 0, 0, 1<<31, 0, 0, 0, 1<<31, 0
66
67perm1: dd 0x00, 0x02, 0x03, 0x01, 0x03, 0x00, 0x02, 0x01
68perm2: dd 0x00, 0x01, 0x02, 0x03, 0x01, 0x00, 0x02, 0x03
69ps_p1p1m1p1root2: dd 1.0, 1.0, -1.0, 1.0, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2
70ps_m1m1p1m1p1m1m1m1: dd 1<<31, 1<<31, 0, 1<<31, 0, 1<<31, 1<<31, 1<<31
71ps_m1p1: dd 1<<31, 0
72
73cextern ps_neg
74
75%assign i 16
76%rep 14
77cextern cos_ %+ i
78%assign i i<<1
79%endrep
80
81%if ARCH_X86_64
82 %define pointer dq
83%else
84 %define pointer dd
85%endif
86
87%macro IF0 1+
88%endmacro
89%macro IF1 1+
90 %1
91%endmacro
92
93SECTION .text
94
95; in: %1 = {r0,i0,r2,i2,r4,i4,r6,i6}
96; %2 = {r1,i1,r3,i3,r5,i5,r7,i7}
97; %3, %4, %5 tmp
98; out: %1 = {r0,r1,r2,r3,i0,i1,i2,i3}
99; %2 = {r4,r5,r6,r7,i4,i5,i6,i7}
100%macro T8_AVX 5
101 vsubps %5, %1, %2 ; v = %1 - %2
102 vaddps %3, %1, %2 ; w = %1 + %2
103 vmulps %2, %5, [ps_p1p1m1p1root2] ; v *= vals1
104 vpermilps %2, %2, [perm1]
105 vblendps %1, %2, %3, 0x33 ; q = {w1,w2,v4,v2,w5,w6,v7,v6}
106 vshufps %5, %3, %2, 0x4e ; r = {w3,w4,v1,v3,w7,w8,v8,v5}
107 vsubps %4, %5, %1 ; s = r - q
108 vaddps %1, %5, %1 ; u = r + q
109 vpermilps %1, %1, [perm2] ; k = {u1,u2,u3,u4,u6,u5,u7,u8}
110 vshufps %5, %4, %1, 0xbb
111 vshufps %3, %4, %1, 0xee
112 vperm2f128 %3, %3, %5, 0x13
113 vxorps %4, %4, [ps_m1m1p1m1p1m1m1m1] ; s *= {1,1,-1,-1,1,-1,-1,-1}
114 vshufps %2, %1, %4, 0xdd
115 vshufps %1, %1, %4, 0x88
116 vperm2f128 %4, %2, %1, 0x02 ; v = {k1,k3,s1,s3,k2,k4,s2,s4}
117 vperm2f128 %1, %1, %2, 0x13 ; w = {k6,k8,s6,s8,k5,k7,s5,s7}
118 vsubps %5, %1, %3
119 vblendps %1, %5, %1, 0x55 ; w -= {0,s7,0,k7,0,s8,0,k8}
120 vsubps %2, %4, %1 ; %2 = v - w
121 vaddps %1, %4, %1 ; %1 = v + w
122%endmacro
123
124; In SSE mode do one fft4 transforms
125; in: %1={r0,i0,r2,i2} %2={r1,i1,r3,i3}
126; out: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3}
127;
128; In AVX mode do two fft4 transforms
129; in: %1={r0,i0,r2,i2,r4,i4,r6,i6} %2={r1,i1,r3,i3,r5,i5,r7,i7}
130; out: %1={r0,r1,r2,r3,r4,r5,r6,r7} %2={i0,i1,i2,i3,i4,i5,i6,i7}
131%macro T4_SSE 3
132 subps %3, %1, %2 ; {t3,t4,-t8,t7}
133 addps %1, %1, %2 ; {t1,t2,t6,t5}
134 xorps %3, %3, [ps_p1p1m1p1]
135 shufps %2, %1, %3, 0xbe ; {t6,t5,t7,t8}
136 shufps %1, %1, %3, 0x44 ; {t1,t2,t3,t4}
137 subps %3, %1, %2 ; {r2,i2,r3,i3}
138 addps %1, %1, %2 ; {r0,i0,r1,i1}
139 shufps %2, %1, %3, 0xdd ; {i0,i1,i2,i3}
140 shufps %1, %1, %3, 0x88 ; {r0,r1,r2,r3}
141%endmacro
142
143; In SSE mode do one FFT8
144; in: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3} %3={r4,i4,r6,i6} %4={r5,i5,r7,i7}
145; out: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3} %1={r4,r5,r6,r7} %2={i4,i5,i6,i7}
146;
147; In AVX mode do two FFT8
148; in: %1={r0,i0,r2,i2,r8, i8, r10,i10} %2={r1,i1,r3,i3,r9, i9, r11,i11}
149; %3={r4,i4,r6,i6,r12,i12,r14,i14} %4={r5,i5,r7,i7,r13,i13,r15,i15}
150; out: %1={r0,r1,r2,r3,r8, r9, r10,r11} %2={i0,i1,i2,i3,i8, i9, i10,i11}
151; %3={r4,r5,r6,r7,r12,r13,r14,r15} %4={i4,i5,i6,i7,i12,i13,i14,i15}
152%macro T8_SSE 6
153 addps %6, %3, %4 ; {t1,t2,t3,t4}
154 subps %3, %3, %4 ; {r5,i5,r7,i7}
155 shufps %4, %3, %3, 0xb1 ; {i5,r5,i7,r7}
156 mulps %3, %3, [ps_root2mppm] ; {-r5,i5,r7,-i7}
157 mulps %4, %4, [ps_root2]
158 addps %3, %3, %4 ; {t8,t7,ta,t9}
159 shufps %4, %6, %3, 0x9c ; {t1,t4,t7,ta}
160 shufps %6, %6, %3, 0x36 ; {t3,t2,t9,t8}
161 subps %3, %6, %4 ; {t6,t5,tc,tb}
162 addps %6, %6, %4 ; {t1,t2,t9,ta}
163 shufps %5, %6, %3, 0x8d ; {t2,ta,t6,tc}
164 shufps %6, %6, %3, 0xd8 ; {t1,t9,t5,tb}
165 subps %3, %1, %6 ; {r4,r5,r6,r7}
166 addps %1, %1, %6 ; {r0,r1,r2,r3}
167 subps %4, %2, %5 ; {i4,i5,i6,i7}
168 addps %2, %2, %5 ; {i0,i1,i2,i3}
169%endmacro
170
171%macro INTERL 5
172%if cpuflag(avx)
173 vunpckhps %3, %2, %1
174 vunpcklps %2, %2, %1
175 vextractf128 %4(%5), %2, 0
176 vextractf128 %4 %+ H(%5), %3, 0
177 vextractf128 %4(%5 + 1), %2, 1
178 vextractf128 %4 %+ H(%5 + 1), %3, 1
179%elif cpuflag(sse)
180 mova %3, %2
181 unpcklps %2, %1
182 unpckhps %3, %1
183 mova %4(%5), %2
184 mova %4(%5+1), %3
185%endif
186%endmacro
187
188; scheduled for cpu-bound sizes
189%macro PASS_SMALL 3 ; (to load m4-m7), wre, wim
190IF%1 mova m4, Z(4)
191IF%1 mova m5, Z(5)
192 mova m0, %2 ; wre
193 mova m1, %3 ; wim
194 mulps m2, m4, m0 ; r2*wre
195IF%1 mova m6, Z2(6)
196 mulps m3, m5, m1 ; i2*wim
197IF%1 mova m7, Z2(7)
198 mulps m4, m4, m1 ; r2*wim
199 mulps m5, m5, m0 ; i2*wre
200 addps m2, m2, m3 ; r2*wre + i2*wim
201 mulps m3, m1, m7 ; i3*wim
202 subps m5, m5, m4 ; i2*wre - r2*wim
203 mulps m1, m1, m6 ; r3*wim
204 mulps m4, m0, m6 ; r3*wre
205 mulps m0, m0, m7 ; i3*wre
206 subps m4, m4, m3 ; r3*wre - i3*wim
207 mova m3, Z(0)
208 addps m0, m0, m1 ; i3*wre + r3*wim
209 subps m1, m4, m2 ; t3
210 addps m4, m4, m2 ; t5
211 subps m3, m3, m4 ; r2
212 addps m4, m4, Z(0) ; r0
213 mova m6, Z(2)
214 mova Z(4), m3
215 mova Z(0), m4
216 subps m3, m5, m0 ; t4
217 subps m4, m6, m3 ; r3
218 addps m3, m3, m6 ; r1
219 mova Z2(6), m4
220 mova Z(2), m3
221 mova m2, Z(3)
222 addps m3, m5, m0 ; t6
223 subps m2, m2, m1 ; i3
224 mova m7, Z(1)
225 addps m1, m1, Z(3) ; i1
226 mova Z2(7), m2
227 mova Z(3), m1
228 subps m4, m7, m3 ; i2
229 addps m3, m3, m7 ; i0
230 mova Z(5), m4
231 mova Z(1), m3
232%endmacro
233
234; scheduled to avoid store->load aliasing
235%macro PASS_BIG 1 ; (!interleave)
236 mova m4, Z(4) ; r2
237 mova m5, Z(5) ; i2
238 mova m0, [wq] ; wre
239 mova m1, [wq+o1q] ; wim
240 mulps m2, m4, m0 ; r2*wre
241 mova m6, Z2(6) ; r3
242 mulps m3, m5, m1 ; i2*wim
243 mova m7, Z2(7) ; i3
244 mulps m4, m4, m1 ; r2*wim
245 mulps m5, m5, m0 ; i2*wre
246 addps m2, m2, m3 ; r2*wre + i2*wim
247 mulps m3, m1, m7 ; i3*wim
248 mulps m1, m1, m6 ; r3*wim
249 subps m5, m5, m4 ; i2*wre - r2*wim
250 mulps m4, m0, m6 ; r3*wre
251 mulps m0, m0, m7 ; i3*wre
252 subps m4, m4, m3 ; r3*wre - i3*wim
253 mova m3, Z(0)
254 addps m0, m0, m1 ; i3*wre + r3*wim
255 subps m1, m4, m2 ; t3
256 addps m4, m4, m2 ; t5
257 subps m3, m3, m4 ; r2
258 addps m4, m4, Z(0) ; r0
259 mova m6, Z(2)
260 mova Z(4), m3
261 mova Z(0), m4
262 subps m3, m5, m0 ; t4
263 subps m4, m6, m3 ; r3
264 addps m3, m3, m6 ; r1
265IF%1 mova Z2(6), m4
266IF%1 mova Z(2), m3
267 mova m2, Z(3)
268 addps m5, m5, m0 ; t6
269 subps m2, m2, m1 ; i3
270 mova m7, Z(1)
271 addps m1, m1, Z(3) ; i1
272IF%1 mova Z2(7), m2
273IF%1 mova Z(3), m1
274 subps m6, m7, m5 ; i2
275 addps m5, m5, m7 ; i0
276IF%1 mova Z(5), m6
277IF%1 mova Z(1), m5
278%if %1==0
279 INTERL m1, m3, m7, Z, 2
280 INTERL m2, m4, m0, Z2, 6
281
282 mova m1, Z(0)
283 mova m2, Z(4)
284
285 INTERL m5, m1, m3, Z, 0
286 INTERL m6, m2, m7, Z, 4
287%endif
288%endmacro
289
290%define Z(x) [r0+mmsize*x]
291%define Z2(x) [r0+mmsize*x]
292%define ZH(x) [r0+mmsize*x+mmsize/2]
293
294INIT_YMM avx
295
296%if HAVE_AVX_EXTERNAL
297align 16
298fft8_avx:
299 mova m0, Z(0)
300 mova m1, Z(1)
301 T8_AVX m0, m1, m2, m3, m4
302 mova Z(0), m0
303 mova Z(1), m1
304 ret
305
306
307align 16
308fft16_avx:
309 mova m2, Z(2)
310 mova m3, Z(3)
311 T4_SSE m2, m3, m7
312
313 mova m0, Z(0)
314 mova m1, Z(1)
315 T8_AVX m0, m1, m4, m5, m7
316
317 mova m4, [ps_cos16_1]
318 mova m5, [ps_cos16_2]
319 vmulps m6, m2, m4
320 vmulps m7, m3, m5
321 vaddps m7, m7, m6
322 vmulps m2, m2, m5
323 vmulps m3, m3, m4
324 vsubps m3, m3, m2
325 vblendps m2, m7, m3, 0xf0
326 vperm2f128 m3, m7, m3, 0x21
327 vaddps m4, m2, m3
328 vsubps m2, m3, m2
329 vperm2f128 m2, m2, m2, 0x01
330 vsubps m3, m1, m2
331 vaddps m1, m1, m2
332 vsubps m5, m0, m4
333 vaddps m0, m0, m4
334 vextractf128 Z(0), m0, 0
335 vextractf128 ZH(0), m1, 0
336 vextractf128 Z(1), m0, 1
337 vextractf128 ZH(1), m1, 1
338 vextractf128 Z(2), m5, 0
339 vextractf128 ZH(2), m3, 0
340 vextractf128 Z(3), m5, 1
341 vextractf128 ZH(3), m3, 1
342 ret
343
344align 16
345fft32_avx:
346 call fft16_avx
347
348 mova m0, Z(4)
349 mova m1, Z(5)
350
351 T4_SSE m0, m1, m4
352
353 mova m2, Z(6)
354 mova m3, Z(7)
355
356 T8_SSE m0, m1, m2, m3, m4, m6
357 ; m0={r0,r1,r2,r3,r8, r9, r10,r11} m1={i0,i1,i2,i3,i8, i9, i10,i11}
358 ; m2={r4,r5,r6,r7,r12,r13,r14,r15} m3={i4,i5,i6,i7,i12,i13,i14,i15}
359
360 vperm2f128 m4, m0, m2, 0x20
361 vperm2f128 m5, m1, m3, 0x20
362 vperm2f128 m6, m0, m2, 0x31
363 vperm2f128 m7, m1, m3, 0x31
364
365 PASS_SMALL 0, [cos_32], [cos_32+32]
366
367 ret
368
369fft32_interleave_avx:
370 call fft32_avx
371 mov r2d, 32
372.deint_loop:
373 mova m2, Z(0)
374 mova m3, Z(1)
375 vunpcklps m0, m2, m3
376 vunpckhps m1, m2, m3
377 vextractf128 Z(0), m0, 0
378 vextractf128 ZH(0), m1, 0
379 vextractf128 Z(1), m0, 1
380 vextractf128 ZH(1), m1, 1
381 add r0, mmsize*2
382 sub r2d, mmsize/4
383 jg .deint_loop
384 ret
385
386%endif
387
388INIT_XMM sse
389
390align 16
391fft4_avx:
392fft4_sse:
393 mova m0, Z(0)
394 mova m1, Z(1)
395 T4_SSE m0, m1, m2
396 mova Z(0), m0
397 mova Z(1), m1
398 ret
399
400align 16
401fft8_sse:
402 mova m0, Z(0)
403 mova m1, Z(1)
404 T4_SSE m0, m1, m2
405 mova m2, Z(2)
406 mova m3, Z(3)
407 T8_SSE m0, m1, m2, m3, m4, m5
408 mova Z(0), m0
409 mova Z(1), m1
410 mova Z(2), m2
411 mova Z(3), m3
412 ret
413
414align 16
415fft16_sse:
416 mova m0, Z(0)
417 mova m1, Z(1)
418 T4_SSE m0, m1, m2
419 mova m2, Z(2)
420 mova m3, Z(3)
421 T8_SSE m0, m1, m2, m3, m4, m5
422 mova m4, Z(4)
423 mova m5, Z(5)
424 mova Z(0), m0
425 mova Z(1), m1
426 mova Z(2), m2
427 mova Z(3), m3
428 T4_SSE m4, m5, m6
429 mova m6, Z2(6)
430 mova m7, Z2(7)
431 T4_SSE m6, m7, m0
432 PASS_SMALL 0, [cos_16], [cos_16+16]
433 ret
434
435
436%define Z(x) [zcq + o1q*(x&6) + mmsize*(x&1)]
437%define Z2(x) [zcq + o3q + mmsize*(x&1)]
438%define ZH(x) [zcq + o1q*(x&6) + mmsize*(x&1) + mmsize/2]
439%define Z2H(x) [zcq + o3q + mmsize*(x&1) + mmsize/2]
440
441%macro DECL_PASS 2+ ; name, payload
442align 16
443%1:
444DEFINE_ARGS zc, w, n, o1, o3
445 lea o3q, [nq*3]
446 lea o1q, [nq*8]
447 shl o3q, 4
448.loop:
449 %2
450 add zcq, mmsize*2
451 add wq, mmsize
452 sub nd, mmsize/8
453 jg .loop
454 rep ret
455%endmacro
456
457%macro FFT_DISPATCH 2; clobbers 5 GPRs, 8 XMMs
458 lea r2, [dispatch_tab%1]
459 mov r2, [r2 + (%2q-2)*gprsize]
460%ifdef PIC
461 lea r3, [$$]
462 add r2, r3
463%endif
464 call r2
465%endmacro ; FFT_DISPATCH
466
467INIT_YMM avx
468
469%if HAVE_AVX_EXTERNAL
470DECL_PASS pass_avx, PASS_BIG 1
471DECL_PASS pass_interleave_avx, PASS_BIG 0
472
473cglobal fft_calc, 2,5,8
474 mov r3d, [r0 + FFTContext.nbits]
475 mov r0, r1
476 mov r1, r3
477 FFT_DISPATCH _interleave %+ SUFFIX, r1
478 RET
479
480%endif
481
482INIT_XMM sse
483
484DECL_PASS pass_sse, PASS_BIG 1
485DECL_PASS pass_interleave_sse, PASS_BIG 0
486
487INIT_XMM sse
488cglobal fft_calc, 2,5,8
489 mov r3d, [r0 + FFTContext.nbits]
490 PUSH r1
491 PUSH r3
492 mov r0, r1
493 mov r1, r3
494 FFT_DISPATCH _interleave %+ SUFFIX, r1
495 POP rcx
496 POP r4
497 cmp rcx, 3+(mmsize/16)
498 jg .end
499 mov r2, -1
500 add rcx, 3
501 shl r2, cl
502 sub r4, r2
503.loop:
504 movaps xmm0, [r4 + r2]
505 movaps xmm1, xmm0
506 unpcklps xmm0, [r4 + r2 + 16]
507 unpckhps xmm1, [r4 + r2 + 16]
508 movaps [r4 + r2], xmm0
509 movaps [r4 + r2 + 16], xmm1
510 add r2, mmsize*2
511 jl .loop
512.end:
513 RET
514
515cglobal fft_permute, 2,7,1
516 mov r4, [r0 + FFTContext.revtab]
517 mov r5, [r0 + FFTContext.tmpbuf]
518 mov ecx, [r0 + FFTContext.nbits]
519 mov r2, 1
520 shl r2, cl
521 xor r0, r0
522%if ARCH_X86_32
523 mov r1, r1m
524%endif
525.loop:
526 movaps xmm0, [r1 + 8*r0]
527 movzx r6, word [r4 + 2*r0]
528 movzx r3, word [r4 + 2*r0 + 2]
529 movlps [r5 + 8*r6], xmm0
530 movhps [r5 + 8*r3], xmm0
531 add r0, 2
532 cmp r0, r2
533 jl .loop
534 shl r2, 3
535 add r1, r2
536 add r5, r2
537 neg r2
538; nbits >= 2 (FFT4) and sizeof(FFTComplex)=8 => at least 32B
539.loopcopy:
540 movaps xmm0, [r5 + r2]
541 movaps xmm1, [r5 + r2 + 16]
542 movaps [r1 + r2], xmm0
543 movaps [r1 + r2 + 16], xmm1
544 add r2, 32
545 jl .loopcopy
546 RET
547
548INIT_XMM sse
549cglobal imdct_calc, 3,5,3
550 mov r3d, [r0 + FFTContext.mdctsize]
551 mov r4, [r0 + FFTContext.imdcthalf]
552 add r1, r3
553 PUSH r3
554 PUSH r1
555%if ARCH_X86_32
556 push r2
557 push r1
558 push r0
559%else
560 sub rsp, 8+32*WIN64 ; allocate win64 shadow space
561%endif
562 call r4
563%if ARCH_X86_32
564 add esp, 12
565%else
566 add rsp, 8+32*WIN64
567%endif
568 POP r1
569 POP r3
570 lea r0, [r1 + 2*r3]
571 mov r2, r3
572 sub r3, mmsize
573 neg r2
574 mova m2, [ps_neg]
575.loop:
576 mova m0, [r1 + r3]
577 mova m1, [r0 + r2]
578 shufps m0, m0, 0x1b
579 shufps m1, m1, 0x1b
580 xorps m0, m2
581 mova [r0 + r3], m1
582 mova [r1 + r2], m0
583 sub r3, mmsize
584 add r2, mmsize
585 jl .loop
586 RET
587
588%ifdef PIC
589%define SECTION_REL - $$
590%else
591%define SECTION_REL
592%endif
593
594%macro DECL_FFT 1-2 ; nbits, suffix
595%ifidn %0, 1
596%xdefine fullsuffix SUFFIX
597%else
598%xdefine fullsuffix %2 %+ SUFFIX
599%endif
600%xdefine list_of_fft fft4 %+ SUFFIX SECTION_REL, fft8 %+ SUFFIX SECTION_REL
601%if %1>=5
602%xdefine list_of_fft list_of_fft, fft16 %+ SUFFIX SECTION_REL
603%endif
604%if %1>=6
605%xdefine list_of_fft list_of_fft, fft32 %+ fullsuffix SECTION_REL
606%endif
607
608%assign n 1<<%1
609%rep 18-%1
610%assign n2 n/2
611%assign n4 n/4
612%xdefine list_of_fft list_of_fft, fft %+ n %+ fullsuffix SECTION_REL
613
614align 16
615fft %+ n %+ fullsuffix:
616 call fft %+ n2 %+ SUFFIX
617 add r0, n*4 - (n&(-2<<%1))
618 call fft %+ n4 %+ SUFFIX
619 add r0, n*2 - (n2&(-2<<%1))
620 call fft %+ n4 %+ SUFFIX
621 sub r0, n*6 + (n2&(-2<<%1))
622 lea r1, [cos_ %+ n]
623 mov r2d, n4/2
624 jmp pass %+ fullsuffix
625
626%assign n n*2
627%endrep
628%undef n
629
630align 8
631dispatch_tab %+ fullsuffix: pointer list_of_fft
632%endmacro ; DECL_FFT
633
634%if HAVE_AVX_EXTERNAL
635INIT_YMM avx
636DECL_FFT 6
637DECL_FFT 6, _interleave
638%endif
639INIT_XMM sse
640DECL_FFT 5
641DECL_FFT 5, _interleave
642
643INIT_XMM sse
644%undef mulps
645%undef addps
646%undef subps
647%undef unpcklps
648%undef unpckhps
649
650%macro PREROTATER 5 ;-2*k, 2*k, input+n4, tcos+n8, tsin+n8
651 movaps xmm0, [%3+%2*4]
652 movaps xmm1, [%3+%1*4-0x10]
653 movaps xmm2, xmm0
654 shufps xmm0, xmm1, 0x88
655 shufps xmm1, xmm2, 0x77
656 movlps xmm4, [%4+%2*2]
657 movlps xmm5, [%5+%2*2+0x0]
658 movhps xmm4, [%4+%1*2-0x8]
659 movhps xmm5, [%5+%1*2-0x8]
660 movaps xmm2, xmm0
661 movaps xmm3, xmm1
662 mulps xmm0, xmm5
663 mulps xmm1, xmm4
664 mulps xmm2, xmm4
665 mulps xmm3, xmm5
666 subps xmm1, xmm0
667 addps xmm2, xmm3
668 movaps xmm0, xmm1
669 unpcklps xmm1, xmm2
670 unpckhps xmm0, xmm2
671%endmacro
672
673%macro CMUL 6 ;j, xmm0, xmm1, 3, 4, 5
674 mulps m6, %3, [%5+%1]
675 mulps m7, %2, [%5+%1]
676 mulps %2, %2, [%6+%1]
677 mulps %3, %3, [%6+%1]
678 subps %2, %2, m6
679 addps %3, %3, m7
680%endmacro
681
682%macro POSROTATESHUF 5 ;j, k, z+n8, tcos+n8, tsin+n8
683.post:
684%if cpuflag(avx)
685 vmovaps ymm1, [%3+%1*2]
686 vmovaps ymm0, [%3+%1*2+0x20]
687 vmovaps ymm3, [%3+%2*2]
688 vmovaps ymm2, [%3+%2*2+0x20]
689
690 CMUL %1, ymm0, ymm1, %3, %4, %5
691 CMUL %2, ymm2, ymm3, %3, %4, %5
692 vshufps ymm1, ymm1, ymm1, 0x1b
693 vshufps ymm3, ymm3, ymm3, 0x1b
694 vperm2f128 ymm1, ymm1, ymm1, 0x01
695 vperm2f128 ymm3, ymm3, ymm3, 0x01
696 vunpcklps ymm6, ymm2, ymm1
697 vunpckhps ymm4, ymm2, ymm1
698 vunpcklps ymm7, ymm0, ymm3
699 vunpckhps ymm5, ymm0, ymm3
700
701 vextractf128 [%3+%1*2], ymm7, 0
702 vextractf128 [%3+%1*2+0x10], ymm5, 0
703 vextractf128 [%3+%1*2+0x20], ymm7, 1
704 vextractf128 [%3+%1*2+0x30], ymm5, 1
705
706 vextractf128 [%3+%2*2], ymm6, 0
707 vextractf128 [%3+%2*2+0x10], ymm4, 0
708 vextractf128 [%3+%2*2+0x20], ymm6, 1
709 vextractf128 [%3+%2*2+0x30], ymm4, 1
710 sub %2, 0x20
711 add %1, 0x20
712 jl .post
713%else
714 movaps xmm1, [%3+%1*2]
715 movaps xmm0, [%3+%1*2+0x10]
716 CMUL %1, xmm0, xmm1, %3, %4, %5
717 movaps xmm5, [%3+%2*2]
718 movaps xmm4, [%3+%2*2+0x10]
719 CMUL %2, xmm4, xmm5, %3, %4, %5
720 shufps xmm1, xmm1, 0x1b
721 shufps xmm5, xmm5, 0x1b
722 movaps xmm6, xmm4
723 unpckhps xmm4, xmm1
724 unpcklps xmm6, xmm1
725 movaps xmm2, xmm0
726 unpcklps xmm0, xmm5
727 unpckhps xmm2, xmm5
728 movaps [%3+%2*2], xmm6
729 movaps [%3+%2*2+0x10], xmm4
730 movaps [%3+%1*2], xmm0
731 movaps [%3+%1*2+0x10], xmm2
732 sub %2, 0x10
733 add %1, 0x10
734 jl .post
735%endif
736%endmacro
737
738%macro DECL_IMDCT 0
739cglobal imdct_half, 3,12,8; FFTContext *s, FFTSample *output, const FFTSample *input
740%if ARCH_X86_64
741%define rrevtab r7
742%define rtcos r8
743%define rtsin r9
744%else
745%define rrevtab r6
746%define rtsin r6
747%define rtcos r5
748%endif
749 mov r3d, [r0+FFTContext.mdctsize]
750 add r2, r3
751 shr r3, 1
752 mov rtcos, [r0+FFTContext.tcos]
753 mov rtsin, [r0+FFTContext.tsin]
754 add rtcos, r3
755 add rtsin, r3
756%if ARCH_X86_64 == 0
757 push rtcos
758 push rtsin
759%endif
760 shr r3, 1
761 mov rrevtab, [r0+FFTContext.revtab]
762 add rrevtab, r3
763%if ARCH_X86_64 == 0
764 push rrevtab
765%endif
766
767 sub r3, 4
768%if ARCH_X86_64
769 xor r4, r4
770 sub r4, r3
771%endif
772.pre:
773%if ARCH_X86_64 == 0
774;unspill
775 xor r4, r4
776 sub r4, r3
777 mov rtcos, [esp+8]
778 mov rtsin, [esp+4]
779%endif
780
781 PREROTATER r4, r3, r2, rtcos, rtsin
782%if ARCH_X86_64
783 movzx r5, word [rrevtab+r4-4]
784 movzx r6, word [rrevtab+r4-2]
785 movzx r10, word [rrevtab+r3]
786 movzx r11, word [rrevtab+r3+2]
787 movlps [r1+r5 *8], xmm0
788 movhps [r1+r6 *8], xmm0
789 movlps [r1+r10*8], xmm1
790 movhps [r1+r11*8], xmm1
791 add r4, 4
792%else
793 mov r6, [esp]
794 movzx r5, word [r6+r4-4]
795 movzx r4, word [r6+r4-2]
796 movlps [r1+r5*8], xmm0
797 movhps [r1+r4*8], xmm0
798 movzx r5, word [r6+r3]
799 movzx r4, word [r6+r3+2]
800 movlps [r1+r5*8], xmm1
801 movhps [r1+r4*8], xmm1
802%endif
803 sub r3, 4
804 jns .pre
805
806 mov r5, r0
807 mov r6, r1
808 mov r0, r1
809 mov r1d, [r5+FFTContext.nbits]
810
811 FFT_DISPATCH SUFFIX, r1
812
813 mov r0d, [r5+FFTContext.mdctsize]
814 add r6, r0
815 shr r0, 1
816%if ARCH_X86_64 == 0
817%define rtcos r2
818%define rtsin r3
819 mov rtcos, [esp+8]
820 mov rtsin, [esp+4]
821%endif
822 neg r0
823 mov r1, -mmsize
824 sub r1, r0
825 POSROTATESHUF r0, r1, r6, rtcos, rtsin
826%if ARCH_X86_64 == 0
827 add esp, 12
828%endif
829 RET
830%endmacro
831
832DECL_IMDCT
833
834INIT_YMM avx
835
836%if HAVE_AVX_EXTERNAL
837DECL_IMDCT
838%endif
libavcodec/x86/fft.h+0−32
@@ -1,32 +0,0 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVCODEC_X86_FFT_H
20#define AVCODEC_X86_FFT_H
21
22#include "libavcodec/fft.h"
23
24void ff_fft_permute_sse(FFTContext *s, FFTComplex *z);
25void ff_fft_calc_avx(FFTContext *s, FFTComplex *z);
26void ff_fft_calc_sse(FFTContext *s, FFTComplex *z);
27
28void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input);
29void ff_imdct_half_sse(FFTContext *s, FFTSample *output, const FFTSample *input);
30void ff_imdct_half_avx(FFTContext *s, FFTSample *output, const FFTSample *input);
31
32#endif /* AVCODEC_X86_FFT_H */
libavcodec/x86/fft_init.c+0−47
@@ -1,47 +0,0 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "config.h"
20
21#include "libavutil/attributes.h"
22#include "libavutil/cpu.h"
23#include "libavutil/x86/cpu.h"
24
25#include "fft.h"
26
27av_cold void ff_fft_init_x86(FFTContext *s)
28{
29 int cpu_flags = av_get_cpu_flags();
30
31 if (s->nbits > 16)
32 return;
33
34 if (EXTERNAL_SSE(cpu_flags)) {
35 s->imdct_calc = ff_imdct_calc_sse;
36 s->imdct_half = ff_imdct_half_sse;
37 s->fft_permute = ff_fft_permute_sse;
38 s->fft_calc = ff_fft_calc_sse;
39 s->fft_permutation = FF_FFT_PERM_SWAP_LSBS;
40 }
41
42 if (EXTERNAL_AVX_FAST(cpu_flags) && s->nbits >= 5) {
43 s->imdct_half = ff_imdct_half_avx;
44 s->fft_calc = ff_fft_calc_avx;
45 s->fft_permutation = FF_FFT_PERM_AVX;
46 }
47}
tests/Makefile+0−1
@@ -181,7 +181,6 @@ include $(SRC_PATH)/tests/fate/enc_external.mak · 180 unmodified lines
181# Must be included after lavf-video.mak181# Must be included after lavf-video.mak
182include $(SRC_PATH)/tests/fate/ffmpeg.mak182include $(SRC_PATH)/tests/fate/ffmpeg.mak
183include $(SRC_PATH)/tests/fate/ffprobe.mak183include $(SRC_PATH)/tests/fate/ffprobe.mak
184include $(SRC_PATH)/tests/fate/fft.mak
185include $(SRC_PATH)/tests/fate/fifo-muxer.mak184include $(SRC_PATH)/tests/fate/fifo-muxer.mak
186include $(SRC_PATH)/tests/fate/filter-audio.mak185include $(SRC_PATH)/tests/fate/filter-audio.mak
187# Must be included after vcodec.mak186# Must be included after vcodec.mak
tests/fate/fft.mak+0−83
@@ -1,83 +0,0 @@
1define DEF_FFT
2FATE_DCT-$(CONFIG_DCT) += fate-dct1d-$(1) fate-idct1d-$(1)
3FATE_FFT-$(CONFIG_FFT) += fate-fft-$(1) fate-ifft-$(1)
4FATE_MDCT-$(CONFIG_MDCT) += fate-mdct-$(1) fate-imdct-$(1)
5FATE_RDFT-$(CONFIG_RDFT) += fate-rdft-$(1) fate-irdft-$(1)
6
7fate-fft-$(N): ARGS = -n$(1)
8fate-ifft-$(N): ARGS = -n$(1) -i
9fate-mdct-$(N): ARGS = -n$(1) -m
10fate-imdct-$(N): ARGS = -n$(1) -m -i
11fate-rdft-$(N): ARGS = -n$(1) -r
12fate-irdft-$(N): ARGS = -n$(1) -r -i
13fate-dct1d-$(N): ARGS = -n$(1) -d
14fate-idct1d-$(N): ARGS = -n$(1) -d -i
15endef
16
17$(foreach N, 4 5 6 7 8 9 10 11 12, $(eval $(call DEF_FFT,$(N))))
18
19fate-dct-float: $(FATE_DCT-yes)
20fate-fft-float: $(FATE_FFT-yes)
21fate-mdct-float: $(FATE_MDCT-yes)
22fate-rdft-float: $(FATE_RDFT-yes)
23
24FATE_FFT_ALL = $(FATE_DCT-yes) $(FATE_FFT-yes) $(FATE_MDCT-yes) $(FATE_RDFT-yes)
25
26$(FATE_FFT_ALL): libavcodec/tests/fft$(EXESUF)
27$(FATE_FFT_ALL): CMD = run libavcodec/tests/fft$(EXESUF) $(CPUFLAGS:%=-c%) $(ARGS)
28
29$(FATE_FFT_ALL): CMP = null
30
31define DEF_FFT_FIXED32
32FATE_FFT_FIXED32 += fate-fft-fixed32-$(1) fate-ifft-fixed32-$(1) \
33 fate-mdct-fixed32-$(1) fate-imdct-fixed32-$(1)
34
35fate-fft-fixed32-$(1): ARGS = -n$(1)
36fate-ifft-fixed32-$(1): ARGS = -n$(1) -i
37#fate-mdct-fixed32-$(1): ARGS = -n$(1) -m
38fate-imdct-fixed32-$(1): ARGS = -n$(1) -m -i
39endef
40
41$(foreach N, 4 5 6 7 8 9 10 11 12, $(eval $(call DEF_FFT_FIXED32,$(N))))
42
43fate-fft-fixed32: $(FATE_FFT_FIXED32)
44$(FATE_FFT_FIXED32): libavcodec/tests/fft-fixed32$(EXESUF)
45$(FATE_FFT_FIXED32): CMD = run libavcodec/tests/fft-fixed32$(EXESUF) $(CPUFLAGS:%=-c%) $(ARGS)
46$(FATE_FFT_FIXED32): CMP = null
47
48define DEF_AV_FFT
49FATE_AV_DCT-$(CONFIG_DCT) += fate-av-dct1d-$(1) fate-av-idct1d-$(1)
50FATE_AV_FFT-$(CONFIG_FFT) += fate-av-fft-$(1) fate-av-ifft-$(1)
51FATE_AV_MDCT-$(CONFIG_MDCT) += fate-av-mdct-$(1) fate-av-imdct-$(1)
52FATE_AV_RDFT-$(CONFIG_RDFT) += fate-av-rdft-$(1) fate-av-irdft-$(1)
53
54fate-av-fft-$(N): ARGS = -n$(1)
55fate-av-ifft-$(N): ARGS = -n$(1) -i
56fate-av-mdct-$(N): ARGS = -n$(1) -m
57fate-av-imdct-$(N): ARGS = -n$(1) -m -i
58fate-av-rdft-$(N): ARGS = -n$(1) -r
59fate-av-irdft-$(N): ARGS = -n$(1) -r -i
60fate-av-dct1d-$(N): ARGS = -n$(1) -d
61fate-av-idct1d-$(N): ARGS = -n$(1) -d -i
62endef
63
64$(foreach N, 4 5 6 7 8 9 10 11 12, $(eval $(call DEF_AV_FFT,$(N))))
65
66fate-av-dct-float: $(FATE_AV_DCT-yes)
67fate-av-fft-float: $(FATE_AV_FFT-yes)
68fate-av-mdct-float: $(FATE_AV_MDCT-yes)
69fate-av-rdft-float: $(FATE_AV_RDFT-yes)
70
71FATE_AV_FFT_ALL = $(FATE_AV_DCT-yes) $(FATE_AV_FFT-yes) $(FATE_AV_MDCT-yes) $(FATE_AV_RDFT-yes)
72
73$(FATE_AV_FFT_ALL): libavcodec/tests/avfft$(EXESUF)
74$(FATE_AV_FFT_ALL): CMD = run libavcodec/tests/avfft$(EXESUF) $(CPUFLAGS:%=-c%) $(ARGS)
75$(FATE_AV_FFT_ALL): CMP = null
76
77fate-dct: fate-dct-float
78fate-fft: fate-fft-float fate-fft-fixed32
79fate-mdct: fate-mdct-float
80fate-rdft: fate-rdft-float
81
82FATE-$(call ALLYES, AVCODEC FFT MDCT) += $(FATE_FFT_ALL) $(FATE_FFT_FIXED32) $(FATE_AV_FFT_ALL)
83fate-fft-all: $(FATE_FFT_ALL) $(FATE_FFT_FIXED32) $(FATE_AV_FFT_ALL)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t