4 Fixed point ANSI-C code structure

26.4113GPPEnhanced aacPlus general audio codecFixed-point ANSI-C codeGeneral audio codec audio processing functionsRelease 17TS

This clause gives an overview of the structure of the fixed point ANSI-C code and provides an overview of the contents and organization of the C code attached to the present document.

The C code has been verified on the following systems:

– IBM PC/AT compatible computers with Windows XP, 2000 and Microsoft Visual C++ v.6.0 compiler.

– IBM PC/AT compatible computers with Linux OS and GCC v.3.3 compiler.

ANSI‑C was selected as the programming language because portability was desirable.

4.1 Contents of the fixed point ANSI-C source code

The C code distribution is organized in two directories for encoder and decoder and further into several subdirectories, reflecting the major building blocks of the Enhanced aacPlus codec. The file descriptions on root level as well as the directory structure is given as follows.

Table 1: Source code directory structure for the encoder (ETSI_aacPlusenc)

Directory

Description

README.txt

information on how to compile

Makefile

UNIX style encoder Makefile

enhAacPlusenc.dsw

Win32 MSVC 6.0 encoder workspace

enhAacPlusenc.dsp

Win32 MSVC 6.0 encoder makefile

src/

directory for the encoder frontend

etsiop_fastaacenc/

AAC encoder library

etsiop_resamplib/

resampler library

etsiop_sbrenclib/

SBR encoder library

Table 2: Source code directory structure for the decoder (ETSI_aacPlusdec)

Directory

Description

README.txt

information on how to compile

Makefile

UNIX style encoder Makefile

enhAacPlusdec.dsw

Win32 MSVC 6.0 decoder workspace

src/

directory for the decoder frontend

etsiop_aacdec

AAC decoder library

etsiop_sbrdeclib/

SBR decoder library

Table 3: Source code directory structure common for encoder and decoder

Directory

Description

etsiop_bitbuf/

bitstream reading/writing library

etsiop_ffrlib/

general purpose functionalities

etsioplib/

ETSI operators implementation

3g_lib/

precompiled libraries for audio and bitstream file format handling

The distributed files with suffix "c" contain the source code and the files with suffix "h" are the header files. Within the respective libraries, the RAM data is contained in "xxx_ram" files with suffix "c", the ROM data is contained in "xxx_rom" files with suffix "c". Makefiles are provided for the platforms in which the C code has been verified (listed above).

A list of source code files is given below:

Table 4: Encoder source code files

Directory

Module

src/

main.c

mp4file.c

etsiop_fastaacenc/

qc_main.c

aacenc.c

ms_stereo.c

spreading.c

interface.c

bit_cnt.c

adj_thr.c

quantize.c

psy_configuration.c

sf_estim.c

tns_param.c

grp_data.c

pre_echo_control.c

stprepro.c

tns.c

dyn_bits.c

psy_main.c

channel_map.c

block_switch.c

band_nrg.c

transform.c

bitenc.c

line_pe.c

stat_bits.c

etsiop_sbrenc/

qmf_enc.c

ton_corr.c

fram_gen.c

env_bit.c

env_est.c

mh_det.c

hybrid.c

bit_sbr.c

ps_bitenc.c

sbr_main.c

tran_det.c

sbr_misc.c

code_env.c

nf_est.c

freq_sca.c

invf_est.c

ps_enc.c

etsiop_resamplib/

downsample_FIR.c

Table 5: Decoder source code files

Directory

Module

src/

main.c

fileifc.c

spline_resampler.c

etsiop_aacdec/

aacdecoder.c

streaminfo.c

channelinfo.c

stereo.c

longblock.c

shortblock.c

pulsedata.c

block.c

pns.c

imdct.c

tns.c

bitstream.c

channel.c

conceal.c

datastream.c

etsiop_sbrdeclib/

env_dec.c

aacpluscheck.c

env_calc.c

lpp_tran.c

sbrdecoder.c

sbr_dec.c

sbr_crc.c

hybrid.c

ps_bitdec.c

env_extr.c

freq_sca.c

ps_dec.c

qmf_dec.c

Table 6: Common source code files

Directory

Module

etsiop_bitbuf/

bitbuffer.c

etsiop_ffrlib/

fft_32x32.c

transcendent.c

transcendent_enc.c

intrinsics.c

vector.c

4.2 Program execution

The Enhanced aacPlus codec is implemented in two programs:

– enhAacPlusEnc.exe.

– enhAacPlusDec.exe.

The programs should be called like:

– enhAacPlusEnc.exe <wav_file> <bitstream_file> <bitrate> <(m)ono/(s)tereo>.

– enhAacPlusDec.exe <bitstream_file> <wav_file> <mode> [error_pattern_file].

The audio files contain 16-bit linear encoded PCM samples with wav header, the bitstream files are of 3GPP type an the error pattern file is a ASCII file, see clause 5.

The encoder and decoder command line handling is also explained by running the applications without input arguments.

4.3 Memory requirements

The data types of variables and tables used in the fixed-point implementation are defined by the ETSI operator data types, the following types are used:

– Word8.

– Word16.

– Word32.

– Flag.

4.3.1 Constants and tables

This clause contains a listing of all constants and tables contributing to the ROM requirements of the encoder and decoder.

Table 7: Encoder constants and tables

Name

Data type

Size [16-bit word]

Allocated in Source File

Description

LongWindowSine

Word16

1 024

aac_rom.c

Window coefficients

ShortWindowSine

Word16

128

aac_rom.c

Window coefficients

LongWindowKBD

Word16

1 024

aac_rom.c

Window coefficients

fftTwiddleTable

