You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
6.1KB

  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. #ifndef AVUTIL_FLOAT_DSP_H
  19. #define AVUTIL_FLOAT_DSP_H
  20. typedef struct AVFloatDSPContext {
  21. /**
  22. * Calculate the product of two vectors of floats and store the result in
  23. * a vector of floats.
  24. *
  25. * @param dst output vector
  26. * constraints: 32-byte aligned
  27. * @param src0 first input vector
  28. * constraints: 32-byte aligned
  29. * @param src1 second input vector
  30. * constraints: 32-byte aligned
  31. * @param len number of elements in the input
  32. * constraints: multiple of 16
  33. */
  34. void (*vector_fmul)(float *dst, const float *src0, const float *src1,
  35. int len);
  36. /**
  37. * Multiply a vector of floats by a scalar float and add to
  38. * destination vector. Source and destination vectors must
  39. * overlap exactly or not at all.
  40. *
  41. * @param dst result vector
  42. * constraints: 32-byte aligned
  43. * @param src input vector
  44. * constraints: 32-byte aligned
  45. * @param mul scalar value
  46. * @param len length of vector
  47. * constraints: multiple of 16
  48. */
  49. void (*vector_fmac_scalar)(float *dst, const float *src, float mul,
  50. int len);
  51. /**
  52. * Multiply a vector of floats by a scalar float. Source and
  53. * destination vectors must overlap exactly or not at all.
  54. *
  55. * @param dst result vector
  56. * constraints: 16-byte aligned
  57. * @param src input vector
  58. * constraints: 16-byte aligned
  59. * @param mul scalar value
  60. * @param len length of vector
  61. * constraints: multiple of 4
  62. */
  63. void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
  64. int len);
  65. /**
  66. * Multiply a vector of double by a scalar double. Source and
  67. * destination vectors must overlap exactly or not at all.
  68. *
  69. * @param dst result vector
  70. * constraints: 32-byte aligned
  71. * @param src input vector
  72. * constraints: 32-byte aligned
  73. * @param mul scalar value
  74. * @param len length of vector
  75. * constraints: multiple of 8
  76. */
  77. void (*vector_dmul_scalar)(double *dst, const double *src, double mul,
  78. int len);
  79. /**
  80. * Overlap/add with window function.
  81. * Used primarily by MDCT-based audio codecs.
  82. * Source and destination vectors must overlap exactly or not at all.
  83. *
  84. * @param dst result vector
  85. * constraints: 16-byte aligned
  86. * @param src0 first source vector
  87. * constraints: 16-byte aligned
  88. * @param src1 second source vector
  89. * constraints: 16-byte aligned
  90. * @param win half-window vector
  91. * constraints: 16-byte aligned
  92. * @param len length of vector
  93. * constraints: multiple of 4
  94. */
  95. void (*vector_fmul_window)(float *dst, const float *src0,
  96. const float *src1, const float *win, int len);
  97. /**
  98. * Calculate the product of two vectors of floats, add a third vector of
  99. * floats and store the result in a vector of floats.
  100. *
  101. * @param dst output vector
  102. * constraints: 32-byte aligned
  103. * @param src0 first input vector
  104. * constraints: 32-byte aligned
  105. * @param src1 second input vector
  106. * constraints: 32-byte aligned
  107. * @param src1 third input vector
  108. * constraints: 32-byte aligned
  109. * @param len number of elements in the input
  110. * constraints: multiple of 16
  111. */
  112. void (*vector_fmul_add)(float *dst, const float *src0, const float *src1,
  113. const float *src2, int len);
  114. /**
  115. * Calculate the product of two vectors of floats, and store the result
  116. * in a vector of floats. The second vector of floats is iterated over
  117. * in reverse order.
  118. *
  119. * @param dst output vector
  120. * constraints: 32-byte aligned
  121. * @param src0 first input vector
  122. * constraints: 32-byte aligned
  123. * @param src1 second input vector
  124. * constraints: 32-byte aligned
  125. * @param src1 third input vector
  126. * constraints: 32-byte aligned
  127. * @param len number of elements in the input
  128. * constraints: multiple of 16
  129. */
  130. void (*vector_fmul_reverse)(float *dst, const float *src0,
  131. const float *src1, int len);
  132. /**
  133. * Calculate the sum and difference of two vectors of floats.
  134. *
  135. * @param v1 first input vector, sum output, 16-byte aligned
  136. * @param v2 second input vector, difference output, 16-byte aligned
  137. * @param len length of vectors, multiple of 4
  138. */
  139. void (*butterflies_float)(float *restrict v1, float *restrict v2, int len);
  140. } AVFloatDSPContext;
  141. /**
  142. * Initialize a float DSP context.
  143. *
  144. * @param fdsp float DSP context
  145. * @param strict setting to non-zero avoids using functions which may not be IEEE-754 compliant
  146. */
  147. void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int strict);
  148. void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp);
  149. void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict);
  150. void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp);
  151. void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp);
  152. #endif /* AVUTIL_FLOAT_DSP_H */