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 /**************************** SBR encoder library ****************************** 96 97 Author(s): Markus Multrus 98 99 Description: PS Wrapper, Downmix header file 100 101 *******************************************************************************/ 102 103 #ifndef PS_MAIN_H 104 #define PS_MAIN_H 105 106 /* Includes ******************************************************************/ 107 108 #include "sbr_def.h" 109 #include "qmf.h" 110 #include "ps_encode.h" 111 #include "FDK_bitstream.h" 112 #include "FDK_hybrid.h" 113 114 /* Data Types ****************************************************************/ 115 typedef enum { 116 PSENC_STEREO_BANDS_INVALID = 0, 117 PSENC_STEREO_BANDS_10 = 10, 118 PSENC_STEREO_BANDS_20 = 20 119 120 } PSENC_STEREO_BANDS_CONFIG; 121 122 typedef enum { 123 PSENC_NENV_1 = 1, 124 PSENC_NENV_2 = 2, 125 PSENC_NENV_4 = 4, 126 PSENC_NENV_DEFAULT = PSENC_NENV_2, 127 PSENC_NENV_MAX = PSENC_NENV_4 128 129 } PSENC_NENV_CONFIG; 130 131 typedef struct { 132 UINT bitrateFrom; /* inclusive */ 133 UINT bitrateTo; /* exclusive */ 134 PSENC_STEREO_BANDS_CONFIG nStereoBands; 135 PSENC_NENV_CONFIG nEnvelopes; 136 LONG iidQuantErrorThreshold; /* quantization threshold to switch between 137 coarse and fine iid quantization */ 138 139 } psTuningTable_t; 140 141 /* Function / Class Declarations *********************************************/ 142 143 typedef struct T_PARAMETRIC_STEREO { 144 HANDLE_PS_ENCODE hPsEncode; 145 PS_OUT psOut[2]; 146 147 FIXP_DBL __staticHybridData[HYBRID_READ_OFFSET][MAX_PS_CHANNELS][2] 148 [MAX_HYBRID_BANDS]; 149 FIXP_DBL 150 *pHybridData[HYBRID_READ_OFFSET + HYBRID_FRAMESIZE][MAX_PS_CHANNELS][2]; 151 152 FIXP_DBL qmfDelayLines[2][32 >> 1][64]; 153 int qmfDelayScale; 154 155 INT psDelay; 156 UINT maxEnvelopes; 157 UCHAR dynBandScale[PS_MAX_BANDS]; 158 FIXP_DBL maxBandValue[PS_MAX_BANDS]; 159 SCHAR dmxScale; 160 INT initPS; 161 INT noQmfSlots; 162 INT noQmfBands; 163 164 FIXP_DBL __staticHybAnaStatesLF[MAX_PS_CHANNELS][2 * HYBRID_FILTER_LENGTH * 165 HYBRID_MAX_QMF_BANDS]; 166 FIXP_DBL __staticHybAnaStatesHF[MAX_PS_CHANNELS][2 * HYBRID_FILTER_DELAY * 167 (64 - HYBRID_MAX_QMF_BANDS)]; 168 FDK_ANA_HYB_FILTER fdkHybAnaFilter[MAX_PS_CHANNELS]; 169 FDK_SYN_HYB_FILTER fdkHybSynFilter; 170 171 } PARAMETRIC_STEREO; 172 173 typedef struct T_PSENC_CONFIG { 174 INT frameSize; 175 INT qmfFilterMode; 176 INT sbrPsDelay; 177 PSENC_STEREO_BANDS_CONFIG nStereoBands; 178 PSENC_NENV_CONFIG maxEnvelopes; 179 FIXP_DBL iidQuantErrorThreshold; 180 181 } PSENC_CONFIG, *HANDLE_PSENC_CONFIG; 182 183 typedef struct T_PARAMETRIC_STEREO *HANDLE_PARAMETRIC_STEREO; 184 185 /** 186 * \brief Create a parametric stereo encoder instance. 187 * 188 * \param phParametricStereo A pointer to a parametric stereo handle to be 189 * allocated. Initialized on return. 190 * 191 * \return 192 * - PSENC_OK, on succes. 193 * - PSENC_INVALID_HANDLE, PSENC_MEMORY_ERROR, on failure. 194 */ 195 FDK_PSENC_ERROR PSEnc_Create(HANDLE_PARAMETRIC_STEREO *phParametricStereo); 196 197 /** 198 * \brief Initialize a parametric stereo encoder instance. 199 * 200 * \param hParametricStereo Meta Data handle. 201 * \param hPsEncConfig Filled parametric stereo configuration 202 * structure. 203 * \param noQmfSlots Number of slots within one audio frame. 204 * \param noQmfBands Number of QMF bands. 205 * \param dynamic_RAM Pointer to preallocated workbuffer. 206 * 207 * \return 208 * - PSENC_OK, on succes. 209 * - PSENC_INVALID_HANDLE, PSENC_INIT_ERROR, on failure. 210 */ 211 FDK_PSENC_ERROR PSEnc_Init(HANDLE_PARAMETRIC_STEREO hParametricStereo, 212 const HANDLE_PSENC_CONFIG hPsEncConfig, 213 INT noQmfSlots, INT noQmfBands, UCHAR *dynamic_RAM); 214 215 /** 216 * \brief Destroy parametric stereo encoder instance. 217 * 218 * Deallocate instance and free whole memory. 219 * 220 * \param phParametricStereo Pointer to the parametric stereo handle to be 221 * deallocated. 222 * 223 * \return 224 * - PSENC_OK, on succes. 225 * - PSENC_INVALID_HANDLE, on failure. 226 */ 227 FDK_PSENC_ERROR PSEnc_Destroy(HANDLE_PARAMETRIC_STEREO *phParametricStereo); 228 229 /** 230 * \brief Apply parametric stereo processing. 231 * 232 * \param hParametricStereo Meta Data handle. 233 * \param samples Pointer to 2 channel audio input signal. 234 * \param timeInStride, Stride factor of input buffer. 235 * \param hQmfAnalysis, Pointer to QMF analysis filterbanks. 236 * \param downmixedRealQmfData Pointer to real QMF buffer to be written to. 237 * \param downmixedImagQmfData Pointer to imag QMF buffer to be written to. 238 * \param downsampledOutSignal Pointer to buffer where to write downmixed 239 * timesignal. 240 * \param sbrSynthQmf Pointer to QMF synthesis filterbank. 241 * \param qmfScale Return scaling factor of the qmf data. 242 * \param sendHeader Signal whether to write header data. 243 * 244 * \return 245 * - PSENC_OK, on succes. 246 * - PSENC_INVALID_HANDLE, PSENC_ENCODE_ERROR, on failure. 247 */ 248 FDK_PSENC_ERROR FDKsbrEnc_PSEnc_ParametricStereoProcessing( 249 HANDLE_PARAMETRIC_STEREO hParametricStereo, INT_PCM *samples[2], 250 UINT timeInStride, QMF_FILTER_BANK **hQmfAnalysis, 251 FIXP_DBL **RESTRICT downmixedRealQmfData, 252 FIXP_DBL **RESTRICT downmixedImagQmfData, INT_PCM *downsampledOutSignal, 253 HANDLE_QMF_FILTER_BANK sbrSynthQmf, SCHAR *qmfScale, const int sendHeader); 254 255 /** 256 * \brief Write parametric stereo bitstream. 257 * 258 * Write ps_data() element to bitstream and return number of written bits. 259 * Returns number of written bits only, if hBitstream == NULL. 260 * 261 * \param hParametricStereo Meta Data handle. 262 * \param hBitstream Bitstream buffer handle. 263 * 264 * \return 265 * - number of written bits. 266 */ 267 INT FDKsbrEnc_PSEnc_WritePSData(HANDLE_PARAMETRIC_STEREO hParametricStereo, 268 HANDLE_FDK_BITSTREAM hBitstream); 269 270 #endif /* PS_MAIN_H */ 271