fixmadd.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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): M. Lohwasser, M. Gayer
  64. Description: fixed point intrinsics
  65. ******************************************************************************/
  66. #if !defined(__FIXMADD_H__)
  67. #define __FIXMADD_H__
  68. #include "FDK_archdef.h"
  69. #include "machine_type.h"
  70. #include "fixmul.h"
  71. #if defined(__arm__)
  72. #include "arm/fixmadd_arm.h"
  73. #elif defined(__mips__) /* cppp replaced: elif */
  74. #include "mips/fixmadd_mips.h"
  75. #endif /* all cores */
  76. /*************************************************************************
  77. *************************************************************************
  78. Software fallbacks for missing functions.
  79. **************************************************************************
  80. **************************************************************************/
  81. /* Divide by two versions. */
  82. #if !defined(FUNCTION_fixmadddiv2_DD)
  83. inline FIXP_DBL fixmadddiv2_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b)
  84. { return (x + fMultDiv2 (a, b)); }
  85. #endif
  86. #if !defined(FUNCTION_fixmadddiv2_SD)
  87. inline FIXP_DBL fixmadddiv2_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
  88. #ifdef FUNCTION_fixmadddiv2_DS
  89. return fixmadddiv2_DS(x, b, a);
  90. #else
  91. return fixmadddiv2_DD(x, FX_SGL2FX_DBL(a), b);
  92. #endif
  93. }
  94. #endif
  95. #if !defined(FUNCTION_fixmadddiv2_DS)
  96. inline FIXP_DBL fixmadddiv2_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
  97. #ifdef FUNCTION_fixmadddiv2_SD
  98. return fixmadddiv2_SD(x, b, a);
  99. #else
  100. return fixmadddiv2_DD(x, a, FX_SGL2FX_DBL(b));
  101. #endif
  102. }
  103. #endif
  104. #if !defined(FUNCTION_fixmadddiv2_SS)
  105. inline FIXP_DBL fixmadddiv2_SS (FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b)
  106. { return x + fMultDiv2(a,b); }
  107. #endif
  108. #if !defined(FUNCTION_fixmsubdiv2_DD)
  109. inline FIXP_DBL fixmsubdiv2_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b)
  110. { return (x - fMultDiv2 (a, b)); }
  111. #endif
  112. #if !defined(FUNCTION_fixmsubdiv2_SD)
  113. inline FIXP_DBL fixmsubdiv2_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
  114. #ifdef FUNCTION_fixmsubdiv2_DS
  115. return fixmsubdiv2_DS(x, b, a);
  116. #else
  117. return fixmsubdiv2_DD(x, FX_SGL2FX_DBL(a), b);
  118. #endif
  119. }
  120. #endif
  121. #if !defined(FUNCTION_fixmsubdiv2_DS)
  122. inline FIXP_DBL fixmsubdiv2_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
  123. #ifdef FUNCTION_fixmsubdiv2_SD
  124. return fixmsubdiv2_SD(x, b, a);
  125. #else
  126. return fixmsubdiv2_DD(x, a, FX_SGL2FX_DBL(b));
  127. #endif
  128. }
  129. #endif
  130. #if !defined(FUNCTION_fixmsubdiv2_SS)
  131. inline FIXP_DBL fixmsubdiv2_SS (FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b)
  132. { return x - fMultDiv2(a,b); }
  133. #endif
  134. #if !defined(FUNCTION_fixmadddiv2BitExact_DD)
  135. #define FUNCTION_fixmadddiv2BitExact_DD
  136. inline FIXP_DBL fixmadddiv2BitExact_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
  137. return x + fMultDiv2BitExact(a, b);
  138. }
  139. #endif
  140. #if !defined(FUNCTION_fixmadddiv2BitExact_SD)
  141. #define FUNCTION_fixmadddiv2BitExact_SD
  142. inline FIXP_DBL fixmadddiv2BitExact_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
  143. #ifdef FUNCTION_fixmadddiv2BitExact_DS
  144. return fixmadddiv2BitExact_DS(x, b, a);
  145. #else
  146. return x + fMultDiv2BitExact(a, b);
  147. #endif
  148. }
  149. #endif
  150. #if !defined(FUNCTION_fixmadddiv2BitExact_DS)
  151. #define FUNCTION_fixmadddiv2BitExact_DS
  152. inline FIXP_DBL fixmadddiv2BitExact_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
  153. #ifdef FUNCTION_fixmadddiv2BitExact_SD
  154. return fixmadddiv2BitExact_SD(x, b, a);
  155. #else
  156. return x + fMultDiv2BitExact(a, b);
  157. #endif
  158. }
  159. #endif
  160. #if !defined(FUNCTION_fixmsubdiv2BitExact_DD)
  161. #define FUNCTION_fixmsubdiv2BitExact_DD
  162. inline FIXP_DBL fixmsubdiv2BitExact_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
  163. return x - fMultDiv2BitExact(a, b);
  164. }
  165. #endif
  166. #if !defined(FUNCTION_fixmsubdiv2BitExact_SD)
  167. #define FUNCTION_fixmsubdiv2BitExact_SD
  168. inline FIXP_DBL fixmsubdiv2BitExact_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
  169. #ifdef FUNCTION_fixmsubdiv2BitExact_DS
  170. return fixmsubdiv2BitExact_DS(x, b, a);
  171. #else
  172. return x - fMultDiv2BitExact(a, b);
  173. #endif
  174. }
  175. #endif
  176. #if !defined(FUNCTION_fixmsubdiv2BitExact_DS)
  177. #define FUNCTION_fixmsubdiv2BitExact_DS
  178. inline FIXP_DBL fixmsubdiv2BitExact_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
  179. #ifdef FUNCTION_fixmsubdiv2BitExact_SD
  180. return fixmsubdiv2BitExact_SD(x, b, a);
  181. #else
  182. return x - fMultDiv2BitExact(a, b);
  183. #endif
  184. }
  185. #endif
  186. /* Normal versions */
  187. #if !defined(FUNCTION_fixmadd_DD)
  188. inline FIXP_DBL fixmadd_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b)
  189. { return fixmadddiv2_DD(x,a,b)<<1; }
  190. #endif
  191. #if !defined(FUNCTION_fixmadd_SD)
  192. inline FIXP_DBL fixmadd_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
  193. #ifdef FUNCTION_fixmadd_DS
  194. return fixmadd_DS(x, b, a);
  195. #else
  196. return fixmadd_DD(x, FX_SGL2FX_DBL(a), b);
  197. #endif
  198. }
  199. #endif
  200. #if !defined(FUNCTION_fixmadd_DS)
  201. inline FIXP_DBL fixmadd_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
  202. #ifdef FUNCTION_fixmadd_SD
  203. return fixmadd_SD(x, b, a);
  204. #else
  205. return fixmadd_DD(x, a, FX_SGL2FX_DBL(b));
  206. #endif
  207. }
  208. #endif
  209. #if !defined(FUNCTION_fixmadd_SS)
  210. inline FIXP_DBL fixmadd_SS (FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b)
  211. { return (x + fMultDiv2(a,b))<<1; }
  212. #endif
  213. #if !defined(FUNCTION_fixmsub_DD)
  214. inline FIXP_DBL fixmsub_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b)
  215. { return fixmsubdiv2_DD(x,a,b)<<1; }
  216. #endif
  217. #if !defined(FUNCTION_fixmsub_SD)
  218. inline FIXP_DBL fixmsub_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
  219. #ifdef FUNCTION_fixmsub_DS
  220. return fixmsub_DS(x, b, a);
  221. #else
  222. return fixmsub_DD(x, FX_SGL2FX_DBL(a), b);
  223. #endif
  224. }
  225. #endif
  226. #if !defined(FUNCTION_fixmsub_DS)
  227. inline FIXP_DBL fixmsub_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
  228. #ifdef FUNCTION_fixmsub_SD
  229. return fixmsub_SD(x, b, a);
  230. #else
  231. return fixmsub_DD(x, a, FX_SGL2FX_DBL(b));
  232. #endif
  233. }
  234. #endif
  235. #if !defined(FUNCTION_fixmsub_SS)
  236. inline FIXP_DBL fixmsub_SS (FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b)
  237. { return (x - fMultDiv2(a,b))<<1; }
  238. #endif
  239. #if !defined(FUNCTION_fixpow2adddiv2_D)
  240. inline INT fixpadddiv2_D (FIXP_DBL x, const FIXP_DBL a)
  241. { return (x + fPow2Div2(a)); }
  242. #endif
  243. #if !defined(FUNCTION_fixpow2add_D)
  244. inline INT fixpadd_D (FIXP_DBL x, const FIXP_DBL a)
  245. { return (x + fPow2(a)); }
  246. #endif
  247. #if !defined(FUNCTION_fixpow2adddiv2_S)
  248. inline INT fixpadddiv2_S (FIXP_DBL x, const FIXP_SGL a)
  249. { return (x + fPow2Div2(a)); }
  250. #endif
  251. #if !defined(FUNCTION_fixpow2add_S)
  252. inline INT fixpadd_S (FIXP_DBL x, const FIXP_SGL a)
  253. { return (x + fPow2(a)); }
  254. #endif
  255. #endif // __FIXMADD_H__