aac_defines.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * AAC defines
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_AAC_DEFINES_H
  21. #define AVCODEC_AAC_DEFINES_H
  22. #ifndef USE_FIXED
  23. #define USE_FIXED 0
  24. #endif
  25. #if USE_FIXED
  26. #include "libavutil/softfloat.h"
  27. #define FFT_FLOAT 0
  28. #define FFT_FIXED_32 1
  29. #define AAC_RENAME(x) x ## _fixed
  30. #define AAC_RENAME_32(x) x ## _fixed_32
  31. typedef int INTFLOAT;
  32. typedef unsigned UINTFLOAT; ///< Equivalent to INTFLOAT, Used as temporal cast to avoid undefined sign overflow operations.
  33. typedef int64_t INT64FLOAT;
  34. typedef int16_t SHORTFLOAT;
  35. typedef SoftFloat AAC_FLOAT;
  36. typedef int AAC_SIGNE;
  37. #define FIXR(a) ((int)((a) * 1 + 0.5))
  38. #define FIXR10(a) ((int)((a) * 1024.0 + 0.5))
  39. #define Q23(a) (int)((a) * 8388608.0 + 0.5)
  40. #define Q30(x) (int)((x)*1073741824.0 + 0.5)
  41. #define Q31(x) (int)((x)*2147483648.0 + 0.5)
  42. #define RANGE15(x) x
  43. #define GET_GAIN(x, y) (-(y) * (1 << (x))) + 1024
  44. #define AAC_MUL16(x, y) (int)(((int64_t)(x) * (y) + 0x8000) >> 16)
  45. #define AAC_MUL26(x, y) (int)(((int64_t)(x) * (y) + 0x2000000) >> 26)
  46. #define AAC_MUL30(x, y) (int)(((int64_t)(x) * (y) + 0x20000000) >> 30)
  47. #define AAC_MUL31(x, y) (int)(((int64_t)(x) * (y) + 0x40000000) >> 31)
  48. #define AAC_MADD28(x, y, a, b) (int)((((int64_t)(x) * (y)) + \
  49. ((int64_t)(a) * (b)) + \
  50. 0x8000000) >> 28)
  51. #define AAC_MADD30(x, y, a, b) (int)((((int64_t)(x) * (y)) + \
  52. ((int64_t)(a) * (b)) + \
  53. 0x20000000) >> 30)
  54. #define AAC_MADD30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \
  55. ((int64_t)(a) * (b)) + \
  56. ((int64_t)(c) * (d)) + \
  57. ((int64_t)(e) * (f)) + \
  58. 0x20000000) >> 30)
  59. #define AAC_MSUB30(x, y, a, b) (int)((((int64_t)(x) * (y)) - \
  60. ((int64_t)(a) * (b)) + \
  61. 0x20000000) >> 30)
  62. #define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \
  63. ((int64_t)(a) * (b)) - \
  64. ((int64_t)(c) * (d)) - \
  65. ((int64_t)(e) * (f)) + \
  66. 0x20000000) >> 30)
  67. #define AAC_MSUB31_V3(x, y, z) (int)((((int64_t)(x) * (z)) - \
  68. ((int64_t)(y) * (z)) + \
  69. 0x40000000) >> 31)
  70. #define AAC_HALF_SUM(x, y) (((x) >> 1) + ((y) >> 1))
  71. #define AAC_SRA_R(x, y) (int)(((x) + (1 << ((y) - 1))) >> (y))
  72. #else
  73. #define FFT_FLOAT 1
  74. #define FFT_FIXED_32 0
  75. #define AAC_RENAME(x) x
  76. #define AAC_RENAME_32(x) x
  77. typedef float INTFLOAT;
  78. typedef float UINTFLOAT;
  79. typedef float INT64FLOAT;
  80. typedef float SHORTFLOAT;
  81. typedef float AAC_FLOAT;
  82. typedef unsigned AAC_SIGNE;
  83. #define FIXR(x) ((float)(x))
  84. #define FIXR10(x) ((float)(x))
  85. #define Q23(x) ((float)(x))
  86. #define Q30(x) ((float)(x))
  87. #define Q31(x) ((float)(x))
  88. #define RANGE15(x) (32768.0 * (x))
  89. #define GET_GAIN(x, y) powf((x), -(y))
  90. #define AAC_MUL16(x, y) ((x) * (y))
  91. #define AAC_MUL26(x, y) ((x) * (y))
  92. #define AAC_MUL30(x, y) ((x) * (y))
  93. #define AAC_MUL31(x, y) ((x) * (y))
  94. #define AAC_MADD28(x, y, a, b) ((x) * (y) + (a) * (b))
  95. #define AAC_MADD30(x, y, a, b) ((x) * (y) + (a) * (b))
  96. #define AAC_MADD30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) + \
  97. (c) * (d) + (e) * (f))
  98. #define AAC_MSUB30(x, y, a, b) ((x) * (y) - (a) * (b))
  99. #define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) - \
  100. (c) * (d) - (e) * (f))
  101. #define AAC_MSUB31_V3(x, y, z) ((x) - (y)) * (z)
  102. #define AAC_HALF_SUM(x, y) ((x) + (y)) * 0.5f
  103. #define AAC_SRA_R(x, y) (x)
  104. #endif /* USE_FIXED */
  105. #endif /* AVCODEC_AAC_DEFINES_H */