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.

112 lines
3.5KB

  1. /*
  2. * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  3. * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * Libav is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef AVCODEC_FFT_H
  22. #define AVCODEC_FFT_H
  23. #include <stdint.h>
  24. #include "config.h"
  25. #include "libavutil/mem.h"
  26. #include "avfft.h"
  27. /* FFT computation */
  28. struct FFTContext {
  29. int nbits;
  30. int inverse;
  31. uint16_t *revtab;
  32. FFTComplex *tmp_buf;
  33. int mdct_size; /* size of MDCT (i.e. number of input data * 2) */
  34. int mdct_bits; /* n = 2^nbits */
  35. /* pre/post rotation tables */
  36. FFTSample *tcos;
  37. FFTSample *tsin;
  38. /**
  39. * Do the permutation needed BEFORE calling fft_calc().
  40. */
  41. void (*fft_permute)(struct FFTContext *s, FFTComplex *z);
  42. /**
  43. * Do a complex FFT with the parameters defined in ff_fft_init(). The
  44. * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
  45. */
  46. void (*fft_calc)(struct FFTContext *s, FFTComplex *z);
  47. void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
  48. void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
  49. void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
  50. int fft_permutation;
  51. #define FF_FFT_PERM_DEFAULT 0
  52. #define FF_FFT_PERM_SWAP_LSBS 1
  53. int mdct_permutation;
  54. #define FF_MDCT_PERM_NONE 0
  55. #define FF_MDCT_PERM_INTERLEAVE 1
  56. };
  57. #if CONFIG_HARDCODED_TABLES
  58. #define COSTABLE_CONST const
  59. #else
  60. #define COSTABLE_CONST
  61. #endif
  62. #define COSTABLE(size) \
  63. COSTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_cos_##size)[size/2]
  64. extern COSTABLE(16);
  65. extern COSTABLE(32);
  66. extern COSTABLE(64);
  67. extern COSTABLE(128);
  68. extern COSTABLE(256);
  69. extern COSTABLE(512);
  70. extern COSTABLE(1024);
  71. extern COSTABLE(2048);
  72. extern COSTABLE(4096);
  73. extern COSTABLE(8192);
  74. extern COSTABLE(16384);
  75. extern COSTABLE(32768);
  76. extern COSTABLE(65536);
  77. extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17];
  78. /**
  79. * Initialize the cosine table in ff_cos_tabs[index]
  80. * \param index index in ff_cos_tabs array of the table to initialize
  81. */
  82. void ff_init_ff_cos_tabs(int index);
  83. /**
  84. * Set up a complex FFT.
  85. * @param nbits log2 of the length of the input array
  86. * @param inverse if 0 perform the forward transform, if 1 perform the inverse
  87. */
  88. int ff_fft_init(FFTContext *s, int nbits, int inverse);
  89. void ff_fft_init_altivec(FFTContext *s);
  90. void ff_fft_init_mmx(FFTContext *s);
  91. void ff_fft_init_arm(FFTContext *s);
  92. void ff_fft_end(FFTContext *s);
  93. int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale);
  94. void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
  95. void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input);
  96. void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
  97. void ff_mdct_end(FFTContext *s);
  98. #endif /* AVCODEC_FFT_H */