tx.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. enum AVTXType {
  27. /**
  28. * Standard complex to complex FFT with sample data type AVComplexFloat.
  29. * Scaling currently unsupported
  30. */
  31. AV_TX_FLOAT_FFT = 0,
  32. /**
  33. * Standard MDCT with sample data type of float and a scale type of
  34. * float. Length is the frame size, not the window size (which is 2x frame)
  35. */
  36. AV_TX_FLOAT_MDCT = 1,
  37. };
  38. /**
  39. * Function pointer to a function to perform the transform.
  40. *
  41. * @note Using a different context than the one allocated during av_tx_init()
  42. * is not allowed.
  43. *
  44. * @param s the transform context
  45. * @param out the output array
  46. * @param in the input array
  47. * @param stride the input or output stride (depending on transform direction)
  48. * in bytes, currently implemented for all MDCT transforms
  49. */
  50. typedef void (*av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride);
  51. /**
  52. * Initialize a transform context with the given configuration
  53. * Currently power of two lengths from 4 to 131072 are supported, along with
  54. * any length decomposable to a power of two and either 3, 5 or 15.
  55. *
  56. * @param ctx the context to allocate, will be NULL on error
  57. * @param tx pointer to the transform function pointer to set
  58. * @param type type the type of transform
  59. * @param inv whether to do an inverse or a forward transform
  60. * @param len the size of the transform in samples
  61. * @param scale pointer to the value to scale the output if supported by type
  62. * @param flags currently unused
  63. *
  64. * @return 0 on success, negative error code on failure
  65. */
  66. int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type,
  67. int inv, int len, const void *scale, uint64_t flags);
  68. /**
  69. * Frees a context and sets ctx to NULL, does nothing when ctx == NULL
  70. */
  71. void av_tx_uninit(AVTXContext **ctx);
  72. #endif /* AVUTIL_TX_H */