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.

143 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. #include "libavutil/mem.h"
  19. #include "avfft.h"
  20. #include "fft.h"
  21. /* FFT */
  22. FFTContext *av_fft_init(int nbits, int inverse)
  23. {
  24. FFTContext *s = av_malloc(sizeof(*s));
  25. if (s)
  26. ff_fft_init(s, nbits, inverse);
  27. return s;
  28. }
  29. void av_fft_permute(FFTContext *s, FFTComplex *z)
  30. {
  31. s->fft_permute(s, z);
  32. }
  33. void av_fft_calc(FFTContext *s, FFTComplex *z)
  34. {
  35. s->fft_calc(s, z);
  36. }
  37. void av_fft_end(FFTContext *s)
  38. {
  39. if (s) {
  40. ff_fft_end(s);
  41. av_free(s);
  42. }
  43. }
  44. #if CONFIG_MDCT
  45. FFTContext *av_mdct_init(int nbits, int inverse, double scale)
  46. {
  47. FFTContext *s = av_malloc(sizeof(*s));
  48. if (s)
  49. ff_mdct_init(s, nbits, inverse, scale);
  50. return s;
  51. }
  52. void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
  53. {
  54. s->imdct_calc(s, output, input);
  55. }
  56. void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
  57. {
  58. s->imdct_half(s, output, input);
  59. }
  60. void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
  61. {
  62. s->mdct_calc(s, output, input);
  63. }
  64. void av_mdct_end(FFTContext *s)
  65. {
  66. if (s) {
  67. ff_mdct_end(s);
  68. av_free(s);
  69. }
  70. }
  71. #endif /* CONFIG_MDCT */
  72. #if CONFIG_RDFT
  73. RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans)
  74. {
  75. RDFTContext *s = av_malloc(sizeof(*s));
  76. if (s)
  77. ff_rdft_init(s, nbits, trans);
  78. return s;
  79. }
  80. void av_rdft_calc(RDFTContext *s, FFTSample *data)
  81. {
  82. ff_rdft_calc(s, data);
  83. }
  84. void av_rdft_end(RDFTContext *s)
  85. {
  86. if (s) {
  87. ff_rdft_end(s);
  88. av_free(s);
  89. }
  90. }
  91. #endif /* CONFIG_RDFT */
  92. #if CONFIG_DCT
  93. DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse)
  94. {
  95. DCTContext *s = av_malloc(sizeof(*s));
  96. if (s)
  97. ff_dct_init(s, nbits, inverse);
  98. return s;
  99. }
  100. void av_dct_calc(DCTContext *s, FFTSample *data)
  101. {
  102. ff_dct_calc(s, data);
  103. }
  104. void av_dct_end(DCTContext *s)
  105. {
  106. if (s) {
  107. ff_dct_end(s);
  108. av_free(s);
  109. }
  110. }
  111. #endif /* CONFIG_DCT */