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.

90 lines
2.7KB

  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. 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. /**
  65. * Set up (Inverse)DCT.
  66. * @param nbits log2 of the length of the input array
  67. * @param inverse >0 forward transform, <0 inverse transform
  68. */
  69. DCTContext *av_dct_init(int nbits, int inverse);
  70. void av_dct_calc(DCTContext *s, FFTSample *data);
  71. void av_dct_end (DCTContext *s);
  72. #endif /* AVCODEC_AVFFT_H */