Word16

513

aac_rom.c

FFT twiddle coefficients

formfac_sqrttable

Word32

192

aac_rom.c

Lookup table for efficient sqrt implementation

mTab_3_4

Word32

1 024

aac_rom.c

Quantizer table, used for efficient pow () implementation

mTab_4_3

Word32

1 024

aac_rom.c

Inverse quantizer table, used for efficient pow () implementation

pow2tominusNover16

Word16

17

aac_rom.c

Lookup table for efficient pow() implementation

specExpMantTableComb_enc

Word32

128

aac_rom.c

Lookup table for efficient inverse quantizer implementation

specExpTableComb_enc

Word8

32

aac_rom.c

Lookup table for efficient inverse quantizer implementation

quantBorders

Word16

16

aac_rom.c

Lookup table for efficient distortion calculation implementation

quantBorders

Word16

12

aac_rom.c

Lookup table for efficient distortion calculation implementation

p_8000_mono_long

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_8000_stereo_long

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_8000_mono_short

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_8000_stereo_short

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_16000_mono_long

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_16000_stereo_long

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_16000_mono_short

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_16000_stereo_short

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_24000_mono_long

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_24000_stereo_long

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_24000_mono_short

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_24000_stereo_short

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_32000_mono_long

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_32000_stereo_long

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_32000_mono_short

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

p_32000_stereo_short

TNS_CONFIG_TABULATED

5

aac_rom.c

TNS tuning parameters

m_log2_table

Word32

64

aac_rom.c

Lookup table for efficient ld() implementation

tnsCoeff3

Word32

16

aac_rom.c

TNS filter coefficients

tnsCoeff3Borders

Word32

16

aac_rom.c

TNS filter borders

tnsCoeff4

Word32

32

aac_rom.c

TNS filter coefficients

tnsCoeff4Borders

Word32

32

aac_rom.c

TNS filter borders

tnsInfoTab

TNS_INFO_TAB

20

aac_rom.c

TNS bitrate to tuning mapping table

tnsMaxBandsTab

TNS_MAX_TAB_ENTRY

12

aac_rom.c

max. TNS bands per sampling rate table

huff_ltab1_2

Word16

81

aac_rom.c

Huffman codeword table AAC

huff_ltab3_4

Word16

81

aac_rom.c

Huffman codeword table AAC

huff_ltab5_6

Word16

81

aac_rom.c

Huffman codeword table AAC

huff_ltab7_8

Word16

64

aac_rom.c

Huffman codeword table AAC

huff_ltab9_10

Word16

169

aac_rom.c

Huffman codeword table AAC

huff_ltab11

Word16

289

aac_rom.c

Huffman codeword table AAC

huff_ltabscf

Word16

121

aac_rom.c

Huffman codeword table AAC

huff_ctab1

Word16

81

aac_rom.c

Huffman codeword table AAC

huff_ctab2

Word16

81

aac_rom.c

Huffman codeword table AAC

huff_ctab3

Word16

81

aac_rom.c

Huffman codeword table AAC

huff_ctab4

Word16

81

aac_rom.c

Huffman codeword table AAC

huff_ctab5

Word16

81

aac_rom.c

Huffman codeword table AAC

huff_ctab6

Word16

81

aac_rom.c

Huffman codeword table AAC

huff_ctab7

Word16

64

aac_rom.c

Huffman codeword table AAC

huff_ctab8

Word16

64

aac_rom.c

Huffman codeword table AAC

huff_ctab9

Word16

169

aac_rom.c

Huffman codeword table AAC

huff_ctab10

Word16

169

aac_rom.c

Huffman codeword table AAC

huff_ctab11

Word16

289

aac_rom.c

Huffman codeword table AAC

huff_ctabscf

Word32

242

aac_rom.c

Huffman codeword table AAC

sfb_16000_long_1024

Word8

22

aac_rom.c

Scalefactor band table

sfb_16000_short_128

Word8

8

aac_rom.c

Scalefactor band table

sfb_22050_long_1024

Word8

24

aac_rom.c

Scalefactor band table

sfb_22050_short_128

Word8

8

aac_rom.c

Scalefactor band table

sfb_24000_long_1024

Word8

24

aac_rom.c

Scalefactor band table

sfb_24000_short_128

Word8

8

aac_rom.c

Scalefactor band table

p4_13

Word32

26

sbr_rom.c

Hybrid filterbank coefficients

p8_13

Word32

26

sbr_rom.c

Hybrid filterbank coefficients

sbr_cos_twiddle_L32_enc

Word16

16

sbr_rom.c

QMF filterbank twiddle table

sbr_cos_twiddle_L64_enc

Word16

32

sbr_rom.c

QMF filterbank twiddle table

sbr_sin_twiddle_L32_enc

Word16

16

sbr_rom.c

QMF filterbank twiddle table

sbr_sin_twiddle_L64_enc

Word16

32

sbr_rom.c

QMF filterbank twiddle table

sbr_alt_sin_twiddle_L32_enc

Word16

17

sbr_rom.c

QMF filterbank twiddle table

sbr_alt_sin_twiddle_L64_enc

Word16

33

sbr_rom.c

QMF filterbank twiddle table

sbr_qmf_64_640_enc

Word16

330

sbr_rom.c

QMF window coefficients

aBookPsIidTimeCode

Word32

58

sbr_rom.c

Huffman codeword table Parametric Stereo

aBookPsIidFreqCode

Word32

58

sbr_rom.c

Huffman codeword table Parametric Stereo

aHybridResolution

Word16

3

sbr_rom.c

Number of hybrid bands in each QMF band

