summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/aacenc/src/block_switch.c
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/codecs/aacenc/src/block_switch.c')
-rw-r--r--media/libstagefright/codecs/aacenc/src/block_switch.c146
1 files changed, 73 insertions, 73 deletions
diff --git a/media/libstagefright/codecs/aacenc/src/block_switch.c b/media/libstagefright/codecs/aacenc/src/block_switch.c
index d54e32f..47fd15e 100644
--- a/media/libstagefright/codecs/aacenc/src/block_switch.c
+++ b/media/libstagefright/codecs/aacenc/src/block_switch.c
@@ -52,7 +52,7 @@ CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
IIR high pass coeffs
*/
Word32 hiPassCoeff[BLOCK_SWITCHING_IIR_LEN] = {
- 0xbec8b439, 0x609d4952 /* -0.5095f, 0.7548f */
+ 0xbec8b439, 0x609d4952 /* -0.5095f, 0.7548f */
};
static const Word32 accWindowNrgFac = 0x26666666; /* factor for accumulating filtered window energies 0.3 */
@@ -76,8 +76,8 @@ Word16 InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
const Word32 bitRate, const Word16 nChannels)
{
/* select attackRatio */
-
- if ((sub(nChannels,1)==0 && L_sub(bitRate, 24000) > 0) ||
+
+ if ((sub(nChannels,1)==0 && L_sub(bitRate, 24000) > 0) ||
(sub(nChannels,1)>0 && bitRate > (nChannels * 16000))) {
blockSwitchingControl->invAttackRatio = invAttackRatioHighBr;
}
@@ -116,7 +116,7 @@ Word16 BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
/* Reset grouping info */
for (i=0; i<TRANS_FAC; i++) {
- blockSwitchingControl->groupLen[i] = 0;
+ blockSwitchingControl->groupLen[i] = 0;
}
@@ -125,21 +125,21 @@ Word16 BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
&blockSwitchingControl->attackIndex,
BLOCK_SWITCH_WINDOWS);
- blockSwitchingControl->attackIndex = blockSwitchingControl->lastAttackIndex;
+ blockSwitchingControl->attackIndex = blockSwitchingControl->lastAttackIndex;
/* Set grouping info */
- blockSwitchingControl->noOfGroups = MAX_NO_OF_GROUPS;
+ blockSwitchingControl->noOfGroups = MAX_NO_OF_GROUPS;
for (i=0; i<MAX_NO_OF_GROUPS; i++) {
- blockSwitchingControl->groupLen[i] = suggestedGroupingTable[blockSwitchingControl->attackIndex][i];
+ blockSwitchingControl->groupLen[i] = suggestedGroupingTable[blockSwitchingControl->attackIndex][i];
}
-
+
/* if the samplerate is less than 16000, it should be all the short block, avoid pre&post echo */
if(sampleRate >= 16000) {
/* Save current window energy as last window energy */
for (w=0; w<BLOCK_SWITCH_WINDOWS; w++) {
- blockSwitchingControl->windowNrg[0][w] = blockSwitchingControl->windowNrg[1][w];
- blockSwitchingControl->windowNrgF[0][w] = blockSwitchingControl->windowNrgF[1][w];
+ blockSwitchingControl->windowNrg[0][w] = blockSwitchingControl->windowNrg[1][w];
+ blockSwitchingControl->windowNrgF[0][w] = blockSwitchingControl->windowNrgF[1][w];
}
@@ -147,10 +147,10 @@ Word16 BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
CalcWindowEnergy(blockSwitchingControl, timeSignal, chIncrement, BLOCK_SWITCH_WINDOW_LEN);
/* reset attack */
- blockSwitchingControl->attack = FALSE;
+ blockSwitchingControl->attack = FALSE;
- enMax = 0;
- enM1 = blockSwitchingControl->windowNrgF[0][BLOCK_SWITCH_WINDOWS-1];
+ enMax = 0;
+ enM1 = blockSwitchingControl->windowNrgF[0][BLOCK_SWITCH_WINDOWS-1];
for (w=0; w<BLOCK_SWITCH_WINDOWS; w++) {
Word32 enM1_Tmp, accWindowNrg_Tmp, windowNrgF_Tmp;
@@ -172,15 +172,15 @@ Word16 BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
/* if the energy with the ratio is bigger than the average, and the attack and short block */
if ((fixmul(windowNrgF_Tmp, blockSwitchingControl->invAttackRatio) >> windowNrgF_Shf) >
blockSwitchingControl->accWindowNrg ) {
- blockSwitchingControl->attack = TRUE;
- blockSwitchingControl->lastAttackIndex = w;
+ blockSwitchingControl->attack = TRUE;
+ blockSwitchingControl->lastAttackIndex = w;
}
- enM1 = blockSwitchingControl->windowNrgF[1][w];
+ enM1 = blockSwitchingControl->windowNrgF[1][w];
enMax = max(enMax, enM1);
}
if (enMax < minAttackNrg) {
- blockSwitchingControl->attack = FALSE;
+ blockSwitchingControl->attack = FALSE;
}
}
else
@@ -188,22 +188,22 @@ Word16 BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
blockSwitchingControl->attack = TRUE;
}
- /* Check if attack spreads over frame border */
+ /* Check if attack spreads over frame border */
if ((!blockSwitchingControl->attack) && (blockSwitchingControl->lastattack)) {
-
+
if (blockSwitchingControl->attackIndex == TRANS_FAC-1) {
- blockSwitchingControl->attack = TRUE;
+ blockSwitchingControl->attack = TRUE;
}
- blockSwitchingControl->lastattack = FALSE;
+ blockSwitchingControl->lastattack = FALSE;
}
else {
- blockSwitchingControl->lastattack = blockSwitchingControl->attack;
+ blockSwitchingControl->lastattack = blockSwitchingControl->attack;
}
- blockSwitchingControl->windowSequence = blockSwitchingControl->nextwindowSequence;
+ blockSwitchingControl->windowSequence = blockSwitchingControl->nextwindowSequence;
+
-
if (blockSwitchingControl->attack) {
blockSwitchingControl->nextwindowSequence = SHORT_WINDOW;
}
@@ -211,27 +211,27 @@ Word16 BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
blockSwitchingControl->nextwindowSequence = LONG_WINDOW;
}
- /* update short block group */
+ /* update short block group */
if (blockSwitchingControl->nextwindowSequence == SHORT_WINDOW) {
-
+
if (blockSwitchingControl->windowSequence== LONG_WINDOW) {
- blockSwitchingControl->windowSequence = START_WINDOW;
+ blockSwitchingControl->windowSequence = START_WINDOW;
}
-
+
if (blockSwitchingControl->windowSequence == STOP_WINDOW) {
- blockSwitchingControl->windowSequence = SHORT_WINDOW;
- blockSwitchingControl->noOfGroups = 3;
- blockSwitchingControl->groupLen[0] = 3;
- blockSwitchingControl->groupLen[1] = 3;
- blockSwitchingControl->groupLen[2] = 2;
+ blockSwitchingControl->windowSequence = SHORT_WINDOW;
+ blockSwitchingControl->noOfGroups = 3;
+ blockSwitchingControl->groupLen[0] = 3;
+ blockSwitchingControl->groupLen[1] = 3;
+ blockSwitchingControl->groupLen[2] = 2;
}
}
- /* update block type */
+ /* update block type */
if (blockSwitchingControl->nextwindowSequence == LONG_WINDOW) {
-
+
if (blockSwitchingControl->windowSequence == SHORT_WINDOW) {
- blockSwitchingControl->nextwindowSequence = STOP_WINDOW;
+ blockSwitchingControl->nextwindowSequence = STOP_WINDOW;
}
}
@@ -252,17 +252,17 @@ static Word32 SrchMaxWithIndex(const Word32 in[], Word16 *index, Word16 n)
Word32 i, idx;
/* Search maximum value in array and return index and value */
- max = 0;
- idx = 0;
+ max = 0;
+ idx = 0;
for (i = 0; i < n; i++) {
-
+
if (in[i+1] > max) {
- max = in[i+1];
- idx = i;
+ max = in[i+1];
+ idx = i;
}
}
- *index = idx;
+ *index = idx;
return(max);
}
@@ -292,11 +292,11 @@ Word32 CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
states1 = blockSwitchingControl->iirStates[1];
Coeff0 = hiPassCoeff[0];
Coeff1 = hiPassCoeff[1];
- tidx = 0;
+ tidx = 0;
for (w=0; w < BLOCK_SWITCH_WINDOWS; w++) {
- accuUE = 0;
- accuFE = 0;
+ accuUE = 0;
+ accuFE = 0;
for(i=0; i<windowLen; i++) {
Word32 accu1, accu2, accu3;
@@ -309,16 +309,16 @@ Word32 CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
accu3 = accu1 - states0;
out = accu3 - accu2;
- states0 = accu1;
- states1 = out;
+ states0 = accu1;
+ states1 = out;
- tempFiltered = extract_h(out);
+ tempFiltered = extract_h(out);
accuUE += (tempUnfiltered * tempUnfiltered) >> ENERGY_SHIFT;
accuFE += (tempFiltered * tempFiltered) >> ENERGY_SHIFT;
}
- blockSwitchingControl->windowNrg[1][w] = accuUE;
- blockSwitchingControl->windowNrgF[1][w] = accuFE;
+ blockSwitchingControl->windowNrg[1][w] = accuUE;
+ blockSwitchingControl->windowNrgF[1][w] = accuFE;
}
@@ -346,8 +346,8 @@ static Word16 IIRFilter(const Word16 in, const Word32 coeff[], Word32 states[])
accu2 = fixmul( coeff[0], states[1] );
out = accu3 - accu2;
- states[0] = accu1;
- states[1] = out;
+ states[0] = accu1;
+ states[1] = out;
return round16(out);
}
@@ -374,54 +374,54 @@ Word16 SyncBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft,
const Word16 nChannels)
{
Word16 i;
- Word16 patchType = LONG_WINDOW;
+ Word16 patchType = LONG_WINDOW;
+
-
if (nChannels == 1) { /* Mono */
if (blockSwitchingControlLeft->windowSequence != SHORT_WINDOW) {
- blockSwitchingControlLeft->noOfGroups = 1;
- blockSwitchingControlLeft->groupLen[0] = 1;
+ blockSwitchingControlLeft->noOfGroups = 1;
+ blockSwitchingControlLeft->groupLen[0] = 1;
for (i=1; i<TRANS_FAC; i++) {
- blockSwitchingControlLeft->groupLen[i] = 0;
+ blockSwitchingControlLeft->groupLen[i] = 0;
}
}
}
else { /* Stereo common Window */
- patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlLeft->windowSequence];
- patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlRight->windowSequence];
+ patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlLeft->windowSequence];
+ patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlRight->windowSequence];
/* Set synchronized Blocktype */
- blockSwitchingControlLeft->windowSequence = patchType;
- blockSwitchingControlRight->windowSequence = patchType;
+ blockSwitchingControlLeft->windowSequence = patchType;
+ blockSwitchingControlRight->windowSequence = patchType;
- /* Synchronize grouping info */
+ /* Synchronize grouping info */
if(patchType != SHORT_WINDOW) { /* Long Blocks */
/* Set grouping info */
- blockSwitchingControlLeft->noOfGroups = 1;
- blockSwitchingControlRight->noOfGroups = 1;
- blockSwitchingControlLeft->groupLen[0] = 1;
- blockSwitchingControlRight->groupLen[0] = 1;
+ blockSwitchingControlLeft->noOfGroups = 1;
+ blockSwitchingControlRight->noOfGroups = 1;
+ blockSwitchingControlLeft->groupLen[0] = 1;
+ blockSwitchingControlRight->groupLen[0] = 1;
for (i=1; i<TRANS_FAC; i++) {
- blockSwitchingControlLeft->groupLen[i] = 0;
- blockSwitchingControlRight->groupLen[i] = 0;
+ blockSwitchingControlLeft->groupLen[i] = 0;
+ blockSwitchingControlRight->groupLen[i] = 0;
}
}
else {
-
+
if (blockSwitchingControlLeft->maxWindowNrg > blockSwitchingControlRight->maxWindowNrg) {
/* Left Channel wins */
- blockSwitchingControlRight->noOfGroups = blockSwitchingControlLeft->noOfGroups;
+ blockSwitchingControlRight->noOfGroups = blockSwitchingControlLeft->noOfGroups;
for (i=0; i<TRANS_FAC; i++) {
- blockSwitchingControlRight->groupLen[i] = blockSwitchingControlLeft->groupLen[i];
+ blockSwitchingControlRight->groupLen[i] = blockSwitchingControlLeft->groupLen[i];
}
}
else {
/* Right Channel wins */
- blockSwitchingControlLeft->noOfGroups = blockSwitchingControlRight->noOfGroups;
+ blockSwitchingControlLeft->noOfGroups = blockSwitchingControlRight->noOfGroups;
for (i=0; i<TRANS_FAC; i++) {
- blockSwitchingControlLeft->groupLen[i] = blockSwitchingControlRight->groupLen[i];
+ blockSwitchingControlLeft->groupLen[i] = blockSwitchingControlRight->groupLen[i];
}
}
}