float_dsp.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. #include "config.h"
  21. typedef struct AVFloatDSPContext {
  22. /**
  23. * Calculate the entry wise product of two vectors of floats and store the result in
  24. * a vector of floats.
  25. *
  26. * @param dst output vector
  27. * constraints: 32-byte aligned
  28. * @param src0 first input vector
  29. * constraints: 32-byte aligned
  30. * @param src1 second input vector
  31. * constraints: 32-byte aligned
  32. * @param len number of elements in the input
  33. * constraints: multiple of 16
  34. */
  35. void (*vector_fmul)(float *dst, const float *src0, const float *src1,
  36. int len);
  37. /**
  38. * Multiply a vector of floats by a scalar float and add to
  39. * destination vector. Source and destination vectors must
  40. * overlap exactly or not at all.
  41. *
  42. * @param dst result vector
  43. * constraints: 32-byte aligned
  44. * @param src input vector
  45. * constraints: 32-byte aligned
  46. * @param mul scalar value
  47. * @param len length of vector
  48. * constraints: multiple of 16
  49. */
  50. void (*vector_fmac_scalar)(float *dst, const float *src, float mul,
  51. int len);
  52. /**
  53. * Multiply a vector of doubles by a scalar double and add to
  54. * destination vector. Source and destination vectors must
  55. * overlap exactly or not at all.
  56. *
  57. * @param dst result vector
  58. * constraints: 32-byte aligned
  59. * @param src input vector
  60. * constraints: 32-byte aligned
  61. * @param mul scalar value
  62. * @param len length of vector
  63. * constraints: multiple of 16
  64. */
  65. void (*vector_dmac_scalar)(double *dst, const double *src, double mul,
  66. int len);
  67. /**
  68. * Multiply a vector of floats by a scalar float. Source and
  69. * destination vectors must overlap exactly or not at all.
  70. *
  71. * @param dst result vector
  72. * constraints: 16-byte aligned
  73. * @param src input vector
  74. * constraints: 16-byte aligned
  75. * @param mul scalar value
  76. * @param len length of vector
  77. * constraints: multiple of 4
  78. */
  79. void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
  80. int len);
  81. /**
  82. * Multiply a vector of double by a scalar double. Source and
  83. * destination vectors must overlap exactly or not at all.
  84. *
  85. * @param dst result vector
  86. * constraints: 32-byte aligned
  87. * @param src input vector
  88. * constraints: 32-byte aligned
  89. * @param mul scalar value
  90. * @param len length of vector
  91. * constraints: multiple of 8
  92. */
  93. void (*vector_dmul_scalar)(double *dst, const double *src, double mul,
  94. int len);
  95. /**
  96. * Overlap/add with window function.
  97. * Used primarily by MDCT-based audio codecs.
  98. * Source and destination vectors must overlap exactly or not at all.
  99. *
  100. * @param dst result vector
  101. * constraints: 16-byte aligned
  102. * @param src0 first source vector
  103. * constraints: 16-byte aligned
  104. * @param src1 second source vector
  105. * constraints: 16-byte aligned
  106. * @param win half-window vector
  107. * constraints: 16-byte aligned
  108. * @param len length of vector
  109. * constraints: multiple of 4
  110. */
  111. void (*vector_fmul_window)(float *dst, const float *src0,
  112. const float *src1, const float *win, int len);
  113. /**
  114. * Calculate the entry wise product of two vectors of floats, add a third vector of
  115. * floats and store the result in a vector of floats.
  116. *
  117. * @param dst output vector
  118. * constraints: 32-byte aligned
  119. * @param src0 first input vector
  120. * constraints: 32-byte aligned
  121. * @param src1 second input vector
  122. * constraints: 32-byte aligned
  123. * @param src2 third input vector
  124. * constraints: 32-byte aligned
  125. * @param len number of elements in the input
  126. * constraints: multiple of 16
  127. */
  128. void (*vector_fmul_add)(float *dst, const float *src0, const float *src1,
  129. const float *src2, int len);
  130. /**
  131. * Calculate the entry wise product of two vectors of floats, and store the result
  132. * in a vector of floats. The second vector of floats is iterated over
  133. * in reverse order.
  134. *
  135. * @param dst output vector
  136. * constraints: 32-byte aligned
  137. * @param src0 first input vector
  138. * constraints: 32-byte aligned
  139. * @param src1 second input vector
  140. * constraints: 32-byte aligned
  141. * @param len number of elements in the input
  142. * constraints: multiple of 16
  143. */
  144. void (*vector_fmul_reverse)(float *dst, const float *src0,
  145. const float *src1, int len);
  146. /**
  147. * Calculate the sum and difference of two vectors of floats.
  148. *
  149. * @param v1 first input vector, sum output, 16-byte aligned
  150. * @param v2 second input vector, difference output, 16-byte aligned
  151. * @param len length of vectors, multiple of 4
  152. */
  153. void (*butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len);
  154. /**
  155. * Calculate the scalar product of two vectors of floats.
  156. *
  157. * @param v1 first vector, 16-byte aligned
  158. * @param v2 second vector, 16-byte aligned
  159. * @param len length of vectors, multiple of 4
  160. *
  161. * @return sum of elementwise products
  162. */
  163. float (*scalarproduct_float)(const float *v1, const float *v2, int len);
  164. /**
  165. * Calculate the entry wise product of two vectors of doubles and store the result in
  166. * a vector of doubles.
  167. *
  168. * @param dst output vector
  169. * constraints: 32-byte aligned
  170. * @param src0 first input vector
  171. * constraints: 32-byte aligned
  172. * @param src1 second input vector
  173. * constraints: 32-byte aligned
  174. * @param len number of elements in the input
  175. * constraints: multiple of 16
  176. */
  177. void (*vector_dmul)(double *dst, const double *src0, const double *src1,
  178. int len);
  179. } AVFloatDSPContext;
  180. /**
  181. * Return the scalar product of two vectors.
  182. *
  183. * @param v1 first input vector
  184. * @param v2 first input vector
  185. * @param len number of elements
  186. *
  187. * @return sum of elementwise products
  188. */
  189. float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len);
  190. void ff_float_dsp_init_aarch64(AVFloatDSPContext *fdsp);
  191. void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp);
  192. void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict);
  193. void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp);
  194. void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp);
  195. /**
  196. * Allocate a float DSP context.
  197. *
  198. * @param strict setting to non-zero avoids using functions which may not be IEEE-754 compliant
  199. */
  200. AVFloatDSPContext *avpriv_float_dsp_alloc(int strict);
  201. #endif /* AVUTIL_FLOAT_DSP_H */