summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/aacenc/src/tns.c
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/codecs/aacenc/src/tns.c')
-rw-r--r--media/libstagefright/codecs/aacenc/src/tns.c140
1 files changed, 70 insertions, 70 deletions
diff --git a/media/libstagefright/codecs/aacenc/src/tns.c b/media/libstagefright/codecs/aacenc/src/tns.c
index 96d890e..473e0a0 100644
--- a/media/libstagefright/codecs/aacenc/src/tns.c
+++ b/media/libstagefright/codecs/aacenc/src/tns.c
@@ -1,27 +1,27 @@
-/*
- ** 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.c
-
- Content: Definition TNS tools functions
-
+/*
+ ** 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.c
+
+ Content: Definition TNS tools functions
+
*******************************************************************************/
-#include "basic_op.h"
-#include "oper_32b.h"
+#include "basic_op.h"
+#include "oper_32b.h"
#include "assert.h"
#include "aac_rom.h"
#include "psy_const.h"
@@ -32,23 +32,23 @@
#define TNS_MODIFY_BEGIN 2600 /* Hz */
#define RATIO_PATCH_LOWER_BORDER 380 /* Hz */
-#define TNS_GAIN_THRESH 141 /* 1.41*100 */
-#define NORM_COEF 0x028f5c28
-
-static const Word32 TNS_PARCOR_THRESH = 0x0ccccccd; /* 0.1*(1 << 31) */
-/* Limit bands to > 2.0 kHz */
-static unsigned short tnsMinBandNumberLong[12] =
-{ 11, 12, 15, 16, 17, 20, 25, 26, 24, 28, 30, 31 };
-static unsigned short tnsMinBandNumberShort[12] =
-{ 2, 2, 2, 3, 3, 4, 6, 6, 8, 10, 10, 12 };
-
-/**************************************/
-/* Main/Low Profile TNS Parameters */
-/**************************************/
-static unsigned short tnsMaxBandsLongMainLow[12] =
-{ 31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39 };
-
-static unsigned short tnsMaxBandsShortMainLow[12] =
+#define TNS_GAIN_THRESH 141 /* 1.41*100 */
+#define NORM_COEF 0x028f5c28
+
+static const Word32 TNS_PARCOR_THRESH = 0x0ccccccd; /* 0.1*(1 << 31) */
+/* Limit bands to > 2.0 kHz */
+static unsigned short tnsMinBandNumberLong[12] =
+{ 11, 12, 15, 16, 17, 20, 25, 26, 24, 28, 30, 31 };
+static unsigned short tnsMinBandNumberShort[12] =
+{ 2, 2, 2, 3, 3, 4, 6, 6, 8, 10, 10, 12 };
+
+/**************************************/
+/* Main/Low Profile TNS Parameters */
+/**************************************/
+static unsigned short tnsMaxBandsLongMainLow[12] =
+{ 31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39 };
+
+static unsigned short tnsMaxBandsShortMainLow[12] =
{ 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14 };
@@ -178,8 +178,8 @@ Word16 InitTnsConfigurationLong(Word32 bitRate, /*!< bitrate */
tC->lpcStopBand = tnsMaxBandsLongMainLow[pC->sampRateIdx];
tC->lpcStopBand = min(tC->lpcStopBand, pC->sfbActive);
- tC->lpcStopLine = pC->sfbOffset[tC->lpcStopBand];
-
+ tC->lpcStopLine = pC->sfbOffset[tC->lpcStopBand];
+
tC->lpcStartBand = tnsMinBandNumberLong[pC->sampRateIdx];
tC->lpcStartLine = pC->sfbOffset[tC->lpcStartBand];
@@ -241,13 +241,13 @@ Word16 InitTnsConfigurationShort(Word32 bitRate, /*!< bitrate */
tC->tnsStartLine = pC->sfbOffset[tC->tnsStartBand];
- tC->lpcStopBand = tnsMaxBandsShortMainLow[pC->sampRateIdx];
+ tC->lpcStopBand = tnsMaxBandsShortMainLow[pC->sampRateIdx];
tC->lpcStopBand = min(tC->lpcStopBand, pC->sfbActive);
tC->lpcStopLine = pC->sfbOffset[tC->lpcStopBand];
- tC->lpcStartBand = tnsMinBandNumberShort[pC->sampRateIdx];
+ tC->lpcStartBand = tnsMinBandNumberShort[pC->sampRateIdx];
tC->lpcStartLine = pC->sfbOffset[tC->lpcStartBand];
@@ -399,12 +399,12 @@ Word16 TnsEncode(TNS_INFO* tnsInfo, /*!< tns info structure (modified) */
{
Word32 i;
Word32 temp_s;
- Word32 temp;
+ Word32 temp;
TNS_SUBBLOCK_INFO *psubBlockInfo;
temp_s = blockType - SHORT_WINDOW;
if ( temp_s != 0) {
- psubBlockInfo = &tnsData->dataRaw.tnsLong.subBlockInfo;
+ psubBlockInfo = &tnsData->dataRaw.tnsLong.subBlockInfo;
if (psubBlockInfo->tnsActive == 0) {
tnsInfo->tnsActive[subBlockNumber] = 0;
return(0);
@@ -449,7 +449,7 @@ Word16 TnsEncode(TNS_INFO* tnsInfo, /*!< tns info structure (modified) */
}
} /* if (blockType!=SHORT_WINDOW) */
else /*short block*/ {
- psubBlockInfo = &tnsData->dataRaw.tnsShort.subBlockInfo[subBlockNumber];
+ psubBlockInfo = &tnsData->dataRaw.tnsShort.subBlockInfo[subBlockNumber];
if (psubBlockInfo->tnsActive == 0) {
tnsInfo->tnsActive[subBlockNumber] = 0;
return(0);
@@ -556,9 +556,9 @@ static void CalcWeightedSpectrum(const Word32 spectrum[], /*!< input sp
tmp2 = sfbEnergy[sfb] - 2;
if( tmp2 > 0) {
tmp = rsqrt(sfbEnergy[sfb], INT_BITS);
- if(tmp > INT_BITS_SCAL)
- {
- shift = norm_l(tmp);
+ if(tmp > INT_BITS_SCAL)
+ {
+ shift = norm_l(tmp);
tmp = Div_32( INT_BITS_SCAL << shift, tmp << shift );
}
else
@@ -601,20 +601,20 @@ static void CalcWeightedSpectrum(const Word32 spectrum[], /*!< input sp
maxWS |= L_abs(pWork32[i]);
}
maxShift = norm_l(maxWS);
-
- maxShift = 16 - maxShift;
- if(maxShift >= 0)
- {
- for (i=lpcStartLine; i<lpcStopLine; i++){
- weightedSpectrum[i] = pWork32[i] >> maxShift;
- }
- }
- else
- {
- maxShift = -maxShift;
- for (i=lpcStartLine; i<lpcStopLine; i++){
- weightedSpectrum[i] = saturate(pWork32[i] << maxShift);
- }
+
+ maxShift = 16 - maxShift;
+ if(maxShift >= 0)
+ {
+ for (i=lpcStartLine; i<lpcStopLine; i++){
+ weightedSpectrum[i] = pWork32[i] >> maxShift;
+ }
+ }
+ else
+ {
+ maxShift = -maxShift;
+ for (i=lpcStartLine; i<lpcStopLine; i++){
+ weightedSpectrum[i] = saturate(pWork32[i] << maxShift);
+ }
}
}
@@ -669,7 +669,7 @@ static Word16 CalcTnsFilter(const Word16 *signal,
* output: acf values
*
*****************************************************************************/
-#ifndef ARMV5E
+#ifndef ARMV5E
void AutoCorrelation(const Word16 input[],
Word32 corr[],
Word16 samples,
@@ -679,12 +679,12 @@ void AutoCorrelation(const Word16 input[],
Word32 scf;
scf = 10 - 1;
-
+
isamples = samples;
/* calc first corrCoef: R[0] = sum { t[i] * t[i] } ; i = 0..N-1 */
accu = 0;
for(j=0; j<isamples; j++) {
- accu = L_add(accu, ((input[j] * input[j]) >> scf));
+ accu = L_add(accu, ((input[j] * input[j]) >> scf));
}
corr[0] = accu;
@@ -696,7 +696,7 @@ void AutoCorrelation(const Word16 input[],
isamples = isamples - 1;
accu = 0;
for(j=0; j<isamples; j++) {
- accu = L_add(accu, ((input[j] * input[j+i]) >> scf));
+ accu = L_add(accu, ((input[j] * input[j+i]) >> scf));
}
corr[i] = accu;
}
@@ -737,7 +737,7 @@ static Word16 AutoToParcor(Word32 workBuffer[], Word32 reflCoeff[], Word16 numOf
if (workBuffer[0] < L_abs(workBuffer[i + numOfCoeff])) {
return 0 ;
}
- shift = norm_l(workBuffer[0]);
+ shift = norm_l(workBuffer[0]);
workBuffer0 = Div_32(1 << shift, workBuffer[0] << shift);
/* calculate refc = -workBuffer[numOfCoeff+i] / workBuffer[0]; -1 <= refc < 1 */
refc = L_negate(fixmul(workBuffer[numOfCoeff + i], workBuffer0));
@@ -758,8 +758,8 @@ static Word16 AutoToParcor(Word32 workBuffer[], Word32 reflCoeff[], Word16 numOf
denom = MULHIGH(workBuffer[0], NORM_COEF);
if (denom != 0) {
- Word32 temp;
- shift = norm_l(denom);
+ Word32 temp;
+ shift = norm_l(denom);
temp = Div_32(1 << shift, denom << shift);
predictionGain = fixmul(num, temp);
}