summaryrefslogtreecommitdiffstats
path: root/libAACdec/src/conceal.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2013-11-01 10:46:40 +0200
committerMartin Storsjo <martin@martin.st>2013-11-01 10:46:40 +0200
commit321233ee92e138f44294c7bb9a375eadad9d24fa (patch)
tree1de928ad26325302f64c56603157f50095dcf2b1 /libAACdec/src/conceal.cpp
parentfcb5f1b692cb8343de35e69f9084328c652cf690 (diff)
parentfa3eba16446cc8f2f5e2dfc20d86a49dbd37299e (diff)
downloadODR-AudioEnc-321233ee92e138f44294c7bb9a375eadad9d24fa.tar.gz
ODR-AudioEnc-321233ee92e138f44294c7bb9a375eadad9d24fa.tar.bz2
ODR-AudioEnc-321233ee92e138f44294c7bb9a375eadad9d24fa.zip
Merge remote-tracking branch 'aosp/kitkat-release' into kitkat-merge
Conflicts: libAACenc/src/quantize.cpp
Diffstat (limited to 'libAACdec/src/conceal.cpp')
-rw-r--r--libAACdec/src/conceal.cpp104
1 files changed, 72 insertions, 32 deletions
diff --git a/libAACdec/src/conceal.cpp b/libAACdec/src/conceal.cpp
index dc5d99f..c26051c 100644
--- a/libAACdec/src/conceal.cpp
+++ b/libAACdec/src/conceal.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -441,7 +441,7 @@ AAC_DECODER_ERROR
/* set confort noise level which will be inserted while in state 'muting' */
if (comfNoiseLevel != AACDEC_CONCEAL_PARAM_NOT_SPECIFIED) {
- if ( (comfNoiseLevel < 0)
+ if ( (comfNoiseLevel < -1)
|| (comfNoiseLevel > 127) ) {
return AAC_DEC_SET_PARAM_FAIL;
}
@@ -1527,8 +1527,13 @@ static void
{
case ConcealState_Ok:
if (!frameOk) {
- /* change to state SINGLE-FRAME-LOSS */
- pConcealmentInfo->concealState = ConcealState_Single;
+ if (pConcealCommonData->numFadeOutFrames > 0) {
+ /* change to state SINGLE-FRAME-LOSS */
+ pConcealmentInfo->concealState = ConcealState_Single;
+ } else {
+ /* change to state MUTE */
+ pConcealmentInfo->concealState = ConcealState_Mute;
+ }
pConcealmentInfo->cntFadeFrames = 0;
pConcealmentInfo->cntValidFrames = 0;
}
@@ -1561,11 +1566,16 @@ static void
case ConcealState_FadeOut:
pConcealmentInfo->cntFadeFrames += 1; /* used to address the fade-out factors */
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
- /* change to state FADE-IN */
- pConcealmentInfo->concealState = ConcealState_FadeIn;
- pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
- pConcealmentInfo->cntFadeFrames-1,
- 0 /* FadeOut -> FadeIn */);
+ if (pConcealCommonData->numFadeInFrames > 0) {
+ /* change to state FADE-IN */
+ pConcealmentInfo->concealState = ConcealState_FadeIn;
+ pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
+ pConcealmentInfo->cntFadeFrames-1,
+ 0 /* FadeOut -> FadeIn */);
+ } else {
+ /* change to state OK */
+ pConcealmentInfo->concealState = ConcealState_Ok;
+ }
} else {
if (pConcealmentInfo->cntFadeFrames >= pConcealCommonData->numFadeOutFrames) {
/* change to state MUTE */
@@ -1576,9 +1586,14 @@ static void
case ConcealState_Mute:
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
- /* change to state FADE-IN */
- pConcealmentInfo->concealState = ConcealState_FadeIn;
- pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1;
+ if (pConcealCommonData->numFadeInFrames > 0) {
+ /* change to state FADE-IN */
+ pConcealmentInfo->concealState = ConcealState_FadeIn;
+ pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1;
+ } else {
+ /* change to state OK */
+ pConcealmentInfo->concealState = ConcealState_Ok;
+ }
}
break;
@@ -1590,11 +1605,16 @@ static void
pConcealmentInfo->concealState = ConcealState_Ok;
}
} else {
- /* change to state FADE-OUT */
- pConcealmentInfo->concealState = ConcealState_FadeOut;
- pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
- pConcealmentInfo->cntFadeFrames+1,
- 1 /* FadeIn -> FadeOut */);
+ if (pConcealCommonData->numFadeOutFrames > 0) {
+ /* change to state FADE-OUT */
+ pConcealmentInfo->concealState = ConcealState_FadeOut;
+ pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
+ pConcealmentInfo->cntFadeFrames+1,
+ 1 /* FadeIn -> FadeOut */);
+ } else {
+ /* change to state MUTE */
+ pConcealmentInfo->concealState = ConcealState_Mute;
+ }
}
break;
@@ -1625,8 +1645,13 @@ static void
case ConcealState_Ok:
if (!(pConcealmentInfo->prevFrameOk[1] ||
(pConcealmentInfo->prevFrameOk[0] && !pConcealmentInfo->prevFrameOk[1] && frameOk))) {
- /* Fade out only if the energy interpolation algorithm can not be applied! */
- pConcealmentInfo->concealState = ConcealState_FadeOut;
+ if (pConcealCommonData->numFadeOutFrames > 0) {
+ /* Fade out only if the energy interpolation algorithm can not be applied! */
+ pConcealmentInfo->concealState = ConcealState_FadeOut;
+ } else {
+ /* change to state MUTE */
+ pConcealmentInfo->concealState = ConcealState_Mute;
+ }
pConcealmentInfo->cntFadeFrames = 0;
pConcealmentInfo->cntValidFrames = 0;
}
@@ -1640,11 +1665,16 @@ static void
pConcealmentInfo->cntFadeFrames += 1;
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
- /* change to state FADE-IN */
- pConcealmentInfo->concealState = ConcealState_FadeIn;
- pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
- pConcealmentInfo->cntFadeFrames-1,
- 0 /* FadeOut -> FadeIn */);
+ if (pConcealCommonData->numFadeInFrames > 0) {
+ /* change to state FADE-IN */
+ pConcealmentInfo->concealState = ConcealState_FadeIn;
+ pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
+ pConcealmentInfo->cntFadeFrames-1,
+ 0 /* FadeOut -> FadeIn */);
+ } else {
+ /* change to state OK */
+ pConcealmentInfo->concealState = ConcealState_Ok;
+ }
} else {
if (pConcealmentInfo->cntFadeFrames >= pConcealCommonData->numFadeOutFrames) {
/* change to state MUTE */
@@ -1655,9 +1685,14 @@ static void
case ConcealState_Mute:
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
- /* change to state FADE-IN */
- pConcealmentInfo->concealState = ConcealState_FadeIn;
- pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1;
+ if (pConcealCommonData->numFadeInFrames > 0) {
+ /* change to state FADE-IN */
+ pConcealmentInfo->concealState = ConcealState_FadeIn;
+ pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1;
+ } else {
+ /* change to state OK */
+ pConcealmentInfo->concealState = ConcealState_Ok;
+ }
}
break;
@@ -1670,11 +1705,16 @@ static void
pConcealmentInfo->concealState = ConcealState_Ok;
}
} else {
- /* change to state FADE-OUT */
- pConcealmentInfo->concealState = ConcealState_FadeOut;
- pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
- pConcealmentInfo->cntFadeFrames+1,
- 1 /* FadeIn -> FadeOut */);
+ if (pConcealCommonData->numFadeOutFrames > 0) {
+ /* change to state FADE-OUT */
+ pConcealmentInfo->concealState = ConcealState_FadeOut;
+ pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
+ pConcealmentInfo->cntFadeFrames+1,
+ 1 /* FadeIn -> FadeOut */);
+ } else {
+ /* change to state MUTE */
+ pConcealmentInfo->concealState = ConcealState_Mute;
+ }
}
break;
} /* End switch(pConcealmentInfo->concealState) */