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.

106 lines
3.5KB

  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_TX_PRIV_H
  19. #define AVUTIL_TX_PRIV_H
  20. #include "tx.h"
  21. #include <stddef.h>
  22. #include "thread.h"
  23. #include "mem.h"
  24. #include "avassert.h"
  25. #include "attributes.h"
  26. #ifdef TX_FLOAT
  27. #define TX_NAME(x) x ## _float
  28. typedef float FFTSample;
  29. typedef AVComplexFloat FFTComplex;
  30. #elif defined(TX_DOUBLE)
  31. #define TX_NAME(x) x ## _double
  32. typedef double FFTSample;
  33. typedef AVComplexDouble FFTComplex;
  34. #else
  35. typedef void FFTComplex;
  36. #endif
  37. #if defined(TX_FLOAT) || defined(TX_DOUBLE)
  38. #define BF(x, y, a, b) do { \
  39. x = (a) - (b); \
  40. y = (a) + (b); \
  41. } while (0)
  42. #define CMUL(dre, dim, are, aim, bre, bim) do { \
  43. (dre) = (are) * (bre) - (aim) * (bim); \
  44. (dim) = (are) * (bim) + (aim) * (bre); \
  45. } while (0)
  46. #endif
  47. #define CMUL3(c, a, b) \
  48. CMUL((c).re, (c).im, (a).re, (a).im, (b).re, (b).im)
  49. #define COSTABLE(size) \
  50. DECLARE_ALIGNED(32, FFTSample, TX_NAME(ff_cos_##size))[size/2]
  51. /* Used by asm, reorder with care */
  52. struct AVTXContext {
  53. int n; /* Nptwo part */
  54. int m; /* Ptwo part */
  55. int inv; /* Is inverted */
  56. int type; /* Type */
  57. FFTComplex *exptab; /* MDCT exptab */
  58. FFTComplex *tmp; /* Temporary buffer needed for all compound transforms */
  59. int *pfatab; /* Input/Output mapping for compound transforms */
  60. int *revtab; /* Input mapping for power of two transforms */
  61. };
  62. /* Shared functions */
  63. int ff_tx_gen_compound_mapping(AVTXContext *s);
  64. int ff_tx_gen_ptwo_revtab(AVTXContext *s);
  65. /* Also used by SIMD init */
  66. static inline int split_radix_permutation(int i, int n, int inverse)
  67. {
  68. int m;
  69. if (n <= 2)
  70. return i & 1;
  71. m = n >> 1;
  72. if (!(i & m))
  73. return split_radix_permutation(i, m, inverse)*2;
  74. m >>= 1;
  75. if (inverse == !(i & m))
  76. return split_radix_permutation(i, m, inverse)*4 + 1;
  77. else
  78. return split_radix_permutation(i, m, inverse)*4 - 1;
  79. }
  80. /* Templated functions */
  81. int ff_tx_init_mdct_fft_float(AVTXContext *s, av_tx_fn *tx,
  82. enum AVTXType type, int inv, int len,
  83. const void *scale, uint64_t flags);
  84. int ff_tx_init_mdct_fft_double(AVTXContext *s, av_tx_fn *tx,
  85. enum AVTXType type, int inv, int len,
  86. const void *scale, uint64_t flags);
  87. typedef struct CosTabsInitOnce {
  88. void (*func)(void);
  89. AVOnce control;
  90. } CosTabsInitOnce;
  91. #endif /* AVUTIL_TX_PRIV_H */