xref: /aosp_15_r20/external/libaom/aom_dsp/x86/fft_avx2.c (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2018, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *
4*77c1e3ccSAndroid Build Coastguard Worker  * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker  * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker  * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker #include <immintrin.h>
13*77c1e3ccSAndroid Build Coastguard Worker 
14*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_dsp_rtcd.h"
15*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/aom_dsp_common.h"
16*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/fft_common.h"
17*77c1e3ccSAndroid Build Coastguard Worker 
18*77c1e3ccSAndroid Build Coastguard Worker extern void aom_transpose_float_sse2(const float *A, float *B, int n);
19*77c1e3ccSAndroid Build Coastguard Worker extern void aom_fft_unpack_2d_output_sse2(const float *col_fft, float *output,
20*77c1e3ccSAndroid Build Coastguard Worker                                           int n);
21*77c1e3ccSAndroid Build Coastguard Worker 
22*77c1e3ccSAndroid Build Coastguard Worker // Generate the 1d forward transforms for float using _mm256
GEN_FFT_8(static inline void,avx2,float,__m256,_mm256_load_ps,_mm256_store_ps,_mm256_set1_ps,_mm256_add_ps,_mm256_sub_ps,_mm256_mul_ps)23*77c1e3ccSAndroid Build Coastguard Worker GEN_FFT_8(static inline void, avx2, float, __m256, _mm256_load_ps,
24*77c1e3ccSAndroid Build Coastguard Worker           _mm256_store_ps, _mm256_set1_ps, _mm256_add_ps, _mm256_sub_ps,
25*77c1e3ccSAndroid Build Coastguard Worker           _mm256_mul_ps)
26*77c1e3ccSAndroid Build Coastguard Worker GEN_FFT_16(static inline void, avx2, float, __m256, _mm256_load_ps,
27*77c1e3ccSAndroid Build Coastguard Worker            _mm256_store_ps, _mm256_set1_ps, _mm256_add_ps, _mm256_sub_ps,
28*77c1e3ccSAndroid Build Coastguard Worker            _mm256_mul_ps)
29*77c1e3ccSAndroid Build Coastguard Worker GEN_FFT_32(static inline void, avx2, float, __m256, _mm256_load_ps,
30*77c1e3ccSAndroid Build Coastguard Worker            _mm256_store_ps, _mm256_set1_ps, _mm256_add_ps, _mm256_sub_ps,
31*77c1e3ccSAndroid Build Coastguard Worker            _mm256_mul_ps)
32*77c1e3ccSAndroid Build Coastguard Worker 
33*77c1e3ccSAndroid Build Coastguard Worker void aom_fft8x8_float_avx2(const float *input, float *temp, float *output) {
34*77c1e3ccSAndroid Build Coastguard Worker   aom_fft_2d_gen(input, temp, output, 8, aom_fft1d_8_avx2,
35*77c1e3ccSAndroid Build Coastguard Worker                  aom_transpose_float_sse2, aom_fft_unpack_2d_output_sse2, 8);
36*77c1e3ccSAndroid Build Coastguard Worker }
37*77c1e3ccSAndroid Build Coastguard Worker 
aom_fft16x16_float_avx2(const float * input,float * temp,float * output)38*77c1e3ccSAndroid Build Coastguard Worker void aom_fft16x16_float_avx2(const float *input, float *temp, float *output) {
39*77c1e3ccSAndroid Build Coastguard Worker   aom_fft_2d_gen(input, temp, output, 16, aom_fft1d_16_avx2,
40*77c1e3ccSAndroid Build Coastguard Worker                  aom_transpose_float_sse2, aom_fft_unpack_2d_output_sse2, 8);
41*77c1e3ccSAndroid Build Coastguard Worker }
42*77c1e3ccSAndroid Build Coastguard Worker 
aom_fft32x32_float_avx2(const float * input,float * temp,float * output)43*77c1e3ccSAndroid Build Coastguard Worker void aom_fft32x32_float_avx2(const float *input, float *temp, float *output) {
44*77c1e3ccSAndroid Build Coastguard Worker   aom_fft_2d_gen(input, temp, output, 32, aom_fft1d_32_avx2,
45*77c1e3ccSAndroid Build Coastguard Worker                  aom_transpose_float_sse2, aom_fft_unpack_2d_output_sse2, 8);
46*77c1e3ccSAndroid Build Coastguard Worker }
47*77c1e3ccSAndroid Build Coastguard Worker 
48*77c1e3ccSAndroid Build Coastguard Worker // Generate the 1d inverse transforms for float using _mm256
GEN_IFFT_8(static inline void,avx2,float,__m256,_mm256_load_ps,_mm256_store_ps,_mm256_set1_ps,_mm256_add_ps,_mm256_sub_ps,_mm256_mul_ps)49*77c1e3ccSAndroid Build Coastguard Worker GEN_IFFT_8(static inline void, avx2, float, __m256, _mm256_load_ps,
50*77c1e3ccSAndroid Build Coastguard Worker            _mm256_store_ps, _mm256_set1_ps, _mm256_add_ps, _mm256_sub_ps,
51*77c1e3ccSAndroid Build Coastguard Worker            _mm256_mul_ps)
52*77c1e3ccSAndroid Build Coastguard Worker GEN_IFFT_16(static inline void, avx2, float, __m256, _mm256_load_ps,
53*77c1e3ccSAndroid Build Coastguard Worker             _mm256_store_ps, _mm256_set1_ps, _mm256_add_ps, _mm256_sub_ps,
54*77c1e3ccSAndroid Build Coastguard Worker             _mm256_mul_ps)
55*77c1e3ccSAndroid Build Coastguard Worker GEN_IFFT_32(static inline void, avx2, float, __m256, _mm256_load_ps,
56*77c1e3ccSAndroid Build Coastguard Worker             _mm256_store_ps, _mm256_set1_ps, _mm256_add_ps, _mm256_sub_ps,
57*77c1e3ccSAndroid Build Coastguard Worker             _mm256_mul_ps)
58*77c1e3ccSAndroid Build Coastguard Worker 
59*77c1e3ccSAndroid Build Coastguard Worker void aom_ifft8x8_float_avx2(const float *input, float *temp, float *output) {
60*77c1e3ccSAndroid Build Coastguard Worker   aom_ifft_2d_gen(input, temp, output, 8, aom_fft1d_8_float, aom_fft1d_8_avx2,
61*77c1e3ccSAndroid Build Coastguard Worker                   aom_ifft1d_8_avx2, aom_transpose_float_sse2, 8);
62*77c1e3ccSAndroid Build Coastguard Worker }
63*77c1e3ccSAndroid Build Coastguard Worker 
aom_ifft16x16_float_avx2(const float * input,float * temp,float * output)64*77c1e3ccSAndroid Build Coastguard Worker void aom_ifft16x16_float_avx2(const float *input, float *temp, float *output) {
65*77c1e3ccSAndroid Build Coastguard Worker   aom_ifft_2d_gen(input, temp, output, 16, aom_fft1d_16_float,
66*77c1e3ccSAndroid Build Coastguard Worker                   aom_fft1d_16_avx2, aom_ifft1d_16_avx2,
67*77c1e3ccSAndroid Build Coastguard Worker                   aom_transpose_float_sse2, 8);
68*77c1e3ccSAndroid Build Coastguard Worker }
69*77c1e3ccSAndroid Build Coastguard Worker 
aom_ifft32x32_float_avx2(const float * input,float * temp,float * output)70*77c1e3ccSAndroid Build Coastguard Worker void aom_ifft32x32_float_avx2(const float *input, float *temp, float *output) {
71*77c1e3ccSAndroid Build Coastguard Worker   aom_ifft_2d_gen(input, temp, output, 32, aom_fft1d_32_float,
72*77c1e3ccSAndroid Build Coastguard Worker                   aom_fft1d_32_avx2, aom_ifft1d_32_avx2,
73*77c1e3ccSAndroid Build Coastguard Worker                   aom_transpose_float_sse2, 8);
74*77c1e3ccSAndroid Build Coastguard Worker }
75