hiResBandBorders

Word8

11

sbr_rom.c

Borders of Parametric Stereo bins

groupBordersMix

Word8

15

sbr_rom.c

Borders of Parametric Stereo groups

bins2groupMap

Word32

58

sbr_rom.c

Mapping of Parametric Stereo bins to Parametric Stereo groups

iidQuantLeft

Word32

14

sbr_rom.c

IID quant values for Parametric Stereo

iidQuantRight

Word32

14

sbr_rom.c

IID quant values for Parametric Stereo

iccQuant

Word32

16

sbr_rom.c

ICC quant values for Parametric Stereo

v_Huff_envelopeLevelC10T

Word32

242

sbr_rom.c

Huffman codeword table SBR

v_Huff_envelopeLevelC10F

Word32

242

sbr_rom.c

Huffman codeword table SBR

bookSbrEnvBalanceC10F

Word32

98

sbr_rom.c

Huffman codeword table SBR

bookSbrEnvBalanceC10T

Word32

98

sbr_rom.c

Huffman codeword table SBR

v_Huff_envelopeLevelC11T

Word32

126

sbr_rom.c

Huffman codeword table SBR

v_Huff_NoiseLevelC11T

Word32

126

sbr_rom.c

Huffman codeword table SBR

bookSbrEnvBalanceC11T

Word32

50

sbr_rom.c

Huffman codeword table SBR

bookSbrNoiseBalanceC11T

Word32

50

sbr_rom.c

Huffman codeword table SBR

v_Huff_envelopeLevelC11F

Word32

126

sbr_rom.c

Huffman codeword table SBR

bookSbrEnvBalanceC11F

Word32

50

sbr_rom.c

Huffman codeword table SBR

aBookPsIidTimeLength

Word8

15

sbr_rom.c

Huffman codeword table Parametric Stereo

aBookPsIidFreqLength

Word8

15

sbr_rom.c

Huffman codeword table Parametric Stereo

aBookPsIccFreqLength

Word8

8

sbr_rom.c

Huffman codeword table Parametric Stereo

aBookPsIccTimeLength

Word8

8

sbr_rom.c

Huffman codeword table Parametric Stereo

aBookPsIccFreqCode

Word16

15

sbr_rom.c

Huffman codeword table Parametric Stereo

aBookPsIccTimeCode;

Word16

15

sbr_rom.c

Huffman codeword table Parametric Stereo

v_Huff_envelopeLevelL10T

Word8

61

sbr_rom.c

Huffman codeword table SBR

v_Huff_envelopeLevelL10F

Word8

61

sbr_rom.c

Huffman codeword table SBR

bookSbrEnvBalanceL10F

Word8

25

sbr_rom.c

Huffman codeword table SBR

bookSbrEnvBalanceL10T

Word8

25

sbr_rom.c

Huffman codeword table SBR

v_Huff_envelopeLevelL11T

Word8

32

sbr_rom.c

Huffman codeword table SBR

bookSbrEnvBalanceL11T

Word8

13

sbr_rom.c

Huffman codeword table SBR

v_Huff_NoiseLevelL11T

Word8

32

sbr_rom.c

Huffman codeword table SBR

bookSbrNoiseBalanceL11T

Word8

13

sbr_rom.c

Huffman codeword table SBR

v_Huff_envelopeLevelL11F

Word8

32

sbr_rom.c

Huffman codeword table SBR

bookSbrEnvBalanceL11F

Word8

13

sbr_rom.c

Huffman codeword table SBR

logDualisTable

Word16

65

transcendent.c

Lookup table for efficient log() implementation

pow2Table

Word32

512

transcendent_enc.c

Lookup table for efficient pow() implementation

FIRenc_band24

Word16

49

downsample_FIR.c

FIR filter coefficients for 2:1 resampling

FIRenc_band63

Word16

127

downsample_FIR.c

FIR filter coefficients for 3:2 resampling

tuningTable

tuningTable

294

sbr_main.c

SBR tuning parameters

Sum

11282

Table 8: Decoder constants and tables

Name

Data type

Size [16-bit word]

Allocated in Source File

Description

tnsCoeff3

Word16

8

aac_rom.c

TNS filter coefficients

tnsCoeff4

Word16

16

aac_rom.c

TNS filter coefficients

trigData

Word16

513

aac_rom.c

Sine table, used for efficient sin(), cos()

OnlyLongWindowKBD

Word16

1 024

aac_rom.c

Window coefficients

OnlyShortWindowKBD

Word16

128

aac_rom.c

Window coefficients

OnlyLongWindowSine

Word16

1 024

aac_rom.c

Window coefficients

OnlyShortWindowSine

Word16

128

aac_rom.c

Window coefficients

sfb_48_1024

Word16

50

aac_rom.c

Scalefactor band table

sfb_48_128

Word16

15

aac_rom.c

Scalefactor band table

sfb_32_1024

Word16

51

aac_rom.c

Scalefactor band table

sfb_24_1024

Word16

49

aac_rom.c

Scalefactor band table

sfb_24_128

Word16

16

aac_rom.c

Scalefactor band table

sfb_16_1024

Word16

44

aac_rom.c

Scalefactor band table

sfb_16_128

Word16

16

aac_rom.c

Scalefactor band table

sfb_8_1024

Word16

41

aac_rom.c

Scalefactor band table

sfb_8_128

Word16

16

aac_rom.c

Scalefactor band table

HuffmanCodeBook_1

Word16

204

aac_rom.c

Huffman codeword table AAC

HuffmanCodeBook_2

Word16

156

aac_rom.c

Huffman codeword table AAC

