summaryrefslogtreecommitdiffstats
path: root/libAACdec/src/conceal.cpp
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2013-08-27 16:28:09 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2013-08-27 16:28:09 -0700
commit5016eb7f6582fbb2d72d79be782325a12df08864 (patch)
treebc2325ebc6840a20d25f35a0c5a6a13454d2e402 /libAACdec/src/conceal.cpp
parentb9774f90651be61065ae40171fc321f6ced60e49 (diff)
downloadfdk-aac-5016eb7f6582fbb2d72d79be782325a12df08864.tar.gz
fdk-aac-5016eb7f6582fbb2d72d79be782325a12df08864.tar.bz2
fdk-aac-5016eb7f6582fbb2d72d79be782325a12df08864.zip
Decoder stability, sanity checks improvements
* AAC-Decoder - Improved PCE handling for saver (re-)configuration and metadata processing. Modified file(s): libAACdec/src/aacdecoder.cpp libAACdec/src/aacdecoder_lib.cpp - Transport layer changes (config found) -> to be evaluated. Modified file(s): libMpegTPDec/include/tpdec_lib.h libMpegTPDec/src/tpdec_latm.h libMpegTPDec/src/version libMpegTPDec/src/tpdec_asc.cpp libMpegTPDec/src/tpdec_lib.cpp libMpegTPDec/src/tpdec_adts.cpp libMpegTPDec/src/tpdec_latm.cpp libSYS/include/FDK_audio.h libSYS/src/genericStds.cpp - Enable concealment state machine to skip states if the corresponding parameter is set to zero. Modified file(s): libAACdec/src/conceal.cpp - Add some more sanity checks to avoid segmentation faults especially when setting dynamic API params. Modified file(s): libAACdec/src/aacdecoder_lib.cpp - Fix to do a fail-safe initialization of IMDCT for all channels even with corrupt streams. Modified file(s): libAACdec/src/aacdecoder.cpp - HCR decoder fix (remove warnings). Modified file(s): libAACdec/src/block.cpp - Fix border calculation in SBR decoder's LPP transposer patch determination. Modified file(s): libSBRdec/src/env_dec.cpp libSBRdec/src/sbrdecoder.cpp libSBRdec/src/lpp_tran.cpp Bug 9428126 Change-Id: Ib415b702b88a7ec8e9a55789d79cafb39296d26b
Diffstat (limited to 'libAACdec/src/conceal.cpp')
-rw-r--r--libAACdec/src/conceal.cpp102
1 files changed, 71 insertions, 31 deletions
diff --git a/libAACdec/src/conceal.cpp b/libAACdec/src/conceal.cpp
index 733b959..c26051c 100644
--- a/libAACdec/src/conceal.cpp
+++ b/libAACdec/src/conceal.cpp
@@ -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) */