cplx_mul.h revision 4f0d97057c5c640b25518358886f8c47da9fc052
10ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 20ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong/* ----------------------------------------------------------------------------------------------------------- 30ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongSoftware License for The Fraunhofer FDK AAC Codec Library for Android 40ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 50ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong� Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F�rderung der angewandten Forschung e.V. 60ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong All rights reserved. 70ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 80ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1. INTRODUCTION 90ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongThe Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements 100ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongthe MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. 110ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongThis FDK AAC Codec software is intended to be used on a wide variety of Android devices. 120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongAAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual 140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongaudio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by 150ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongindependent studies and is widely deployed. AAC has been standardized by ISO and IEC as part 160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongof the MPEG specifications. 170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongPatent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer) 190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongmay be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners 200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongindividually for the purpose of encoding or decoding bit streams in products that are compliant with 210ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongthe ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license 220ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongthese patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec 230ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongsoftware may already be covered under those patent licenses when it is used for those licensed purposes only. 240ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 250ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongCommercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality, 260ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongare also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional 270ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongapplications information and documentation. 280ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 290ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong2. COPYRIGHT LICENSE 300ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 310ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongRedistribution and use in source and binary forms, with or without modification, are permitted without 320ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongpayment of copyright license fees provided that you satisfy the following conditions: 330ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 340ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongYou must retain the complete text of this software license in redistributions of the FDK AAC Codec or 350ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongyour modifications thereto in source code form. 360ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 370ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongYou must retain the complete text of this software license in the documentation and/or other materials 380ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongprovided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. 390ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongYou must make available free of charge copies of the complete source code of the FDK AAC Codec and your 400ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongmodifications thereto to recipients of copies in binary form. 410ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 420ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongThe name of Fraunhofer may not be used to endorse or promote products derived from this library without 430ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongprior written permission. 440ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 450ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongYou may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec 460ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongsoftware or your modifications thereto. 470ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 480ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongYour modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software 490ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongand the date of any change. For modified versions of the FDK AAC Codec, the term 500ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term 510ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android." 520ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 530ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong3. NO PATENT LICENSE 540ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 550ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongNO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, 560ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with 570ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongrespect to this software. 580ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 590ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongYou may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized 600ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongby appropriate patent licenses. 610ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 620ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong4. DISCLAIMER 630ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 640ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongThis FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors 650ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties 660ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongof merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 670ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongCONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, 680ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongincluding but not limited to procurement of substitute goods or services; loss of use, data, or profits, 690ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongor business interruption, however caused and on any theory of liability, whether in contract, strict 700ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongliability, or tort (including negligence), arising in any way out of the use of this software, even if 710ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongadvised of the possibility of such damage. 720ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 730ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong5. CONTACT INFORMATION 740ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 750ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongFraunhofer Institute for Integrated Circuits IIS 760ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongAttention: Audio and Multimedia Departments - FDK AAC LL 770ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongAm Wolfsmantel 33 780ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong91058 Erlangen, Germany 790ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 800ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongwww.iis.fraunhofer.de/amm 810ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongamm-info@iis.fraunhofer.de 820ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong----------------------------------------------------------------------------------------------------------- */ 830ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 840ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong/*************************** Fraunhofer IIS FDK Tools ********************** 850ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 860ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong Author(s): 870ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong Description: fixed point intrinsics 880ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 890ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong******************************************************************************/ 900ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 910ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 920ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#if defined(__GNUC__) && defined(__mips__) 930ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 940ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 950ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//#define FUNCTION_cplxMultDiv2_32x16 960ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//#define FUNCTION_cplxMultDiv2_32x16X2 970ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#define FUNCTION_cplxMultDiv2_32x32X2 980ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//#define FUNCTION_cplxMult_32x16 990ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//#define FUNCTION_cplxMult_32x16X2 1000ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#define FUNCTION_cplxMult_32x32X2 1010ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1020ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#if defined(FUNCTION_cplxMultDiv2_32x32X2) 1030ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Konginline void cplxMultDiv2( FIXP_DBL *c_Re, 1040ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong FIXP_DBL *c_Im, 1050ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong FIXP_DBL a_Re, 1060ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong FIXP_DBL a_Im, 1070ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong FIXP_DBL b_Re, 1080ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong FIXP_DBL b_Im) 1090ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong{ 1100ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong INT result; 1110ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong __asm__ ("mult %[a_Re], %[b_Re];\n" 1130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong "msub %[a_Im], %[b_Im];\n" 1140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong "mfhi %[result];\n" 1150ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong : [result]"=r"(result) 1160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong : [a_Re]"d"(a_Re), [b_Re]"d"(b_Re), [a_Im]"d"(a_Im), [b_Im]"d"(b_Im) 1170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong : "lo"); 1180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong *c_Re = result; 1200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1210ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong __asm__ ("mult %[a_Re], %[b_Im];\n" 1220ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong "madd %[a_Im], %[b_Re];\n" 1230ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong "mfhi %[result];\n" 1240ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong : [result]"=r"(result) 1250ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong : [a_Re]"r"(a_Re), [b_Im]"r"(b_Im), [a_Im]"r"(a_Im), [b_Re]"r"(b_Re) 1260ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong : "lo"); 1270ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong *c_Im = result; 1280ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong} 1290ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#endif 1300ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1310ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#if defined(FUNCTION_cplxMult_32x32X2) 1320ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Konginline void cplxMult( FIXP_DBL *c_Re, 1330ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong FIXP_DBL *c_Im, 1340ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong FIXP_DBL a_Re, 1350ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong FIXP_DBL a_Im, 136 FIXP_DBL b_Re, 137 FIXP_DBL b_Im) 138{ 139 INT result; 140 141 __asm__ ("mult %[a_Re], %[b_Re];\n" 142 "msub %[a_Im], %[b_Im];\n" 143 "mfhi %[result];\n" 144 //"extr_w %[result], 31;\n" 145 : [result]"=r"(result) 146 : [a_Re]"r"(a_Re), [b_Re]"r"(b_Re), [a_Im]"r"(a_Im), [b_Im]"r"(b_Im) 147 : "lo"); 148 *c_Re = result<<1; 149 150 __asm__ ("mult %[a_Re], %[b_Im];\n" 151 "madd %[a_Im], %[b_Re];\n" 152 "mfhi %[result];\n" 153 //"extr_w %[result], 31;\n" 154 : [result]"=r"(result) 155 : [a_Re]"r"(a_Re), [b_Im]"r"(b_Im), [a_Im]"r"(a_Im), [b_Re]"r"(b_Re) 156 : "lo"); 157 *c_Im = result<<1; 158} 159#endif 160 161#endif /* defined(__GNUC__) && defined(__mips__) */ 162 163