12228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 22228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project/* ----------------------------------------------------------------------------------------------------------- 32228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectSoftware License for The Fraunhofer FDK AAC Codec Library for Android 42228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 54f0d97057c5c640b25518358886f8c47da9fc052Jean-Michel Trivi� Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F�rderung der angewandten Forschung e.V. 62228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project All rights reserved. 72228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 82228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 1. INTRODUCTION 92228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectThe Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements 102228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectthe MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. 112228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectThis FDK AAC Codec software is intended to be used on a wide variety of Android devices. 122228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 132228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectAAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual 142228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectaudio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by 152228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectindependent studies and is widely deployed. AAC has been standardized by ISO and IEC as part 162228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectof the MPEG specifications. 172228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 182228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectPatent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer) 192228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectmay be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners 202228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectindividually for the purpose of encoding or decoding bit streams in products that are compliant with 212228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectthe ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license 222228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectthese patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec 232228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectsoftware may already be covered under those patent licenses when it is used for those licensed purposes only. 242228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 252228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectCommercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality, 262228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectare also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional 272228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectapplications information and documentation. 282228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 292228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project2. COPYRIGHT LICENSE 302228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 312228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectRedistribution and use in source and binary forms, with or without modification, are permitted without 322228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectpayment of copyright license fees provided that you satisfy the following conditions: 332228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 342228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectYou must retain the complete text of this software license in redistributions of the FDK AAC Codec or 352228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectyour modifications thereto in source code form. 362228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 372228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectYou must retain the complete text of this software license in the documentation and/or other materials 382228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectprovided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. 392228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectYou must make available free of charge copies of the complete source code of the FDK AAC Codec and your 402228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectmodifications thereto to recipients of copies in binary form. 412228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 422228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectThe name of Fraunhofer may not be used to endorse or promote products derived from this library without 432228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectprior written permission. 442228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 452228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectYou may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec 462228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectsoftware or your modifications thereto. 472228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 482228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectYour modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software 492228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectand the date of any change. For modified versions of the FDK AAC Codec, the term 502228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term 512228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android." 522228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 532228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project3. NO PATENT LICENSE 542228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 552228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectNO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, 562228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with 572228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectrespect to this software. 582228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 592228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectYou may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized 602228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectby appropriate patent licenses. 612228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 622228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project4. DISCLAIMER 632228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 642228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectThis FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors 652228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties 662228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectof merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 672228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectCONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, 682228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectincluding but not limited to procurement of substitute goods or services; loss of use, data, or profits, 692228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projector business interruption, however caused and on any theory of liability, whether in contract, strict 702228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectliability, or tort (including negligence), arising in any way out of the use of this software, even if 712228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectadvised of the possibility of such damage. 722228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 732228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project5. CONTACT INFORMATION 742228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 752228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectFraunhofer Institute for Integrated Circuits IIS 762228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectAttention: Audio and Multimedia Departments - FDK AAC LL 772228e360595641dd906bf1773307f43d304f5b2The Android Open Source ProjectAm Wolfsmantel 33 782228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project91058 Erlangen, Germany 792228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 802228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectwww.iis.fraunhofer.de/amm 812228e360595641dd906bf1773307f43d304f5b2The Android Open Source Projectamm-info@iis.fraunhofer.de 822228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project----------------------------------------------------------------------------------------------------------- */ 832228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 846ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi/*************************** Fraunhofer IIS FDK Tools ********************** 852228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 866ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi Author(s): 876ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi Description: fixed point intrinsics 882228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 892228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project******************************************************************************/ 902228e360595641dd906bf1773307f43d304f5b2The Android Open Source Project 916ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi#if defined(__GNUC__) && (defined(__x86__) || defined(__x86_64__)) 926ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi 936ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi #define FUNCTION_fixnormz_D 946ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi #define FUNCTION_fixnorm_D 956ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi 966ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi inline INT fixnormz_D(LONG value) 976ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi { 986ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi INT result; 996ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi 1006ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi if (value != 0) { 1016ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi result = __builtin_clz(value); 1026ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } else { 1036ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi result = 32; 1046ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } 1056ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi return result; 1066ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } 1076ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi 1086ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi inline INT fixnorm_D(LONG value) 1096ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi { 1106ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi INT result; 1116ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi if (value == 0) { 1126ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi return 0; 1136ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } 1146ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi if (value < 0) { 1156ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi value = ~value; 1166ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } 1176ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi result = fixnormz_D(value); 1186ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi return result - 1; 1196ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } 1206ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi 1216ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi 1226ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) 1236ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi 1246ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi#include <intrin.h> 1256ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi 1266ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi #define FUNCTION_fixnormz_D 1276ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi #define FUNCTION_fixnorm_D 1286ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi 1296ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi inline INT fixnormz_D(LONG value) 1306ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi { 1316ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi unsigned long result = 0; 1326ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi unsigned char err; 1336ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi err = _BitScanReverse(&result, value); 1346ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi if (err) { 1356ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi return 31 - result; 1366ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } else { 1376ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi return 32; 1386ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } 1396ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } 1406ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi 1416ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi inline INT fixnorm_D(LONG value) 1426ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi { 1436ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi INT result; 1446ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi if (value == 0) { 1456ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi return 0; 1466ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } 1476ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi if (value < 0) { 1486ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi value = ~value; 1496ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } 1506ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi result = fixnormz_D(value); 1516ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi return result - 1; 1526ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi } 1536ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi 1546ab36997af5d5acda4f21d33031f4e45c85f96b7Jean-Michel Trivi#endif /* toolchain */ 155