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.

145 lines
2.8KB

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