float_dsp_init.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #include "config.h"
  19. #include "libavutil/attributes.h"
  20. #include "libavutil/cpu.h"
  21. #include "libavutil/float_dsp.h"
  22. #include "cpu.h"
  23. #include "asm.h"
  24. void ff_vector_fmul_sse(float *dst, const float *src0, const float *src1,
  25. int len);
  26. void ff_vector_fmul_avx(float *dst, const float *src0, const float *src1,
  27. int len);
  28. void ff_vector_fmac_scalar_sse(float *dst, const float *src, float mul,
  29. int len);
  30. void ff_vector_fmac_scalar_avx(float *dst, const float *src, float mul,
  31. int len);
  32. void ff_vector_fmac_scalar_fma3(float *dst, const float *src, float mul,
  33. int len);
  34. void ff_vector_fmul_scalar_sse(float *dst, const float *src, float mul,
  35. int len);
  36. void ff_vector_dmac_scalar_sse2(double *dst, const double *src, double mul,
  37. int len);
  38. void ff_vector_dmac_scalar_avx(double *dst, const double *src, double mul,
  39. int len);
  40. void ff_vector_dmac_scalar_fma3(double *dst, const double *src, double mul,
  41. int len);
  42. void ff_vector_dmul_scalar_sse2(double *dst, const double *src,
  43. double mul, int len);
  44. void ff_vector_dmul_scalar_avx(double *dst, const double *src,
  45. double mul, int len);
  46. void ff_vector_fmul_window_3dnowext(float *dst, const float *src0,
  47. const float *src1, const float *win, int len);
  48. void ff_vector_fmul_window_sse(float *dst, const float *src0,
  49. const float *src1, const float *win, int len);
  50. void ff_vector_fmul_add_sse(float *dst, const float *src0, const float *src1,
  51. const float *src2, int len);
  52. void ff_vector_fmul_add_avx(float *dst, const float *src0, const float *src1,
  53. const float *src2, int len);
  54. void ff_vector_fmul_add_fma3(float *dst, const float *src0, const float *src1,
  55. const float *src2, int len);
  56. void ff_vector_fmul_reverse_sse(float *dst, const float *src0,
  57. const float *src1, int len);
  58. void ff_vector_fmul_reverse_avx(float *dst, const float *src0,
  59. const float *src1, int len);
  60. void ff_vector_fmul_reverse_avx2(float *dst, const float *src0,
  61. const float *src1, int len);
  62. float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order);
  63. void ff_butterflies_float_sse(float *av_restrict src0, float *av_restrict src1, int len);
  64. av_cold void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp)
  65. {
  66. int cpu_flags = av_get_cpu_flags();
  67. if (EXTERNAL_AMD3DNOWEXT(cpu_flags)) {
  68. fdsp->vector_fmul_window = ff_vector_fmul_window_3dnowext;
  69. }
  70. if (EXTERNAL_SSE(cpu_flags)) {
  71. fdsp->vector_fmul = ff_vector_fmul_sse;
  72. fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_sse;
  73. fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_sse;
  74. fdsp->vector_fmul_window = ff_vector_fmul_window_sse;
  75. fdsp->vector_fmul_add = ff_vector_fmul_add_sse;
  76. fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_sse;
  77. fdsp->scalarproduct_float = ff_scalarproduct_float_sse;
  78. fdsp->butterflies_float = ff_butterflies_float_sse;
  79. }
  80. if (EXTERNAL_SSE2(cpu_flags)) {
  81. fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_sse2;
  82. fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_sse2;
  83. }
  84. if (EXTERNAL_AVX_FAST(cpu_flags)) {
  85. fdsp->vector_fmul = ff_vector_fmul_avx;
  86. fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_avx;
  87. fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_avx;
  88. fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_avx;
  89. fdsp->vector_fmul_add = ff_vector_fmul_add_avx;
  90. fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_avx;
  91. }
  92. if (EXTERNAL_AVX2_FAST(cpu_flags)) {
  93. fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_avx2;
  94. }
  95. if (EXTERNAL_FMA3_FAST(cpu_flags)) {
  96. fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_fma3;
  97. fdsp->vector_fmul_add = ff_vector_fmul_add_fma3;
  98. fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_fma3;
  99. }
  100. }