HuffmanCodeBook_3

Word16

156

aac_rom.c

Huffman codeword table AAC

HuffmanCodeBook_4

Word16

152

aac_rom.c

Huffman codeword table AAC

HuffmanCodeBook_5

Word16

164

aac_rom.c

Huffman codeword table AAC

HuffmanCodeBook_6

Word16

160

aac_rom.c

Huffman codeword table AAC

HuffmanCodeBook_7

Word16

124

aac_rom.c

Huffman codeword table AAC

HuffmanCodeBook_8

Word16

124

aac_rom.c

Huffman codeword table AAC

HuffmanCodeBook_9

Word16

336

aac_rom.c

Huffman codeword table AAC

HuffmanCodeBook_10

Word16

328

aac_rom.c

Huffman codeword table AAC

HuffmanCodeBook_11

Word16

544

aac_rom.c

Huffman codeword table AAC

HuffmanCodeBook_SCL

Word16

260

aac_rom.c

Huffman codeword table AAC

SamplingRateInfoTable

Word16

45

aac_rom.c

Sampling rate to scalefactor mapping table AAC

HuffmanCodeBooks

mixed

52

aac_rom.c

Huffman codeword table AAC

specExpTableComb

Word8

52

aac_rom.c

Lookup table for efficient exponent implementation

specExpTableMant

Word32

104

aac_rom.c

Lookup table for efficient exponent implementation, mantissa

InverseQuantTable

Word32

514

aac_rom.c

Lookup table for efficient inverse quantizer implementation

sgn_mask

Word16

3

aac_rom.c

Helper vector for efficient bit-wise operations in the TNS module

neg_mask

Word16

3

aac_rom.c

Helper vector for efficient bit-wise operations in the TNS module

tns_max_bands_tbl

Word8

18

aac_rom.c

max. TNS bands per sampling rate table

sbr_limGains_m

Word16

4

sbr_rom.c

SBR limiter gain values. mantissa

sbr_limGains_e

Word16

4

sbr_rom.c

SBR limiter gain values, exponent

sbr_limiterBandsPerOctaveDiv4

Word16

4

sbr_rom.c

Number of SBR limiter bands, divided by 4

sbr_smoothFilter

Word16

4

sbr_rom.c

Smoothing filter for gain values

sbr_invIntTable

Word16

49

sbr_rom.c

Table of 1/x function

sbr_randomPhase

Word16 or Word32

1 120

sbr_rom.c

Random numbers for SBR noise addition and PNS. Note: for mono only case the data type Word16 can be used.

sbr_qmf_64_640

Word16

340

sbr_rom.c

QMF window coefficients

sbr_ralt_sin_twiddle_L64

Word16

64

sbr_rom.c

FFT twiddle table

sbr_ralt_sin_twiddle_L32

Word16

32

sbr_rom.c

FFT twiddle table

sbr_cos_twiddle_L64

Word16

32

sbr_rom.c

FFT twiddle table, obsolete for mono only decoder

sbr_cos_twiddle_L32

Word16

16

sbr_rom.c

FFT twiddle table, obsolete for mono only decoder

sbr_sin_twiddle_L64

Word16

32

sbr_rom.c

FFT twiddle table, obsolete for mono only decoder

sbr_sin_twiddle_L32

Word16

16

sbr_rom.c

FFT twiddle table, obsolete for mono only decoder

sbr_alt_sin_twiddle_L64

Word16

33

sbr_rom.c

FFT twiddle table, obsolete for mono only decoder

sbr_cos_twiddle_ds_L32

Word16

32

sbr_rom.c

FFT twiddle table, obsolete for mono only decoder

sbr_sin_twiddle_ds_L32

Word16

32

sbr_rom.c

FFT twiddle table, obsolete for mono only decoder

sbr_t_cos_L32

Wrod16

32

sbr_rom.c

FFT twiddle table, obsolete for mono only decoder

sbr_t_sin_L32

Word16

32

sbr_rom.c

FFT twiddle table, obsolete for mono only decoder

pHybridResolution

Word16

3

sbr_rom.c

Parametric Stereo hybrid filterbank resolution

groupShift

Word16

6

sbr_rom.c

Parametric Stereo shift bits for uppermost frequency groups

aRevLinkDecaySer

Word16

3

sbr_rom.c

Parametric Stereo all-pass filter coefficients

aFractDelayPhaseFactorReQmf

Word16

20

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorImQmf

Word16

20

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorReSubQmf

Word16

10

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorImSubQmf

Word16

10

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerReQmf0

Word16

20

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerReQmf1

Word16

20

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerReQmf2

Word16

20

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerImQmf0

Word16

20

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerImQmf1

Word16

20

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerImQmf2

Word16

20

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerReSubQmf0

Word16

10

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerReSubQmf1

Word16

10

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerReSubQmf2

Word16

10

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerImSubQmf0

Word16

10

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerImSubQmf1

Word16

10

sbr_rom.c

Parametric Stereo phase rotation factor

aFractDelayPhaseFactorSerImSubQmf2

Word16

10

sbr_rom.c

Parametric Stereo phase rotation factor

aaFractDelayPhaseFactorSerReQmf

Word16

3

sbr_rom.c

Parametric Stereo phase rotation factor

aaFractDelayPhaseFactorSerImQmf

Word16

3

sbr_rom.c

Parametric Stereo phase rotation factor

aaFractDelayPhaseFactorSerReSubQmf

Word16

3

sbr_rom.c

Parametric Stereo phase rotation factor

aaFractDelayPhaseFactorSerImSubQmf

Word16

3

sbr_rom.c

Parametric Stereo phase rotation factor

