summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/aacenc/inc
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-05-14 15:45:22 -0700
committerJames Dong <jdong@google.com>2010-05-19 07:21:25 -0700
commit956c553ab0ce72f8074ad0fda2ffd66a0305700c (patch)
treefe111ecd29e01c270246f5f338c56806d6d5b136 /media/libstagefright/codecs/aacenc/inc
parente1f61055b4abb96a86d1ff24b5a7777dfe40fe5f (diff)
downloadframeworks_av-956c553ab0ce72f8074ad0fda2ffd66a0305700c.zip
frameworks_av-956c553ab0ce72f8074ad0fda2ffd66a0305700c.tar.gz
frameworks_av-956c553ab0ce72f8074ad0fda2ffd66a0305700c.tar.bz2
Initial software encoder checkins
Change-Id: I27f387db23594e46384c4eb3a0093ce220bb6b60
Diffstat (limited to 'media/libstagefright/codecs/aacenc/inc')
-rw-r--r--media/libstagefright/codecs/aacenc/inc/aac_rom.h117
-rw-r--r--media/libstagefright/codecs/aacenc/inc/aacenc_core.h117
-rw-r--r--media/libstagefright/codecs/aacenc/inc/adj_thr.h57
-rw-r--r--media/libstagefright/codecs/aacenc/inc/adj_thr_data.h69
-rw-r--r--media/libstagefright/codecs/aacenc/inc/band_nrg.h46
-rw-r--r--media/libstagefright/codecs/aacenc/inc/bit_cnt.h106
-rw-r--r--media/libstagefright/codecs/aacenc/inc/bitbuffer.h89
-rw-r--r--media/libstagefright/codecs/aacenc/inc/bitenc.h50
-rw-r--r--media/libstagefright/codecs/aacenc/inc/block_switch.h72
-rw-r--r--media/libstagefright/codecs/aacenc/inc/channel_map.h37
-rw-r--r--media/libstagefright/codecs/aacenc/inc/config.h36
-rw-r--r--media/libstagefright/codecs/aacenc/inc/dyn_bits.h82
-rw-r--r--media/libstagefright/codecs/aacenc/inc/grp_data.h44
-rw-r--r--media/libstagefright/codecs/aacenc/inc/interface.h106
-rw-r--r--media/libstagefright/codecs/aacenc/inc/line_pe.h75
-rw-r--r--media/libstagefright/codecs/aacenc/inc/memalign.h35
-rw-r--r--media/libstagefright/codecs/aacenc/inc/ms_stereo.h45
-rw-r--r--media/libstagefright/codecs/aacenc/inc/pre_echo_control.h42
-rw-r--r--media/libstagefright/codecs/aacenc/inc/psy_configuration.h107
-rw-r--r--media/libstagefright/codecs/aacenc/inc/psy_const.h80
-rw-r--r--media/libstagefright/codecs/aacenc/inc/psy_data.h66
-rw-r--r--media/libstagefright/codecs/aacenc/inc/psy_main.h69
-rw-r--r--media/libstagefright/codecs/aacenc/inc/qc_data.h143
-rw-r--r--media/libstagefright/codecs/aacenc/inc/qc_main.h64
-rw-r--r--media/libstagefright/codecs/aacenc/inc/quantize.h42
-rw-r--r--media/libstagefright/codecs/aacenc/inc/sf_estim.h46
-rw-r--r--media/libstagefright/codecs/aacenc/inc/spreading.h33
-rw-r--r--media/libstagefright/codecs/aacenc/inc/stat_bits.h34
-rw-r--r--media/libstagefright/codecs/aacenc/inc/tns.h108
-rw-r--r--media/libstagefright/codecs/aacenc/inc/tns_func.h75
-rw-r--r--media/libstagefright/codecs/aacenc/inc/tns_param.h52
-rw-r--r--media/libstagefright/codecs/aacenc/inc/transform.h36
32 files changed, 2180 insertions, 0 deletions
diff --git a/media/libstagefright/codecs/aacenc/inc/aac_rom.h b/media/libstagefright/codecs/aacenc/inc/aac_rom.h
new file mode 100644
index 0000000..b0429fc
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/aac_rom.h
@@ -0,0 +1,117 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: aac_rom.h
+
+ Content: constant tables
+
+*******************************************************************************/
+
+#ifndef ROM_H
+#define ROM_H
+
+#include "config.h"
+#include "psy_const.h"
+#include "tns_param.h"
+
+/*
+ mdct
+*/
+extern const int ShortWindowSine[FRAME_LEN_SHORT/2];
+extern const int LongWindowKBD[FRAME_LEN_LONG/2];
+
+extern const unsigned char bitrevTab[17 + 129];
+extern const int cossintab[128 + 1024];
+
+#if defined (ARMV5E) && !defined (ARMV7Neon)
+extern const int twidTab64[(4*6 + 16*6)/2];
+extern const int twidTab512[(8*6 + 32*6 + 128*6)/2];
+#else
+extern const int twidTab64[4*6 + 16*6];
+extern const int twidTab512[8*6 + 32*6 + 128*6];
+#endif
+
+/*
+ form factor
+*/
+extern const Word32 formfac_sqrttable[96];
+
+/*
+ quantizer
+*/
+extern const Word32 mTab_3_4[512];
+extern const Word32 mTab_4_3[512];
+/*! $2^{-\frac{n}{16}}$ table */
+extern const Word16 pow2tominusNover16[17] ;
+
+extern Word32 specExpMantTableComb_enc[4][14];
+extern const UWord8 specExpTableComb_enc[4][14];
+
+extern const Word16 quantBorders[4][4];
+//extern const Word16 quantRecon[3][4];
+extern const Word16 quantRecon[4][3];
+
+/*
+ huffman
+*/
+extern const UWord16 huff_ltab1_2[3][3][3][3];
+extern const UWord16 huff_ltab3_4[3][3][3][3];
+extern const UWord16 huff_ltab5_6[9][9];
+extern const UWord16 huff_ltab7_8[8][8];
+extern const UWord16 huff_ltab9_10[13][13];
+extern const UWord16 huff_ltab11[17][17];
+extern const UWord16 huff_ltabscf[121];
+extern const UWord16 huff_ctab1[3][3][3][3];
+extern const UWord16 huff_ctab2[3][3][3][3];
+extern const UWord16 huff_ctab3[3][3][3][3];
+extern const UWord16 huff_ctab4[3][3][3][3];
+extern const UWord16 huff_ctab5[9][9];
+extern const UWord16 huff_ctab6[9][9];
+extern const UWord16 huff_ctab7[8][8];
+extern const UWord16 huff_ctab8[8][8];
+extern const UWord16 huff_ctab9[13][13];
+extern const UWord16 huff_ctab10[13][13];
+extern const UWord16 huff_ctab11[17][17];
+extern const UWord32 huff_ctabscf[121];
+
+
+
+/*
+ misc
+*/
+extern const int sampRateTab[NUM_SAMPLE_RATES];
+extern const int BandwithCoefTab[8][NUM_SAMPLE_RATES];
+extern const int rates[8];
+extern const UWord8 sfBandTotalShort[NUM_SAMPLE_RATES];
+extern const UWord8 sfBandTotalLong[NUM_SAMPLE_RATES];
+extern const int sfBandTabShortOffset[NUM_SAMPLE_RATES];
+extern const short sfBandTabShort[76];
+extern const int sfBandTabLongOffset[NUM_SAMPLE_RATES];
+extern const short sfBandTabLong[325];
+
+extern const Word32 m_log2_table[INT_BITS];
+
+/*
+ TNS
+*/
+extern const Word32 tnsCoeff3[8];
+extern const Word32 tnsCoeff3Borders[8];
+extern const Word32 tnsCoeff4[16];
+extern const Word32 tnsCoeff4Borders[16];
+extern const Word32 invSBF[24];
+extern const Word16 sideInfoTabLong[MAX_SFB_LONG + 1];
+extern const Word16 sideInfoTabShort[MAX_SFB_SHORT + 1];
+#endif
diff --git a/media/libstagefright/codecs/aacenc/inc/aacenc_core.h b/media/libstagefright/codecs/aacenc/inc/aacenc_core.h
new file mode 100644
index 0000000..faa1d20
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/aacenc_core.h
@@ -0,0 +1,117 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: aacenc_core.h
+
+ Content: aac encoder interface functions
+
+*******************************************************************************/
+
+#ifndef _aacenc_core_h_
+#define _aacenc_core_h_
+
+
+#include "typedef.h"
+#include "config.h"
+#include "bitenc.h"
+
+#include "psy_configuration.h"
+#include "psy_main.h"
+#include "qc_main.h"
+#include "psy_main.h"
+/*-------------------------- defines --------------------------------------*/
+
+
+/*-------------------- structure definitions ------------------------------*/
+typedef struct {
+ Word32 sampleRate; /* audio file sample rate */
+ Word32 bitRate; /* encoder bit rate in bits/sec */
+ Word16 nChannelsIn; /* number of channels on input (1,2) */
+ Word16 nChannelsOut; /* number of channels on output (1,2) */
+ Word16 bandWidth; /* targeted audio bandwidth in Hz */
+ Word16 adtsUsed; /* whether write adts header */
+} AACENC_CONFIG;
+
+
+typedef struct {
+
+ AACENC_CONFIG config; /* Word16 size: 8 */
+
+ ELEMENT_INFO elInfo; /* Word16 size: 4 */
+
+ QC_STATE qcKernel; /* Word16 size: 6 + 5(PADDING) + 7(ELEMENT_BITS) + 54(ADJ_THR_STATE) = 72 */
+ QC_OUT qcOut; /* Word16 size: MAX_CHANNELS*920(QC_OUT_CHANNEL) + 5(QC_OUT_ELEMENT) + 7 = 932 / 1852 */
+
+ PSY_OUT psyOut; /* Word16 size: MAX_CHANNELS*186 + 2 = 188 / 374 */
+ PSY_KERNEL psyKernel; /* Word16 size: 2587 / 4491 */
+
+ struct BITSTREAMENCODER_INIT bseInit; /* Word16 size: 6 */
+ struct BIT_BUF bitStream; /* Word16 size: 8 */
+ HANDLE_BIT_BUF hBitStream;
+ int initOK;
+
+ short *intbuf;
+ short *encbuf;
+ short *inbuf;
+ int enclen;
+ int inlen;
+ int intlen;
+ int uselength;
+
+ void *hCheck;
+ VO_MEM_OPERATOR *voMemop;
+ VO_MEM_OPERATOR voMemoprator;
+
+}AAC_ENCODER; /* Word16 size: 3809 / 6851 */
+
+/*-----------------------------------------------------------------------------
+
+functionname: AacInitDefaultConfig
+description: gives reasonable default configuration
+returns: ---
+
+------------------------------------------------------------------------------*/
+void AacInitDefaultConfig(AACENC_CONFIG *config);
+
+/*---------------------------------------------------------------------------
+
+functionname:AacEncOpen
+description: allocate and initialize a new encoder instance
+returns: AACENC_OK if success
+
+---------------------------------------------------------------------------*/
+
+Word16 AacEncOpen (AAC_ENCODER *hAacEnc, /* pointer to an encoder handle, initialized on return */
+ const AACENC_CONFIG config); /* pre-initialized config struct */
+
+Word16 AacEncEncode(AAC_ENCODER *hAacEnc,
+ Word16 *timeSignal,
+ const UWord8 *ancBytes, /*!< pointer to ancillary data bytes */
+ Word16 *numAncBytes, /*!< number of ancillary Data Bytes, send as fill element */
+ UWord8 *outBytes, /*!< pointer to output buffer */
+ Word32 *numOutBytes /*!< number of bytes in output buffer */
+ );
+
+/*---------------------------------------------------------------------------
+
+functionname:AacEncClose
+description: deallocate an encoder instance
+
+---------------------------------------------------------------------------*/
+
+void AacEncClose (AAC_ENCODER* hAacEnc, VO_MEM_OPERATOR *pMemOP); /* an encoder handle */
+
+#endif /* _aacenc_h_ */
diff --git a/media/libstagefright/codecs/aacenc/inc/adj_thr.h b/media/libstagefright/codecs/aacenc/inc/adj_thr.h
new file mode 100644
index 0000000..4057cbe
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/adj_thr.h
@@ -0,0 +1,57 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: adj_thr.h
+
+ Content: Threshold compensation function
+
+*******************************************************************************/
+
+#ifndef __ADJ_THR_H
+#define __ADJ_THR_H
+
+#include "adj_thr_data.h"
+#include "qc_data.h"
+#include "interface.h"
+
+Word16 bits2pe(const Word16 bits);
+
+Word32 AdjThrNew(ADJ_THR_STATE** phAdjThr,
+ Word32 nElements);
+
+void AdjThrDelete(ADJ_THR_STATE *hAdjThr);
+
+void AdjThrInit(ADJ_THR_STATE *hAdjThr,
+ const Word32 peMean,
+ Word32 chBitrate);
+
+void AdjustThresholds(ADJ_THR_STATE *adjThrState,
+ ATS_ELEMENT* AdjThrStateElement,
+ PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS],
+ PSY_OUT_ELEMENT *psyOutElement,
+ Word16 *chBitDistribution,
+ Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB],
+ Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB],
+ QC_OUT_ELEMENT* qcOE,
+ ELEMENT_BITS* elBits,
+ const Word16 nChannels,
+ const Word16 maxBitFac);
+
+void AdjThrUpdate(ATS_ELEMENT *AdjThrStateElement,
+ const Word16 dynBitsUsed);
+
+
+#endif
diff --git a/media/libstagefright/codecs/aacenc/inc/adj_thr_data.h b/media/libstagefright/codecs/aacenc/inc/adj_thr_data.h
new file mode 100644
index 0000000..25dd437
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/adj_thr_data.h
@@ -0,0 +1,69 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: adj_thr_data.h
+
+ Content: Threshold compensation parameter
+
+*******************************************************************************/
+
+#ifndef __ADJ_THR_DATA_H
+#define __ADJ_THR_DATA_H
+
+#include "typedef.h"
+#include "psy_const.h"
+#include "line_pe.h"
+
+typedef struct {
+ Word16 clipSaveLow, clipSaveHigh;
+ Word16 minBitSave, maxBitSave;
+ Word16 clipSpendLow, clipSpendHigh;
+ Word16 minBitSpend, maxBitSpend;
+} BRES_PARAM;
+
+typedef struct {
+ UWord8 modifyMinSnr;
+ Word16 startSfbL, startSfbS;
+} AH_PARAM;
+
+typedef struct {
+ Word32 maxRed;
+ Word32 startRatio, maxRatio;
+ Word32 redRatioFac;
+ Word32 redOffs;
+} MINSNR_ADAPT_PARAM;
+
+typedef struct {
+ /* parameters for bitreservoir control */
+ Word16 peMin, peMax;
+ /* constant offset to pe */
+ Word16 peOffset;
+ /* avoid hole parameters */
+ AH_PARAM ahParam;
+ /* paramters for adaptation of minSnr */
+ MINSNR_ADAPT_PARAM minSnrAdaptParam;
+ /* values for correction of pe */
+ Word16 peLast;
+ Word16 dynBitsLast;
+ Word16 peCorrectionFactor;
+} ATS_ELEMENT;
+
+typedef struct {
+ BRES_PARAM bresParamLong, bresParamShort; /* Word16 size: 2*8 */
+ ATS_ELEMENT adjThrStateElem; /* Word16 size: 19 */
+} ADJ_THR_STATE;
+
+#endif
diff --git a/media/libstagefright/codecs/aacenc/inc/band_nrg.h b/media/libstagefright/codecs/aacenc/inc/band_nrg.h
new file mode 100644
index 0000000..68509da
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/band_nrg.h
@@ -0,0 +1,46 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: band_nrg.h
+
+ Content: Band/Line energy calculations functions
+
+*******************************************************************************/
+
+
+#ifndef _BAND_NRG_H
+#define _BAND_NRG_H
+
+#include "typedef.h"
+
+
+void CalcBandEnergy(const Word32 *mdctSpectrum,
+ const Word16 *bandOffset,
+ const Word16 numBands,
+ Word32 *bandEnergy,
+ Word32 *bandEnergySum);
+
+
+void CalcBandEnergyMS(const Word32 *mdctSpectrumLeft,
+ const Word32 *mdctSpectrumRight,
+ const Word16 *bandOffset,
+ const Word16 numBands,
+ Word32 *bandEnergyMid,
+ Word32 *bandEnergyMidSum,
+ Word32 *bandEnergySide,
+ Word32 *bandEnergySideSum);
+
+#endif
diff --git a/media/libstagefright/codecs/aacenc/inc/bit_cnt.h b/media/libstagefright/codecs/aacenc/inc/bit_cnt.h
new file mode 100644
index 0000000..808319e
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/bit_cnt.h
@@ -0,0 +1,106 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: bit_cnt.h
+
+ Content: Huffman Bitcounter & coder structure and functions
+
+*******************************************************************************/
+
+#ifndef __BITCOUNT_H
+#define __BITCOUNT_H
+
+#include "bitbuffer.h"
+#include "basic_op.h"
+#define INVALID_BITCOUNT (MAX_16/4)
+
+/*
+ code book number table
+*/
+
+enum codeBookNo{
+ CODE_BOOK_ZERO_NO= 0,
+ CODE_BOOK_1_NO= 1,
+ CODE_BOOK_2_NO= 2,
+ CODE_BOOK_3_NO= 3,
+ CODE_BOOK_4_NO= 4,
+ CODE_BOOK_5_NO= 5,
+ CODE_BOOK_6_NO= 6,
+ CODE_BOOK_7_NO= 7,
+ CODE_BOOK_8_NO= 8,
+ CODE_BOOK_9_NO= 9,
+ CODE_BOOK_10_NO= 10,
+ CODE_BOOK_ESC_NO= 11,
+ CODE_BOOK_RES_NO= 12,
+ CODE_BOOK_PNS_NO= 13
+};
+
+/*
+ code book index table
+*/
+
+enum codeBookNdx{
+ CODE_BOOK_ZERO_NDX=0,
+ CODE_BOOK_1_NDX,
+ CODE_BOOK_2_NDX,
+ CODE_BOOK_3_NDX,
+ CODE_BOOK_4_NDX,
+ CODE_BOOK_5_NDX,
+ CODE_BOOK_6_NDX,
+ CODE_BOOK_7_NDX,
+ CODE_BOOK_8_NDX,
+ CODE_BOOK_9_NDX,
+ CODE_BOOK_10_NDX,
+ CODE_BOOK_ESC_NDX,
+ CODE_BOOK_RES_NDX,
+ CODE_BOOK_PNS_NDX,
+ NUMBER_OF_CODE_BOOKS
+};
+
+/*
+ code book lav table
+*/
+
+enum codeBookLav{
+ CODE_BOOK_ZERO_LAV=0,
+ CODE_BOOK_1_LAV=1,
+ CODE_BOOK_2_LAV=1,
+ CODE_BOOK_3_LAV=2,
+ CODE_BOOK_4_LAV=2,
+ CODE_BOOK_5_LAV=4,
+ CODE_BOOK_6_LAV=4,
+ CODE_BOOK_7_LAV=7,
+ CODE_BOOK_8_LAV=7,
+ CODE_BOOK_9_LAV=12,
+ CODE_BOOK_10_LAV=12,
+ CODE_BOOK_ESC_LAV=16,
+ CODE_BOOK_SCF_LAV=60,
+ CODE_BOOK_PNS_LAV=60
+};
+
+Word16 bitCount(const Word16 *aQuantSpectrum,
+ const Word16 noOfSpecLines,
+ Word16 maxVal,
+ Word16 *bitCountLut);
+
+Word16 codeValues(Word16 *values, Word16 width, Word16 codeBook, HANDLE_BIT_BUF hBitstream);
+
+Word16 bitCountScalefactorDelta(Word16 delta);
+Word16 codeScalefactorDelta(Word16 scalefactor, HANDLE_BIT_BUF hBitstream);
+
+
+
+#endif
diff --git a/media/libstagefright/codecs/aacenc/inc/bitbuffer.h b/media/libstagefright/codecs/aacenc/inc/bitbuffer.h
new file mode 100644
index 0000000..cb850c9
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/bitbuffer.h
@@ -0,0 +1,89 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: bitbuffer.h
+
+ Content: Bit Buffer Management structure and functions
+
+*******************************************************************************/
+
+#ifndef BITBUFFER_H
+#define BITBUFFER_H
+
+#include "typedef.h"
+
+
+enum direction
+{
+ forwardDirection,
+ backwardDirection
+};
+
+
+/*!
+ The pointer 'pReadNext' points to the next available word, where bits can be read from. The pointer
+ 'pWriteNext' points to the next available word, where bits can be written to. The pointer pBitBufBase
+ points to the start of the bitstream buffer and the pointer pBitBufEnd points to the end of the bitstream
+ buffer. The two pointers are used as lower-bound respectively upper-bound address for the modulo addressing
+ mode.
+
+ The element cntBits contains the currently available bits in the bit buffer. It will be incremented when
+ bits are written to the bitstream buffer and decremented when bits are read from the bitstream buffer.
+*/
+struct BIT_BUF
+{
+ UWord8 *pBitBufBase; /*!< pointer points to first position in bitstream buffer */
+ UWord8 *pBitBufEnd; /*!< pointer points to last position in bitstream buffer */
+
+ UWord8 *pWriteNext; /*!< pointer points to next available word in bitstream buffer to write */
+
+ UWord32 cache;
+
+ Word16 wBitPos; /*!< 31<=wBitPos<=0*/
+ Word16 cntBits; /*!< number of available bits in the bitstream buffer
+ write bits to bitstream buffer => increment cntBits
+ read bits from bitstream buffer => decrement cntBits */
+ Word16 size; /*!< size of bitbuffer in bits */
+ Word16 isValid; /*!< indicates whether the instance has been initialized */
+}; /* size Word16: 8 */
+
+/*! Define pointer to bit buffer structure */
+typedef struct BIT_BUF *HANDLE_BIT_BUF;
+
+
+HANDLE_BIT_BUF CreateBitBuffer(HANDLE_BIT_BUF hBitBuf,
+ UWord8 *pBitBufBase,
+ Word16 bitBufSize);
+
+
+void DeleteBitBuffer(HANDLE_BIT_BUF *hBitBuf);
+
+
+Word16 GetBitsAvail(HANDLE_BIT_BUF hBitBuf);
+
+
+Word16 WriteBits(HANDLE_BIT_BUF hBitBuf,
+ Word32 writeValue,
+ Word16 noBitsToWrite);
+
+void ResetBitBuf(HANDLE_BIT_BUF hBitBuf,
+ UWord8 *pBitBufBase,
+ Word16 bitBufSize);
+
+#define GetNrBitsAvailable(hBitBuf) ( (hBitBuf)->cntBits)
+#define GetNrBitsRead(hBitBuf) ((hBitBuf)->size-(hBitBuf)->cntBits)
+
+#endif /* BITBUFFER_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/bitenc.h b/media/libstagefright/codecs/aacenc/inc/bitenc.h
new file mode 100644
index 0000000..1151057
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/bitenc.h
@@ -0,0 +1,50 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: bitenc.h
+
+ Content: Bitstream encoder structure and functions
+
+*******************************************************************************/
+
+#ifndef _BITENC_H
+#define _BITENC_H
+
+#include "qc_data.h"
+#include "tns.h"
+#include "channel_map.h"
+#include "interface.h"
+
+struct BITSTREAMENCODER_INIT
+{
+ Word16 nChannels;
+ Word32 bitrate;
+ Word32 sampleRate;
+ Word16 profile;
+};
+
+
+
+Word16 WriteBitstream (HANDLE_BIT_BUF hBitstream,
+ ELEMENT_INFO elInfo,
+ QC_OUT *qcOut,
+ PSY_OUT *psyOut,
+ Word16 *globUsedBits,
+ const UWord8 *ancBytes,
+ Word16 samplerate
+ );
+
+#endif /* _BITENC_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/block_switch.h b/media/libstagefright/codecs/aacenc/inc/block_switch.h
new file mode 100644
index 0000000..3e35819
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/block_switch.h
@@ -0,0 +1,72 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: block_switch.h
+
+ Content: Block switching structure and functions
+
+*******************************************************************************/
+
+#ifndef _BLOCK_SWITCH_H
+#define _BLOCK_SWITCH_H
+
+#include "typedef.h"
+
+
+/****************** Defines ******************************/
+#define BLOCK_SWITCHING_IIR_LEN 2 /* Length of HighPass-FIR-Filter for Attack-Detection */
+#define BLOCK_SWITCH_WINDOWS TRANS_FAC /* number of windows for energy calculation */
+#define BLOCK_SWITCH_WINDOW_LEN FRAME_LEN_SHORT /* minimal granularity of energy calculation */
+
+
+
+/****************** Structures ***************************/
+typedef struct{
+ Word32 invAttackRatio;
+ Word16 windowSequence;
+ Word16 nextwindowSequence;
+ Flag attack;
+ Flag lastattack;
+ Word16 attackIndex;
+ Word16 lastAttackIndex;
+ Word16 noOfGroups;
+ Word16 groupLen[TRANS_FAC];
+ Word32 windowNrg[2][BLOCK_SWITCH_WINDOWS]; /* time signal energy in Subwindows (last and current) */
+ Word32 windowNrgF[2][BLOCK_SWITCH_WINDOWS]; /* filtered time signal energy in segments (last and current) */
+ Word32 iirStates[BLOCK_SWITCHING_IIR_LEN]; /* filter delay-line */
+ Word32 maxWindowNrg; /* max energy in subwindows */
+ Word32 accWindowNrg; /* recursively accumulated windowNrgF */
+}BLOCK_SWITCHING_CONTROL;
+
+
+
+
+
+Word16 InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
+ const Word32 bitRate, const Word16 nChannels);
+
+Word16 BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
+ Word16 *timeSignal,
+ Word32 sampleRate,
+ Word16 chIncrement);
+
+Word16 SyncBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft,
+ BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight,
+ const Word16 noOfChannels);
+
+
+
+#endif /* #ifndef _BLOCK_SWITCH_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/channel_map.h b/media/libstagefright/codecs/aacenc/inc/channel_map.h
new file mode 100644
index 0000000..e3aa8dc
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/channel_map.h
@@ -0,0 +1,37 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: channel_map.h
+
+ Content: channel mapping functions
+
+*******************************************************************************/
+
+#ifndef _CHANNEL_MAP_H
+#define _CHANNEL_MAP_H
+
+#include "psy_const.h"
+#include "qc_data.h"
+
+Word16 InitElementInfo (Word16 nChannels, ELEMENT_INFO* elInfo);
+
+Word16 InitElementBits(ELEMENT_BITS *elementBits,
+ ELEMENT_INFO elInfo,
+ Word32 bitrateTot,
+ Word16 averageBitsTot,
+ Word16 staticBitsTot);
+
+#endif /* CHANNEL_MAP_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/config.h b/media/libstagefright/codecs/aacenc/inc/config.h
new file mode 100644
index 0000000..6211c8f
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/config.h
@@ -0,0 +1,36 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: config.h
+
+ Content: aac encoder parameter
+
+*******************************************************************************/
+
+#ifndef _AACENC_CONFIG_H_
+#define _AACENC_CONFIG_H_
+
+#define MAX_CHANNELS 2
+
+#define AACENC_BLOCKSIZE 1024 /*! encoder only takes BLOCKSIZE samples at a time */
+#define AACENC_TRANS_FAC 8 /*! encoder short long ratio */
+
+
+#define MAXBITS_COEF 6144
+#define MINBITS_COEF 744
+
+
+#endif \ No newline at end of file
diff --git a/media/libstagefright/codecs/aacenc/inc/dyn_bits.h b/media/libstagefright/codecs/aacenc/inc/dyn_bits.h
new file mode 100644
index 0000000..0468fa2
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/dyn_bits.h
@@ -0,0 +1,82 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: dyn_bits.h
+
+ Content: Noiseless coder module structure and functions
+
+*******************************************************************************/
+
+#ifndef __DYN_BITS_H
+#define __DYN_BITS_H
+
+#include "psy_const.h"
+#include "tns.h"
+#include "bit_cnt.h"
+
+
+
+#define MAX_SECTIONS MAX_GROUPED_SFB
+#define SECT_ESC_VAL_LONG 31
+#define SECT_ESC_VAL_SHORT 7
+#define CODE_BOOK_BITS 4
+#define SECT_BITS_LONG 5
+#define SECT_BITS_SHORT 3
+
+typedef struct
+{
+ Word16 codeBook;
+ Word16 sfbStart;
+ Word16 sfbCnt;
+ Word16 sectionBits;
+}
+SECTION_INFO;
+
+
+
+
+typedef struct
+{
+ Word16 blockType;
+ Word16 noOfGroups;
+ Word16 sfbCnt;
+ Word16 maxSfbPerGroup;
+ Word16 sfbPerGroup;
+ Word16 noOfSections;
+ SECTION_INFO sectionInfo[MAX_SECTIONS];
+ Word16 sideInfoBits; /* sectioning bits */
+ Word16 huffmanBits; /* huffman coded bits */
+ Word16 scalefacBits; /* scalefac coded bits */
+ Word16 firstScf; /* first scf to be coded */
+ Word16 bitLookUp[MAX_SFB_LONG*(CODE_BOOK_ESC_NDX+1)];
+ Word16 mergeGainLookUp[MAX_SFB_LONG];
+}
+SECTION_DATA; /* Word16 size: 10 + 60(MAX_SECTIONS)*4(SECTION_INFO) + 51(MAX_SFB_LONG)*12(CODE_BOOK_ESC_NDX+1) + 51(MAX_SFB_LONG) = 913 */
+
+
+Word16 BCInit(void);
+
+Word16 dynBitCount(const Word16 *quantSpectrum,
+ const UWord16 *maxValueInSfb,
+ const Word16 *scalefac,
+ const Word16 blockType,
+ const Word16 sfbCnt,
+ const Word16 maxSfbPerGroup,
+ const Word16 sfbPerGroup,
+ const Word16 *sfbOffset,
+ SECTION_DATA *sectionData);
+
+#endif
diff --git a/media/libstagefright/codecs/aacenc/inc/grp_data.h b/media/libstagefright/codecs/aacenc/inc/grp_data.h
new file mode 100644
index 0000000..9666577
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/grp_data.h
@@ -0,0 +1,44 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: grp_data.h
+
+ Content: Short block grouping function
+
+*******************************************************************************/
+
+#ifndef __GRP_DATA_H__
+#define __GRP_DATA_H__
+#include "psy_data.h"
+#include "typedefs.h"
+
+void
+groupShortData(Word32 *mdctSpectrum,
+ Word32 *tmpSpectrum,
+ SFB_THRESHOLD *sfbThreshold,
+ SFB_ENERGY *sfbEnergy,
+ SFB_ENERGY *sfbEnergyMS,
+ SFB_ENERGY *sfbSpreadedEnergy,
+ const Word16 sfbCnt,
+ const Word16 *sfbOffset,
+ const Word16 *sfbMinSnr,
+ Word16 *groupedSfbOffset,
+ Word16 *maxSfbPerGroup,
+ Word16 *groupedSfbMinSnr,
+ const Word16 noOfGroups,
+ const Word16 *groupLen);
+
+#endif /* _INTERFACE_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/interface.h b/media/libstagefright/codecs/aacenc/inc/interface.h
new file mode 100644
index 0000000..b84334a
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/interface.h
@@ -0,0 +1,106 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: interface.h
+
+ Content: psychoaccoustic/quantizer structures and interface
+
+*******************************************************************************/
+
+#ifndef _INTERFACE_H
+#define _INTERFACE_H
+
+#include "config.h"
+#include "psy_const.h"
+#include "psy_data.h"
+#include "typedefs.h"
+
+
+enum
+{
+ MS_NONE = 0,
+ MS_SOME = 1,
+ MS_ALL = 2
+};
+
+enum
+{
+ MS_ON = 1
+};
+
+struct TOOLSINFO {
+ Word16 msDigest;
+ Word16 msMask[MAX_GROUPED_SFB];
+};
+
+
+typedef struct {
+ Word16 sfbCnt;
+ Word16 sfbPerGroup;
+ Word16 maxSfbPerGroup;
+ Word16 windowSequence;
+ Word16 windowShape;
+ Word16 groupingMask;
+ Word16 sfbOffsets[MAX_GROUPED_SFB+1];
+ Word16 mdctScale;
+ Word32 *sfbEnergy;
+ Word32 *sfbSpreadedEnergy;
+ Word32 *sfbThreshold;
+ Word32 *mdctSpectrum;
+ Word32 sfbEnSumLR;
+ Word32 sfbEnSumMS;
+ Word32 sfbDist[MAX_GROUPED_SFB];
+ Word32 sfbDistNew[MAX_GROUPED_SFB];
+ Word16 sfbMinSnr[MAX_GROUPED_SFB];
+ Word16 minSfMaxQuant[MAX_GROUPED_SFB];
+ Word16 minScfCalculated[MAX_GROUPED_SFB];
+ Word16 prevScfLast[MAX_GROUPED_SFB];
+ Word16 prevScfNext[MAX_GROUPED_SFB];
+ Word16 deltaPeLast[MAX_GROUPED_SFB];
+ TNS_INFO tnsInfo;
+} PSY_OUT_CHANNEL; /* Word16 size: 14 + 60(MAX_GROUPED_SFB) + 112(TNS_INFO) = 186 */
+
+typedef struct {
+ struct TOOLSINFO toolsInfo;
+ Word16 groupedSfbOffset[MAX_CHANNELS][MAX_GROUPED_SFB+1]; /* plus one for last dummy offset ! */
+ Word16 groupedSfbMinSnr[MAX_CHANNELS][MAX_GROUPED_SFB];
+} PSY_OUT_ELEMENT;
+
+typedef struct {
+ /* information shared by both channels */
+ PSY_OUT_ELEMENT psyOutElement;
+ /* information specific to each channel */
+ PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS];
+}PSY_OUT;
+
+void BuildInterface(Word32 *mdctSpectrum,
+ const Word16 mdctScale,
+ SFB_THRESHOLD *sfbThreshold,
+ SFB_ENERGY *sfbEnergy,
+ SFB_ENERGY *sfbSpreadedEnergy,
+ const SFB_ENERGY_SUM sfbEnergySumLR,
+ const SFB_ENERGY_SUM sfbEnergySumMS,
+ const Word16 windowSequence,
+ const Word16 windowShape,
+ const Word16 sfbCnt,
+ const Word16 *sfbOffset,
+ const Word16 maxSfbPerGroup,
+ const Word16 *groupedSfbMinSnr,
+ const Word16 noOfGroups,
+ const Word16 *groupLen,
+ PSY_OUT_CHANNEL *psyOutCh);
+
+#endif /* _INTERFACE_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/line_pe.h b/media/libstagefright/codecs/aacenc/inc/line_pe.h
new file mode 100644
index 0000000..fed938b
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/line_pe.h
@@ -0,0 +1,75 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: line_pe.h
+
+ Content: Perceptual entropie module structure and functions
+
+*******************************************************************************/
+
+#ifndef __LINE_PE_H
+#define __LINE_PE_H
+
+
+#include "psy_const.h"
+#include "interface.h"
+
+
+typedef struct {
+ Word16 sfbLdEnergy[MAX_GROUPED_SFB]; /* 4*log(sfbEnergy)/log(2) */
+ Word16 sfbNLines4[MAX_GROUPED_SFB]; /* 4*number of relevant lines in sfb */
+ Word16 sfbPe[MAX_GROUPED_SFB]; /* pe for each sfb */
+ Word16 sfbConstPart[MAX_GROUPED_SFB]; /* constant part for each sfb */
+ Word16 sfbNActiveLines[MAX_GROUPED_SFB]; /* number of active lines in sfb */
+ Word16 pe; /* sum of sfbPe */
+ Word16 constPart; /* sum of sfbConstPart */
+ Word16 nActiveLines; /* sum of sfbNActiveLines */
+} PE_CHANNEL_DATA; /* size Word16: 303 */
+
+
+typedef struct {
+ PE_CHANNEL_DATA peChannelData[MAX_CHANNELS];
+ Word16 pe;
+ Word16 constPart;
+ Word16 nActiveLines;
+ Word16 offset;
+ Word16 ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB];
+ Word32 thrExp[MAX_CHANNELS][MAX_GROUPED_SFB];
+ Word32 sfbPeFactors[MAX_CHANNELS][MAX_GROUPED_SFB];
+} PE_DATA; /* size Word16: 303 + 4 + 120 + 240 = 667 */
+
+
+
+
+void prepareSfbPe(PE_DATA *peData,
+ PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS],
+ Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB],
+ Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB],
+ const Word16 nChannels,
+ const Word16 peOffset);
+
+
+
+
+
+void calcSfbPe(PE_DATA *peData,
+ PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS],
+ const Word16 nChannels);
+
+
+
+
+#endif
diff --git a/media/libstagefright/codecs/aacenc/inc/memalign.h b/media/libstagefright/codecs/aacenc/inc/memalign.h
new file mode 100644
index 0000000..3b302a7
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/memalign.h
@@ -0,0 +1,35 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: memalign.h
+
+ Content: Memory alloc alignments functions
+
+*******************************************************************************/
+
+#ifndef __VO_AACENC_MEM_ALIGN_H__
+#define __VO_AACENC_MEM_ALIGN_H__
+
+#include "voMem.h"
+#include "typedef.h"
+
+extern void *mem_malloc(VO_MEM_OPERATOR *pMemop, unsigned int size, unsigned char alignment, unsigned int CodecID);
+extern void mem_free(VO_MEM_OPERATOR *pMemop, void *mem_ptr, unsigned int CodecID);
+
+#endif /* __VO_MEM_ALIGN_H__ */
+
+
+
diff --git a/media/libstagefright/codecs/aacenc/inc/ms_stereo.h b/media/libstagefright/codecs/aacenc/inc/ms_stereo.h
new file mode 100644
index 0000000..6d43dec
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/ms_stereo.h
@@ -0,0 +1,45 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: ms_stereo.h
+
+ Content: Declaration MS stereo processing structure and functions
+
+*******************************************************************************/
+
+#ifndef __MS_STEREO_H__
+#define __MS_STEREO_H__
+#include "typedef.h"
+
+void MsStereoProcessing(Word32 *sfbEnergyLeft,
+ Word32 *sfbEnergyRight,
+ const Word32 *sfbEnergyMid,
+ const Word32 *sfbEnergySide,
+ Word32 *mdctSpectrumLeft,
+ Word32 *mdctSpectrumRight,
+ Word32 *sfbThresholdLeft,
+ Word32 *sfbThresholdRight,
+ Word32 *sfbSpreadedEnLeft,
+ Word32 *sfbSpreadedEnRight,
+ Word16 *msDigest,
+ Word16 *msMask,
+ const Word16 sfbCnt,
+ const Word16 sfbPerGroup,
+ const Word16 maxSfbPerGroup,
+ const Word16 *sfbOffset);
+
+
+#endif
diff --git a/media/libstagefright/codecs/aacenc/inc/pre_echo_control.h b/media/libstagefright/codecs/aacenc/inc/pre_echo_control.h
new file mode 100644
index 0000000..35f36e8
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/pre_echo_control.h
@@ -0,0 +1,42 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: pre_echo_control.h
+
+ Content: Pre echo control functions
+
+*******************************************************************************/
+
+#ifndef __PRE_ECHO_CONTROL_H
+#define __PRE_ECHO_CONTROL_H
+
+#include "typedefs.h"
+
+void InitPreEchoControl(Word32 *pbThresholdnm1,
+ Word16 numPb,
+ Word32 *pbThresholdQuiet);
+
+
+void PreEchoControl(Word32 *pbThresholdNm1,
+ Word16 numPb,
+ Word32 maxAllowedIncreaseFactor,
+ Word16 minRemainingThresholdFactor,
+ Word32 *pbThreshold,
+ Word16 mdctScale,
+ Word16 mdctScalenm1);
+
+#endif
+
diff --git a/media/libstagefright/codecs/aacenc/inc/psy_configuration.h b/media/libstagefright/codecs/aacenc/inc/psy_configuration.h
new file mode 100644
index 0000000..53cf25b
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/psy_configuration.h
@@ -0,0 +1,107 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: psy_configuration.h
+
+ Content: Psychoaccoustic configuration structure and functions
+
+*******************************************************************************/
+
+#ifndef _PSY_CONFIGURATION_H
+#define _PSY_CONFIGURATION_H
+
+#include "typedefs.h"
+#include "psy_const.h"
+#include "tns.h"
+
+typedef struct{
+
+ Word16 sfbCnt;
+ Word16 sfbActive; /* number of sf bands containing energy after lowpass */
+ Word16 *sfbOffset;
+
+ Word32 sfbThresholdQuiet[MAX_SFB_LONG];
+
+ Word16 maxAllowedIncreaseFactor; /* preecho control */
+ Word16 minRemainingThresholdFactor;
+
+ Word16 lowpassLine;
+ Word16 sampRateIdx;
+ Word32 clipEnergy; /* for level dependend tmn */
+
+ Word16 ratio;
+ Word16 sfbMaskLowFactor[MAX_SFB_LONG];
+ Word16 sfbMaskHighFactor[MAX_SFB_LONG];
+
+ Word16 sfbMaskLowFactorSprEn[MAX_SFB_LONG];
+ Word16 sfbMaskHighFactorSprEn[MAX_SFB_LONG];
+
+
+ Word16 sfbMinSnr[MAX_SFB_LONG]; /* minimum snr (formerly known as bmax) */
+
+ TNS_CONFIG tnsConf;
+
+}PSY_CONFIGURATION_LONG; /*Word16 size: 8 + 52 + 102 + 51 + 51 + 51 + 51 + 47 = 515 */
+
+
+typedef struct{
+
+ Word16 sfbCnt;
+ Word16 sfbActive; /* number of sf bands containing energy after lowpass */
+ Word16 *sfbOffset;
+
+ Word32 sfbThresholdQuiet[MAX_SFB_SHORT];
+
+ Word16 maxAllowedIncreaseFactor; /* preecho control */
+ Word16 minRemainingThresholdFactor;
+
+ Word16 lowpassLine;
+ Word16 sampRateIdx;
+ Word32 clipEnergy; /* for level dependend tmn */
+
+ Word16 ratio;
+ Word16 sfbMaskLowFactor[MAX_SFB_SHORT];
+ Word16 sfbMaskHighFactor[MAX_SFB_SHORT];
+
+ Word16 sfbMaskLowFactorSprEn[MAX_SFB_SHORT];
+ Word16 sfbMaskHighFactorSprEn[MAX_SFB_SHORT];
+
+
+ Word16 sfbMinSnr[MAX_SFB_SHORT]; /* minimum snr (formerly known as bmax) */
+
+ TNS_CONFIG tnsConf;
+
+}PSY_CONFIGURATION_SHORT; /*Word16 size: 8 + 16 + 16 + 16 + 16 + 16 + 16 + 16 + 47 = 167 */
+
+
+/* Returns the sample rate index */
+Word32 GetSRIndex(Word32 sampleRate);
+
+
+Word16 InitPsyConfigurationLong(Word32 bitrate,
+ Word32 samplerate,
+ Word16 bandwidth,
+ PSY_CONFIGURATION_LONG *psyConf);
+
+Word16 InitPsyConfigurationShort(Word32 bitrate,
+ Word32 samplerate,
+ Word16 bandwidth,
+ PSY_CONFIGURATION_SHORT *psyConf);
+
+#endif /* _PSY_CONFIGURATION_H */
+
+
+
diff --git a/media/libstagefright/codecs/aacenc/inc/psy_const.h b/media/libstagefright/codecs/aacenc/inc/psy_const.h
new file mode 100644
index 0000000..5455ab1
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/psy_const.h
@@ -0,0 +1,80 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: psy_const.h
+
+ Content: Global psychoacoustic constants structures
+
+*******************************************************************************/
+
+#ifndef _PSYCONST_H
+#define _PSYCONST_H
+
+#include "config.h"
+
+#define TRUE 1
+#define FALSE 0
+
+#define FRAME_LEN_LONG AACENC_BLOCKSIZE
+#define TRANS_FAC 8
+#define FRAME_LEN_SHORT (FRAME_LEN_LONG/TRANS_FAC)
+
+
+
+/* Block types */
+enum
+{
+ LONG_WINDOW = 0,
+ START_WINDOW,
+ SHORT_WINDOW,
+ STOP_WINDOW
+};
+
+/* Window shapes */
+enum
+{
+ SINE_WINDOW = 0,
+ KBD_WINDOW = 1
+};
+
+/*
+ MS stuff
+*/
+enum
+{
+ SI_MS_MASK_NONE = 0,
+ SI_MS_MASK_SOME = 1,
+ SI_MS_MASK_ALL = 2
+};
+
+#define MAX_NO_OF_GROUPS 4
+#define MAX_SFB_SHORT 15 /* 15 for a memory optimized implementation, maybe 16 for convenient debugging */
+#define MAX_SFB_LONG 51 /* 51 for a memory optimized implementation, maybe 64 for convenient debugging */
+#define MAX_SFB (MAX_SFB_SHORT > MAX_SFB_LONG ? MAX_SFB_SHORT : MAX_SFB_LONG) /* = MAX_SFB_LONG */
+#define MAX_GROUPED_SFB (MAX_NO_OF_GROUPS*MAX_SFB_SHORT > MAX_SFB_LONG ? \
+ MAX_NO_OF_GROUPS*MAX_SFB_SHORT : MAX_SFB_LONG)
+
+#define BLOCK_SWITCHING_OFFSET (1*1024+3*128+64+128)
+#define BLOCK_SWITCHING_DATA_SIZE FRAME_LEN_LONG
+
+#define TRANSFORM_OFFSET_LONG 0
+#define TRANSFORM_OFFSET_SHORT 448
+
+#define LOG_NORM_PCM -15
+
+#define NUM_SAMPLE_RATES 12
+
+#endif /* _PSYCONST_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/psy_data.h b/media/libstagefright/codecs/aacenc/inc/psy_data.h
new file mode 100644
index 0000000..1412d53
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/psy_data.h
@@ -0,0 +1,66 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: psy_data.h
+
+ Content: Psychoacoustic data and structures
+
+*******************************************************************************/
+
+#ifndef _PSY_DATA_H
+#define _PSY_DATA_H
+
+#include "block_switch.h"
+#include "tns.h"
+
+/*
+ the structs can be implemented as unions
+*/
+
+typedef struct{
+ Word32 sfbLong[MAX_GROUPED_SFB];
+ Word32 sfbShort[TRANS_FAC][MAX_SFB_SHORT];
+}SFB_THRESHOLD; /* Word16 size: 260 */
+
+typedef struct{
+ Word32 sfbLong[MAX_GROUPED_SFB];
+ Word32 sfbShort[TRANS_FAC][MAX_SFB_SHORT];
+}SFB_ENERGY; /* Word16 size: 260 */
+
+typedef struct{
+ Word32 sfbLong;
+ Word32 sfbShort[TRANS_FAC];
+}SFB_ENERGY_SUM; /* Word16 size: 18 */
+
+
+typedef struct{
+ BLOCK_SWITCHING_CONTROL blockSwitchingControl; /* block switching */
+ Word16 *mdctDelayBuffer; /* mdct delay buffer [BLOCK_SWITCHING_OFFSET]*/
+ Word32 sfbThresholdnm1[MAX_SFB]; /* PreEchoControl */
+ Word16 mdctScalenm1; /* scale of last block's mdct (PreEchoControl) */
+
+ SFB_THRESHOLD sfbThreshold; /* adapt */
+ SFB_ENERGY sfbEnergy; /* sfb Energy */
+ SFB_ENERGY sfbEnergyMS;
+ SFB_ENERGY_SUM sfbEnergySum;
+ SFB_ENERGY_SUM sfbEnergySumMS;
+ SFB_ENERGY sfbSpreadedEnergy;
+
+ Word32 *mdctSpectrum; /* mdct spectrum [FRAME_LEN_LONG] */
+ Word16 mdctScale; /* scale of mdct */
+}PSY_DATA; /* Word16 size: 4 + 87 + 102 + 360 + 360 + 360 + 18 + 18 + 360 = 1669 */
+
+#endif /* _PSY_DATA_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/psy_main.h b/media/libstagefright/codecs/aacenc/inc/psy_main.h
new file mode 100644
index 0000000..ab0b8b1
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/psy_main.h
@@ -0,0 +1,69 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: psy_main.h
+
+ Content: Psychoacoustic major function block
+
+*******************************************************************************/
+
+#ifndef _PSYMAIN_H
+#define _PSYMAIN_H
+
+#include "psy_configuration.h"
+#include "qc_data.h"
+#include "memalign.h"
+
+/*
+ psy kernel
+*/
+typedef struct {
+ PSY_CONFIGURATION_LONG psyConfLong; /* Word16 size: 515 */
+ PSY_CONFIGURATION_SHORT psyConfShort; /* Word16 size: 167 */
+ PSY_DATA psyData[MAX_CHANNELS]; /* Word16 size: MAX_CHANNELS*1669*/
+ TNS_DATA tnsData[MAX_CHANNELS]; /* Word16 size: MAX_CHANNELS*235 */
+ Word32* pScratchTns;
+ Word16 sampleRateIdx;
+}PSY_KERNEL; /* Word16 size: 2587 / 4491 */
+
+
+Word16 PsyNew( PSY_KERNEL *hPsy, Word32 nChan, VO_MEM_OPERATOR *pMemOP);
+Word16 PsyDelete( PSY_KERNEL *hPsy, VO_MEM_OPERATOR *pMemOP);
+
+Word16 PsyOutNew( PSY_OUT *hPsyOut, VO_MEM_OPERATOR *pMemOP);
+Word16 PsyOutDelete( PSY_OUT *hPsyOut, VO_MEM_OPERATOR *pMemOP);
+
+Word16 psyMainInit( PSY_KERNEL *hPsy,
+ Word32 sampleRate,
+ Word32 bitRate,
+ Word16 channels,
+ Word16 tnsMask,
+ Word16 bandwidth);
+
+
+Word16 psyMain(Word16 nChannels, /*!< total number of channels */
+ ELEMENT_INFO *elemInfo,
+ Word16 *timeSignal, /*!< interleaved time signal */
+ PSY_DATA psyData[MAX_CHANNELS],
+ TNS_DATA tnsData[MAX_CHANNELS],
+ PSY_CONFIGURATION_LONG* psyConfLong,
+ PSY_CONFIGURATION_SHORT* psyConfShort,
+ PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS],
+ PSY_OUT_ELEMENT *psyOutElement,
+ Word32 *pScratchTns,
+ Word32 sampleRate);
+
+#endif /* _PSYMAIN_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/qc_data.h b/media/libstagefright/codecs/aacenc/inc/qc_data.h
new file mode 100644
index 0000000..81d4051
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/qc_data.h
@@ -0,0 +1,143 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: qc_data.h
+
+ Content: Quantizing & coding structures
+
+*******************************************************************************/
+
+#ifndef _QC_DATA_H
+#define _QC_DATA_H
+
+#include "psy_const.h"
+#include "dyn_bits.h"
+#include "adj_thr_data.h"
+
+
+#define MAX_MODES 10
+
+typedef enum {
+ MODE_INVALID = 0,
+ MODE_1, /* mono */
+ MODE_1_1, /* dual mono */
+ MODE_2 /* stereo */
+} ENCODER_MODE;
+
+typedef enum {
+ ID_SCE=0, /* Single Channel Element */
+ ID_CPE=1, /* Channel Pair Element */
+ ID_CCE=2, /* Coupling Channel Element */
+ ID_LFE=3, /* LFE Channel Element */
+ ID_DSE=4, /* current one DSE element for ancillary is supported */
+ ID_PCE=5,
+ ID_FIL=6,
+ ID_END=7
+}ELEMENT_TYPE;
+
+typedef struct {
+ ELEMENT_TYPE elType;
+ Word16 instanceTag;
+ Word16 nChannelsInEl;
+ Word16 ChannelIndex[MAX_CHANNELS];
+} ELEMENT_INFO;
+
+typedef struct {
+ Word32 paddingRest;
+} PADDING;
+
+
+/* Quantizing & coding stage */
+
+struct QC_INIT{
+ ELEMENT_INFO *elInfo;
+ Word16 maxBits; /* maximum number of bits in reservoir */
+ Word16 averageBits; /* average number of bits we should use */
+ Word16 bitRes;
+ Word16 meanPe;
+ Word32 chBitrate;
+ Word16 maxBitFac;
+ Word32 bitrate;
+
+ PADDING padding;
+};
+
+typedef struct
+{
+ Word16 *quantSpec; /* [FRAME_LEN_LONG]; */
+ UWord16 *maxValueInSfb; /* [MAX_GROUPED_SFB]; */
+ Word16 *scf; /* [MAX_GROUPED_SFB]; */
+ Word16 globalGain;
+ Word16 mdctScale;
+ Word16 groupingMask;
+ SECTION_DATA sectionData;
+ Word16 windowShape;
+} QC_OUT_CHANNEL;
+
+typedef struct
+{
+ Word16 adtsUsed;
+ Word16 staticBitsUsed; /* for verification purposes */
+ Word16 dynBitsUsed; /* for verification purposes */
+ Word16 pe;
+ Word16 ancBitsUsed;
+ Word16 fillBits;
+} QC_OUT_ELEMENT;
+
+typedef struct
+{
+ QC_OUT_CHANNEL qcChannel[MAX_CHANNELS];
+ QC_OUT_ELEMENT qcElement;
+ Word16 totStaticBitsUsed; /* for verification purposes */
+ Word16 totDynBitsUsed; /* for verification purposes */
+ Word16 totAncBitsUsed; /* for verification purposes */
+ Word16 totFillBits;
+ Word16 alignBits;
+ Word16 bitResTot;
+ Word16 averageBitsTot;
+} QC_OUT;
+
+typedef struct {
+ Word32 chBitrate;
+ Word16 averageBits; /* brutto -> look ancillary.h */
+ Word16 maxBits;
+ Word16 bitResLevel;
+ Word16 maxBitResBits;
+ Word16 relativeBits; /* Bits relative to total Bits scaled down by 2 */
+} ELEMENT_BITS;
+
+typedef struct
+{
+ /* this is basically struct QC_INIT */
+ Word16 averageBitsTot;
+ Word16 maxBitsTot;
+ Word16 globStatBits;
+ Word16 nChannels;
+ Word16 bitResTot;
+
+ Word16 maxBitFac;
+
+ PADDING padding;
+
+ ELEMENT_BITS elementBits;
+ ADJ_THR_STATE adjThr;
+
+ Word16 logSfbFormFactor[MAX_CHANNELS][MAX_GROUPED_SFB];
+ Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB];
+ Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB];
+} QC_STATE;
+
+#endif /* _QC_DATA_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/qc_main.h b/media/libstagefright/codecs/aacenc/inc/qc_main.h
new file mode 100644
index 0000000..e1138b2
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/qc_main.h
@@ -0,0 +1,64 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: qc_main.h
+
+ Content: Quantizing & coding functions
+
+*******************************************************************************/
+
+#ifndef _QC_MAIN_H
+#define _QC_MAIN_H
+
+#include "qc_data.h"
+#include "interface.h"
+#include "memalign.h"
+
+/* Quantizing & coding stage */
+
+Word16 QCOutNew(QC_OUT *hQC, Word16 nChannels, VO_MEM_OPERATOR *pMemOP);
+
+void QCOutDelete(QC_OUT *hQC, VO_MEM_OPERATOR *pMemOP);
+
+Word16 QCNew(QC_STATE *hQC, VO_MEM_OPERATOR *pMemOP);
+
+Word16 QCInit(QC_STATE *hQC,
+ struct QC_INIT *init);
+
+void QCDelete(QC_STATE *hQC, VO_MEM_OPERATOR *pMemOP);
+
+
+Word16 QCMain(QC_STATE *hQC,
+ ELEMENT_BITS* elBits,
+ ATS_ELEMENT* adjThrStateElement,
+ PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], /* may be modified in-place */
+ PSY_OUT_ELEMENT* psyOutElement,
+ QC_OUT_CHANNEL qcOutChannel[MAX_CHANNELS], /* out */
+ QC_OUT_ELEMENT* qcOutElement,
+ Word16 nChannels,
+ Word16 ancillaryDataBytes); /* returns error code */
+
+void updateBitres(QC_STATE* qcKernel,
+ QC_OUT* qcOut);
+
+Word16 FinalizeBitConsumption(QC_STATE *hQC,
+ QC_OUT* qcOut);
+
+Word16 AdjustBitrate(QC_STATE *hQC,
+ Word32 bitRate,
+ Word32 sampleRate);
+
+#endif /* _QC_MAIN_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/quantize.h b/media/libstagefright/codecs/aacenc/inc/quantize.h
new file mode 100644
index 0000000..88a95e1
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/quantize.h
@@ -0,0 +1,42 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: quantize.h
+
+ Content: Quantization functions
+
+*******************************************************************************/
+
+#ifndef _QUANTIZE_H_
+#define _QUANTIZE_H_
+#include "typedefs.h"
+
+/* quantizing */
+
+#define MAX_QUANT 8191
+
+void QuantizeSpectrum(Word16 sfbCnt,
+ Word16 maxSfbPerGroup,
+ Word16 sfbPerGroup,
+ Word16 *sfbOffset, Word32 *mdctSpectrum,
+ Word16 globalGain, Word16 *scalefactors,
+ Word16 *quantizedSpectrum);
+
+Word32 calcSfbDist(const Word32 *spec,
+ Word16 sfbWidth,
+ Word16 gain);
+
+#endif /* _QUANTIZE_H_ */
diff --git a/media/libstagefright/codecs/aacenc/inc/sf_estim.h b/media/libstagefright/codecs/aacenc/inc/sf_estim.h
new file mode 100644
index 0000000..b25ec3c
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/sf_estim.h
@@ -0,0 +1,46 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: sf_estim.h
+
+ Content: Scale factor estimation functions
+
+*******************************************************************************/
+
+#ifndef __SF_ESTIM_H__
+#define __SF_ESTIM_H__
+/*
+ Scale factor estimation
+ */
+#include "psy_const.h"
+#include "interface.h"
+#include "qc_data.h"
+
+void
+CalcFormFactor(Word16 logSfbFormFactor[MAX_CHANNELS][MAX_GROUPED_SFB],
+ Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB],
+ Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB],
+ PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS],
+ const Word16 nChannels);
+
+void
+EstimateScaleFactors(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS],
+ QC_OUT_CHANNEL qcOutChannel[MAX_CHANNELS],
+ Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB],
+ Word16 logSfbFormFactor[MAX_CHANNELS][MAX_GROUPED_SFB],
+ Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB],
+ const Word16 nChannels);
+#endif \ No newline at end of file
diff --git a/media/libstagefright/codecs/aacenc/inc/spreading.h b/media/libstagefright/codecs/aacenc/inc/spreading.h
new file mode 100644
index 0000000..29cf63d
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/spreading.h
@@ -0,0 +1,33 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: spreading.h
+
+ Content: Spreading of energy functions
+
+*******************************************************************************/
+
+#ifndef _SPREADING_H
+#define _SPREADING_H
+#include "typedefs.h"
+
+
+void SpreadingMax(const Word16 pbCnt,
+ const Word16 *maskLowFactor,
+ const Word16 *maskHighFactor,
+ Word32 *pbSpreadedEnergy);
+
+#endif /* #ifndef _SPREADING_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/stat_bits.h b/media/libstagefright/codecs/aacenc/inc/stat_bits.h
new file mode 100644
index 0000000..6e90b9c
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/stat_bits.h
@@ -0,0 +1,34 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: stat_bits.h
+
+ Content: Static bit counter functions
+
+*******************************************************************************/
+
+#ifndef __STAT_BITS_H
+#define __STAT_BITS_H
+
+#include "psy_const.h"
+#include "interface.h"
+
+Word16 countStaticBitdemand(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS],
+ PSY_OUT_ELEMENT *psyOutElement,
+ Word16 nChannels,
+ Word16 adtsUsed);
+
+#endif /* __STAT_BITS_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/tns.h b/media/libstagefright/codecs/aacenc/inc/tns.h
new file mode 100644
index 0000000..9ffcce9
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/tns.h
@@ -0,0 +1,108 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: tns.h
+
+ Content: TNS structures
+
+*******************************************************************************/
+
+#ifndef _TNS_H
+#define _TNS_H
+
+#include "typedef.h"
+#include "psy_const.h"
+
+
+
+#define TNS_MAX_ORDER 12
+#define TNS_MAX_ORDER_SHORT 5
+
+#define FILTER_DIRECTION 0
+
+typedef struct{ /*stuff that is tabulated dependent on bitrate etc. */
+ Word16 threshOn; /* min. prediction gain for using tns TABUL * 100*/
+ Word32 lpcStartFreq; /* lowest freq for lpc TABUL*/
+ Word32 lpcStopFreq; /* TABUL */
+ Word32 tnsTimeResolution;
+}TNS_CONFIG_TABULATED;
+
+
+typedef struct { /*assigned at InitTime*/
+ Word16 tnsActive;
+ Word16 tnsMaxSfb;
+
+ Word16 maxOrder; /* max. order of tns filter */
+ Word16 tnsStartFreq; /* lowest freq. for tns filtering */
+ Word16 coefRes;
+
+ TNS_CONFIG_TABULATED confTab;
+
+ Word32 acfWindow[TNS_MAX_ORDER+1];
+
+ Word16 tnsStartBand;
+ Word16 tnsStartLine;
+
+ Word16 tnsStopBand;
+ Word16 tnsStopLine;
+
+ Word16 lpcStartBand;
+ Word16 lpcStartLine;
+
+ Word16 lpcStopBand;
+ Word16 lpcStopLine;
+
+ Word16 tnsRatioPatchLowestCb;
+ Word16 tnsModifyBeginCb;
+
+ Word16 threshold; /* min. prediction gain for using tns TABUL * 100 */
+
+}TNS_CONFIG;
+
+
+typedef struct {
+ Word16 tnsActive;
+ Word32 parcor[TNS_MAX_ORDER];
+ Word16 predictionGain;
+} TNS_SUBBLOCK_INFO; /* Word16 size: 26 */
+
+typedef struct{
+ TNS_SUBBLOCK_INFO subBlockInfo[TRANS_FAC];
+} TNS_DATA_SHORT;
+
+typedef struct{
+ TNS_SUBBLOCK_INFO subBlockInfo;
+} TNS_DATA_LONG;
+
+typedef struct{
+ TNS_DATA_LONG tnsLong;
+ TNS_DATA_SHORT tnsShort;
+}TNS_DATA_RAW;
+
+typedef struct{
+ Word16 numOfSubblocks;
+ TNS_DATA_RAW dataRaw;
+}TNS_DATA; /* Word16 size: 1 + 8*26 + 26 = 235 */
+
+typedef struct{
+ Word16 tnsActive[TRANS_FAC];
+ Word16 coefRes[TRANS_FAC];
+ Word16 length[TRANS_FAC];
+ Word16 order[TRANS_FAC];
+ Word16 coef[TRANS_FAC*TNS_MAX_ORDER_SHORT];
+}TNS_INFO; /* Word16 size: 72 */
+
+#endif /* _TNS_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/tns_func.h b/media/libstagefright/codecs/aacenc/inc/tns_func.h
new file mode 100644
index 0000000..58b75b6
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/tns_func.h
@@ -0,0 +1,75 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: tns_func.h
+
+ Content: TNS functions
+
+*******************************************************************************/
+
+/*
+ Temporal noise shaping
+ */
+#ifndef _TNS_FUNC_H
+#define _TNS_FUNC_H
+#include "typedef.h"
+#include "psy_configuration.h"
+
+Word16 InitTnsConfigurationLong(Word32 bitrate,
+ Word32 samplerate,
+ Word16 channels,
+ TNS_CONFIG *tnsConfig,
+ PSY_CONFIGURATION_LONG *psyConfig,
+ Word16 active);
+
+Word16 InitTnsConfigurationShort(Word32 bitrate,
+ Word32 samplerate,
+ Word16 channels,
+ TNS_CONFIG *tnsConfig,
+ PSY_CONFIGURATION_SHORT *psyConfig,
+ Word16 active);
+
+Word32 TnsDetect(TNS_DATA* tnsData,
+ TNS_CONFIG tC,
+ Word32* pScratchTns,
+ const Word16 sfbOffset[],
+ Word32* spectrum,
+ Word16 subBlockNumber,
+ Word16 blockType,
+ Word32 * sfbEnergy);
+
+void TnsSync(TNS_DATA *tnsDataDest,
+ const TNS_DATA *tnsDataSrc,
+ const TNS_CONFIG tC,
+ const Word16 subBlockNumber,
+ const Word16 blockType);
+
+Word16 TnsEncode(TNS_INFO* tnsInfo,
+ TNS_DATA* tnsData,
+ Word16 numOfSfb,
+ TNS_CONFIG tC,
+ Word16 lowPassLine,
+ Word32* spectrum,
+ Word16 subBlockNumber,
+ Word16 blockType);
+
+void ApplyTnsMultTableToRatios(Word16 startCb,
+ Word16 stopCb,
+ TNS_SUBBLOCK_INFO subInfo,
+ Word32 *thresholds);
+
+
+#endif /* _TNS_FUNC_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/tns_param.h b/media/libstagefright/codecs/aacenc/inc/tns_param.h
new file mode 100644
index 0000000..26266ac
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/tns_param.h
@@ -0,0 +1,52 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: tns_param.h
+
+ Content: TNS parameters
+
+*******************************************************************************/
+
+/*
+ TNS parameters
+ */
+#ifndef _TNS_PARAM_H
+#define _TNS_PARAM_H
+
+#include "tns.h"
+
+typedef struct{
+ Word32 samplingRate;
+ Word16 maxBandLong;
+ Word16 maxBandShort;
+}TNS_MAX_TAB_ENTRY;
+
+typedef struct{
+ Word32 bitRateFrom;
+ Word32 bitRateTo;
+ const TNS_CONFIG_TABULATED *paramMono_Long; /* contains TNS parameters */
+ const TNS_CONFIG_TABULATED *paramMono_Short;
+ const TNS_CONFIG_TABULATED *paramStereo_Long;
+ const TNS_CONFIG_TABULATED *paramStereo_Short;
+}TNS_INFO_TAB;
+
+
+void GetTnsParam(TNS_CONFIG_TABULATED *tnsConfigTab,
+ Word32 bitRate, Word16 channels, Word16 blockType);
+
+void GetTnsMaxBands(Word32 samplingRate, Word16 blockType, Word16* tnsMaxSfb);
+
+#endif /* _TNS_PARAM_H */
diff --git a/media/libstagefright/codecs/aacenc/inc/transform.h b/media/libstagefright/codecs/aacenc/inc/transform.h
new file mode 100644
index 0000000..2666914
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/inc/transform.h
@@ -0,0 +1,36 @@
+/*
+ ** Copyright 2003-2010, VisualOn, Inc.
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+/*******************************************************************************
+ File: transform.h
+
+ Content: MDCT Transform functions
+
+*******************************************************************************/
+
+#ifndef __TRANSFORM_H__
+#define __TRANSFORM_H__
+
+#include "typedef.h"
+
+void Transform_Real(Word16 *mdctDelayBuffer,
+ Word16 *timeSignal,
+ Word16 chIncrement, /*! channel increment */
+ Word32 *realOut,
+ Word16 *mdctScale,
+ Word16 windowSequence
+ );
+
+#endif \ No newline at end of file