avfft.h 2.8 KB

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