scaleFactors

Word16

15

sbr_rom.c

Parametric Stereo quantization table

scaleFactorsFine

Word16

31

sbr_rom.c

Parametric Stereo quantization table

alphas

Word16

8

sbr_rom.c

Parametric Stereo quantization table

p2_6

Word16

6

sbr_rom.c

Hybrid filterbank coefficients

p8_13

Word16

13

sbr_rom.c

Hybrid filterbank coefficients

sbr_start_freq_16

Word8

16

sbr_rom.c

SBR frequency scale index

sbr_start_freq_22

Word8

16

sbr_rom.c

SBR frequency scale index

sbr_start_freq_24

Word8

16

sbr_rom.c

SBR frequency scale index

sbr_start_freq_32

Word8

16

sbr_rom.c

SBR frequency scale index

sbr_start_freq_44

Word8

16

sbr_rom.c

SBR frequency scale index

sbr_start_freq_48

Word8

16

sbr_rom.c

SBR frequency scale index

sbr_frame_info1_16

Word16

18

sbr_rom.c

SBR frequency scale index

sbr_frame_info2_16

Word16

18

sbr_rom.c

SBR frequency scale index

sbr_frame_info4_16

Word16

18

sbr_rom.c

SBR frequency scale index

sbr_huffBook_EnvLevel10T

Word16

120

sbr_rom.c

Huffman codeword table SBR

sbr_huffBook_EnvLevel10F

Word16

120

sbr_rom.c

Huffman codeword table SBR

sbr_huffBook_EnvBalance10T

Word16

48

sbr_rom.c

Huffman codeword table SBR

sbr_huffBook_EnvBalance10F

Word16

48

sbr_rom.c

Huffman codeword table SBR

sbr_huffBook_EnvLevel11T

Word16

62

sbr_rom.c

Huffman codeword table SBR

sbr_huffBook_EnvLevel11F

Word16

62

sbr_rom.c

Huffman codeword table SBR

sbr_huffBook_EnvBalance11T

Word16

24

sbr_rom.c

Huffman codeword table SBR

sbr_huffBook_EnvBalance11F

Word16

24

sbr_rom.c

Huffman codeword table SBR

sbr_huffBook_NoiseLevel11T

Word16

62

sbr_rom.c

Huffman codeword table SBR

sbr_huffBook_NoiseBalance11T

Word16

24

sbr_rom.c

Huffman codeword table SBR

aRevLinkDelaySer

Word16

3

sbr_rom.c

Parametric Stereo all-pass delay line lengths

groupBorders

Word16

23

sbr_rom.c

Borders of Parametric Stereo groups

aGroupToBin

Word16

22

sbr_rom.c

Parametric Stereo group to bin table

aHybridToBin

Word16

12

sbr_rom.c

Parametric Stereo hybrid to bin table

aDelayToBin

Word16

20

sbr_rom.c

Parametric Stereo delay to bin table

aBookPsIidTimeDecode

Word16

28

sbr_rom.c

Huffman codeword table Parametric Stereo

aBookPsIidFreqDecode

Word16

28

sbr_rom.c

Huffman codeword table Parametric Stereo

aBookPsIccTimeDecode

Word16

14

sbr_rom.c

Huffman codeword table Parametric Stereo

aBookPsIccFreqDecode

Word16

14

sbr_rom.c

Huffman codeword table Parametric Stereo

aBookPsIidFineTimeDecode

Word16

60

sbr_rom.c

Huffman codeword table Parametric Stereo

aBookPsIidFineFreqDecode

Word16

60

sbr_rom.c

Huffman codeword table Parametric Stereo

sbr_defaultHeader

mixed

22

sbr_rom.c

Default SBR header data

logDualisTable

Word16

65

transcendent.c

Lookup table for efficient log() implementation

invTable

Word16

256

transcendent.c

Lookup table for efficient 1/x implementation

Sum

10222

NOTE: All Parametric Stereo related coefficients which are marked as such in the table above are obsolete for mono only capable decoders.

4.3.2 Static memory

This clause contains a listing of all static buffers contributing to the RAM requirements of the encoder and decoder.

Table 9: Encoder static memory

Name

Data type

Size [16-bit word]

Allocated in Source File

Description

mdctDelayBuffer

Word16

3200

aac_ram.c

Time domain input signal delay , only half the size for mono only encoder

quantSpec

Word16

2048

aac_ram.c

Quantized spectrum, only half the size for mono only encoder

scf

Word16

120

aac_ram.c

Scalefactors, only half the size for mono only encoder

maxValueInSfb

Word16

120

aac_ram.c

Max. value per calefactor, only half the size for mono only encoder

sideInfoTabLong

Word16

52

aac_ram.c

Table lookup for side information, long blocks

sideInfoTabShort

Word16

16

aac_ram.c

Table lookup for side information, short blocks

aacEncoder

AAC_ENCODER

6 851

aacenc.c

AAC encoder instance, can be reduced to 3809 for mono only encoder

sbr_QmfStatesAnalysis

Word16

1 280

sbr_ram.c

QMF filterbank states buffer, only half the size for mono only encoder

sbr_QmfStatesSynthesis

Word32

640

sbr_ram.c

QMF filterbank states buffer, not needed for mono only encoder

sbr_envYBuffer

Word32

8 192

sbr_ram.c

QMF band energy buffer, only half the size for mono only encoder

sbr_quotaMatrix

Word32

1 024

sbr_ram.c

Tonality values. only half the size for mono only encoder

sbr_thresholds

Word32

256

sbr_ram.c

Detector parameters, only half the size for mono only encoder

