Commit 5016eb7f authored by Jean-Michel Trivi's avatar Jean-Michel Trivi

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
parent b9774f90
...@@ -394,18 +394,21 @@ static AAC_DECODER_ERROR CDataStreamElement_Read ( ...@@ -394,18 +394,21 @@ static AAC_DECODER_ERROR CDataStreamElement_Read (
\brief Read Program Config Element \brief Read Program Config Element
\bs Bitstream Handle \bs Bitstream Handle
\count Pointer to program config element. \pTp Transport decoder handle for CRC handling
\pce Pointer to PCE buffer
\channelConfig Current channel configuration
\alignAnchor Anchor for byte alignment
\return Error code \return PCE status (-1: fail, 0: no new PCE, 1: PCE updated, 2: PCE updated need re-config).
*/ */
static AAC_DECODER_ERROR CProgramConfigElement_Read ( static int CProgramConfigElement_Read (
HANDLE_FDK_BITSTREAM bs, HANDLE_FDK_BITSTREAM bs,
HANDLE_TRANSPORTDEC pTp, HANDLE_TRANSPORTDEC pTp,
CProgramConfig *pce, CProgramConfig *pce,
UINT channelConfig, const UINT channelConfig,
UINT alignAnchor ) const UINT alignAnchor )
{ {
AAC_DECODER_ERROR error = AAC_DEC_OK; int pceStatus = 0;
int crcReg; int crcReg;
/* read PCE to temporal buffer first */ /* read PCE to temporal buffer first */
...@@ -421,22 +424,43 @@ static AAC_DECODER_ERROR CProgramConfigElement_Read ( ...@@ -421,22 +424,43 @@ static AAC_DECODER_ERROR CProgramConfigElement_Read (
transportDec_CrcEndReg(pTp, crcReg); transportDec_CrcEndReg(pTp, crcReg);
if ( CProgramConfig_IsValid(tmpPce) if ( CProgramConfig_IsValid(tmpPce)
&& ( (channelConfig == 6 && (tmpPce->NumChannels == 6))
|| (channelConfig == 5 && (tmpPce->NumChannels == 5))
|| (channelConfig == 0 && (tmpPce->NumChannels == pce->NumChannels)) )
&& (tmpPce->NumFrontChannelElements == 2)
&& (tmpPce->NumSideChannelElements == 0)
&& (tmpPce->NumBackChannelElements == 1)
&& (tmpPce->Profile == 1) ) && (tmpPce->Profile == 1) )
{ /* Copy the complete PCE including metadata. */ {
FDKmemcpy(pce, tmpPce, sizeof(CProgramConfig)); if ( !pce->isValid && (channelConfig > 0) ) {
/* Create a standard channel config PCE to compare with */
CProgramConfig_GetDefault( pce, channelConfig );
}
if (pce->isValid) {
/* Compare the new and the old PCE (tags ignored) */
switch ( CProgramConfig_Compare( pce, tmpPce ) )
{
case 1: /* Channel configuration not changed. Just new metadata. */
FDKmemcpy(pce, tmpPce, sizeof(CProgramConfig)); /* Store the complete PCE */
pceStatus = 1; /* New PCE but no change of config */
break;
case 2: /* The number of channels are identical but not the config */
if (channelConfig == 0) {
FDKmemcpy(pce, tmpPce, sizeof(CProgramConfig)); /* Store the complete PCE */
pceStatus = 2; /* Decoder needs re-configuration */
}
break;
case -1: /* The channel configuration is completely different */
pceStatus = -1; /* Not supported! */
break;
case 0: /* Nothing to do because PCE matches the old one exactly. */
default:
/* pceStatus = 0; */
break;
}
}
} }
C_ALLOC_SCRATCH_END(tmpPce, CProgramConfig, 1); C_ALLOC_SCRATCH_END(tmpPce, CProgramConfig, 1);
return error; return pceStatus;
} }
#endif #endif /* TP_PCE_ENABLE */
/*! /*!
\brief Parse Extension Payload \brief Parse Extension Payload
...@@ -609,9 +633,7 @@ AAC_DECODER_ERROR CAacDecoder_ExtPayloadParse (HANDLE_AACDECODER self, ...@@ -609,9 +633,7 @@ AAC_DECODER_ERROR CAacDecoder_ExtPayloadParse (HANDLE_AACDECODER self,
/* Check NOTE 2: The extension_payload() included here must /* Check NOTE 2: The extension_payload() included here must
not have extension_type == EXT_DATA_LENGTH. */ not have extension_type == EXT_DATA_LENGTH. */
error = AAC_DEC_PARSE_ERROR; error = AAC_DEC_PARSE_ERROR;
goto bail; } else {
}
else {
/* rewind and call myself again. */ /* rewind and call myself again. */
FDKpushBack(hBs, 4); FDKpushBack(hBs, 4);
...@@ -622,7 +644,7 @@ AAC_DECODER_ERROR CAacDecoder_ExtPayloadParse (HANDLE_AACDECODER self, ...@@ -622,7 +644,7 @@ AAC_DECODER_ERROR CAacDecoder_ExtPayloadParse (HANDLE_AACDECODER self,
&bitCnt, &bitCnt,
previous_element, previous_element,
elIndex, elIndex,
1 ); /* Treat same as fill element */ 0 );
*count -= len - bitCnt; *count -= len - bitCnt;
} }
...@@ -754,9 +776,13 @@ LINKSPEC_CPP void CAacDecoder_Close(HANDLE_AACDECODER self) ...@@ -754,9 +776,13 @@ LINKSPEC_CPP void CAacDecoder_Close(HANDLE_AACDECODER self)
for (ch=0; ch<(6); ch++) { for (ch=0; ch<(6); ch++) {
if (self->pAacDecoderStaticChannelInfo[ch] != NULL) { if (self->pAacDecoderStaticChannelInfo[ch] != NULL) {
if (self->pAacDecoderStaticChannelInfo[ch]->pOverlapBuffer != NULL) {
FreeOverlapBuffer (&self->pAacDecoderStaticChannelInfo[ch]->pOverlapBuffer); FreeOverlapBuffer (&self->pAacDecoderStaticChannelInfo[ch]->pOverlapBuffer);
}
if (self->pAacDecoderStaticChannelInfo[ch] != NULL) {
FreeAacDecoderStaticChannelInfo (&self->pAacDecoderStaticChannelInfo[ch]); FreeAacDecoderStaticChannelInfo (&self->pAacDecoderStaticChannelInfo[ch]);
} }
}
if (self->pAacDecoderChannelInfo[ch] != NULL) { if (self->pAacDecoderChannelInfo[ch] != NULL) {
FreeAacDecoderChannelInfo (&self->pAacDecoderChannelInfo[ch]); FreeAacDecoderChannelInfo (&self->pAacDecoderChannelInfo[ch]);
} }
...@@ -768,8 +794,12 @@ LINKSPEC_CPP void CAacDecoder_Close(HANDLE_AACDECODER self) ...@@ -768,8 +794,12 @@ LINKSPEC_CPP void CAacDecoder_Close(HANDLE_AACDECODER self)
FreeDrcInfo(&self->hDrcInfo); FreeDrcInfo(&self->hDrcInfo);
} }
if (self->aacCommonData.workBufferCore1 != NULL) {
FreeWorkBufferCore1 (&self->aacCommonData.workBufferCore1); FreeWorkBufferCore1 (&self->aacCommonData.workBufferCore1);
}
if (self->aacCommonData.workBufferCore2 != NULL) {
FreeWorkBufferCore2 (&self->aacCommonData.workBufferCore2); FreeWorkBufferCore2 (&self->aacCommonData.workBufferCore2);
}
FreeAacDecoder ( &self); FreeAacDecoder ( &self);
} }
...@@ -994,12 +1024,14 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self, const CS ...@@ -994,12 +1024,14 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self, const CS
CPns_InitPns(&self->pAacDecoderChannelInfo[ch]->data.aac.PnsData, &self->aacCommonData.pnsInterChannelData, &self->aacCommonData.pnsCurrentSeed, self->aacCommonData.pnsRandomSeed); CPns_InitPns(&self->pAacDecoderChannelInfo[ch]->data.aac.PnsData, &self->aacCommonData.pnsInterChannelData, &self->aacCommonData.pnsCurrentSeed, self->aacCommonData.pnsRandomSeed);
} }
if (ascChannels > self->aacChannels)
{
/* Make allocated channel count persistent in decoder context. */
self->aacChannels = ascChannels;
}
HcrInitRom(&self->aacCommonData.overlay.aac.erHcrInfo); HcrInitRom(&self->aacCommonData.overlay.aac.erHcrInfo);
setHcrType(&self->aacCommonData.overlay.aac.erHcrInfo, ID_SCE); setHcrType(&self->aacCommonData.overlay.aac.erHcrInfo, ID_SCE);
/* Make allocated channel count persistent in decoder context. */
self->aacChannels = ascChannels;
} }
/* Make amount of signalled channels persistent in decoder context. */ /* Make amount of signalled channels persistent in decoder context. */
...@@ -1009,8 +1041,10 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self, const CS ...@@ -1009,8 +1041,10 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self, const CS
/* Update structures */ /* Update structures */
if (ascChanged) { if (ascChanged) {
/* Things to be done for each channel, which do not involved allocating memory. */ /* Things to be done for each channel, which do not involve allocating memory.
for (ch = 0; ch < ascChannels; ch++) { Doing these things only on the channels needed for the current configuration
(ascChannels) could lead to memory access violation later (error concealment). */
for (ch = 0; ch < self->aacChannels; ch++) {
switch (self->streamInfo.aot) { switch (self->streamInfo.aot) {
case AOT_ER_AAC_ELD: case AOT_ER_AAC_ELD:
case AOT_ER_AAC_LD: case AOT_ER_AAC_LD:
...@@ -1241,10 +1275,10 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame( ...@@ -1241,10 +1275,10 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
else { else {
self->frameOK = 0; self->frameOK = 0;
} }
/* Create SBR element for SBR for upsampling. */ /* Create SBR element for SBR for upsampling for LFE elements,
if ( (type == ID_LFE) and if SBR was explicitly signaled, because the first frame(s)
&& ( (self->flags & AC_SBR_PRESENT) may not contain SBR payload (broken encoder, bit errors). */
|| (self->sbrEnabled == 1) ) ) if ( (self->flags & AC_SBR_PRESENT) || (self->sbrEnabled == 1) )
{ {
SBR_ERROR sbrError; SBR_ERROR sbrError;
...@@ -1254,7 +1288,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame( ...@@ -1254,7 +1288,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
self->streamInfo.extSamplingRate, self->streamInfo.extSamplingRate,
self->streamInfo.aacSamplesPerFrame, self->streamInfo.aacSamplesPerFrame,
self->streamInfo.aot, self->streamInfo.aot,
ID_LFE, type,
previous_element_index previous_element_index
); );
if (sbrError != SBRDEC_OK) { if (sbrError != SBRDEC_OK) {
...@@ -1394,13 +1428,20 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame( ...@@ -1394,13 +1428,20 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
#ifdef TP_PCE_ENABLE #ifdef TP_PCE_ENABLE
case ID_PCE: case ID_PCE:
{
if ( CProgramConfigElement_Read( bs, int result = CProgramConfigElement_Read(
bs,
self->hInput, self->hInput,
pce, pce,
self->streamInfo.channelConfig, self->streamInfo.channelConfig,
auStartAnchor ) ) auStartAnchor );
{ /* Built element table */ if ( result < 0 ) {
/* Something went wrong */
ErrorStatus = AAC_DEC_PARSE_ERROR;
self->frameOK = 0;
}
else if ( result > 1 ) {
/* Built element table */
int elIdx = CProgramConfig_GetElementTable(pce, self->elements, 7); int elIdx = CProgramConfig_GetElementTable(pce, self->elements, 7);
/* Reset the remaining tabs */ /* Reset the remaining tabs */
for ( ; elIdx<7; elIdx++) { for ( ; elIdx<7; elIdx++) {
...@@ -1413,7 +1454,8 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame( ...@@ -1413,7 +1454,8 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
self->frameOK = 0; self->frameOK = 0;
} }
} }
pceRead = 1; pceRead = (result>=0) ? 1 : 0;
}
break; break;
#endif /* TP_PCE_ENABLE */ #endif /* TP_PCE_ENABLE */
......
...@@ -110,7 +110,7 @@ amm-info@iis.fraunhofer.de ...@@ -110,7 +110,7 @@ amm-info@iis.fraunhofer.de
/* Decoder library info */ /* Decoder library info */
#define AACDECODER_LIB_VL0 2 #define AACDECODER_LIB_VL0 2
#define AACDECODER_LIB_VL1 5 #define AACDECODER_LIB_VL1 5
#define AACDECODER_LIB_VL2 3 #define AACDECODER_LIB_VL2 4
#define AACDECODER_LIB_TITLE "AAC Decoder Lib" #define AACDECODER_LIB_TITLE "AAC Decoder Lib"
#define AACDECODER_LIB_BUILD_DATE __DATE__ #define AACDECODER_LIB_BUILD_DATE __DATE__
#define AACDECODER_LIB_BUILD_TIME __TIME__ #define AACDECODER_LIB_BUILD_TIME __TIME__
...@@ -261,7 +261,7 @@ setConcealMethod ( const HANDLE_AACDECODER self, /*!< Handle of the decoder i ...@@ -261,7 +261,7 @@ setConcealMethod ( const HANDLE_AACDECODER self, /*!< Handle of the decoder i
HANDLE_SBRDECODER hSbrDec = NULL; HANDLE_SBRDECODER hSbrDec = NULL;
HANDLE_AAC_DRC hDrcInfo = NULL; HANDLE_AAC_DRC hDrcInfo = NULL;
HANDLE_PCM_DOWNMIX hPcmDmx = NULL; HANDLE_PCM_DOWNMIX hPcmDmx = NULL;
CConcealmentMethod backupMethod; CConcealmentMethod backupMethod = ConcealMethodNone;
int backupDelay = 0; int backupDelay = 0;
int bsDelay = 0; int bsDelay = 0;
...@@ -396,11 +396,15 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode ...@@ -396,11 +396,15 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode
AAC_DECODER_ERROR errorStatus = AAC_DEC_OK; AAC_DECODER_ERROR errorStatus = AAC_DEC_OK;
CConcealParams *pConcealData = NULL; CConcealParams *pConcealData = NULL;
HANDLE_AAC_DRC hDrcInfo = NULL; HANDLE_AAC_DRC hDrcInfo = NULL;
HANDLE_PCM_DOWNMIX hPcmDmx = NULL;
/* check decoder handle */ /* check decoder handle */
if (self != NULL) { if (self != NULL) {
pConcealData = &self->concealCommonData; pConcealData = &self->concealCommonData;
hDrcInfo = self->hDrcInfo; hDrcInfo = self->hDrcInfo;
hPcmDmx = self->hPcmUtils;
} else {
errorStatus = AAC_DEC_INVALID_HANDLE;
} }
/* configure the subsystems */ /* configure the subsystems */
...@@ -417,11 +421,14 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode ...@@ -417,11 +421,14 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode
break; break;
case AAC_PCM_OUTPUT_CHANNELS: case AAC_PCM_OUTPUT_CHANNELS:
if (value < -1 || value > (6)) {
return AAC_DEC_SET_PARAM_FAIL;
}
{ {
PCMDMX_ERROR err; PCMDMX_ERROR err;
err = pcmDmx_SetParam ( err = pcmDmx_SetParam (
self->hPcmUtils, hPcmDmx,
NUMBER_OF_OUTPUT_CHANNELS, NUMBER_OF_OUTPUT_CHANNELS,
value ); value );
...@@ -441,7 +448,7 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode ...@@ -441,7 +448,7 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode
PCMDMX_ERROR err; PCMDMX_ERROR err;
err = pcmDmx_SetParam ( err = pcmDmx_SetParam (
self->hPcmUtils, hPcmDmx,
DUAL_CHANNEL_DOWNMIX_MODE, DUAL_CHANNEL_DOWNMIX_MODE,
value ); value );
...@@ -459,10 +466,14 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode ...@@ -459,10 +466,14 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode
case AAC_PCM_OUTPUT_CHANNEL_MAPPING: case AAC_PCM_OUTPUT_CHANNEL_MAPPING:
switch (value) { switch (value) {
case 0: case 0:
if (self != NULL) {
self->channelOutputMapping = channelMappingTablePassthrough; self->channelOutputMapping = channelMappingTablePassthrough;
}
break; break;
case 1: case 1:
if (self != NULL) {
self->channelOutputMapping = channelMappingTableWAV; self->channelOutputMapping = channelMappingTableWAV;
}
break; break;
default: default:
errorStatus = AAC_DEC_SET_PARAM_FAIL; errorStatus = AAC_DEC_SET_PARAM_FAIL;
...@@ -472,6 +483,9 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode ...@@ -472,6 +483,9 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode
case AAC_QMF_LOWPOWER: case AAC_QMF_LOWPOWER:
if (value < -1 || value > 1) {
return AAC_DEC_SET_PARAM_FAIL;
}
if (self == NULL) { if (self == NULL) {
return AAC_DEC_INVALID_HANDLE; return AAC_DEC_INVALID_HANDLE;
} }
......
...@@ -589,7 +589,6 @@ AAC_DECODER_ERROR CBlock_ReadSpectralData(HANDLE_FDK_BITSTREAM bs, ...@@ -589,7 +589,6 @@ AAC_DECODER_ERROR CBlock_ReadSpectralData(HANDLE_FDK_BITSTREAM bs,
{ {
H_HCR_INFO hHcr = &pAacDecoderChannelInfo->pComData->overlay.aac.erHcrInfo; H_HCR_INFO hHcr = &pAacDecoderChannelInfo->pComData->overlay.aac.erHcrInfo;
int hcrStatus = 0; int hcrStatus = 0;
int hcrConcealWholeFrame = 0;
/* advanced Huffman decoding starts here (HCR decoding :) */ /* advanced Huffman decoding starts here (HCR decoding :) */
if ( pAacDecoderChannelInfo->pDynData->specificTo.aac.lenOfReorderedSpectralData != 0 ) { if ( pAacDecoderChannelInfo->pDynData->specificTo.aac.lenOfReorderedSpectralData != 0 ) {
...@@ -598,24 +597,19 @@ AAC_DECODER_ERROR CBlock_ReadSpectralData(HANDLE_FDK_BITSTREAM bs, ...@@ -598,24 +597,19 @@ AAC_DECODER_ERROR CBlock_ReadSpectralData(HANDLE_FDK_BITSTREAM bs,
hcrStatus = HcrInit(hHcr, pAacDecoderChannelInfo, pSamplingRateInfo, bs); hcrStatus = HcrInit(hHcr, pAacDecoderChannelInfo, pSamplingRateInfo, bs);
if (hcrStatus != 0) { if (hcrStatus != 0) {
#if HCR_ERROR_CONCEALMENT
hcrConcealWholeFrame = 1;
return AAC_DEC_DECODE_FRAME_ERROR; /* concealment is muting in the first step, therefore return now */
// hcr decoding is not skipped because of returning above
#else
return AAC_DEC_DECODE_FRAME_ERROR; return AAC_DEC_DECODE_FRAME_ERROR;
#endif
} }
/* HCR decoding short */ /* HCR decoding short */
hcrStatus = HcrDecoder(hHcr, pAacDecoderChannelInfo, pSamplingRateInfo, bs); hcrStatus = HcrDecoder(hHcr, pAacDecoderChannelInfo, pSamplingRateInfo, bs);
if (hcrStatus != 0) {
#if HCR_ERROR_CONCEALMENT #if HCR_ERROR_CONCEALMENT
HcrMuteErroneousLines(hHcr); HcrMuteErroneousLines(hHcr);
#else #else
return AAC_DEC_DECODE_FRAME_ERROR; return AAC_DEC_DECODE_FRAME_ERROR;
#endif /* HCR_ERROR_CONCEALMENT */ #endif /* HCR_ERROR_CONCEALMENT */
}
FDKpushFor (bs, pAacDecoderChannelInfo->pDynData->specificTo.aac.lenOfReorderedSpectralData); FDKpushFor (bs, pAacDecoderChannelInfo->pDynData->specificTo.aac.lenOfReorderedSpectralData);
} }
......
...@@ -441,7 +441,7 @@ AAC_DECODER_ERROR ...@@ -441,7 +441,7 @@ AAC_DECODER_ERROR
/* set confort noise level which will be inserted while in state 'muting' */ /* set confort noise level which will be inserted while in state 'muting' */
if (comfNoiseLevel != AACDEC_CONCEAL_PARAM_NOT_SPECIFIED) { if (comfNoiseLevel != AACDEC_CONCEAL_PARAM_NOT_SPECIFIED) {
if ( (comfNoiseLevel < 0) if ( (comfNoiseLevel < -1)
|| (comfNoiseLevel > 127) ) { || (comfNoiseLevel > 127) ) {
return AAC_DEC_SET_PARAM_FAIL; return AAC_DEC_SET_PARAM_FAIL;
} }
...@@ -1527,8 +1527,13 @@ static void ...@@ -1527,8 +1527,13 @@ static void
{ {
case ConcealState_Ok: case ConcealState_Ok:
if (!frameOk) { if (!frameOk) {
if (pConcealCommonData->numFadeOutFrames > 0) {
/* change to state SINGLE-FRAME-LOSS */ /* change to state SINGLE-FRAME-LOSS */
pConcealmentInfo->concealState = ConcealState_Single; pConcealmentInfo->concealState = ConcealState_Single;
} else {
/* change to state MUTE */
pConcealmentInfo->concealState = ConcealState_Mute;
}
pConcealmentInfo->cntFadeFrames = 0; pConcealmentInfo->cntFadeFrames = 0;
pConcealmentInfo->cntValidFrames = 0; pConcealmentInfo->cntValidFrames = 0;
} }
...@@ -1561,11 +1566,16 @@ static void ...@@ -1561,11 +1566,16 @@ static void
case ConcealState_FadeOut: case ConcealState_FadeOut:
pConcealmentInfo->cntFadeFrames += 1; /* used to address the fade-out factors */ pConcealmentInfo->cntFadeFrames += 1; /* used to address the fade-out factors */
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) { if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
if (pConcealCommonData->numFadeInFrames > 0) {
/* change to state FADE-IN */ /* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn; pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData, pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames-1, pConcealmentInfo->cntFadeFrames-1,
0 /* FadeOut -> FadeIn */); 0 /* FadeOut -> FadeIn */);
} else {
/* change to state OK */
pConcealmentInfo->concealState = ConcealState_Ok;
}
} else { } else {
if (pConcealmentInfo->cntFadeFrames >= pConcealCommonData->numFadeOutFrames) { if (pConcealmentInfo->cntFadeFrames >= pConcealCommonData->numFadeOutFrames) {
/* change to state MUTE */ /* change to state MUTE */
...@@ -1576,9 +1586,14 @@ static void ...@@ -1576,9 +1586,14 @@ static void
case ConcealState_Mute: case ConcealState_Mute:
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) { if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
if (pConcealCommonData->numFadeInFrames > 0) {
/* change to state FADE-IN */ /* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn; pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1; pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1;
} else {
/* change to state OK */
pConcealmentInfo->concealState = ConcealState_Ok;
}
} }
break; break;
...@@ -1590,11 +1605,16 @@ static void ...@@ -1590,11 +1605,16 @@ static void
pConcealmentInfo->concealState = ConcealState_Ok; pConcealmentInfo->concealState = ConcealState_Ok;
} }
} else { } else {
if (pConcealCommonData->numFadeOutFrames > 0) {
/* change to state FADE-OUT */ /* change to state FADE-OUT */
pConcealmentInfo->concealState = ConcealState_FadeOut; pConcealmentInfo->concealState = ConcealState_FadeOut;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData, pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames+1, pConcealmentInfo->cntFadeFrames+1,
1 /* FadeIn -> FadeOut */); 1 /* FadeIn -> FadeOut */);
} else {
/* change to state MUTE */
pConcealmentInfo->concealState = ConcealState_Mute;
}
} }
break; break;
...@@ -1625,8 +1645,13 @@ static void ...@@ -1625,8 +1645,13 @@ static void
case ConcealState_Ok: case ConcealState_Ok:
if (!(pConcealmentInfo->prevFrameOk[1] || if (!(pConcealmentInfo->prevFrameOk[1] ||
(pConcealmentInfo->prevFrameOk[0] && !pConcealmentInfo->prevFrameOk[1] && frameOk))) { (pConcealmentInfo->prevFrameOk[0] && !pConcealmentInfo->prevFrameOk[1] && frameOk))) {
if (pConcealCommonData->numFadeOutFrames > 0) {
/* Fade out only if the energy interpolation algorithm can not be applied! */ /* Fade out only if the energy interpolation algorithm can not be applied! */
pConcealmentInfo->concealState = ConcealState_FadeOut; pConcealmentInfo->concealState = ConcealState_FadeOut;
} else {
/* change to state MUTE */
pConcealmentInfo->concealState = ConcealState_Mute;
}
pConcealmentInfo->cntFadeFrames = 0; pConcealmentInfo->cntFadeFrames = 0;
pConcealmentInfo->cntValidFrames = 0; pConcealmentInfo->cntValidFrames = 0;
} }
...@@ -1640,11 +1665,16 @@ static void ...@@ -1640,11 +1665,16 @@ static void
pConcealmentInfo->cntFadeFrames += 1; pConcealmentInfo->cntFadeFrames += 1;
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) { if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
if (pConcealCommonData->numFadeInFrames > 0) {
/* change to state FADE-IN */ /* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn; pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData, pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames-1, pConcealmentInfo->cntFadeFrames-1,
0 /* FadeOut -> FadeIn */); 0 /* FadeOut -> FadeIn */);
} else {
/* change to state OK */
pConcealmentInfo->concealState = ConcealState_Ok;
}
} else { } else {
if (pConcealmentInfo->cntFadeFrames >= pConcealCommonData->numFadeOutFrames) { if (pConcealmentInfo->cntFadeFrames >= pConcealCommonData->numFadeOutFrames) {
/* change to state MUTE */ /* change to state MUTE */
...@@ -1655,9 +1685,14 @@ static void ...@@ -1655,9 +1685,14 @@ static void
case ConcealState_Mute: case ConcealState_Mute:
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) { if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
if (pConcealCommonData->numFadeInFrames > 0) {
/* change to state FADE-IN */ /* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn; pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1; pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1;
} else {
/* change to state OK */
pConcealmentInfo->concealState = ConcealState_Ok;
}
} }
break; break;
...@@ -1670,11 +1705,16 @@ static void ...@@ -1670,11 +1705,16 @@ static void
pConcealmentInfo->concealState = ConcealState_Ok; pConcealmentInfo->concealState = ConcealState_Ok;
} }
} else { } else {
if (pConcealCommonData->numFadeOutFrames > 0) {
/* change to state FADE-OUT */ /* change to state FADE-OUT */
pConcealmentInfo->concealState = ConcealState_FadeOut; pConcealmentInfo->concealState = ConcealState_FadeOut;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData, pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames+1, pConcealmentInfo->cntFadeFrames+1,
1 /* FadeIn -> FadeOut */); 1 /* FadeIn -> FadeOut */);
} else {
/* change to state MUTE */
pConcealmentInfo->concealState = ConcealState_Mute;
}
} }
break; break;
} /* End switch(pConcealmentInfo->concealState) */ } /* End switch(pConcealmentInfo->concealState) */
......
...@@ -186,6 +186,27 @@ int CProgramConfig_IsValid ( const CProgramConfig *pPce ); ...@@ -186,6 +186,27 @@ int CProgramConfig_IsValid ( const CProgramConfig *pPce );
void CProgramConfig_Read ( CProgramConfig *pPce, void CProgramConfig_Read ( CProgramConfig *pPce,
HANDLE_FDK_BITSTREAM bs, HANDLE_FDK_BITSTREAM bs,
UINT alignAnchor ); UINT alignAnchor );
/*!
\brief Compare two Program Config Elements.
\param pPce1 Pointer to first Program Config Element structure.
\param pPce2 Pointer to second Program Config Element structure.
\return -1 if PCEs are completely different,
0 if PCEs are completely equal,
1 if PCEs are different but have the same channel config,
2 if PCEs have different channel config but same number of channels.
*/
int CProgramConfig_Compare ( const CProgramConfig * const pPce1,
const CProgramConfig * const pPce2 );
/*!
\brief Get a Program Config Element that matches the predefined MPEG-4 channel configurations 1-14.
\param pPce Program Config Element structure.
\param channelConfig MPEG-4 channel configuration.
\return void
*/
void CProgramConfig_GetDefault ( CProgramConfig *pPce,
const UINT channelConfig );
#endif /* TP_PCE_ENABLE */ #endif /* TP_PCE_ENABLE */
/** /**
......
...@@ -374,12 +374,12 @@ int adtsRead_GetRawDataBlockLength( ...@@ -374,12 +374,12 @@ int adtsRead_GetRawDataBlockLength(
length = -1; /* raw data block length is unknown */ length = -1; /* raw data block length is unknown */
} else { } else {
if (blockNum < 0 || blockNum > 3) { if (blockNum < 0 || blockNum > 3) {
return TRANSPORTDEC_INVALID_PARAMETER; length = -1;
} }
length = (pAdts->rawDataBlockDist[blockNum] << 3) - 16; length = (pAdts->rawDataBlockDist[blockNum] << 3) - 16;
} }
} }
if (blockNum == 0) { if (blockNum == 0 && length > 0) {
length -= pAdts->bs.num_pce_bits; length -= pAdts->bs.num_pce_bits;
} }
return length; return length;
......
...@@ -205,6 +205,145 @@ void CProgramConfig_Read( ...@@ -205,6 +205,145 @@ void CProgramConfig_Read(
pPce->isValid = 1; pPce->isValid = 1;
} }
/*
* Compare two program configurations.
* Returns the result of the comparison:
* -1 - completely different
* 0 - completely equal
* 1 - different but same channel configuration
* 2 - different channel configuration but same number of channels
*/
int CProgramConfig_Compare ( const CProgramConfig * const pPce1,
const CProgramConfig * const pPce2 )
{
int result = 0; /* Innocent until proven false. */
if (FDKmemcmp(pPce1, pPce2, sizeof(CProgramConfig)) != 0)
{ /* Configurations are not completely different.
So look into details and analyse the channel configurations: */
result = -1;
if (pPce1->NumChannels == pPce2->NumChannels)
{ /* Now the logic changes. We first assume to have the same channel configuration
and then prove if this assumption is true. */
result = 1;
/* Front channels */
if (pPce1->NumFrontChannelElements != pPce2->NumFrontChannelElements) {
result = 2; /* different number of front channel elements */
} else {
int el, numCh1 = 0, numCh2 = 0;
for (el = 0; el < pPce1->NumFrontChannelElements; el += 1) {
numCh1 += pPce1->FrontElementIsCpe[el] ? 2 : 1;
numCh2 += pPce2->FrontElementIsCpe[el] ? 2 : 1;
}
if (numCh1 != numCh2) {
result = 2; /* different number of front channels */
}
}
/* Side channels */
if (pPce1->NumSideChannelElements != pPce2->NumSideChannelElements) {
result = 2; /* different number of side channel elements */
} else {
int el, numCh1 = 0, numCh2 = 0;
for (el = 0; el < pPce1->NumSideChannelElements; el += 1) {
numCh1 += pPce1->SideElementIsCpe[el] ? 2 : 1;
numCh2 += pPce2->SideElementIsCpe[el] ? 2 : 1;
}
if (numCh1 != numCh2) {
result = 2; /* different number of side channels */
}
}
/* Back channels */
if (pPce1->NumBackChannelElements != pPce2->NumBackChannelElements) {
result = 2; /* different number of back channel elements */
} else {
int el, numCh1 = 0, numCh2 = 0;
for (el = 0; el < pPce1->NumBackChannelElements; el += 1) {
numCh1 += pPce1->BackElementIsCpe[el] ? 2 : 1;
numCh2 += pPce2->BackElementIsCpe[el] ? 2 : 1;
}
if (numCh1 != numCh2) {
result = 2; /* different number of back channels */
}
}
/* LFE channels */
if (pPce1->NumLfeChannelElements != pPce2->NumLfeChannelElements) {
result = 2; /* different number of lfe channels */
}
/* LFEs are always SCEs so we don't need to count the channels. */
}
}
return result;
}
void CProgramConfig_GetDefault( CProgramConfig *pPce,
const UINT channelConfig )
{
FDK_ASSERT(pPce != NULL);
/* Init PCE */
CProgramConfig_Init(pPce);
pPce->Profile = 1; /* Set AAC LC because it is the only supported object type. */
switch (channelConfig) {
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case 6: /* 3/0/2.1ch */
pPce->NumLfeChannelElements += 1;
pPce->NumChannels += 1;
case 5: /* 3/0/2.0ch */
case 4: /* 3/0/1.0ch */
pPce->NumBackChannelElements += 1;
pPce->BackElementIsCpe[0] = (channelConfig>4) ? 1 : 0;
pPce->NumChannels += (channelConfig>4) ? 2 : 1;
pPce->NumEffectiveChannels += (channelConfig>4) ? 2 : 1;
case 3: /* 3/0/0.0ch */
pPce->NumFrontChannelElements += 1;
pPce->FrontElementIsCpe[1] = 1;
pPce->NumChannels += 2;
pPce->NumEffectiveChannels += 2;
case 1: /* 1/0/0.0ch */
pPce->NumFrontChannelElements += 1;
pPce->FrontElementIsCpe[0] = 0;
pPce->NumChannels += 1;
pPce->NumEffectiveChannels += 1;
pPce->isValid = 1;
break;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case 2: /* 2/0/0.ch */
pPce->NumFrontChannelElements = 1;
pPce->FrontElementIsCpe[0] = 1;
pPce->NumChannels += 2;
pPce->NumEffectiveChannels += 2;
pPce->isValid = 1;
break;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
default:
pPce->isValid = 0; /* To be explicit! */
break;
}
if (pPce->isValid) {
/* Create valid element instance tags */
int el, elTagSce = 0, elTagCpe = 0;
for (el = 0; el < pPce->NumFrontChannelElements; el += 1) {
pPce->FrontElementTagSelect[el] = (pPce->FrontElementIsCpe) ? elTagCpe++ : elTagSce++;
}
for (el = 0; el < pPce->NumSideChannelElements; el += 1) {
pPce->SideElementTagSelect[el] = (pPce->SideElementIsCpe) ? elTagCpe++ : elTagSce++;
}
for (el = 0; el < pPce->NumBackChannelElements; el += 1) {
pPce->BackElementTagSelect[el] = (pPce->BackElementIsCpe) ? elTagCpe++ : elTagSce++;
}
elTagSce = 0;
for (el = 0; el < pPce->NumLfeChannelElements; el += 1) {
pPce->LfeElementTagSelect[el] = elTagSce++;
}
}
}
#endif /* TP_PCE_ENABLE */ #endif /* TP_PCE_ENABLE */
/** /**
...@@ -589,18 +728,18 @@ static INT ld_sbr_header( const CSAudioSpecificConfig *asc, ...@@ -589,18 +728,18 @@ static INT ld_sbr_header( const CSAudioSpecificConfig *asc,
} }
switch ( channelConfiguration ) { switch ( channelConfiguration ) {
case 7:
error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++);
case 6:
case 5: case 5:
error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++); error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++);
case 3: case 3:
error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++); error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++);
break; break;
case 7:
error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_SCE, i++);
case 6:
error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++);
case 4: case 4:
error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++); error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++);
error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_SCE, i++);
break; break;
} }
......
...@@ -120,7 +120,8 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadAudioMuxElement( ...@@ -120,7 +120,8 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadAudioMuxElement(
CLatmDemux *pLatmDemux, CLatmDemux *pLatmDemux,
int m_muxConfigPresent, int m_muxConfigPresent,
CSTpCallBacks *pTpDecCallbacks, CSTpCallBacks *pTpDecCallbacks,
CSAudioSpecificConfig *pAsc CSAudioSpecificConfig *pAsc,
int *pfConfigFound
) )
{ {
TRANSPORTDEC_ERROR ErrorStatus = TRANSPORTDEC_OK; TRANSPORTDEC_ERROR ErrorStatus = TRANSPORTDEC_OK;
...@@ -129,12 +130,17 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadAudioMuxElement( ...@@ -129,12 +130,17 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadAudioMuxElement(
pLatmDemux->m_useSameStreamMux = FDKreadBits(bs,1); pLatmDemux->m_useSameStreamMux = FDKreadBits(bs,1);
if (!pLatmDemux->m_useSameStreamMux) { if (!pLatmDemux->m_useSameStreamMux) {
if ((ErrorStatus = CLatmDemux_ReadStreamMuxConfig(bs, pLatmDemux, pTpDecCallbacks, pAsc))) { if ((ErrorStatus = CLatmDemux_ReadStreamMuxConfig(bs, pLatmDemux, pTpDecCallbacks, pAsc, pfConfigFound))) {
return (ErrorStatus); return (ErrorStatus);
} }
} }
} }
/* If there was no configuration read, its not possible to parse PayloadLengthInfo below. */
if (! *pfConfigFound) {
return TRANSPORTDEC_SYNC_ERROR;
}
if (pLatmDemux->m_AudioMuxVersionA == 0) { if (pLatmDemux->m_AudioMuxVersionA == 0) {
/* Do only once per call, because parsing and decoding is done in-line. */ /* Do only once per call, because parsing and decoding is done in-line. */
if ((ErrorStatus = CLatmDemux_ReadPayloadLengthInfo(bs,pLatmDemux))) { if ((ErrorStatus = CLatmDemux_ReadPayloadLengthInfo(bs,pLatmDemux))) {
...@@ -154,6 +160,7 @@ TRANSPORTDEC_ERROR CLatmDemux_Read( ...@@ -154,6 +160,7 @@ TRANSPORTDEC_ERROR CLatmDemux_Read(
TRANSPORT_TYPE tt, TRANSPORT_TYPE tt,
CSTpCallBacks *pTpDecCallbacks, CSTpCallBacks *pTpDecCallbacks,
CSAudioSpecificConfig *pAsc, CSAudioSpecificConfig *pAsc,
int *pfConfigFound,
const INT ignoreBufferFullness const INT ignoreBufferFullness
) )
{ {
...@@ -168,7 +175,7 @@ TRANSPORTDEC_ERROR CLatmDemux_Read( ...@@ -168,7 +175,7 @@ TRANSPORTDEC_ERROR CLatmDemux_Read(
return TRANSPORTDEC_NOT_ENOUGH_BITS; return TRANSPORTDEC_NOT_ENOUGH_BITS;
} }
if ((ErrorStatus = CLatmDemux_ReadAudioMuxElement(bs, pLatmDemux, (tt != TT_MP4_LATM_MCP0), pTpDecCallbacks, pAsc))) if ((ErrorStatus = CLatmDemux_ReadAudioMuxElement(bs, pLatmDemux, (tt != TT_MP4_LATM_MCP0), pTpDecCallbacks, pAsc, pfConfigFound)))
return (ErrorStatus); return (ErrorStatus);
if (!ignoreBufferFullness) if (!ignoreBufferFullness)
...@@ -205,7 +212,8 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadStreamMuxConfig( ...@@ -205,7 +212,8 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadStreamMuxConfig(
HANDLE_FDK_BITSTREAM bs, HANDLE_FDK_BITSTREAM bs,
CLatmDemux *pLatmDemux, CLatmDemux *pLatmDemux,
CSTpCallBacks *pTpDecCallbacks, CSTpCallBacks *pTpDecCallbacks,
CSAudioSpecificConfig *pAsc CSAudioSpecificConfig *pAsc,
int * pfConfigFound
) )
{ {
LATM_LAYER_INFO *p_linfo = NULL; LATM_LAYER_INFO *p_linfo = NULL;
...@@ -272,6 +280,7 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadStreamMuxConfig( ...@@ -272,6 +280,7 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadStreamMuxConfig(
if ((ErrorStatus = AudioSpecificConfig_Parse(&pAsc[TPDEC_TRACKINDEX(prog,lay)], &tmpBs, 1, pTpDecCallbacks))) { if ((ErrorStatus = AudioSpecificConfig_Parse(&pAsc[TPDEC_TRACKINDEX(prog,lay)], &tmpBs, 1, pTpDecCallbacks))) {
return (ErrorStatus); return (ErrorStatus);
} }
*pfConfigFound = 1;
/* The field p_linfo->m_ascLen could be wrong, so check if */ /* The field p_linfo->m_ascLen could be wrong, so check if */
if ( 0 > (INT)FDKgetValidBits(&tmpBs)) { if ( 0 > (INT)FDKgetValidBits(&tmpBs)) {
...@@ -292,6 +301,7 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadStreamMuxConfig( ...@@ -292,6 +301,7 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadStreamMuxConfig(
if (cbError != 0) { if (cbError != 0) {
return TRANSPORTDEC_UNKOWN_ERROR; return TRANSPORTDEC_UNKOWN_ERROR;
} }
*pfConfigFound = 1;
} }
} }
...@@ -377,7 +387,7 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadPayloadLengthInfo(HANDLE_FDK_BITSTREAM bs, CLa ...@@ -377,7 +387,7 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadPayloadLengthInfo(HANDLE_FDK_BITSTREAM bs, CLa
else { else {
ErrorStatus = TRANSPORTDEC_PARSE_ERROR; //AAC_DEC_LATM_TIMEFRAMING; ErrorStatus = TRANSPORTDEC_PARSE_ERROR; //AAC_DEC_LATM_TIMEFRAMING;
} }
if (pLatmDemux->m_audioMuxLengthBytes > 0 && totalPayloadBits > pLatmDemux->m_audioMuxLengthBytes*8) { if (pLatmDemux->m_audioMuxLengthBytes > (UINT)0 && totalPayloadBits > (int)pLatmDemux->m_audioMuxLengthBytes*8) {
return TRANSPORTDEC_PARSE_ERROR; return TRANSPORTDEC_PARSE_ERROR;
} }
return (ErrorStatus); return (ErrorStatus);
......
...@@ -144,14 +144,25 @@ TRANSPORTDEC_ERROR CLatmDemux_Read( ...@@ -144,14 +144,25 @@ TRANSPORTDEC_ERROR CLatmDemux_Read(
TRANSPORT_TYPE tt, TRANSPORT_TYPE tt,
CSTpCallBacks *pTpDecCallbacks, CSTpCallBacks *pTpDecCallbacks,
CSAudioSpecificConfig *pAsc, CSAudioSpecificConfig *pAsc,
int *pfConfigFound,
const INT ignoreBufferFullness const INT ignoreBufferFullness
); );
/**
* \brief Read StreamMuxConfig
* \param bs bit stream handle as data source
* \param pLatmDemux pointer to CLatmDemux struct of current LATM context
* \param pTpDecCallbacks Call back structure for configuration callbacks
* \param pAsc pointer to a ASC for configuration storage
* \param pfConfigFound pointer to a flag which is set to 1 if a configuration was found and processed successfully
* \return error code
*/
TRANSPORTDEC_ERROR CLatmDemux_ReadStreamMuxConfig( TRANSPORTDEC_ERROR CLatmDemux_ReadStreamMuxConfig(
HANDLE_FDK_BITSTREAM bs, HANDLE_FDK_BITSTREAM bs,
CLatmDemux *pLatmDemux, CLatmDemux *pLatmDemux,
CSTpCallBacks *pTpDecCallbacks, CSTpCallBacks *pTpDecCallbacks,
CSAudioSpecificConfig *pAsc CSAudioSpecificConfig *pAsc,
int * pfConfigFound
); );
TRANSPORTDEC_ERROR CLatmDemux_ReadPayloadLengthInfo(HANDLE_FDK_BITSTREAM bs, CLatmDemux *pLatmDemux); TRANSPORTDEC_ERROR CLatmDemux_ReadPayloadLengthInfo(HANDLE_FDK_BITSTREAM bs, CLatmDemux *pLatmDemux);
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* library info */ /* library info */
#define TP_LIB_VL0 2 #define TP_LIB_VL0 2
#define TP_LIB_VL1 3 #define TP_LIB_VL1 3
#define TP_LIB_VL2 1 #define TP_LIB_VL2 2
#define TP_LIB_TITLE "MPEG Transport" #define TP_LIB_TITLE "MPEG Transport"
#define TP_LIB_BUILD_DATE __DATE__ #define TP_LIB_BUILD_DATE __DATE__
#define TP_LIB_BUILD_TIME __TIME__ #define TP_LIB_BUILD_TIME __TIME__
...@@ -624,8 +624,8 @@ timeCompensateFirstEnvelope (HANDLE_SBR_HEADER_DATA hHeaderData, /*!< Static con ...@@ -624,8 +624,8 @@ timeCompensateFirstEnvelope (HANDLE_SBR_HEADER_DATA hHeaderData, /*!< Static con
deltaExp = FDK_getNumOctavesDiv8(newLen, refLen); deltaExp = FDK_getNumOctavesDiv8(newLen, refLen);
/* Shift by -3 to rescale ld-table, 1-ampRes to enable coarser steps */ /* Shift by -3 to rescale ld-table, ampRes-1 to enable coarser steps */
shift = (FRACT_BITS - 1 - ENV_EXP_FRACT + 1 - h_sbr_data->ampResolutionCurrentFrame - 3); shift = (FRACT_BITS - 1 - ENV_EXP_FRACT - 1 + h_sbr_data->ampResolutionCurrentFrame - 3);
deltaExp = deltaExp >> shift; deltaExp = deltaExp >> shift;
pFrameInfo->borders[0] = estimatedStartPos; pFrameInfo->borders[0] = estimatedStartPos;
pFrameInfo->bordersNoise[0] = estimatedStartPos; pFrameInfo->bordersNoise[0] = estimatedStartPos;
......
...@@ -875,22 +875,8 @@ resetLppTransposer (HANDLE_SBR_LPP_TRANS hLppTrans, /*!< Handle of lpp transpos ...@@ -875,22 +875,8 @@ resetLppTransposer (HANDLE_SBR_LPP_TRANS hLppTrans, /*!< Handle of lpp transpos
/* /*
* Initialize the patching parameter * Initialize the patching parameter
*/ */
desiredBorder = 21; /* ISO/IEC 14496-3 (Figure 4.48): goalSb = round( 2.048e6 / fs ) */
if (fs < 92017) { desiredBorder = (((2048000*2) / fs) + 1) >> 1;
desiredBorder = 23;
}
if (fs < 75132) {
desiredBorder = 32;
}
if (fs < 55426) {
desiredBorder = 43;
}
if (fs < 46009) {
desiredBorder = 46;
}
if (fs < 35777) {
desiredBorder = 64;
}
desiredBorder = findClosestEntry(desiredBorder, v_k_master, numMaster, 1); /* Adapt region to master-table */ desiredBorder = findClosestEntry(desiredBorder, v_k_master, numMaster, 1); /* Adapt region to master-table */
......
...@@ -137,7 +137,7 @@ amm-info@iis.fraunhofer.de ...@@ -137,7 +137,7 @@ amm-info@iis.fraunhofer.de
/* Decoder library info */ /* Decoder library info */
#define SBRDECODER_LIB_VL0 2 #define SBRDECODER_LIB_VL0 2
#define SBRDECODER_LIB_VL1 2 #define SBRDECODER_LIB_VL1 2
#define SBRDECODER_LIB_VL2 2 #define SBRDECODER_LIB_VL2 3
#define SBRDECODER_LIB_TITLE "SBR Decoder" #define SBRDECODER_LIB_TITLE "SBR Decoder"
#define SBRDECODER_LIB_BUILD_DATE __DATE__ #define SBRDECODER_LIB_BUILD_DATE __DATE__
#define SBRDECODER_LIB_BUILD_TIME __TIME__ #define SBRDECODER_LIB_BUILD_TIME __TIME__
...@@ -552,7 +552,7 @@ bail: ...@@ -552,7 +552,7 @@ bail:
sbrDecoder_DestroyElement( self, elementIndex ); sbrDecoder_DestroyElement( self, elementIndex );
} else if (self->pSbrElement[elementIndex] != NULL) { } else if (self->pSbrElement[elementIndex] != NULL) {
/* Set error flag to trigger concealment */ /* Set error flag to trigger concealment */
self->pSbrElement[elementIndex]->frameErrorFlag[self->pSbrElement[elementIndex]->useFrameSlot] = 1;; self->pSbrElement[elementIndex]->frameErrorFlag[self->pSbrElement[elementIndex]->useFrameSlot] = 1;
} }
} }
...@@ -731,6 +731,12 @@ SBR_ERROR sbrDecoder_SetParam (HANDLE_SBRDECODER self, ...@@ -731,6 +731,12 @@ SBR_ERROR sbrDecoder_SetParam (HANDLE_SBRDECODER self,
case SBR_BS_INTERRUPTION: case SBR_BS_INTERRUPTION:
{ {
int elementIndex; int elementIndex;
if (self == NULL) {
errorStatus = SBRDEC_NOT_INITIALIZED;
break;
}
/* Loop over SBR elements */ /* Loop over SBR elements */
for (elementIndex = 0; elementIndex < self->numSbrElements; elementIndex++) for (elementIndex = 0; elementIndex < self->numSbrElements; elementIndex++)
{ {
......
...@@ -144,6 +144,12 @@ typedef enum ...@@ -144,6 +144,12 @@ typedef enum
} TRANSPORT_TYPE; } TRANSPORT_TYPE;
#define TT_IS_PACKET(x) \
( ((x) == TT_MP4_RAW) \
|| ((x) == TT_DRM) \
|| ((x) == TT_MP4_LATM_MCP0) \
|| ((x) == TT_MP4_LATM_MCP1) )
/** /**
* Audio Object Type definitions. * Audio Object Type definitions.
*/ */
......
...@@ -99,7 +99,7 @@ amm-info@iis.fraunhofer.de ...@@ -99,7 +99,7 @@ amm-info@iis.fraunhofer.de
/* library info */ /* library info */
#define SYS_LIB_VL0 1 #define SYS_LIB_VL0 1
#define SYS_LIB_VL1 3 #define SYS_LIB_VL1 3
#define SYS_LIB_VL2 1 #define SYS_LIB_VL2 2
#define SYS_LIB_TITLE "System Integration Library" #define SYS_LIB_TITLE "System Integration Library"
#define SYS_LIB_BUILD_DATE __DATE__ #define SYS_LIB_BUILD_DATE __DATE__
#define SYS_LIB_BUILD_TIME __TIME__ #define SYS_LIB_BUILD_TIME __TIME__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment