float_dsp.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 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 floats by a scalar float. Source and
  54. * destination vectors must overlap exactly or not at all.
  55. *
  56. * @param dst result vector
  57. * constraints: 16-byte aligned
  58. * @param src input vector
  59. * constraints: 16-byte aligned
  60. * @param mul scalar value
  61. * @param len length of vector
  62. * constraints: multiple of 4
  63. */
  64. void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
  65. int len);
  66. /**
  67. * Multiply a vector of double by a scalar double. Source and
  68. * destination vectors must overlap exactly or not at all.
  69. *
  70. * @param dst result vector
  71. * constraints: 32-byte aligned
  72. * @param src input vector
  73. * constraints: 32-byte aligned
  74. * @param mul scalar value
  75. * @param len length of vector
  76. * constraints: multiple of 8
  77. */
  78. void (*vector_dmul_scalar)(double *dst, const double *src, double mul,
  79. int len);
  80. /**
  81. * Overlap/add with window function.
  82. * Used primarily by MDCT-based audio codecs.
  83. * Source and destination vectors must overlap exactly or not at all.
  84. *
  85. * @param dst result vector
  86. * constraints: 16-byte aligned
  87. * @param src0 first source vector
  88. * constraints: 16-byte aligned
  89. * @param src1 second source vector
  90. * constraints: 16-byte aligned
  91. * @param win half-window vector
  92. * constraints: 16-byte aligned
  93. * @param len length of vector
  94. * constraints: multiple of 4
  95. */
  96. void (*vector_fmul_window)(float *dst, const float *src0,
  97. const float *src1, const float *win, int len);
  98. /**
  99. * Calculate the product of two vectors of floats, add a third vector of
  100. * floats and store the result in a vector of floats.
  101. *
  102. * @param dst output vector
  103. * constraints: 32-byte aligned
  104. * @param src0 first input vector
  105. * constraints: 32-byte aligned
  106. * @param src1 second input vector
  107. * constraints: 32-byte aligned
  108. * @param src1 third input vector
  109. * constraints: 32-byte aligned
  110. * @param len number of elements in the input
  111. * constraints: multiple of 16
  112. */
  113. void (*vector_fmul_add)(float *dst, const float *src0, const float *src1,
  114. const float *src2, int len);
  115. /**
  116. * Calculate the product of two vectors of floats, and store the result
  117. * in a vector of floats. The second vector of floats is iterated over
  118. * in reverse order.
  119. *
  120. * @param dst output vector
  121. * constraints: 32-byte aligned
  122. * @param src0 first input vector
  123. * constraints: 32-byte aligned
  124. * @param src1 second input vector
  125. * constraints: 32-byte aligned
  126. * @param src1 third input vector
  127. * constraints: 32-byte aligned
  128. * @param len number of elements in the input
  129. * constraints: multiple of 16
  130. */
  131. void (*vector_fmul_reverse)(float *dst, const float *src0,
  132. const float *src1, int len);
  133. /**
  134. * Calculate the sum and difference of two vectors of floats.
  135. *
  136. * @param v1 first input vector, sum output, 16-byte aligned
  137. * @param v2 second input vector, difference output, 16-byte aligned
  138. * @param len length of vectors, multiple of 4
  139. */
  140. void (*butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len);
  141. /**
  142. * Calculate the scalar product of two vectors of floats.
  143. *
  144. * @param v1 first vector, 16-byte aligned
  145. * @param v2 second vector, 16-byte aligned
  146. * @param len length of vectors, multiple of 4
  147. *
  148. * @return sum of elementwise products
  149. */
  150. float (*scalarproduct_float)(const float *v1, const float *v2, int len);
  151. } AVFloatDSPContext;
  152. /**
  153. * Return the scalar product of two vectors.
  154. *
  155. * @param v1 first input vector
  156. * @param v2 first input vector
  157. * @param len number of elements
  158. *
  159. * @return sum of elementwise products
  160. */
  161. float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len);
  162. /**
  163. * Initialize a float DSP context.
  164. *
  165. * @param fdsp float DSP context
  166. * @param strict setting to non-zero avoids using functions which may not be IEEE-754 compliant
  167. */
  168. void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int strict);
  169. void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp);
  170. void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict);
  171. void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp);
  172. void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp);
  173. #endif /* AVUTIL_FLOAT_DSP_H */