sbr_toncorrBuff

Word32

2 160

sbr_ram.c

Detector value buffer, only half the size for mono only encoder

ps_IccDataBuffer

Word32

40

sbr_ram.c

ICC buffer, not needed for mono only encoder

ps_IidDataBuffer

Word32

40

sbr_ram.c

Iid buffer, not needed for mono only encoder

ps_histQmfBuffer

Word16

1 608

sbr_ram.c

QMF history buffer, not needed for mono only encoder

sbr_freqBandTableLO

Word16

14

sbr_ram.c

SBR frequency band table, low resolution

sbr_freqBandTableHI

Word16

28

sbr_ram.c

SBR frequency band table, high resolution

sbr_v_k_master

Word16

28

sbr_ram.c

SBR frequency band table index

sbr_guideScfb

Word16

54

sbr_ram.c

Additional sine detection parameter, only half the size for mono only encoder

sbr_detectionVectors

Word16

108

sbr_ram.c

Additional sine detection parameter, only half the size for mono only encoder

sbr_prevEnvelopeCompensation

Word16

54

sbr_ram.c

Additional sine detection parameter, only half the size for mono only encoder

sbr_guideVectorDetected

Word16

108

sbr_ram.c

Additional sine detection parameter, only half the size for mono only encoder

sbrEncoder

SBR_ENCODER

3 650

sbr_main.c

SBR encoder instance, can be reduced to 1722 for mono only encoder

outputBuffer

Word8

384

main.c

Bitstream output buffer

inputBuffer

Word16

8 234

main.c

Time domain input signal buffer, only half the size for mono only encoder

up2Sampler

RESAMPLER_FIR_2_1

144

main.c

1:2 FIR resampler instance (includes states) , only half the size for mono only encoder

down3Sampler

RESAMPLER_FIR_3_2

208

main.c

3:2 FIR resampler instance (includes states) , only half the size for mono only encoder

down2Sampler

RESAMPLER_FIR_2_1

144

main.c

2:1 FIR resampler instance (includes states) , only half the size for mono only encoder

Sum

40 643

Table 10: Decoder static memory

Name

Data type

Size [16-bit word]

Allocated in Source File

Description

OverlapBuffer[nChan]

Word16

1 024

aac_ram.c

Delay buffer for overlap and add, only half the size for mono only decoder

AacDecoderInstance

AAC_DECODER_INSTANCE

12

aacdecoder.c

AAC decoder instance

sbrPayloadBuffer

Word8

540

aacdecoder.c

SBR payload buffer

StreamInfo

CStreamInfo

7

aac_ram.c

Bitstream information

AacDecoderStaticChannelInfo[nChan]

CaacDecoderStaticChannelInfo

16

aac_ram.c

Channel information, only half the size for mono only decoder

PnsStaticInterChannelData

Word16

2

aac_ram.c

PNS static data

ConcealmentInfoInstance

CConcealmentInfo

4 127

aac_ram.c

Concealment static data

sbr_CodecQmfStatesAnalysis

Word16

640

sbr_ram.c

QMF analysis filter bank states

sbr_GainSmooth_m

Word16

96

sbr_ram.c

Gain smoothing filter states, mantissa

sbr_GainSmooth_e

Word16

96

sbr_ram.c

Gain smoothing filter states, exponent

sbr_NoiseSmooth_m

Word16

96

sbr_ram.c

Noise level smoothing filter states, mantissa

sbr_QmfStatesSynthesis

Word16

2 560

sbr_ram.c

QMF synthesis filter bank states

sbr_OverlapBuffer

Word32

3 072

sbr_ram.c

SBR delay buffer, only half the size for mono only decoder

sbr_LpcFilterStatesReal

Word32

256

sbr_ram.c

LPC filter states

sbr_LpcFilterStatesImag

Word32

256

sbr_ram.c

LPC filter states, obsolete for mono only decoder

sbr_TransposerSettings

TRANSPOSER_SETTINGS

61

sbr_ram.c

Transposer configuration parameters

FreqBandData

FREQ_BAND_DATA

164

sbr_ram.c

SBR Frequency band information

PrevFrameData[nChan]

SBR_PREV_FRAME_DATA

120

sbr_ram.c

SBR previous frame data, only half the size for mono only decoder

sbrDecoderInstance

SBR_DECODER_INSTANCE

797

sbrdecoder.c

SBR decoder instance

timeData

Word16

4 096

main.c

Output buffer for time-domain signal, only half the size for mono only decoder

inBuffer

short

768

main.c

Input buffer for bitstream

splineResamplerInstance

SPLINE_RESAMPLER

19

spline_resampler.c

Spline resampler instance

Sum

18825

4.3.3 Dynamic memory

This clause contains a listing of all dynamic buffers contributing to the RAM requirements of the encoder and decoder. Dynamic memory can be re-used outside of the encoder or decoder application.

Table 11: Encoder dynamic memory

Name

Data type

Size [16-bit word]

Allocated in Source File

Description

ps_tempQmfBuffer

Word16

1 608

sbr_ram.c

NOTE: reused in AAC encoder, not needed for mono only encoder

sbr_envRBuffer

Word16

4 096

sbr_ram.c

NOTE: reused in AAC encoder

sbr_envIBuffer

Word16

4 096

sbr_ram.c

NOTE: reused in AAC encoder

sbr_transients

Word32

384

sbr_ram.c

NOTE: reused in AAC encoder

Sum

10 184

Table 12: Decoder dynamic memory

Name

Data type

Size [16-bit word]

Allocated in Source File

Description

WorkBufferCore

Word32

4 096

aac_ram.c

