fixmul.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /* -----------------------------------------------------------------------------------------------------------
  2. Software License for The Fraunhofer FDK AAC Codec Library for Android
  3. © Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
  4. All rights reserved.
  5. 1. INTRODUCTION
  6. The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
  7. the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
  8. This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
  9. AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
  10. audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
  11. independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
  12. of the MPEG specifications.
  13. Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
  14. may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
  15. individually for the purpose of encoding or decoding bit streams in products that are compliant with
  16. the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
  17. these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
  18. software may already be covered under those patent licenses when it is used for those licensed purposes only.
  19. Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
  20. are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
  21. applications information and documentation.
  22. 2. COPYRIGHT LICENSE
  23. Redistribution and use in source and binary forms, with or without modification, are permitted without
  24. payment of copyright license fees provided that you satisfy the following conditions:
  25. You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
  26. your modifications thereto in source code form.
  27. You must retain the complete text of this software license in the documentation and/or other materials
  28. provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
  29. You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
  30. modifications thereto to recipients of copies in binary form.
  31. The name of Fraunhofer may not be used to endorse or promote products derived from this library without
  32. prior written permission.
  33. You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
  34. software or your modifications thereto.
  35. Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
  36. and the date of any change. For modified versions of the FDK AAC Codec, the term
  37. "Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
  38. "Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
  39. 3. NO PATENT LICENSE
  40. NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
  41. ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
  42. respect to this software.
  43. You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
  44. by appropriate patent licenses.
  45. 4. DISCLAIMER
  46. This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
  47. "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
  48. of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  49. CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
  50. including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
  51. or business interruption, however caused and on any theory of liability, whether in contract, strict
  52. liability, or tort (including negligence), arising in any way out of the use of this software, even if
  53. advised of the possibility of such damage.
  54. 5. CONTACT INFORMATION
  55. Fraunhofer Institute for Integrated Circuits IIS
  56. Attention: Audio and Multimedia Departments - FDK AAC LL
  57. Am Wolfsmantel 33
  58. 91058 Erlangen, Germany
  59. www.iis.fraunhofer.de/amm
  60. [email protected]
  61. ----------------------------------------------------------------------------------------------------------- */
  62. /*************************** Fraunhofer IIS FDK Tools **********************
  63. Author(s): Stefan Gewinner
  64. Description: fixed point multiplication
  65. ******************************************************************************/
  66. #if !defined(__FIXMUL_H__)
  67. #define __FIXMUL_H__
  68. #include "FDK_archdef.h"
  69. #include "machine_type.h"
  70. #if defined(__arm__)
  71. #include "arm/fixmul_arm.h"
  72. #elif defined(__aarch64__) || defined(__AARCH64EL__)
  73. #include "aarch64/fixmul_aarch64.h"
  74. #elif defined(__mips__) /* cppp replaced: elif */
  75. #include "mips/fixmul_mips.h"
  76. #elif defined(__x86__) /* cppp replaced: elif */
  77. #include "x86/fixmul_x86.h"
  78. #elif defined(__powerpc__)
  79. #include "ppc/fixmul_ppc.h"
  80. #endif /* all cores */
  81. /*************************************************************************
  82. *************************************************************************
  83. Software fallbacks for missing functions
  84. **************************************************************************
  85. **************************************************************************/
  86. #if !defined(FUNCTION_fixmuldiv2_DD)
  87. #define FUNCTION_fixmuldiv2_DD
  88. #if defined(_MSC_VER) || defined(__CC_ARM) || defined(__ANALOG_EXTENSIONS__) || defined(__TI_COMPILER_VERSION__)
  89. #pragma message ("Extremely slow implementation of fixmuldiv2_DD !!")
  90. #else
  91. #warning Extremely slow implementation of fixmuldiv2_DD !!
  92. #endif
  93. inline LONG fixmuldiv2_DD (const LONG a, const LONG b)
  94. {
  95. return (LONG) ((((INT64)a) * b) >> 32) ;
  96. }
  97. #endif
  98. #if !defined(FUNCTION_fixmuldiv2BitExact_DD)
  99. #define FUNCTION_fixmuldiv2BitExact_DD
  100. #if defined(_MSC_VER) || defined(__CC_ARM) || defined(__ANALOG_EXTENSIONS__) || defined(__TI_COMPILER_VERSION__)
  101. #pragma message ("Extremely slow implementation of fixmuldiv2BitExact_DD !!")
  102. #else
  103. #warning Extremely slow implementation of fixmuldiv2BitExact_DD !!
  104. #endif
  105. inline LONG fixmuldiv2BitExact_DD (const LONG a, const LONG b)
  106. {
  107. return (LONG) ((((INT64)a) * b) >> 32) ;
  108. }
  109. #endif
  110. #if !defined(FUNCTION_fixmul_DD)
  111. #define FUNCTION_fixmul_DD
  112. inline LONG fixmul_DD (const LONG a, const LONG b)
  113. { return fixmuldiv2_DD (a, b) << 1 ; }
  114. #endif
  115. #if !defined(FUNCTION_fixmulBitExact_DD)
  116. #define FUNCTION_fixmulBitExact_DD
  117. #if defined(_MSC_VER) || defined(__CC_ARM) || defined(__ANALOG_EXTENSIONS__) || defined(__TI_COMPILER_VERSION__) || defined(__XTENSA__)
  118. #pragma message ("Extremely slow implementation of fixmulBitExact_DD !!")
  119. #else
  120. #warning Extremely slow implementation of fixmulBitExact_DD !!
  121. #endif
  122. inline LONG fixmulBitExact_DD (const LONG a, const LONG b)
  123. {
  124. return ( (LONG) ((((INT64)a) * b) >> 32) ) << 1;
  125. }
  126. #endif
  127. #if !defined(FUNCTION_fixmuldiv2_SS)
  128. #define FUNCTION_fixmuldiv2_SS
  129. inline LONG fixmuldiv2_SS (const SHORT a, const SHORT b)
  130. { return ((LONG)a*b); }
  131. #endif
  132. #if !defined(FUNCTION_fixmul_SS)
  133. #define FUNCTION_fixmul_SS
  134. inline LONG fixmul_SS (const SHORT a, const SHORT b)
  135. { return (a*b) <<1; }
  136. #endif
  137. #if !defined(FUNCTION_fixmuldiv2_SD)
  138. #define FUNCTION_fixmuldiv2_SD
  139. inline LONG fixmuldiv2_SD (const SHORT a, const LONG b)
  140. #ifdef FUNCTION_fixmuldiv2_DS
  141. { return fixmuldiv2_DS(b, a); }
  142. #else
  143. { return fixmuldiv2_DD(FX_SGL2FX_DBL(a), b); }
  144. #endif
  145. #endif
  146. #if !defined(FUNCTION_fixmuldiv2_DS)
  147. #define FUNCTION_fixmuldiv2_DS
  148. inline LONG fixmuldiv2_DS (const LONG a, const SHORT b)
  149. #ifdef FUNCTION_fixmuldiv2_SD
  150. { return fixmuldiv2_SD(b, a); }
  151. #else
  152. { return fixmuldiv2_DD(a, FX_SGL2FX_DBL(b)); }
  153. #endif
  154. #endif
  155. #if !defined(FUNCTION_fixmuldiv2BitExact_SD)
  156. #define FUNCTION_fixmuldiv2BitExact_SD
  157. inline LONG fixmuldiv2BitExact_SD (const SHORT a, const LONG b)
  158. #ifdef FUNCTION_fixmuldiv2BitExact_DS
  159. { return fixmuldiv2BitExact_DS(b, a); }
  160. #else
  161. { return (LONG) ((((INT64)a) * b) >> 16) ; }
  162. #endif
  163. #endif
  164. #if !defined(FUNCTION_fixmuldiv2BitExact_DS)
  165. #define FUNCTION_fixmuldiv2BitExact_DS
  166. inline LONG fixmuldiv2BitExact_DS (const LONG a, const SHORT b)
  167. #ifdef FUNCTION_fixmuldiv2BitExact_SD
  168. { return fixmuldiv2BitExact_SD(b, a); }
  169. #else
  170. { return (LONG) ((((INT64)a) * b) >> 16) ; }
  171. #endif
  172. #endif
  173. #if !defined(FUNCTION_fixmul_SD)
  174. #define FUNCTION_fixmul_SD
  175. inline LONG fixmul_SD (const SHORT a, const LONG b) {
  176. #ifdef FUNCTION_fixmul_DS
  177. return fixmul_SD(b, a);
  178. #else
  179. return fixmuldiv2_SD (a, b) << 1 ;
  180. #endif
  181. }
  182. #endif
  183. #if !defined(FUNCTION_fixmul_DS)
  184. #define FUNCTION_fixmul_DS
  185. inline LONG fixmul_DS (const LONG a, const SHORT b) {
  186. #ifdef FUNCTION_fixmul_SD
  187. return fixmul_SD(b, a);
  188. #else
  189. return fixmuldiv2_DS(a, b) << 1 ;
  190. #endif
  191. }
  192. #endif
  193. #if !defined(FUNCTION_fixmulBitExact_SD)
  194. #define FUNCTION_fixmulBitExact_SD
  195. inline LONG fixmulBitExact_SD (const SHORT a, const LONG b)
  196. #ifdef FUNCTION_fixmulBitExact_DS
  197. { return fixmulBitExact_DS(b, a); }
  198. #else
  199. { return (LONG) (((((INT64)a) * b) >> 16) << 1); }
  200. #endif
  201. #endif
  202. #if !defined(FUNCTION_fixmulBitExact_DS)
  203. #define FUNCTION_fixmulBitExact_DS
  204. inline LONG fixmulBitExact_DS (const LONG a, const SHORT b)
  205. #ifdef FUNCTION_fixmulBitExact_SD
  206. { return fixmulBitExact_SD(b, a); }
  207. #else
  208. { return (LONG) (((((INT64)a) * b) >> 16) << 1); }
  209. #endif
  210. #endif
  211. #if !defined(FUNCTION_fixpow2div2_D)
  212. #ifdef ARCH_WA_16BITMULT
  213. #error Fallback for fixpow2div2_D is not 16 bit safe !
  214. #endif
  215. #define FUNCTION_fixpow2div2_D
  216. inline LONG fixpow2div2_D (const LONG a)
  217. { return fixmuldiv2_DD(a, a); }
  218. #endif
  219. #if !defined(FUNCTION_fixpow2_D)
  220. #ifdef ARCH_WA_16BITMULT
  221. #error Fallback for fixpow2_D is not 16 bit safe !
  222. #endif
  223. #define FUNCTION_fixpow2_D
  224. inline LONG fixpow2_D (const LONG a)
  225. { return fixpow2div2_D(a)<<1; }
  226. #endif
  227. #if !defined(FUNCTION_fixpow2div2_S)
  228. #define FUNCTION_fixpow2div2_S
  229. inline LONG fixpow2div2_S (const SHORT a)
  230. { return fixmuldiv2_SS(a, a); }
  231. #endif
  232. #if !defined(FUNCTION_fixpow2_S)
  233. #define FUNCTION_fixpow2_S
  234. inline LONG fixpow2_S (const SHORT a)
  235. { return fixpow2div2_S(a)<<1; }
  236. #endif
  237. #endif /* __FIXMUL_H__ */