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.

107 lines
3.4KB

  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_H
  19. #define AVUTIL_TX_H
  20. #include <stdint.h>
  21. #include <stddef.h>
  22. typedef struct AVTXContext AVTXContext;
  23. typedef struct AVComplexFloat {
  24. float re, im;
  25. } AVComplexFloat;
  26. typedef struct AVComplexDouble {
  27. double re, im;
  28. } AVComplexDouble;
  29. typedef struct AVComplexInt32 {
  30. int32_t re, im;
  31. } AVComplexInt32;
  32. enum AVTXType {
  33. /**
  34. * Standard complex to complex FFT with sample data type AVComplexFloat.
  35. * Output is not 1/len normalized. Scaling currently unsupported.
  36. */
  37. AV_TX_FLOAT_FFT = 0,
  38. /**
  39. * Standard MDCT with sample data type of float and a scale type of
  40. * float. Length is the frame size, not the window size (which is 2x frame)
  41. */
  42. AV_TX_FLOAT_MDCT = 1,
  43. /**
  44. * Same as AV_TX_FLOAT_FFT with a data type of AVComplexDouble.
  45. */
  46. AV_TX_DOUBLE_FFT = 2,
  47. /**
  48. * Same as AV_TX_FLOAT_MDCT with data and scale type of double.
  49. */
  50. AV_TX_DOUBLE_MDCT = 3,
  51. /**
  52. * Same as AV_TX_FLOAT_FFT with a data type of AVComplexInt32.
  53. */
  54. AV_TX_INT32_FFT = 4,
  55. /**
  56. * Same as AV_TX_FLOAT_MDCT with data type of int32_t and scale type of float.
  57. * Only scale values less than or equal to 1.0 are supported.
  58. */
  59. AV_TX_INT32_MDCT = 5,
  60. };
  61. /**
  62. * Function pointer to a function to perform the transform.
  63. *
  64. * @note Using a different context than the one allocated during av_tx_init()
  65. * is not allowed.
  66. *
  67. * @param s the transform context
  68. * @param out the output array
  69. * @param in the input array
  70. * @param stride the input or output stride (depending on transform direction)
  71. * in bytes, currently implemented for all MDCT transforms
  72. */
  73. typedef void (*av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride);
  74. /**
  75. * Initialize a transform context with the given configuration
  76. * Currently power of two lengths from 4 to 131072 are supported, along with
  77. * any length decomposable to a power of two and either 3, 5 or 15.
  78. *
  79. * @param ctx the context to allocate, will be NULL on error
  80. * @param tx pointer to the transform function pointer to set
  81. * @param type type the type of transform
  82. * @param inv whether to do an inverse or a forward transform
  83. * @param len the size of the transform in samples
  84. * @param scale pointer to the value to scale the output if supported by type
  85. * @param flags currently unused
  86. *
  87. * @return 0 on success, negative error code on failure
  88. */
  89. int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type,
  90. int inv, int len, const void *scale, uint64_t flags);
  91. /**
  92. * Frees a context and sets ctx to NULL, does nothing when ctx == NULL
  93. */
  94. void av_tx_uninit(AVTXContext **ctx);
  95. #endif /* AVUTIL_TX_H */