NOTE: reused in SBR decoder

WorkBuffer1

Word32

4 096

sbr_ram.c

Work buffer, obsolete for mono only decoder

Sum

8 192

4.3.4 Maximum stack size

This clause contains tables for the encoder and the decoder which describe the call stack that results in the maximum stack size usage.

Table 13: Encoder call stack

Function

Local variables / Function call arguments

Stack used [16-bit words]

main

AACENC_CONFIG config;

Word16 error;

Flag bEncodeMono;

Word16 ch;

Word16 dummy;

Word32 bitrate;

Word16 nChannelsAAC, nChannelsSBR;

Word32 sampleRateAAC;

Word32 frmCnt ;

Word32 bandwidth;

UWord16 numAncDataBytes;

UWord8 ancDataBytes[MAX_PAYLOAD_SIZE];

Word32 numSamplesRead;

Flag bDingleRate;

Flag useParametricStereo;

Word32 coreWriteOffset;

Word32 coreReadOffset;

Word32 envWriteOffset;

Word32 envReadOffset;

Word32 writeOffset;

struct AAC_ENCODER *hAacEnc;

struct SBR_ENCODER *hEnvEnc;

Flag bDoUpsample;

Flag upsampleReadOffset;

Word16 inSamples;

Flag bDo32Resample;

Word16 nRuns;

Word16 *resamplerScratch;

UWord32 numOutBytes;

Word32 i;

UWord8 *bitstreamOut;

Word32 *nOutBytes;

Word16 numEncSamples;

Flag downsample;

8

1

1

1

1

2

2

2

2

1

2

64

2

1

1

2

2

2

2

2

1

1

1

1

1

1

1

1

2

2

1

1

1

1

=116

AacEncEncode

struct AAC_ENCODER *aacEnc;

Word16 *timeSignal;

const UWord8 *ancBytes;

UWord16 *numAncBytes;

UWord8 *outBytes;

Word32 *numOutBytes;

ELEMENT_INFO *elInfo;

Word16 globUsedBits;

Word16 ancDataBytes, ancDataBytesLeft;

1

1

1

1

1

1

1

1

1

=9

QCMain

QC_STATE* hQC,

Word16 nChannels,

ELEMENT_BITS* elBits,

ATS_ELEMENT* adjThrStateElement,

PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS_PER_ELEM],

PSY_OUT_ELEMENT* psyOutElement,

QC_OUT_CHANNEL qcOutChannel[MAX_CHANNELS_PER_ELEM],

QC_OUT_ELEMENT* qcOutElement,

Word16 ancillaryDataBytes

Word16 ch;

Word16 logSfbFormFactor[MAX_CHANNELS_PER_ELEM][MAX_GROUPED_SFB];

Word16 sfbNRelevantLines[MAX_CHANNELS_PER_ELEM][MAX_GROUPED_SFB];

Word16 logSfbEnergy[MAX_CHANNELS_PER_ELEM][MAX_GROUPED_SFB];

Word16 maxChDynBits[MAX_CHANNELS_PER_ELEM];

Word16 chBitDistribution[MAX_CHANNELS_PER_ELEM];

1

1

1

1

1

1

1

1

1

1

120

120

120

2

2

=375

AdjustThresholds

ADJ_THR_STATE *adjThrState;

ATS_ELEMENT *AdjThrStateElement;

PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS_PER_ELEM];

PSY_OUT_ELEMENT *psyOutElement;

Word16 *chBitDistribution;

Word16 logSfbEnergy[MAX_CHANNELS_PER_ELEM][MAX_GROUPED_SFB];

Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB];

const Word16 nChannels;

QC_OUT_ELEMENT *qcOE;

const Word16 avgBits;

const Word16 bitresBits;

const Word16 maxBitresBits;

const Word16 maxBitFac;

const Word16 sideInfoBits;

Word16 noRedPe, grantedPe, grantedPeCorr;

Word16 curWindowSequence;

PE_DATA peData;

Word16 bitFactor;

Word16 ch;

1

1

1

1

1

1

1

1

1

1

1

1

1

1

2

1

667

1

1

=686

adaptThresholdsToPe

PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS_PER_ELEM];

PSY_OUT_ELEMENT *psyOutElement;

Word16 logSfbEnergy[MAX_CHANNELS_PER_ELEM][MAX_GROUPED_SFB];

PE_DATA *peData;

const Word16 nChannels;

const Word16 desiredPe;

AH_PARAM *ahParam;

MINSNR_ADAPT_PARAM *msaParam;

Word16 noRedPe, redPe, redPeNoAH;

Word16 constPart, constPartNoAH;

Word16 nActiveLines, nActiveLinesNoAH;

Word16 desiredPeNoAH;

Word32 redVal, avgThrExp;

Word16 iter;

1

1

1

1

1

1

1

1

4

2

2

1

4

1

=22

correctThresh

PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS_PER_ELEM];

Word16 ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB];

PE_DATA *peData;

Word32 thrExp[MAX_CHANNELS][MAX_GROUPED_SFB];

const Word32 redVal;

const Word16 nChannels;

const Word32 deltaPe;

Word16 ch, sfb, sfbGrp;

PSY_OUT_CHANNEL *psyOutChan;

PE_CHANNEL_DATA *peChanData;

Word32 deltaSfbPe;

Word32 sfbPeFactors[MAX_CHANNELS][MAX_GROUPED_SFB], normFactor;

Word32 sfbEn, sfbThr;

Word32 sfbThrReduced;

Word32 thrFactor;

1

1

1

1

2

1

2

3

1

1

2

242

4

2

2

=266

ffr_pow2_xy

