2 * This file is part of FFmpeg.
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.
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.
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
21 #include "libavutil/attributes.h"
22 #include "libavutil/cpu.h"
23 #include "libavutil/float_dsp.h"
27 void ff_vector_fmul_sse(float *dst, const float *src0, const float *src1,
29 void ff_vector_fmul_avx(float *dst, const float *src0, const float *src1,
32 void ff_vector_dmul_sse2(double *dst, const double *src0, const double *src1,
34 void ff_vector_dmul_avx(double *dst, const double *src0, const double *src1,
37 void ff_vector_fmac_scalar_sse(float *dst, const float *src, float mul,
39 void ff_vector_fmac_scalar_avx(float *dst, const float *src, float mul,
41 void ff_vector_fmac_scalar_fma3(float *dst, const float *src, float mul,
44 void ff_vector_fmul_scalar_sse(float *dst, const float *src, float mul,
47 void ff_vector_dmac_scalar_sse2(double *dst, const double *src, double mul,
49 void ff_vector_dmac_scalar_avx(double *dst, const double *src, double mul,
51 void ff_vector_dmac_scalar_fma3(double *dst, const double *src, double mul,
54 void ff_vector_dmul_scalar_sse2(double *dst, const double *src,
56 void ff_vector_dmul_scalar_avx(double *dst, const double *src,
59 void ff_vector_fmul_window_3dnowext(float *dst, const float *src0,
60 const float *src1, const float *win, int len);
61 void ff_vector_fmul_window_sse(float *dst, const float *src0,
62 const float *src1, const float *win, int len);
64 void ff_vector_fmul_add_sse(float *dst, const float *src0, const float *src1,
65 const float *src2, int len);
66 void ff_vector_fmul_add_avx(float *dst, const float *src0, const float *src1,
67 const float *src2, int len);
68 void ff_vector_fmul_add_fma3(float *dst, const float *src0, const float *src1,
69 const float *src2, int len);
71 void ff_vector_fmul_reverse_sse(float *dst, const float *src0,
72 const float *src1, int len);
73 void ff_vector_fmul_reverse_avx(float *dst, const float *src0,
74 const float *src1, int len);
75 void ff_vector_fmul_reverse_avx2(float *dst, const float *src0,
76 const float *src1, int len);
78 float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order);
80 void ff_butterflies_float_sse(float *av_restrict src0, float *av_restrict src1, int len);
82 av_cold void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp)
84 int cpu_flags = av_get_cpu_flags();
86 if (EXTERNAL_AMD3DNOWEXT(cpu_flags)) {
87 fdsp->vector_fmul_window = ff_vector_fmul_window_3dnowext;
89 if (EXTERNAL_SSE(cpu_flags)) {
90 fdsp->vector_fmul = ff_vector_fmul_sse;
91 fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_sse;
92 fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_sse;
93 fdsp->vector_fmul_window = ff_vector_fmul_window_sse;
94 fdsp->vector_fmul_add = ff_vector_fmul_add_sse;
95 fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_sse;
96 fdsp->scalarproduct_float = ff_scalarproduct_float_sse;
97 fdsp->butterflies_float = ff_butterflies_float_sse;
99 if (EXTERNAL_SSE2(cpu_flags)) {
100 fdsp->vector_dmul = ff_vector_dmul_sse2;
101 fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_sse2;
102 fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_sse2;
104 if (EXTERNAL_AVX_FAST(cpu_flags)) {
105 fdsp->vector_fmul = ff_vector_fmul_avx;
106 fdsp->vector_dmul = ff_vector_dmul_avx;
107 fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_avx;
108 fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_avx;
109 fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_avx;
110 fdsp->vector_fmul_add = ff_vector_fmul_add_avx;
111 fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_avx;
113 if (EXTERNAL_AVX2_FAST(cpu_flags)) {
114 fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_avx2;
116 if (EXTERNAL_FMA3_FAST(cpu_flags)) {
117 fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_fma3;
118 fdsp->vector_fmul_add = ff_vector_fmul_add_fma3;
119 fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_fma3;