⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 constants.h

📁 本程序为ST公司开发的源代码
💻 H
字号:
/*
 * $Copyright: 
 * ----------------------------------------------------------------
 * This confidential and proprietary software may be used only as
 * authorised by a licensing agreement from ARM Limited
 *   (C) COPYRIGHT 2001,2002 ARM Limited
 *       ALL RIGHTS RESERVED
 * The entire notice above must be reproduced on all authorised
 * copies and copies may only be made to the extent permitted
 * by a licensing agreement from ARM Limited.
 * ----------------------------------------------------------------
 * File:     constants.h,v
 * Revision: 1.2
 * ----------------------------------------------------------------
 * $
 *
 * Definitions of constant AAC decoder parameters and types
 */

#ifndef _CONSTANTS_H_
#define _CONSTANTS_H_

#ifndef min //MIN
#define min(x,y) ( ((x) < (y)) ? (x) : (y) )
//#define MIN(x,y) ( ((x) < (y)) ? (x) : (y) )
#define max(x,y) ( ((x) > (y)) ? (x) : (y) )
//#define MAX(x,y) ( ((x) > (y)) ? (x) : (y) )
#endif

#include "options_c.h"

/* CONSTANT VALUES */

#define NUMBER_OF_WINDOWS          8

#define NUMBER_OF_GROUPS           NUMBER_OF_WINDOWS    // maximum number of window groups

#define NUMBER_OF_BANDS_LONG      51    // maximum number of scalefactor bands
#define NUMBER_OF_BANDS_SHORT     15

#define NUMBER_OF_BANDS            max(NUMBER_OF_BANDS_LONG, NUMBER_OF_BANDS_SHORT) 

#define NUMBER_OF_SECTIONS_LONG    NUMBER_OF_BANDS_LONG
#define NUMBER_OF_SECTIONS_SHORT   NUMBER_OF_BANDS_SHORT
#define NUMBER_OF_SECTIONS         NUMBER_OF_BANDS

/* codebook numbers */
#define ZERO_CODE_BOOK             0    // index of first (zero) spectral codebook
#define ESCAPE_CODE_BOOK          11    // index of last (escape) spectral codebook
#define NOISE_CODE_BOOK           13    // PNS coding used (MPEG4 only)
#define INTENSITY2_CODE_BOOK      14    // signal out-of-phase intensity coding
#define INTENSITY1_CODE_BOOK      15    // signal in-phase intensity coding
 
#define SF_INDEX_OFFSET           60    // offset of scalefactor difference values
#define NOISE_OFFSET              90    // offset of noise energy values

#define NUMBER_OF_PULSES           4

#define TNS_ORDER_LONG            12
#define TNS_FILTERS_LONG           3

#define TNS_ORDER_SHORT            7
#define TNS_FILTERS_SHORT          1

#define TNS_ORDER                  max(TNS_ORDER_LONG, TNS_ORDER_SHORT)

#define NUMBER_OF_COUPLING_TARGETS min(Chans, 16)
#define NO_CHANNEL                 0xff
#define NO_TAG                     0xff


/* TYPES */

typedef unsigned char byte;

typedef enum
{
    eOnlyLongSequence,
    eLongStartSequence,
    eEightShortSequence,
    eLongStopSequence
} tWindowSequence;

typedef enum
{
    eKBDWindow,
    eSineWindow
} tWindowShape;

typedef enum
{
    eTNS_3bits,
    eTNS_4bits
} tTNS_Resolution;

typedef enum
{
    eTNS_Up,
    eTNS_Down
} tTNS_Direction;

typedef enum
{
    eAAC_ConstantRate,
    eAAC_VariableRate
} tAAC_BitstreamType;

typedef enum
{
    eAAC_96000,
    eAAC_88200,
    eAAC_64000,
    eAAC_48000,
    eAAC_44100,
    eAAC_32000,
    eAAC_24000,
    eAAC_22050,
    eAAC_16000,
    eAAC_12000,
    eAAC_11025,
    eAAC_8000,
    eAAC_InvalidFrequency
} tAAC_Frequency;

typedef struct
{
    int iNextIndex;    // byte offset into PulseData table (i.e. table index * 2)
    int nNumber;
    int iNextOffset;
    struct
    {
        int iOffset;
        int nAmp;
    } Data[NUMBER_OF_PULSES];
    int bPresent;
    int iStartBand;
} tHuffman_PulseData;


typedef struct
{
    char nLength;
    char nOrder;
    tTNS_Direction Direction;
    signed char anCoefficient[TNS_ORDER];
} tTNS_Filter;

typedef struct
{
    char nFilters;
    tTNS_Resolution Resolution;
} tTNS_Window;

typedef struct
{
    char           nLength;
    char           nOrder;
    tTNS_Direction Direction;
    signed char    anCoefficient[TNS_ORDER_LONG];
} tTNS_Filter_Long;

typedef struct
{
    char             nFilters;
    tTNS_Resolution  Resolution;
    tTNS_Filter_Long aFilter[TNS_FILTERS_LONG];
} tTNS_Window_Long;

typedef struct
{
    char           nLength;
    char           nOrder;
    tTNS_Direction Direction;
    signed char    anCoefficient[TNS_ORDER_SHORT];
} tTNS_Filter_Short;

typedef struct
{
    char              nFilters;
    tTNS_Resolution   Resolution;
    tTNS_Filter_Short aFilter[TNS_FILTERS_SHORT];
} tTNS_Window_Short;