Word32 x, Word32 y;

Word32 iPart,fPart;

Word32 res;

Word32 tmp, tmp2;

Word16 shift, shift2;

Word16 denom_h, denom_l;

4

4

2

4

2

2

=18

Sum

992

Table 14: Decoder call stack

Function

Local variables / Function call arguments

Stack used
[16-bit words]

main()

Flag endOfFile;

Flag frameOk;

Word32 i;

Word32 written16;

Word8 channelMode;

struct BIT_BUF bitBuf, *hBitBuf;

AACDECODER aacDecoderInfo;

SBRBITSTREAM streamSBR;

SBRDECODER sbrDecoderInfo;

HANDLE_SPLINE_RESAMPLER splineResampler;

Word32 frameSize;

Word32 sampleRate, outputSampleRate;

Word8 numChannels;

Word8 numChannelsLast;

Word16 numOutSamples;

Flag bDownSample;

Flag fosr16;

Flag fosr8;

Flag bBitstreamDownMix;

Flag bValidMode;

1

1

2

2

1

14

1

6

1

1

2

4

1

1

1

1

1

1

1

1

=44

applySBR()

SBRDECODER self,

SBRBITSTREAM * Bitstr,

Word16 *timeData,

Word8 *numChannels,

Flag SbrFrameOK,

Flag bDownSample,

Flag bBitstreamDownMix

Word16 lr;

Word32 i;

Word8 prevStereo, prevPs;

Word8 psPresent;

Word8 stereo;

Word8 readHeader;

Word32 err;

SBR_CHANNEL *SbrChannel;

struct BIT_BUF bitBuf;

HANDLE_SBR_HEADER_DATA hHeaderData;

SBR_HEADER_STATUS headerStatus;

Word32 codecFrameSize;

SBR_SYNC_STATE initialSyncState;

SBR_FRAME_DATA *hFrameDataLeft;

SBR_FRAME_DATA *hFrameDataRight;

Flag bUseLP;

1

1

1

1

1

1

1

1

2

2

1

1

1

2

1

1

1

1

2

1

1

1

1

=28

sbr_dec()

HANDLE_SBR_DEC hSbrDec,

Word16 *timeIn,

Word16 *timeOut,

HANDLE_SBR_HEADER_DATA hHeaderData, HANDLE_SBR_FRAME_DATA hFrameData, HANDLE_SBR_PREV_

FRAME_DATA hPrevFrameData,

HANDLE_PS_DEC hPS,

HANDLE_SBR_QMF_FILTER_BANK hSynthesisQmfBankRight, SBR_SCALE_FACTOR *sbrScaleFactorRight,

Flag applyProcessing,

Flag bUseLP

Word32 i, k;

Word16 slot, reserve;

Word16 saveLbScale;

Word16 ov_len;

Word32 *QmfBufferReal[MAX_ENV_COLS];

Word32 *QmfBufferImag[MAX_ENV_COLS];

Word32 *ptr;

Word16 noCols;

1

1

1

1

1

1

1

1

1

1

1

1

4

2

1

1

38

38

1

1

= 98

cplxSynthesisQmfFiltering()

Word32 **qmfReal,

Word32 **qmfImag,

Word32 splitSlot,

SBR_SCALE_FACTOR *sbrScaleFactor,

Word16 *timeOut,

HANDLE_SBR_QMF_FILTER_BANK qmfBank, HANDLE_PS_DEC hPS,

Flag active,

Flag bUseLP

Word16 i, j;

Word16 codScalefactor;

Word16 sbrScalefactor;

Word16 outScalefactor;

Word16 scaleFactorLowBand;

Word16 scaleFactorHighBand;

Word16 *filterStates;

Word32 qmfReal2[NO_SYNTHESIS_CHANNELS];

Word16 no_synthesis_channels;

Word32 qmfRealTmp[NO_SYNTHESIS_CHANNELS];

Word32 *qmfImagTmp;

Word8 env;

Word16 scaleFactorLowBandSplit;

Word32 *imagSlot;

1

1

2

1

1

1

1

1

1

2

1

1

1

1

1

1

128

1

128

1

1

1

1

= 277

inverseModulationLP()

Word32 *qmfReal,

Word32 *qmfReal2,

const Word16 scaleFactorLowBand,

const Word16 scaleFactorHighBand, HANDLE_SBR_QMF_FILTER_BANK synQmf

Word16 i;

const Word16 L;

const Word16 M;

Word32 timeOut[2*NO_SYNTHESIS_CHANNELS];

1

1

1

1

1

1

1

1

256

= 264

dct2 ()

Word32 *data,

Word32 *tmp,

Word32 L,

HANDLE_SBR_QMF_FILTER_BANK qmfBank

Word16 cosphi,sinphi;

Word16 i;

Word32 M;

Word32 N;

Word32 a1,a2,a3,a4,a5,a6;

1

1

2

1

2

1

2

2

12

= 24

DSP_fft32x32s()

Word32 npoints

Word32 *ptr_x

2

1

= 3

__fft32()

Word32 x[]

Word16 m;

Word32 re, ie, ro, io, rx, ix ;

Word32 *x1m, *x2m, *x1mm, *x2mm;

2

1

12

4

= 19

__fft2x16()

Word32 x[]

Word16 sch, sh, ch;

Word32 a0, a1, a2, a3, a00, a10, a20, a30 ;

Word32 tr, ti, vr, vi ;

Word32 even [32], odd [32] ;

2

3

16

8

128

= 157

fixmul_32x16b()

Word32 a;
Word16 b;

Word16 hi1 lo1

2

1

2

= 5

Sum

919