1 /* ----------------------------------------------------------------------------- 2 Software License for The Fraunhofer FDK AAC Codec Library for Android 3 4 © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten 5 Forschung e.V. All rights reserved. 6 7 1. INTRODUCTION 8 The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software 9 that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding 10 scheme for digital audio. This FDK AAC Codec software is intended to be used on 11 a wide variety of Android devices. 12 13 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient 14 general perceptual audio codecs. AAC-ELD is considered the best-performing 15 full-bandwidth communications codec by independent studies and is widely 16 deployed. AAC has been standardized by ISO and IEC as part of the MPEG 17 specifications. 18 19 Patent licenses for necessary patent claims for the FDK AAC Codec (including 20 those of Fraunhofer) may be obtained through Via Licensing 21 (www.vialicensing.com) or through the respective patent owners individually for 22 the purpose of encoding or decoding bit streams in products that are compliant 23 with the ISO/IEC MPEG audio standards. Please note that most manufacturers of 24 Android devices already license these patent claims through Via Licensing or 25 directly from the patent owners, and therefore FDK AAC Codec software may 26 already be covered under those patent licenses when it is used for those 27 licensed purposes only. 28 29 Commercially-licensed AAC software libraries, including floating-point versions 30 with enhanced sound quality, are also available from Fraunhofer. Users are 31 encouraged to check the Fraunhofer website for additional applications 32 information and documentation. 33 34 2. COPYRIGHT LICENSE 35 36 Redistribution and use in source and binary forms, with or without modification, 37 are permitted without payment of copyright license fees provided that you 38 satisfy the following conditions: 39 40 You must retain the complete text of this software license in redistributions of 41 the FDK AAC Codec or your modifications thereto in source code form. 42 43 You must retain the complete text of this software license in the documentation 44 and/or other materials provided with redistributions of the FDK AAC Codec or 45 your modifications thereto in binary form. You must make available free of 46 charge copies of the complete source code of the FDK AAC Codec and your 47 modifications thereto to recipients of copies in binary form. 48 49 The name of Fraunhofer may not be used to endorse or promote products derived 50 from this library without prior written permission. 51 52 You may not charge copyright license fees for anyone to use, copy or distribute 53 the FDK AAC Codec software or your modifications thereto. 54 55 Your modified versions of the FDK AAC Codec must carry prominent notices stating 56 that you changed the software and the date of any change. For modified versions 57 of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android" 58 must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK 59 AAC Codec Library for Android." 60 61 3. NO PATENT LICENSE 62 63 NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without 64 limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE. 65 Fraunhofer provides no warranty of patent non-infringement with respect to this 66 software. 67 68 You may use this FDK AAC Codec software or modifications thereto only for 69 purposes that are authorized by appropriate patent licenses. 70 71 4. DISCLAIMER 72 73 This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright 74 holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 75 including but not limited to the implied warranties of merchantability and 76 fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 77 CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, 78 or consequential damages, including but not limited to procurement of substitute 79 goods or services; loss of use, data, or profits, or business interruption, 80 however caused and on any theory of liability, whether in contract, strict 81 liability, or tort (including negligence), arising in any way out of the use of 82 this software, even if advised of the possibility of such damage. 83 84 5. CONTACT INFORMATION 85 86 Fraunhofer Institute for Integrated Circuits IIS 87 Attention: Audio and Multimedia Departments - FDK AAC LL 88 Am Wolfsmantel 33 89 91058 Erlangen, Germany 90 91 www.iis.fraunhofer.de/amm 92 amm-info@iis.fraunhofer.de 93 ----------------------------------------------------------------------------- */ 94 95 /************************* System integration library ************************** 96 97 Author(s): 98 99 Description: 100 101 *******************************************************************************/ 102 103 /** \file machine_type.h 104 * \brief Type defines for various processors and compiler tools. 105 */ 106 107 #if !defined(MACHINE_TYPE_H) 108 #define MACHINE_TYPE_H 109 110 #include <stddef.h> /* Needed to define size_t */ 111 112 #if defined(__ANDROID__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 4) && \ 113 (__GNUC_GNU_INLINE__ == 1) 114 typedef unsigned long long uint64_t; 115 #include <sys/types.h> 116 #endif 117 118 /* Library calling convention spec. __cdecl and friends might be added here as 119 * required. */ 120 #define LINKSPEC_H 121 #define LINKSPEC_CPP 122 123 /* for doxygen the following docu parts must be separated */ 124 /** \var SCHAR 125 * Data type representing at least 1 byte signed integer on all supported 126 * platforms. 127 */ 128 /** \var UCHAR 129 * Data type representing at least 1 byte unsigned integer on all 130 * supported platforms. 131 */ 132 /** \var INT 133 * Data type representing at least 4 byte signed integer on all supported 134 * platforms. 135 */ 136 /** \var UINT 137 * Data type representing at least 4 byte unsigned integer on all 138 * supported platforms. 139 */ 140 /** \var LONG 141 * Data type representing 4 byte signed integer on all supported 142 * platforms. 143 */ 144 /** \var ULONG 145 * Data type representing 4 byte unsigned integer on all supported 146 * platforms. 147 */ 148 /** \var SHORT 149 * Data type representing 2 byte signed integer on all supported 150 * platforms. 151 */ 152 /** \var USHORT 153 * Data type representing 2 byte unsigned integer on all supported 154 * platforms. 155 */ 156 /** \var INT64 157 * Data type representing 8 byte signed integer on all supported 158 * platforms. 159 */ 160 /** \var UINT64 161 * Data type representing 8 byte unsigned integer on all supported 162 * platforms. 163 */ 164 /** \def SHORT_BITS 165 * Number of bits the data type short represents. sizeof() is not suited 166 * to get this info, because a byte is not always defined as 8 bits. 167 */ 168 /** \def CHAR_BITS 169 * Number of bits the data type char represents. sizeof() is not suited 170 * to get this info, because a byte is not always defined as 8 bits. 171 */ 172 /** \var INT_PCM 173 * Data type representing the width of input and output PCM samples. 174 */ 175 176 typedef signed int INT; 177 typedef unsigned int UINT; 178 #ifdef __LP64__ 179 /* force FDK long-datatypes to 4 byte */ 180 /* Use defines to avoid type alias problems on 64 bit machines. */ 181 #define LONG INT 182 #define ULONG UINT 183 #else /* __LP64__ */ 184 typedef signed long LONG; 185 typedef unsigned long ULONG; 186 #endif /* __LP64__ */ 187 typedef signed short SHORT; 188 typedef unsigned short USHORT; 189 typedef signed char SCHAR; 190 typedef unsigned char UCHAR; 191 192 #define SHORT_BITS 16 193 #define CHAR_BITS 8 194 195 /* Define 64 bit base integer type. */ 196 #ifdef _MSC_VER 197 typedef __int64 INT64; 198 typedef unsigned __int64 UINT64; 199 #else 200 typedef long long INT64; 201 typedef unsigned long long UINT64; 202 #endif 203 204 #ifndef NULL 205 #ifdef __cplusplus 206 #define NULL 0 207 #else 208 #define NULL ((void *)0) 209 #endif 210 #endif 211 212 #if ((defined(__i686__) || defined(__i586__) || defined(__i386__) || \ 213 defined(__x86_64__)) || \ 214 (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)))) && \ 215 !defined(FDK_ASSERT_ENABLE) 216 #define FDK_ASSERT_ENABLE 217 #endif 218 219 #if defined(FDK_ASSERT_ENABLE) 220 #include <assert.h> 221 #define FDK_ASSERT(x) assert(x) 222 #else 223 #define FDK_ASSERT(ignore) 224 #endif 225 226 typedef SHORT INT_PCM; 227 #define MAXVAL_PCM MAXVAL_SGL 228 #define MINVAL_PCM MINVAL_SGL 229 #define WAV_BITS 16 230 #define SAMPLE_BITS 16 231 #define SAMPLE_MAX ((INT_PCM)(((ULONG)1 << (SAMPLE_BITS - 1)) - 1)) 232 #define SAMPLE_MIN (~SAMPLE_MAX) 233 234 /*! 235 * \def RAM_ALIGN 236 * Used to align memory as prefix before memory declaration. For example: 237 \code 238 RAM_ALIGN 239 int myArray[16]; 240 \endcode 241 242 Note, that not all platforms support this mechanism. For example with TI 243 compilers a preprocessor pragma is used, but to do something like 244 245 \code 246 #define RAM_ALIGN #pragma DATA_ALIGN(x) 247 \endcode 248 249 would require the preprocessor to process this line twice to fully resolve 250 it. Hence, a fully platform-independant way to use alignment is not supported. 251 252 * \def ALIGNMENT_DEFAULT 253 * Default alignment in bytes. 254 */ 255 256 #define ALIGNMENT_DEFAULT 8 257 258 /* RAM_ALIGN keyword causes memory alignment of global variables. */ 259 #if defined(_MSC_VER) 260 #define RAM_ALIGN __declspec(align(ALIGNMENT_DEFAULT)) 261 #elif defined(__GNUC__) 262 #define RAM_ALIGN __attribute__((aligned(ALIGNMENT_DEFAULT))) 263 #else 264 #define RAM_ALIGN 265 #endif 266 267 /*! 268 * \def RESTRICT 269 * The restrict keyword is supported by some platforms and RESTRICT maps 270 * to either the corresponding keyword on each platform or to void if the 271 * compiler does not provide such feature. It tells the compiler that a 272 * pointer points to memory that does not overlap with other memories pointed to 273 * by other pointers. If this keyword is used and the assumption of no 274 * overlap is not true the resulting code might crash. 275 * 276 * \def WORD_ALIGNED(x) 277 * Tells the compiler that pointer x is 16 bit aligned. It does not cause 278 * the address itself to be aligned, but serves as a hint to the optimizer. The 279 * alignment of the pointer must be guarranteed, if not the code might 280 * crash. 281 * 282 * \def DWORD_ALIGNED(x) 283 * Tells the compiler that pointer x is 32 bit aligned. It does not cause 284 * the address itself to be aligned, but serves as a hint to the optimizer. The 285 * alignment of the pointer must be guarranteed, if not the code might 286 * crash. 287 * 288 */ 289 #define RESTRICT 290 #define WORD_ALIGNED(x) C_ALLOC_ALIGNED_CHECK2((const void *)(x), 2); 291 #define DWORD_ALIGNED(x) C_ALLOC_ALIGNED_CHECK2((const void *)(x), 4); 292 293 /*----------------------------------------------------------------------------------- 294 * ALIGN_SIZE 295 *-----------------------------------------------------------------------------------*/ 296 /*! 297 * \brief This macro aligns a given value depending on ::ALIGNMENT_DEFAULT. 298 * 299 * For example if #ALIGNMENT_DEFAULT equals 8, then: 300 * - ALIGN_SIZE(3) returns 8 301 * - ALIGN_SIZE(8) returns 8 302 * - ALIGN_SIZE(9) returns 16 303 */ 304 #define ALIGN_SIZE(a) \ 305 ((a) + (((INT)ALIGNMENT_DEFAULT - ((size_t)(a) & (ALIGNMENT_DEFAULT - 1))) & \ 306 (ALIGNMENT_DEFAULT - 1))) 307 308 /*! 309 * \brief This macro aligns a given address depending on ::ALIGNMENT_DEFAULT. 310 */ 311 #define ALIGN_PTR(a) \ 312 ((void *)((unsigned char *)(a) + \ 313 ((((INT)ALIGNMENT_DEFAULT - \ 314 ((size_t)(a) & (ALIGNMENT_DEFAULT - 1))) & \ 315 (ALIGNMENT_DEFAULT - 1))))) 316 317 /* Alignment macro for libSYS heap implementation */ 318 #define ALIGNMENT_EXTRES (ALIGNMENT_DEFAULT) 319 #define ALGN_SIZE_EXTRES(a) \ 320 ((a) + (((INT)ALIGNMENT_EXTRES - ((INT)(a) & (ALIGNMENT_EXTRES - 1))) & \ 321 (ALIGNMENT_EXTRES - 1))) 322 323 /*! 324 * \def FDK_FORCEINLINE 325 * Sometimes compiler do not do what they are told to do, and in case of 326 * inlining some additional command might be necessary depending on the 327 * platform. 328 * 329 * \def FDK_INLINE 330 * Defines how the compiler is told to inline stuff. 331 */ 332 #ifndef FDK_FORCEINLINE 333 #if defined(__GNUC__) && !defined(__SDE_MIPS__) 334 #define FDK_FORCEINLINE inline __attribute((always_inline)) 335 #else 336 #define FDK_FORCEINLINE inline 337 #endif 338 #endif 339 340 #define FDK_INLINE static inline 341 342 /*! 343 * \def LNK_SECTION_DATA_L1 344 * The LNK_SECTION_* defines allow memory to be drawn from specific memory 345 * sections. Used as prefix before variable declaration. 346 * 347 * \def LNK_SECTION_DATA_L2 348 * See ::LNK_SECTION_DATA_L1 349 * \def LNK_SECTION_L1_DATA_A 350 * See ::LNK_SECTION_DATA_L1 351 * \def LNK_SECTION_L1_DATA_B 352 * See ::LNK_SECTION_DATA_L1 353 * \def LNK_SECTION_CONSTDATA_L1 354 * See ::LNK_SECTION_DATA_L1 355 * \def LNK_SECTION_CONSTDATA 356 * See ::LNK_SECTION_DATA_L1 357 * \def LNK_SECTION_CODE_L1 358 * See ::LNK_SECTION_DATA_L1 359 * \def LNK_SECTION_CODE_L2 360 * See ::LNK_SECTION_DATA_L1 361 * \def LNK_SECTION_INITCODE 362 * See ::LNK_SECTION_DATA_L1 363 */ 364 /************************************************** 365 * Code Section macros 366 **************************************************/ 367 #define LNK_SECTION_CODE_L1 368 #define LNK_SECTION_CODE_L2 369 #define LNK_SECTION_INITCODE 370 371 /* Memory section macros. */ 372 373 /* default fall back */ 374 #define LNK_SECTION_DATA_L1 375 #define LNK_SECTION_DATA_L2 376 #define LNK_SECTION_CONSTDATA 377 #define LNK_SECTION_CONSTDATA_L1 378 379 #define LNK_SECTION_L1_DATA_A 380 #define LNK_SECTION_L1_DATA_B 381 382 /************************************************** 383 * Macros regarding static code analysis 384 **************************************************/ 385 #if defined(__clang__) 386 #define FDK_FALLTHROUGH [[clang::fallthrough]] 387 #elif defined(__GNUC__) && (__GNUC__ >= 7) 388 #define FDK_FALLTHROUGH __attribute__((fallthrough)) 389 #else 390 #define FDK_FALLTHROUGH 391 #endif 392 393 #ifdef _MSC_VER 394 /* 395 * Sometimes certain features are excluded from compilation and therefore the 396 * warning 4065 may occur: "switch statement contains 'default' but no 'case' 397 * labels" We consider this warning irrelevant and disable it. 398 */ 399 #pragma warning(disable : 4065) 400 #endif 401 402 #endif /* MACHINE_TYPE_H */ 403