videoeditorengine/mp3aacManipLib/AACGain/inc/env_extr.h
changeset 0 951a5db380a0
equal deleted inserted replaced
-1:000000000000 0:951a5db380a0
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Ixonos Plc
       
    14 *
       
    15 * Description:
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /*
       
    21   \file
       
    22   \brief  Envelope extraction prototypes $Revision: 1.2.4.1 $
       
    23 */
       
    24 
       
    25 /**************************************************************************
       
    26   env_extr.h - SBR bitstream demultiplexer interface + constants.
       
    27  
       
    28   Author(s): Juha Ojanpera
       
    29   Copyright (c) 2004 by Nokia Research Center, Multimedia Technologies.
       
    30   *************************************************************************/
       
    31 
       
    32 #ifndef SBR_BITDEMUX_H_
       
    33 #define SBR_BITDEMUX_H_
       
    34 
       
    35 /*-- Project Headers. --*/
       
    36 #include "sbr_codec.h"
       
    37 
       
    38 #define SBR_FREQ_SCALE_DEF       (2)
       
    39 #define SBR_ALTER_SCALE_DEF      (1)
       
    40 #define SBR_NOISE_BANDS_DEF      (2)
       
    41 
       
    42 #define SBR_LIMITER_BANDS_DEF    (2)
       
    43 #define SBR_LIMITER_GAINS_DEF    (2)
       
    44 #define SBR_INTERPOL_FREQ_DEF    (1)
       
    45 #define SBR_SMOOTHING_LENGTH_DEF (1)
       
    46 
       
    47 #define SBR_AMP_RES_1_5          (0)
       
    48 #define SBR_AMP_RES_3_0          (1)
       
    49 
       
    50 #define FIXFIX                   (0)
       
    51 #define FIXVAR                   (1)
       
    52 #define VARFIX                   (2)
       
    53 #define VARVAR                   (3)
       
    54 
       
    55 #define SBR_UPSAMPLE_FAC         (2)
       
    56 #define NO_SYNTHESIS_CHANNELS    (64)
       
    57 #define NO_ANALYSIS_CHANNELS     (NO_SYNTHESIS_CHANNELS / SBR_UPSAMPLE_FAC)
       
    58 #define MAX_NOISE_ENVELOPES      (2)
       
    59 #define MAX_NOISE_COEFFS         (8)
       
    60 #define MAX_NUM_NOISE_VALUES     (MAX_NOISE_ENVELOPES * MAX_NOISE_COEFFS)
       
    61 #define MAX_NUM_LIMITERS         (12)
       
    62 #define MAX_ENVELOPES            (8)
       
    63 #define MAX_FREQ_COEFFS          (48)
       
    64 #define MAX_FREQ_COEFFS_FS44100  (35)
       
    65 #define MAX_FREQ_COEFFS_FS48000  (32)
       
    66 #define MAX_NUM_ENVELOPE_VALUES  (MAX_ENVELOPES * MAX_FREQ_COEFFS)
       
    67 #define MAX_INVF_BANDS           (MAX_NOISE_COEFFS)
       
    68 #define SBR_PARAMETRIC_STEREO_ID (2)
       
    69 
       
    70 /**
       
    71  * SBR header status.
       
    72  */
       
    73 typedef enum
       
    74 {
       
    75   HEADER_OK,
       
    76   HEADER_RESET,
       
    77   CONCEALMENT,
       
    78   HEADER_NOT_INITIALIZED
       
    79 
       
    80 } SBR_HEADER_STATUS;
       
    81 
       
    82 /**
       
    83  * SBR codec status.
       
    84  */
       
    85 typedef enum
       
    86 {
       
    87   SBR_NOT_INITIALIZED,
       
    88   UPSAMPLING,
       
    89   SBR_ACTIVE
       
    90 
       
    91 } SBR_SYNC_STATE;
       
    92 
       
    93 /**
       
    94  * SBR coupling modes.
       
    95  */
       
    96 typedef enum
       
    97 {
       
    98   COUPLING_OFF,
       
    99   COUPLING_LEVEL,
       
   100   COUPLING_BAL
       
   101 
       
   102 } COUPLING_MODE;
       
   103 
       
   104 /**
       
   105  * Frequency scale tables for SBR.
       
   106  */
       
   107 typedef struct FreqBandDataStr
       
   108 {
       
   109   uint8 nSfb[2];
       
   110   uint8 nNfb;
       
   111   uint8 numMaster;
       
   112   uint8 noLimiterBands;
       
   113   uint8 nInvfBands;
       
   114   uint8 v_k_master[MAX_FREQ_COEFFS + 1];
       
   115 
       
   116 } FreqBandData;
       
   117 
       
   118 /**
       
   119  * SBR header element.
       
   120  */
       
   121 typedef struct SbrHeaderDataStr
       
   122 {
       
   123   SBR_SYNC_STATE syncState;
       
   124   uint8 numberTimeSlots;
       
   125   uint8 timeStep;
       
   126   uint16 codecFrameSize;
       
   127   int32 outSampleRate;
       
   128 
       
   129   uint8 ampResolution;
       
   130 
       
   131   uint8 startFreq;
       
   132   uint8 stopFreq;
       
   133   uint8 xover_band;
       
   134   uint8 freqScale;
       
   135   uint8 alterScale;
       
   136   uint8 noise_bands;
       
   137 
       
   138   uint8 limiterBands;
       
   139   uint8 limiterGains;
       
   140   uint8 interpolFreq;
       
   141   uint8 smoothingLength;
       
   142 
       
   143   FreqBandData *hFreqBandData;
       
   144 
       
   145 } SbrHeaderData;
       
   146 
       
   147 /**
       
   148  * SBR frame info element.
       
   149  */
       
   150 typedef struct FRAME_INFOStr
       
   151 {
       
   152   uint8 frameClass;
       
   153   uint8 nEnvelopes;
       
   154   uint8 freqRes;
       
   155   uint8 nNoiseEnvelopes;
       
   156 
       
   157 } FRAME_INFO;
       
   158 
       
   159 /**
       
   160  * SBR grid info element.
       
   161  */
       
   162 typedef struct SbrGridInfoStr
       
   163 {
       
   164   uint8 bs_num_env;
       
   165 
       
   166   uint8 bs_pointer;
       
   167   uint8 bs_num_rel[2];
       
   168   uint8 bs_var_board[2];
       
   169   uint8 bs_rel_board_0[4];
       
   170   uint8 bs_rel_board_1[4];
       
   171 
       
   172 } SbrGridInfo;
       
   173 
       
   174 /**
       
   175  * SBR frame data element.
       
   176  */
       
   177 typedef struct SbrFrameDataStr
       
   178 {
       
   179   uint8 dataPresent;
       
   180 
       
   181   FRAME_INFO frameInfo;
       
   182   SbrGridInfo sbrGridInfo;
       
   183 
       
   184   uint8 domain_vec;
       
   185   uint8 domain_vec_noise;
       
   186 
       
   187   uint16 sbr_invf_mode;
       
   188   COUPLING_MODE coupling;
       
   189 
       
   190   uint8 isSinesPresent;
       
   191   uint32 addHarmonics[2];
       
   192 
       
   193   int8 iEnvelope[MAX_NUM_ENVELOPE_VALUES];
       
   194   int8 sbrNoiseFloorLevel[MAX_NUM_NOISE_VALUES];
       
   195 
       
   196 } SbrFrameData;
       
   197 
       
   198 /**
       
   199  * SBR extension data element.
       
   200  */
       
   201 typedef struct SbrExtensionDataStr
       
   202 {
       
   203   uint8 writePsData;
       
   204   uint8 extensionDataPresent;
       
   205   int16 byteCount;
       
   206   uint8 extension_id;
       
   207   int16 extDataBufLen;
       
   208   uint8 *extensioData;
       
   209 
       
   210 } SbrExtensionData;
       
   211 
       
   212 /**
       
   213     * Reads SBR single channel element.
       
   214     *
       
   215   * @param hHeaderData  Handle to SBR header data
       
   216   * @param hFrameData   Handle to SBR frame data
       
   217   * @param sbrExtData   Handle to SBR extension data
       
   218   * @param bs           Input bitstream
       
   219   * @param decVal       Volume level adjustment factor
       
   220   * @param isMono       1 if mono SBR bitstream, 0 otherwise
       
   221   * @return             Error code, 0 on success
       
   222     * 
       
   223     */
       
   224 int16
       
   225 sbrGetSCE(SbrHeaderData *hHeaderData,
       
   226           SbrFrameData  *hFrameData,
       
   227           SbrExtensionData *sbrExtData,
       
   228           TBitStream *bs,
       
   229           int16 decVal,
       
   230           uint8 isMono);
       
   231 
       
   232 /**
       
   233     * Reads SBR channel pair element.
       
   234     *
       
   235   * @param hHeaderData     Handle to SBR header data
       
   236   * @param hFrameDataLeft  Handle to left channel SBR frame data
       
   237   * @param hFrameDataRight Handle to right channel SBR frame data
       
   238   * @param sbrExtData      Handle to SBR extension data
       
   239   * @param bs              Input bitstream
       
   240   * @param decVal          Volume level adjustment factor
       
   241   * @return                Error code, 0 on success
       
   242     * 
       
   243     */
       
   244 int16 
       
   245 sbrGetCPE(SbrHeaderData *hHeaderData,
       
   246           SbrFrameData *hFrameDataLeft,
       
   247           SbrFrameData *hFrameDataRight,
       
   248           SbrExtensionData *sbrExtData,
       
   249           TBitStream *bs,
       
   250           int16 decVal);
       
   251 
       
   252 /**
       
   253     * Reads SBR header element.
       
   254     *
       
   255   * @param hHeaderData  Handle to SBR header data
       
   256   * @param bs           Input bitstream
       
   257   * @return             Status of header processing, see status codes
       
   258     * 
       
   259     */
       
   260 SBR_HEADER_STATUS
       
   261 sbrGetHeaderData(SbrHeaderData *h_sbr_header,
       
   262                  TBitStream *bs);
       
   263 
       
   264 /**
       
   265     * Initalizes SBR header element.
       
   266     *
       
   267   * @param hHeaderData     Handle to SBR header data
       
   268   * @param FreqBandData    Handle to SBR frequency scale data
       
   269   * @param sampleRate      Sampling rate of AAC bitstream
       
   270   * @param samplesPerFrame Number of samples in a frame (1024 or 960)
       
   271     * 
       
   272     */
       
   273 void
       
   274 initHeaderData(SbrHeaderData *headerData, 
       
   275                FreqBandData *FreqBandData,
       
   276                int32 sampleRate, 
       
   277                int16 samplesPerFrame);
       
   278 
       
   279 /**
       
   280     * Initalizes SBR frequency scale tables.
       
   281     *
       
   282   * @param hHeaderData     Handle to SBR header data
       
   283   * @return                Error code, 0 on success
       
   284     * 
       
   285     */
       
   286 int16
       
   287 resetFreqBandTables(SbrHeaderData *hHeaderData);
       
   288 
       
   289 FLOAT 
       
   290 FloatFR_logDualis(int16 a);
       
   291 
       
   292 FLOAT 
       
   293 FloatFR_getNumOctaves(int16 a, int16 b);
       
   294 
       
   295 #endif /*-- SBR_BITDEMUX_H_ --*/