diff options
Diffstat (limited to 'media/libstagefright/codecs/aacenc/src/psy_configuration.c')
-rw-r--r-- | media/libstagefright/codecs/aacenc/src/psy_configuration.c | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/media/libstagefright/codecs/aacenc/src/psy_configuration.c b/media/libstagefright/codecs/aacenc/src/psy_configuration.c index 586e00f..8e599b0 100644 --- a/media/libstagefright/codecs/aacenc/src/psy_configuration.c +++ b/media/libstagefright/codecs/aacenc/src/psy_configuration.c @@ -1,26 +1,26 @@ -/*
- ** 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.c
-
- Content: Psychoaccoustic configuration 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: psy_configuration.c + + Content: Psychoaccoustic configuration functions + *******************************************************************************/ -#include "basic_op.h"
+#include "basic_op.h" #include "oper_32b.h" #include "psy_configuration.h" #include "adj_thr.h" @@ -29,10 +29,10 @@ #define BARC_SCALE 100 /* integer barc values are scaled with 100 */ -#define LOG2_1000 301 /* log2*1000 */
-#define PI2_1000 1571 /* pi/2*1000*/
-#define ATAN_COEF1 3560 /* 1000/0.280872f*/
-#define ATAN_COEF2 281 /* 1000*0.280872f*/
+#define LOG2_1000 301 /* log2*1000 */ +#define PI2_1000 1571 /* pi/2*1000*/ +#define ATAN_COEF1 3560 /* 1000/0.280872f*/ +#define ATAN_COEF2 281 /* 1000*0.280872f*/ typedef struct{ @@ -57,30 +57,30 @@ static const Word16 maskLowSprEnLong = 30; /* in 1dB/bark */ static const Word16 maskHighSprEnLong = 20; /* in 1dB/bark */ static const Word16 maskHighSprEnLongLowBr = 15; /* in 1dB/bark */ static const Word16 maskLowSprEnShort = 20; /* in 1dB/bark */ -static const Word16 maskHighSprEnShort = 15; /* in 1dB/bark */
-static const Word16 c_minRemainingThresholdFactor = 0x0148; /* 0.01 *(1 << 15)*/
-static const Word32 c_maxsnr = 0x66666666; /* upper limit is -1 dB */
-static const Word32 c_minsnr = 0x00624dd3; /* lower limit is -25 dB */
-
-static const Word32 c_maxClipEnergyLong = 0x77359400; /* 2.0e9f*/
-static const Word32 c_maxClipEnergyShort = 0x01dcd650; /* 2.0e9f/(AACENC_TRANS_FAC*AACENC_TRANS_FAC)*/
-
-
-Word32 GetSRIndex(Word32 sampleRate)
-{
- if (92017 <= sampleRate) return 0;
- if (75132 <= sampleRate) return 1;
- if (55426 <= sampleRate) return 2;
- if (46009 <= sampleRate) return 3;
- if (37566 <= sampleRate) return 4;
- if (27713 <= sampleRate) return 5;
- if (23004 <= sampleRate) return 6;
- if (18783 <= sampleRate) return 7;
- if (13856 <= sampleRate) return 8;
- if (11502 <= sampleRate) return 9;
- if (9391 <= sampleRate) return 10;
-
- return 11;
+static const Word16 maskHighSprEnShort = 15; /* in 1dB/bark */ +static const Word16 c_minRemainingThresholdFactor = 0x0148; /* 0.01 *(1 << 15)*/ +static const Word32 c_maxsnr = 0x66666666; /* upper limit is -1 dB */ +static const Word32 c_minsnr = 0x00624dd3; /* lower limit is -25 dB */ + +static const Word32 c_maxClipEnergyLong = 0x77359400; /* 2.0e9f*/ +static const Word32 c_maxClipEnergyShort = 0x01dcd650; /* 2.0e9f/(AACENC_TRANS_FAC*AACENC_TRANS_FAC)*/ + + +Word32 GetSRIndex(Word32 sampleRate) +{ + if (92017 <= sampleRate) return 0; + if (75132 <= sampleRate) return 1; + if (55426 <= sampleRate) return 2; + if (46009 <= sampleRate) return 3; + if (37566 <= sampleRate) return 4; + if (27713 <= sampleRate) return 5; + if (23004 <= sampleRate) return 6; + if (18783 <= sampleRate) return 7; + if (13856 <= sampleRate) return 8; + if (11502 <= sampleRate) return 9; + if (9391 <= sampleRate) return 10; + + return 11; } @@ -89,8 +89,8 @@ Word32 GetSRIndex(Word32 sampleRate) * function name: atan_1000 * description: calculates 1000*atan(x/1000) * based on atan approx for x > 0 -* atan(x) = x/((float)1.0f+(float)0.280872f*x*x) if x < 1
-* = pi/2 - x/((float)0.280872f +x*x) if x >= 1
+* atan(x) = x/((float)1.0f+(float)0.280872f*x*x) if x < 1 +* = pi/2 - x/((float)0.280872f +x*x) if x >= 1 * return: 1000*atan(x/1000) * **********************************************************************************/ @@ -272,7 +272,7 @@ static void initBarcValues(Word16 numPb, * * function name: initMinSnr * description: calculate min snr parameter -* minSnr(n) = 1/(2^sfbPemin(n)/w(n) - 1.5)
+* minSnr(n) = 1/(2^sfbPemin(n)/w(n) - 1.5) * *****************************************************************************/ static void initMinSnr(const Word32 bitrate, @@ -303,7 +303,7 @@ static void initMinSnr(const Word32 bitrate, barcWidth = pbVal1 - pbVal0; pbVal0 = pbVal1; - /* allow at least 2.4% of pe for each active barc */
+ /* allow at least 2.4% of pe for each active barc */ pePart = ((pePerWindow * 24) * (max_bark * barcWidth)) / (pbBarcVal[sfbActive-1] * (sfbOffset[sfb+1] - sfbOffset[sfb])); @@ -311,15 +311,15 @@ static void initMinSnr(const Word32 bitrate, pePart = min(pePart, 8400); pePart = max(pePart, 1400); - /* minSnr(n) = 1/(2^sfbPemin(n)/w(n) - 1.5)*/
+ /* minSnr(n) = 1/(2^sfbPemin(n)/w(n) - 1.5)*/ /* we add an offset of 2^16 to the pow functions */ - /* 0xc000 = 1.5*(1 << 15)*/
+ /* 0xc000 = 1.5*(1 << 15)*/ snr = pow2_xy((pePart - 16*1000),1000) - 0x0000c000; - if(snr > 0x00008000)
- {
- shift = norm_l(snr);
+ if(snr > 0x00008000) + { + shift = norm_l(snr); snr = Div_32(0x00008000 << shift, snr << shift); } else @@ -347,16 +347,16 @@ Word16 InitPsyConfigurationLong(Word32 bitrate, Word16 bandwidth, PSY_CONFIGURATION_LONG *psyConf) { - Word32 samplerateindex;
- Word16 sfbBarcVal[MAX_SFB_LONG];
+ Word32 samplerateindex; + Word16 sfbBarcVal[MAX_SFB_LONG]; Word16 sfb; /* init sfb table - */
- samplerateindex = GetSRIndex(samplerate);
- psyConf->sfbCnt = sfBandTotalLong[samplerateindex];
- psyConf->sfbOffset = sfBandTabLong + sfBandTabLongOffset[samplerateindex];
+ */ + samplerateindex = GetSRIndex(samplerate); + psyConf->sfbCnt = sfBandTotalLong[samplerateindex]; + psyConf->sfbOffset = sfBandTabLong + sfBandTabLongOffset[samplerateindex]; psyConf->sampRateIdx = samplerateindex; /* @@ -429,7 +429,7 @@ Word16 InitPsyConfigurationLong(Word32 bitrate, Word16 InitPsyConfigurationShort(Word32 bitrate, Word32 samplerate, Word16 bandwidth, - PSY_CONFIGURATION_SHORT *psyConf)
+ PSY_CONFIGURATION_SHORT *psyConf) { Word32 samplerateindex; Word16 sfbBarcVal[MAX_SFB_SHORT]; @@ -437,8 +437,8 @@ Word16 InitPsyConfigurationShort(Word32 bitrate, /* init sfb table */ - samplerateindex = GetSRIndex(samplerate);
- psyConf->sfbCnt = sfBandTotalShort[samplerateindex];
+ samplerateindex = GetSRIndex(samplerate); + psyConf->sfbCnt = sfBandTotalShort[samplerateindex]; psyConf->sfbOffset = sfBandTabShort + sfBandTabShortOffset[samplerateindex]; psyConf->sampRateIdx = samplerateindex; /* |