1 2 /* ----------------------------------------------------------------------------------------------------------- 3 Software License for The Fraunhofer FDK AAC Codec Library for Android 4 5 � Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F�rderung der angewandten Forschung e.V. 6 All rights reserved. 7 8 1. INTRODUCTION 9 The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements 10 the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. 11 This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 12 13 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual 14 audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by 15 independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part 16 of the MPEG specifications. 17 18 Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer) 19 may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners 20 individually for the purpose of encoding or decoding bit streams in products that are compliant with 21 the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license 22 these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec 23 software may already be covered under those patent licenses when it is used for those licensed purposes only. 24 25 Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality, 26 are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional 27 applications information and documentation. 28 29 2. COPYRIGHT LICENSE 30 31 Redistribution and use in source and binary forms, with or without modification, are permitted without 32 payment of copyright license fees provided that you satisfy the following conditions: 33 34 You must retain the complete text of this software license in redistributions of the FDK AAC Codec or 35 your modifications thereto in source code form. 36 37 You must retain the complete text of this software license in the documentation and/or other materials 38 provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. 39 You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 40 modifications thereto to recipients of copies in binary form. 41 42 The name of Fraunhofer may not be used to endorse or promote products derived from this library without 43 prior written permission. 44 45 You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec 46 software or your modifications thereto. 47 48 Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software 49 and the date of any change. For modified versions of the FDK AAC Codec, the term 50 "Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term 51 "Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android." 52 53 3. NO PATENT LICENSE 54 55 NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, 56 ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with 57 respect to this software. 58 59 You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized 60 by appropriate patent licenses. 61 62 4. DISCLAIMER 63 64 This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors 65 "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties 66 of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 67 CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, 68 including but not limited to procurement of substitute goods or services; loss of use, data, or profits, 69 or business interruption, however caused and on any theory of liability, whether in contract, strict 70 liability, or tort (including negligence), arising in any way out of the use of this software, even if 71 advised of the possibility of such damage. 72 73 5. CONTACT INFORMATION 74 75 Fraunhofer Institute for Integrated Circuits IIS 76 Attention: Audio and Multimedia Departments - FDK AAC LL 77 Am Wolfsmantel 33 78 91058 Erlangen, Germany 79 80 www.iis.fraunhofer.de/amm 81 amm-info@iis.fraunhofer.de 82 ----------------------------------------------------------------------------------------------------------- */ 83 84 /*! 85 \file 86 \brief Framing generator prototypes and structs 87 */ 88 #ifndef _FRAM_GEN_H 89 #define _FRAM_GEN_H 90 91 #include "sbr_def.h" /* for MAX_ENVELOPES and MAX_NOISE_ENVELOPES in struct FRAME_INFO and CODEC_TYPE */ 92 93 #define MAX_ENVELOPES_VARVAR MAX_ENVELOPES /*!< worst case number of envelopes in a VARVAR frame */ 94 #define MAX_ENVELOPES_FIXVAR_VARFIX 4 /*!< worst case number of envelopes in VARFIX and FIXVAR frames */ 95 #define MAX_NUM_REL 3 /*!< maximum number of relative borders in any VAR frame */ 96 97 /* SBR frame class definitions */ 98 typedef enum { 99 FIXFIX = 0, /*!< bs_frame_class: leading and trailing frame borders are fixed */ 100 FIXVAR, /*!< bs_frame_class: leading frame border is fixed, trailing frame border is variable */ 101 VARFIX, /*!< bs_frame_class: leading frame border is variable, trailing frame border is fixed */ 102 VARVAR /*!< bs_frame_class: leading and trailing frame borders are variable */ 103 ,FIXFIXonly /*!< bs_frame_class: leading border fixed (0), trailing border fixed (nrTimeSlots) and encased borders are dynamically derived from the tranPos */ 104 }FRAME_CLASS; 105 106 107 /* helper constants */ 108 #define DC 4711 /*!< helper constant: don't care */ 109 #define EMPTY (-99) /*!< helper constant: empty */ 110 111 112 /* system constants: AAC+SBR, DRM Frame-Length */ 113 #define FRAME_MIDDLE_SLOT_1920 4 114 #define NUMBER_TIME_SLOTS_1920 15 115 116 #define LD_PRETRAN_OFF 3 117 #define FRAME_MIDDLE_SLOT_512LD 0 118 #define NUMBER_TIME_SLOTS_512LD 8 119 #define TRANSIENT_OFFSET_LD 0 120 121 122 123 /* 124 system constants: AAC+SBR or aacPRO (hybrid format), Standard Frame-Length, Multi-Rate 125 --------------------------------------------------------------------------- 126 Number of slots (numberTimeSlots): 16 (NUMBER_TIME_SLOTS_2048) 127 Detector-offset (frameMiddleSlot): 4 128 Overlap : 3 129 Buffer-offset : 8 (BUFFER_FRAME_START_2048 = 0) 130 131 132 |<------------tranPos---------->| 133 |c|d|e|f|0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f| 134 FixFix | | 135 FixVar | :<- ->: 136 VarFix :<- ->: | 137 VarVar :<- ->: :<- ->: 138 0 1 2 3 4 5 6 7 8 9 a b c d e f 0 1 2 3 139 ................................................................................ 140 141 |-|-|-|-|-|-|-|-B-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-B-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-| 142 143 frame-generator:0 16 24 32 144 analysis-buffer:8 24 32 40 145 */ 146 #define FRAME_MIDDLE_SLOT_2048 4 147 #define NUMBER_TIME_SLOTS_2048 16 148 149 150 /* 151 system constants: mp3PRO, Multi-Rate & Single-Rate 152 -------------------------------------------------- 153 Number of slots (numberTimeSlots): 9 (NUMBER_TIME_SLOTS_1152) 154 Detector-offset (frameMiddleSlot): 4 (FRAME_MIDDLE_SLOT_1152) 155 Overlap : 3 156 Buffer-offset : 4.5 (BUFFER_FRAME_START_1152 = 0) 157 158 159 |<----tranPos---->| 160 |5|6|7|8|0|1|2|3|4|5|6|7|8| 161 FixFix | | 162 FixVar | :<- ->: 163 VarFix :<- ->: | 164 VarVar :<- ->: :<- ->: 165 0 1 2 3 4 5 6 7 8 0 1 2 3 166 ............................................. 167 168 -|-|-|-|-B-|-|-|-|-|-|-|-|-B-|-|-|-|-|-|-|-|-| 169 170 frame-generator: 0 9 13 18 171 analysis-buffer: 4.5 13.5 22.5 172 */ 173 #define FRAME_MIDDLE_SLOT_1152 4 174 #define NUMBER_TIME_SLOTS_1152 9 175 176 177 /* system constants: Layer2+SBR */ 178 #define FRAME_MIDDLE_SLOT_2304 8 179 #define NUMBER_TIME_SLOTS_2304 18 180 181 182 /*! 183 \struct SBR_GRID 184 \brief sbr_grid() signals to be converted to bitstream elements 185 186 The variables hold the signals (e.g. lengths and numbers) in "clear text" 187 */ 188 189 typedef struct 190 { 191 /* system constants */ 192 INT bufferFrameStart; /*!< frame generator vs analysis buffer time alignment (currently set to 0, offset added elsewhere) */ 193 INT numberTimeSlots; /*!< number of SBR timeslots per frame */ 194 195 /* will be adjusted for every frame */ 196 FRAME_CLASS frameClass; /*!< SBR frame class */ 197 INT bs_num_env; /*!< bs_num_env, number of envelopes for FIXFIX */ 198 INT bs_abs_bord; /*!< bs_abs_bord, absolute border for VARFIX and FIXVAR */ 199 INT n; /*!< number of relative borders for VARFIX and FIXVAR */ 200 INT p; /*!< pointer-to-transient-border */ 201 INT bs_rel_bord[MAX_NUM_REL]; /*!< bs_rel_bord, relative borders for all VAR */ 202 INT v_f[MAX_ENVELOPES_FIXVAR_VARFIX]; /*!< envelope frequency resolutions for FIXVAR and VARFIX */ 203 204 INT bs_abs_bord_0; /*!< bs_abs_bord_0, leading absolute border for VARVAR */ 205 INT bs_abs_bord_1; /*!< bs_abs_bord_1, trailing absolute border for VARVAR */ 206 INT bs_num_rel_0; /*!< bs_num_rel_0, number of relative borders associated with leading absolute border for VARVAR */ 207 INT bs_num_rel_1; /*!< bs_num_rel_1, number of relative borders associated with trailing absolute border for VARVAR */ 208 INT bs_rel_bord_0[MAX_NUM_REL]; /*!< bs_rel_bord_0, relative borders associated with leading absolute border for VARVAR */ 209 INT bs_rel_bord_1[MAX_NUM_REL]; /*!< bs_rel_bord_1, relative borders associated with trailing absolute border for VARVAR */ 210 INT v_fLR[MAX_ENVELOPES_VARVAR]; /*!< envelope frequency resolutions for VARVAR */ 211 212 } 213 SBR_GRID; 214 typedef SBR_GRID *HANDLE_SBR_GRID; 215 216 217 218 /*! 219 \struct SBR_FRAME_INFO 220 \brief time/frequency grid description for one frame 221 */ 222 typedef struct 223 { 224 INT nEnvelopes; /*!< number of envelopes */ 225 INT borders[MAX_ENVELOPES+1]; /*!< envelope borders in SBR timeslots */ 226 FREQ_RES freqRes[MAX_ENVELOPES]; /*!< frequency resolution of each envelope */ 227 INT shortEnv; /*!< number of an envelope to be shortened (starting at 1) or 0 for no shortened envelope */ 228 INT nNoiseEnvelopes; /*!< number of noise floors */ 229 INT bordersNoise[MAX_NOISE_ENVELOPES+1];/*!< noise floor borders in SBR timeslots */ 230 } 231 SBR_FRAME_INFO; 232 /* WARNING: When rearranging the elements of this struct keep in mind that the static 233 * initializations in the corresponding C-file have to be rearranged as well! 234 * snd 2002/01/23 235 */ 236 typedef SBR_FRAME_INFO *HANDLE_SBR_FRAME_INFO; 237 238 239 /*! 240 \struct SBR_ENVELOPE_FRAME 241 \brief frame generator main struct 242 243 Contains tuning parameters, time/frequency grid description, sbr_grid() bitstream elements, and generator internal signals 244 */ 245 typedef struct 246 { 247 /* system constants */ 248 INT frameMiddleSlot; /*!< transient detector offset in SBR timeslots */ 249 250 /* basic tuning parameters */ 251 INT staticFraming; /*!< 1: run static framing in time, i.e. exclusive use of bs_frame_class = FIXFIX */ 252 INT numEnvStatic; /*!< number of envelopes per frame for static framing */ 253 INT freq_res_fixfix; /*!< envelope frequency resolution to use for bs_frame_class = FIXFIX */ 254 255 /* expert tuning parameters */ 256 const int *v_tuningSegm; /*!< segment lengths to use around transient */ 257 const int *v_tuningFreq; /*!< frequency resolutions to use around transient */ 258 INT dmin; /*!< minimum length of dependent segments */ 259 INT dmax; /*!< maximum length of dependent segments */ 260 INT allowSpread; /*!< 1: allow isolated transient to influence grid of 3 consecutive frames */ 261 262 /* internally used signals */ 263 FRAME_CLASS frameClassOld; /*!< frame class used for previous frame */ 264 INT spreadFlag; /*!< 1: use VARVAR instead of VARFIX to follow up old transient */ 265 266 INT v_bord[2 * MAX_ENVELOPES_VARVAR + 1]; /*!< borders for current frame and preliminary borders for next frame (fixed borders excluded) */ 267 INT length_v_bord; /*!< helper variable: length of v_bord */ 268 INT v_freq[2 * MAX_ENVELOPES_VARVAR + 1]; /*!< frequency resolutions for current frame and preliminary resolutions for next frame */ 269 INT length_v_freq; /*!< helper variable: length of v_freq */ 270 271 INT v_bordFollow[MAX_ENVELOPES_VARVAR]; /*!< preliminary borders for current frame (calculated during previous frame) */ 272 INT length_v_bordFollow; /*!< helper variable: length of v_bordFollow */ 273 INT i_tranFollow; /*!< points to transient border in v_bordFollow (may be negative, see keepForFollowUp()) */ 274 INT i_fillFollow; /*!< points to first fill border in v_bordFollow */ 275 INT v_freqFollow[MAX_ENVELOPES_VARVAR]; /*!< preliminary frequency resolutions for current frame (calculated during previous frame) */ 276 INT length_v_freqFollow; /*!< helper variable: length of v_freqFollow */ 277 278 279 /* externally needed signals */ 280 SBR_GRID SbrGrid; /*!< sbr_grid() signals to be converted to bitstream elements */ 281 SBR_FRAME_INFO SbrFrameInfo; /*!< time/frequency grid description for one frame */ 282 } 283 SBR_ENVELOPE_FRAME; 284 typedef SBR_ENVELOPE_FRAME *HANDLE_SBR_ENVELOPE_FRAME; 285 286 287 288 void 289 FDKsbrEnc_initFrameInfoGenerator (HANDLE_SBR_ENVELOPE_FRAME hSbrEnvFrame, 290 INT allowSpread, 291 INT numEnvStatic, 292 INT staticFraming, 293 INT timeSlots, 294 INT freq_res_fixfix 295 ,int ldGrid 296 ); 297 298 HANDLE_SBR_FRAME_INFO 299 FDKsbrEnc_frameInfoGenerator (HANDLE_SBR_ENVELOPE_FRAME hSbrEnvFrame, 300 UCHAR *v_transient_info, 301 UCHAR *v_transient_info_pre, 302 int ldGrid, 303 const int *v_tuning); 304 305 #endif 306