fft-internal.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_FFT_INTERNAL_H
  19. #define AVCODEC_FFT_INTERNAL_H
  20. #if FFT_FLOAT
  21. #define FIX15(v) (v)
  22. #define sqrthalf (float)M_SQRT1_2
  23. #define BF(x, y, a, b) do { \
  24. x = a - b; \
  25. y = a + b; \
  26. } while (0)
  27. #define CMUL(dre, dim, are, aim, bre, bim) do { \
  28. (dre) = (are) * (bre) - (aim) * (bim); \
  29. (dim) = (are) * (bim) + (aim) * (bre); \
  30. } while (0)
  31. #else
  32. #define SCALE_FLOAT(a, bits) lrint((a) * (double)(1 << (bits)))
  33. #if FFT_FIXED_32
  34. #define CMUL(dre, dim, are, aim, bre, bim) do { \
  35. int64_t accu; \
  36. (accu) = (int64_t)(bre) * (are); \
  37. (accu) -= (int64_t)(bim) * (aim); \
  38. (dre) = (int)(((accu) + 0x40000000) >> 31); \
  39. (accu) = (int64_t)(bre) * (aim); \
  40. (accu) += (int64_t)(bim) * (are); \
  41. (dim) = (int)(((accu) + 0x40000000) >> 31); \
  42. } while (0)
  43. #define FIX15(a) av_clip(SCALE_FLOAT(a, 31), -2147483647, 2147483647)
  44. #else /* FFT_FIXED_32 */
  45. #include "fft.h"
  46. #include "mathops.h"
  47. void ff_mdct_calcw_c(FFTContext *s, FFTDouble *output, const FFTSample *input);
  48. #define FIX15(a) av_clip(SCALE_FLOAT(a, 15), -32767, 32767)
  49. #define sqrthalf ((int16_t)((1<<15)*M_SQRT1_2))
  50. #define BF(x, y, a, b) do { \
  51. x = (a - b) >> 1; \
  52. y = (a + b) >> 1; \
  53. } while (0)
  54. #define CMULS(dre, dim, are, aim, bre, bim, sh) do { \
  55. (dre) = (MUL16(are, bre) - MUL16(aim, bim)) >> sh; \
  56. (dim) = (MUL16(are, bim) + MUL16(aim, bre)) >> sh; \
  57. } while (0)
  58. #define CMUL(dre, dim, are, aim, bre, bim) \
  59. CMULS(dre, dim, are, aim, bre, bim, 15)
  60. #define CMULL(dre, dim, are, aim, bre, bim) \
  61. CMULS(dre, dim, are, aim, bre, bim, 0)
  62. #endif /* FFT_FIXED_32 */
  63. #endif /* FFT_FLOAT */
  64. #define ff_imdct_calc_c FFT_NAME(ff_imdct_calc_c)
  65. #define ff_imdct_half_c FFT_NAME(ff_imdct_half_c)
  66. #define ff_mdct_calc_c FFT_NAME(ff_mdct_calc_c)
  67. void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
  68. void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input);
  69. void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
  70. #endif /* AVCODEC_FFT_INTERNAL_H */