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 decoder library ****************************** 96 97 Author(s): Matthias Hildenbrand 98 99 Description: Decode Predictive Vector Coding Data 100 101 *******************************************************************************/ 102 103 #ifndef PVC_DEC_H 104 #define PVC_DEC_H 105 106 #include "common_fix.h" 107 108 #define PVC_DIVMODE_BITS 3 109 #define PVC_REUSEPVCID_BITS 1 110 #define PVC_PVCID_BITS 7 111 #define PVC_GRIDINFO_BITS 1 112 113 #define MAX_PVC_ENVELOPES 2 114 #define PVC_NTIMESLOT 16 115 #define PVC_NBLOW 3 /* max. number of grouped QMF subbands below SBR range */ 116 117 #define PVC_NBHIGH_MODE1 8 118 #define PVC_NBHIGH_MODE2 6 119 #define PVC_NBHIGH_MAX (PVC_NBHIGH_MODE1) 120 #define PVC_NS_MAX 16 121 122 /** Data for each PVC instance which needs to be persistent accross SBR frames 123 */ 124 typedef struct { 125 UCHAR kx_last; /**< Xover frequency of last frame */ 126 UCHAR pvc_mode_last; /**< PVC mode of last frame */ 127 UCHAR Esg_slot_index; /**< Ring buffer index to current Esg time slot */ 128 UCHAR pvcBorder0; /**< Start SBR time slot of PVC frame */ 129 FIXP_DBL Esg[PVC_NS_MAX][PVC_NBLOW]; /**< Esg(ksg,t) of current and 15 130 previous time slots (ring buffer) in 131 logarithmical domain */ 132 } PVC_STATIC_DATA; 133 134 /** Data for each PVC instance which is valid during one SBR frame */ 135 typedef struct { 136 UCHAR pvc_mode; /**< PVC mode 1 or 2, 0 means legacy SBR */ 137 UCHAR pvcBorder0; /**< Start SBR time slot of PVC frame */ 138 UCHAR kx; /**< Index of the first QMF subband in the SBR range */ 139 UCHAR RATE; /**< Number of QMF subband samples per time slot (2 or 4) */ 140 UCHAR ns; /**< Number of time slots for time-domain smoothing of Esg(ksg,t) */ 141 const UCHAR 142 *pPvcID; /**< Pointer to prediction coefficient matrix index table */ 143 UCHAR pastEsgSlotsAvail; /**< Number of past Esg(ksg,t) which are available 144 for smoothing filter */ 145 const FIXP_SGL *pSCcoeffs; /**< Pointer to smoothing window table */ 146 SCHAR 147 sg_offset_low[PVC_NBLOW + 1]; /**< Offset table for PVC grouping of SBR 148 subbands below SBR range */ 149 SCHAR sg_offset_high_kx[PVC_NBHIGH_MAX + 1]; /**< Offset table for PVC 150 grouping of SBR subbands in 151 SBR range (relativ to kx) */ 152 UCHAR nbHigh; /**< Number of grouped QMF subbands in the SBR range */ 153 const SCHAR *pScalingCoef; /**< Pointer to scaling coeff table */ 154 const UCHAR *pPVCTab1; /**< PVC mode 1 table */ 155 const UCHAR *pPVCTab2; /**< PVC mode 2 table */ 156 const UCHAR *pPVCTab1_dp; /**< Mapping of pvcID to PVC mode 1 table */ 157 FIXP_DBL predEsg[PVC_NTIMESLOT] 158 [PVC_NBHIGH_MAX]; /**< Predicted Energy in linear domain */ 159 int predEsg_exp[PVC_NTIMESLOT]; /**< Exponent of predicted Energy in linear 160 domain */ 161 int predEsg_expMax; /**< Maximum of predEsg_exp[] */ 162 } PVC_DYNAMIC_DATA; 163 164 /** 165 * \brief Initialize PVC data structures for current frame (call if pvcMode = 166 * 0,1,2) 167 * \param[in] pPvcStaticData Pointer to PVC persistent data 168 * \param[out] pPvcDynamicData Pointer to PVC dynamic data 169 * \param[in] pvcMode PVC mode 1 or 2, 0 means legacy SBR 170 * \param[in] ns Number of time slots for time-domain smoothing of Esg(ksg,t) 171 * \param[in] RATE Number of QMF subband samples per time slot (2 or 4) 172 * \param[in] kx Index of the first QMF subband in the SBR range 173 * \param[in] pvcBorder0 Start SBR time slot of PVC frame 174 * \param[in] pPvcID Pointer to array of PvcIDs read from bitstream 175 */ 176 int pvcInitFrame(PVC_STATIC_DATA *pPvcStaticData, 177 PVC_DYNAMIC_DATA *pPvcDynamicData, const UCHAR pvcMode, 178 const UCHAR ns, const int RATE, const int kx, 179 const int pvcBorder0, const UCHAR *pPvcID); 180 181 /** 182 * \brief Wrapper function for pvcDecodeTimeSlot() to decode PVC data of one 183 * frame (call if pvcMode = 1,2) 184 * \param[in,out] pPvcStaticData Pointer to PVC persistent data 185 * \param[in,out] pPvcDynamicData Pointer to PVC dynamic data 186 * \param[in] qmfBufferReal Pointer to array with real QMF subbands 187 * \param[in] qmfBufferImag Pointer to array with imag QMF subbands 188 * \param[in] overlap Number of QMF overlap slots 189 * \param[in] qmfExponentOverlap Exponent of qmfBuffer (low part) of overlap 190 * slots 191 * \param[in] qmfExponentCurrent Exponent of qmfBuffer (low part) 192 */ 193 void pvcDecodeFrame(PVC_STATIC_DATA *pPvcStaticData, 194 PVC_DYNAMIC_DATA *pPvcDynamicData, FIXP_DBL **qmfBufferReal, 195 FIXP_DBL **qmfBufferImag, const int overlap, 196 const int qmfExponentOverlap, const int qmfExponentCurrent); 197 198 /** 199 * \brief Decode PVC data for one SBR time slot (call if pvcMode = 1,2) 200 * \param[in,out] pPvcStaticData Pointer to PVC persistent data 201 * \param[in,out] pPvcDynamicData Pointer to PVC dynamic data 202 * \param[in] qmfBufferReal Pointer to array with real QMF subbands 203 * \param[in] qmfBufferImag Pointer to array with imag QMF subbands 204 * \param[in] qmfExponent Exponent of qmfBuffer of current time slot 205 * \param[in] pvcBorder0 Start SBR time slot of PVC frame 206 * \param[in] timeSlotNumber Number of current SBR time slot (0..15) 207 * \param[out] predictedEsgSlot Predicted Energy of current time slot 208 * \param[out] predictedEsg_exp Exponent of predicted Energy of current time 209 * slot 210 */ 211 void pvcDecodeTimeSlot(PVC_STATIC_DATA *pPvcStaticData, 212 PVC_DYNAMIC_DATA *pPvcDynamicData, 213 FIXP_DBL **qmfSlotReal, FIXP_DBL **qmfSlotImag, 214 const int qmfExponent, const int pvcBorder0, 215 const int timeSlotNumber, FIXP_DBL predictedEsgSlot[], 216 int *predictedEsg_exp); 217 218 /** 219 * \brief Finish the current PVC frame (call if pvcMode = 0,1,2) 220 * \param[in,out] pPvcStaticData Pointer to PVC persistent data 221 * \param[in,out] pPvcDynamicData Pointer to PVC dynamic data 222 */ 223 void pvcEndFrame(PVC_STATIC_DATA *pPvcStaticData, 224 PVC_DYNAMIC_DATA *pPvcDynamicData); 225 226 /** 227 * \brief Expand predicted PVC grouped energies to full QMF subband resolution 228 * \param[in] pPvcDynamicData Pointer to PVC dynamic data 229 * \param[in] timeSlot Number of current SBR time slot (0..15) 230 * \param[in] lengthOutputVector Lenght of output vector 231 * \param[out] pOutput Output array for predicted energies 232 * \param[out] pOutput_exp Exponent of predicted energies 233 */ 234 void expandPredEsg(const PVC_DYNAMIC_DATA *pPvcDynamicData, const int timeSlot, 235 const int lengthOutputVector, FIXP_DBL *pOutput, 236 SCHAR *pOutput_exp); 237 238 #endif /* PVC_DEC_H*/ 239