avfft.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 AVCODEC_AVFFT_H
  19. #define AVCODEC_AVFFT_H
  20. /**
  21. * @file
  22. * @ingroup lavc_fft
  23. * FFT functions
  24. */
  25. /**
  26. * @defgroup lavc_fft FFT functions
  27. * @ingroup lavc_misc
  28. *
  29. * @{
  30. */
  31. typedef float FFTSample;
  32. typedef struct FFTComplex {
  33. FFTSample re, im;
  34. } FFTComplex;
  35. typedef struct FFTContext FFTContext;
  36. /**
  37. * Set up a complex FFT.
  38. * @param nbits log2 of the length of the input array
  39. * @param inverse if 0 perform the forward transform, if 1 perform the inverse
  40. */
  41. FFTContext *av_fft_init(int nbits, int inverse);
  42. /**
  43. * Do the permutation needed BEFORE calling ff_fft_calc().
  44. */
  45. void av_fft_permute(FFTContext *s, FFTComplex *z);
  46. /**
  47. * Do a complex FFT with the parameters defined in av_fft_init(). The
  48. * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
  49. */
  50. void av_fft_calc(FFTContext *s, FFTComplex *z);
  51. void av_fft_end(FFTContext *s);
  52. FFTContext *av_mdct_init(int nbits, int inverse, double scale);
  53. void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
  54. void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
  55. void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
  56. void av_mdct_end(FFTContext *s);
  57. /* Real Discrete Fourier Transform */
  58. enum RDFTransformType {
  59. DFT_R2C,
  60. IDFT_C2R,
  61. IDFT_R2C,
  62. DFT_C2R,
  63. };
  64. typedef struct RDFTContext RDFTContext;
  65. /**
  66. * Set up a real FFT.
  67. * @param nbits log2 of the length of the input array
  68. * @param trans the type of transform
  69. */
  70. RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
  71. void av_rdft_calc(RDFTContext *s, FFTSample *data);
  72. void av_rdft_end(RDFTContext *s);
  73. /* Discrete Cosine Transform */
  74. typedef struct DCTContext DCTContext;
  75. enum DCTTransformType {
  76. DCT_II = 0,
  77. DCT_III,
  78. DCT_I,
  79. DST_I,
  80. };
  81. /**
  82. * Set up DCT.
  83. * @param nbits size of the input array:
  84. * (1 << nbits) for DCT-II, DCT-III and DST-I
  85. * (1 << nbits) + 1 for DCT-I
  86. *
  87. * @note the first element of the input of DST-I is ignored
  88. */
  89. DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
  90. void av_dct_calc(DCTContext *s, FFTSample *data);
  91. void av_dct_end (DCTContext *s);
  92. /**
  93. * @}
  94. */
  95. #endif /* AVCODEC_AVFFT_H */