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): 98 99 Description: 100 101 *******************************************************************************/ 102 103 /*! 104 \file 105 \brief Framing generator prototypes and structs $Revision: 92790 $ 106 */ 107 #ifndef FRAM_GEN_H 108 #define FRAM_GEN_H 109 110 #include "sbr_def.h" /* for MAX_ENVELOPES and MAX_NOISE_ENVELOPES in struct FRAME_INFO and CODEC_TYPE */ 111 #include "sbr_encoder.h" /* for FREQ_RES */ 112 113 #define MAX_ENVELOPES_VARVAR \ 114 MAX_ENVELOPES /*!< worst case number of envelopes in a VARVAR frame */ 115 #define MAX_ENVELOPES_FIXVAR_VARFIX \ 116 4 /*!< worst case number of envelopes in VARFIX and FIXVAR frames */ 117 #define MAX_NUM_REL \ 118 3 /*!< maximum number of relative borders in any VAR frame */ 119 120 /* SBR frame class definitions */ 121 typedef enum { 122 FIXFIX = 123 0, /*!< bs_frame_class: leading and trailing frame borders are fixed */ 124 FIXVAR, /*!< bs_frame_class: leading frame border is fixed, trailing frame 125 border is variable */ 126 VARFIX, /*!< bs_frame_class: leading frame border is variable, trailing frame 127 border is fixed */ 128 VARVAR /*!< bs_frame_class: leading and trailing frame borders are variable */ 129 , 130 FIXFIXonly /*!< bs_frame_class: leading border fixed (0), trailing border 131 fixed (nrTimeSlots) and encased borders are dynamically derived 132 from the tranPos */ 133 } FRAME_CLASS; 134 135 /* helper constants */ 136 #define DC 4711 /*!< helper constant: don't care */ 137 #define EMPTY (-99) /*!< helper constant: empty */ 138 139 /* system constants: AAC+SBR, DRM Frame-Length */ 140 #define FRAME_MIDDLE_SLOT_1920 4 141 #define NUMBER_TIME_SLOTS_1920 15 142 143 #define LD_PRETRAN_OFF 3 144 #define FRAME_MIDDLE_SLOT_512LD 4 145 #define NUMBER_TIME_SLOTS_512LD 8 146 #define TRANSIENT_OFFSET_LD 0 147 148 /* 149 system constants: AAC+SBR or aacPRO (hybrid format), Standard Frame-Length, 150 Multi-Rate 151 --------------------------------------------------------------------------- 152 Number of slots (numberTimeSlots): 16 (NUMBER_TIME_SLOTS_2048) 153 Detector-offset (frameMiddleSlot): 4 154 Overlap : 3 155 Buffer-offset : 8 (BUFFER_FRAME_START_2048 = 0) 156 157 158 |<------------tranPos---------->| 159 |c|d|e|f|0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f| 160 FixFix | | 161 FixVar | :<- ->: 162 VarFix :<- ->: | 163 VarVar :<- ->: :<- ->: 164 0 1 2 3 4 5 6 7 8 9 a b c d e f 0 1 2 3 165 ................................................................................ 166 167 |-|-|-|-|-|-|-|-B-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-B-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-| 168 169 frame-generator:0 16 24 32 170 analysis-buffer:8 24 32 40 171 */ 172 #define FRAME_MIDDLE_SLOT_2048 4 173 #define NUMBER_TIME_SLOTS_2048 16 174 175 /* 176 system constants: mp3PRO, Multi-Rate & Single-Rate 177 -------------------------------------------------- 178 Number of slots (numberTimeSlots): 9 (NUMBER_TIME_SLOTS_1152) 179 Detector-offset (frameMiddleSlot): 4 (FRAME_MIDDLE_SLOT_1152) 180 Overlap : 3 181 Buffer-offset : 4.5 (BUFFER_FRAME_START_1152 = 0) 182 183 184 |<----tranPos---->| 185 |5|6|7|8|0|1|2|3|4|5|6|7|8| 186 FixFix | | 187 FixVar | :<- ->: 188 VarFix :<- ->: | 189 VarVar :<- ->: :<- ->: 190 0 1 2 3 4 5 6 7 8 0 1 2 3 191 ............................................. 192 193 -|-|-|-|-B-|-|-|-|-|-|-|-|-B-|-|-|-|-|-|-|-|-| 194 195 frame-generator: 0 9 13 18 196 analysis-buffer: 4.5 13.5 22.5 197 */ 198 #define FRAME_MIDDLE_SLOT_1152 4 199 #define NUMBER_TIME_SLOTS_1152 9 200 201 /* system constants: Layer2+SBR */ 202 #define FRAME_MIDDLE_SLOT_2304 8 203 #define NUMBER_TIME_SLOTS_2304 18 204 205 /*! 206 \struct SBR_GRID 207 \brief sbr_grid() signals to be converted to bitstream elements 208 209 The variables hold the signals (e.g. lengths and numbers) in "clear text" 210 */ 211 212 typedef struct { 213 /* system constants */ 214 INT bufferFrameStart; /*!< frame generator vs analysis buffer time alignment 215 (currently set to 0, offset added elsewhere) */ 216 INT numberTimeSlots; /*!< number of SBR timeslots per frame */ 217 218 /* will be adjusted for every frame */ 219 FRAME_CLASS frameClass; /*!< SBR frame class */ 220 INT bs_num_env; /*!< bs_num_env, number of envelopes for FIXFIX */ 221 INT bs_abs_bord; /*!< bs_abs_bord, absolute border for VARFIX and FIXVAR */ 222 INT n; /*!< number of relative borders for VARFIX and FIXVAR */ 223 INT p; /*!< pointer-to-transient-border */ 224 INT bs_rel_bord[MAX_NUM_REL]; /*!< bs_rel_bord, relative borders for all VAR 225 */ 226 INT v_f[MAX_ENVELOPES_FIXVAR_VARFIX]; /*!< envelope frequency resolutions for 227 FIXVAR and VARFIX */ 228 229 INT bs_abs_bord_0; /*!< bs_abs_bord_0, leading absolute border for VARVAR */ 230 INT bs_abs_bord_1; /*!< bs_abs_bord_1, trailing absolute border for VARVAR */ 231 INT bs_num_rel_0; /*!< bs_num_rel_0, number of relative borders associated 232 with leading absolute border for VARVAR */ 233 INT bs_num_rel_1; /*!< bs_num_rel_1, number of relative borders associated 234 with trailing absolute border for VARVAR */ 235 INT bs_rel_bord_0[MAX_NUM_REL]; /*!< bs_rel_bord_0, relative borders 236 associated with leading absolute border 237 for VARVAR */ 238 INT bs_rel_bord_1[MAX_NUM_REL]; /*!< bs_rel_bord_1, relative borders 239 associated with trailing absolute border 240 for VARVAR */ 241 INT v_fLR[MAX_ENVELOPES_VARVAR]; /*!< envelope frequency resolutions for 242 VARVAR */ 243 244 } SBR_GRID; 245 typedef SBR_GRID *HANDLE_SBR_GRID; 246 247 /*! 248 \struct SBR_FRAME_INFO 249 \brief time/frequency grid description for one frame 250 */ 251 typedef struct { 252 INT nEnvelopes; /*!< number of envelopes */ 253 INT borders[MAX_ENVELOPES + 1]; /*!< envelope borders in SBR timeslots */ 254 FREQ_RES freqRes[MAX_ENVELOPES]; /*!< frequency resolution of each envelope */ 255 INT shortEnv; /*!< number of an envelope to be shortened (starting at 1) or 0 256 for no shortened envelope */ 257 INT nNoiseEnvelopes; /*!< number of noise floors */ 258 INT bordersNoise[MAX_NOISE_ENVELOPES + 259 1]; /*!< noise floor borders in SBR timeslots */ 260 } SBR_FRAME_INFO; 261 /* WARNING: When rearranging the elements of this struct keep in mind that the 262 * static initializations in the corresponding C-file have to be rearranged as 263 * well! snd 2002/01/23 264 */ 265 typedef SBR_FRAME_INFO *HANDLE_SBR_FRAME_INFO; 266 267 /*! 268 \struct SBR_ENVELOPE_FRAME 269 \brief frame generator main struct 270 271 Contains tuning parameters, time/frequency grid description, sbr_grid() 272 bitstream elements, and generator internal signals 273 */ 274 typedef struct { 275 /* system constants */ 276 INT frameMiddleSlot; /*!< transient detector offset in SBR timeslots */ 277 278 /* basic tuning parameters */ 279 INT staticFraming; /*!< 1: run static framing in time, i.e. exclusive use of 280 bs_frame_class = FIXFIX */ 281 INT numEnvStatic; /*!< number of envelopes per frame for static framing */ 282 FREQ_RES 283 freq_res_fixfix[2]; /*!< envelope frequency resolution to use for 284 bs_frame_class = FIXFIX; single env and split */ 285 UCHAR 286 fResTransIsLow; /*!< frequency resolution for transient frames - always 287 low (0) or according to table (1) */ 288 289 /* expert tuning parameters */ 290 const int *v_tuningSegm; /*!< segment lengths to use around transient */ 291 const int *v_tuningFreq; /*!< frequency resolutions to use around transient */ 292 INT dmin; /*!< minimum length of dependent segments */ 293 INT dmax; /*!< maximum length of dependent segments */ 294 INT allowSpread; /*!< 1: allow isolated transient to influence grid of 3 295 consecutive frames */ 296 297 /* internally used signals */ 298 FRAME_CLASS frameClassOld; /*!< frame class used for previous frame */ 299 INT spreadFlag; /*!< 1: use VARVAR instead of VARFIX to follow up old 300 transient */ 301 302 INT v_bord[2 * MAX_ENVELOPES_VARVAR + 1]; /*!< borders for current frame and 303 preliminary borders for next 304 frame (fixed borders excluded) */ 305 INT length_v_bord; /*!< helper variable: length of v_bord */ 306 INT v_freq[2 * MAX_ENVELOPES_VARVAR + 1]; /*!< frequency resolutions for 307 current frame and preliminary 308 resolutions for next frame */ 309 INT length_v_freq; /*!< helper variable: length of v_freq */ 310 311 INT v_bordFollow[MAX_ENVELOPES_VARVAR]; /*!< preliminary borders for current 312 frame (calculated during previous 313 frame) */ 314 INT length_v_bordFollow; /*!< helper variable: length of v_bordFollow */ 315 INT i_tranFollow; /*!< points to transient border in v_bordFollow (may be 316 negative, see keepForFollowUp()) */ 317 INT i_fillFollow; /*!< points to first fill border in v_bordFollow */ 318 INT v_freqFollow[MAX_ENVELOPES_VARVAR]; /*!< preliminary frequency resolutions 319 for current frame (calculated 320 during previous frame) */ 321 INT length_v_freqFollow; /*!< helper variable: length of v_freqFollow */ 322 323 /* externally needed signals */ 324 SBR_GRID 325 SbrGrid; /*!< sbr_grid() signals to be converted to bitstream elements */ 326 SBR_FRAME_INFO 327 SbrFrameInfo; /*!< time/frequency grid description for one frame */ 328 } SBR_ENVELOPE_FRAME; 329 typedef SBR_ENVELOPE_FRAME *HANDLE_SBR_ENVELOPE_FRAME; 330 331 void FDKsbrEnc_initFrameInfoGenerator(HANDLE_SBR_ENVELOPE_FRAME hSbrEnvFrame, 332 INT allowSpread, INT numEnvStatic, 333 INT staticFraming, INT timeSlots, 334 const FREQ_RES *freq_res_fixfix, 335 UCHAR fResTransIsLow, INT ldGrid); 336 337 HANDLE_SBR_FRAME_INFO 338 FDKsbrEnc_frameInfoGenerator(HANDLE_SBR_ENVELOPE_FRAME hSbrEnvFrame, 339 UCHAR *v_transient_info, const INT rightBorderFIX, 340 UCHAR *v_transient_info_pre, int ldGrid, 341 const int *v_tuning); 342 343 #endif 344