typedef struct
{
    char bPresent;
    union
    {
        tTNS_Window_Long  Long;
        tTNS_Window_Short aShort[NUMBER_OF_WINDOWS];
    } uData;
} tTNS_Data;


/* Element IDs */
typedef enum
{
    eID_SCE, eID_CPE, eID_CCE, eID_LFE, eID_DSE, eID_PCE, eID_FIL, eID_END
} tDemux_ElementID;

/* M/S mask present values */
typedef enum
{
    eMS_Zero,
    eMS_Mask,
    eMS_One
} tStereo_MSPresent;

/* Single bit channel flag values */
typedef enum
{
    eChannel_Pair      =0x01,     /* flag to indicate channel is first of a pair */
    eChannel_MSPresent =0x02,     /* flag to indicate MS Stereo coding used */
    eChannel_PNS       =0x04,     /* flag to indicate PNS used on the channel */
    eChannel_Intensity =0x08,     /* flag to indicate intensity coding used */
//  eChannel_TNS       =0x10,     /* flag to indicate TNS coding is used */
    eChannel_EndStop
} tChannel_Flags;

typedef struct {char aMask[NUMBER_OF_BANDS      ];} tStereo_MSMask;
typedef struct {char aMask[NUMBER_OF_BANDS_LONG ];} tStereo_MSMask_Long;
typedef struct {char aMask[NUMBER_OF_BANDS_SHORT];} tStereo_MSMask_Short;

typedef struct {short aFactor[NUMBER_OF_BANDS      ];} tDemux_ScaleFactors;
typedef struct {short aFactor[NUMBER_OF_BANDS_LONG ];} tDemux_ScaleFactors_Long;
typedef struct {short aFactor[NUMBER_OF_BANDS_SHORT];} tDemux_ScaleFactors_Short;

/* Coupling domain values */
typedef enum {
    eCP_BeforeTNS,
    eCP_AfterTNS,
    eCP_Independent
} tCoupling_Domain;

typedef struct
{
    int nBands;
    const short *anBandOffset;
} tDemux_Bands;

typedef struct
{
    char nLength;
    char iCodeBook;
} tDemux_Section;

typedef struct
{
    char nSections;
    tDemux_Section aSection[NUMBER_OF_SECTIONS];
} tDemux_Sections;

typedef struct
{
    char nSections;
    tDemux_Section aSection[NUMBER_OF_SECTIONS_LONG];
} tDemux_Sections_Long;

typedef struct
{
    char nSections;
    tDemux_Section aSection[NUMBER_OF_SECTIONS_SHORT];
} tDemux_Sections_Short;

typedef struct
{
    char bLongSequence;
    char nMaxBands;

    /* Boolean flags for the channel */
    tChannel_Flags Flags;
    
    /* stereo mask is correct only if the MSPresent flag is set */
    union
    {
        tStereo_MSMask_Long   Long;
        tStereo_MSMask_Short aShort[NUMBER_OF_GROUPS];
    } uMSMask;
  
    /* Window grouping for "eight short" sequence */
    char    nGroups;
    char  anGroupLength[NUMBER_OF_GROUPS];

    short   nGlobalGain;

    /* Layout of codebook sections */
    union
    {
        tDemux_Sections_Long  Long;
        tDemux_Sections_Short aShort[NUMBER_OF_GROUPS];
    } uSections;
    
    /* Layout of scalefactor bands */
    const tDemux_Bands *Bands;
    union
    {
        tDemux_ScaleFactors_Short aShort[NUMBER_OF_GROUPS];
        tDemux_ScaleFactors_Long  Long;
    } uScaleFactors;
  
    /* Pulse coding data */
    tHuffman_PulseData PulseData;

    /* Temporal Noise Shaping data */
    tTNS_Data TNS_Data;
  
} tDemux_ChannelInfo;

typedef struct
{
    tWindowSequence WindowSequence;
    tWindowShape    CurrentWindowShape;
    tWindowShape    PreviousWindowShape;
} tTransform_Info;

typedef struct
{
    char iChannel;    // Index of target channel
    char iGainList;   // Index of gain list 
} tCoupling_Target;

/* Gain values for coupling channels. The values are encoded as follows:
     Bit     0: sign (0 for +1, 1 for -1)
     Bits 1-15: value
     Then gain is sign * 2^( (value>>1) / 8 )
 */
typedef struct
{
    char  bCommonGain; // Set if there is a common gain
    char  nCommonGain;
    short aanGainList[NUMBER_OF_GROUPS][NUMBER_OF_BANDS];
} tCoupling_GainList;

typedef struct
{
    tCoupling_Domain   Domain;
    int                nTargets;
    tCoupling_Target   aTarget[NUMBER_OF_COUPLING_TARGETS];
    tCoupling_GainList aGainList[NUMBER_OF_COUPLING_TARGETS];
    tDemux_ChannelInfo ChannelInfo;
    tTransform_Info    TransformInfo;
} tCoupling_Info;

/* Constant look-up tables */
extern const tDemux_Bands iDemux_aShortBands[];
extern const tDemux_Bands iDemux_aLongBands[];

extern const char iTNS_aMaxBands[12][2];

extern const int idct_table_1024[1024];
extern const int idct_table_128[128];
extern WTYPE *const iwind_long[2];
extern WTYPE *const iwind_short[2];
extern const int iSampFreqs[12];

extern const int AAC_DecoderSize;
typedef struct sAAC_Decoder tAAC_Decoder;

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -