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