FDKv2 additional fixes

Bug: 71430241
Bug: 79220129
Test: cts-tradefed run commandAndExit cts-dev -m CtsMediaTestCases -t android.media.cts.DecoderTestXheAac
      cts-tradefed run commandAndExit cts-dev -m CtsMediaTestCases -t android.media.cts.DecoderTestAacDrc

Add restriction to call intensity stereo tool only for applicable configurations

Change-Id: I30ec6640bd484c56cc9d5b8b35186fc1c875e021

Fix high band energy calculation in sbr encoder

Change-Id: I964dd46fab2ed797c440a983512bbab7e1aff98a

Fix out-of-bounds read access in noiseless coder

Change-Id: I9a669435dbdca421ff9e4affec57811002d75b3b

Use temporary buffer for dummy parsing to check presence of audioPreroll data

Change-Id: I2d42c5c8deddde34351c3d2858b9fe196b3a0906

Set applyAsc to 1 in case that the ASC parsing fails

Change-Id: I552a8b960270bc18cae459ad28a3ba241035668e

Parametric stereo together with mps not supported

Change-Id: Icde14a2774a4303bb0c41046861a59d04b624365

Align ssc callback error path for drm

Change-Id: Ie8ecbfa42c702e6df81c1aec532a9ff1e653dac9

Ensure that the bit counter starts at a multiple of TPDEC_SYNCSKIP

Change-Id: I08d69ec361b2e2ed800282e333fd248b4b3ca245

Allow flushing only when audioPreroll is enabled in current and new config

Change-Id: I52e95d75de4bbed692be922a59a23bda58870625

Omit reverse channel mapping in pass through mode

Change-Id: I335e209c29a700cc091be069f1d08e4288b40793
This commit is contained in:
Fraunhofer IIS FDK 2018-05-04 15:51:23 +02:00 committed by Jean-Michel Trivi
parent 6cfabd3536
commit 9ab67882ec
10 changed files with 55 additions and 31 deletions

View File

@ -396,7 +396,8 @@ static INT aacDecoder_SscCallback(void *handle, HANDLE_FDK_BITSTREAM hBs,
/* MPS found but invalid or not decodable by this instance */
hAacDecoder->mpsEnableCurr = 0;
hAacDecoder->mpsApplicable = 0;
if ((coreCodec == AOT_USAC) || IS_LOWDELAY(coreCodec)) {
if ((coreCodec == AOT_USAC) || (coreCodec == AOT_DRM_USAC) ||
IS_LOWDELAY(coreCodec)) {
errTp = TRANSPORTDEC_PARSE_ERROR;
} else {
errTp = TRANSPORTDEC_OK;
@ -1654,14 +1655,14 @@ aacDecoder_DecodeFrame(HANDLE_AACDECODER self, INT_PCM *pTimeData_extern,
self->streamInfo.frameSize;
for (ch = 0; ch < self->streamInfo.numChannels; ch++) {
int mapValue = FDK_chMapDescr_getMapValue(
UCHAR mapValue = FDK_chMapDescr_getMapValue(
&self->mapDescr, (UCHAR)ch, self->chMapIndex);
reverseInChannelMap[mapValue] = ch;
if (mapValue < (8)) reverseInChannelMap[mapValue] = ch;
}
for (ch = 0; ch < (int)numDrcOutChannels; ch++) {
int mapValue = FDK_chMapDescr_getMapValue(
UCHAR mapValue = FDK_chMapDescr_getMapValue(
&self->mapDescr, (UCHAR)ch, numDrcOutChannels);
reverseOutChannelMap[mapValue] = ch;
if (mapValue < (8)) reverseOutChannelMap[mapValue] = ch;
}
/* The output of SBR and MPS is interleaved. Deinterleaving may be

View File

@ -225,15 +225,18 @@ void CChannelElement_Decode(
/* apply intensity stereo */ /* modifies pAacDecoderChannelInfo[]->aSpecSfb
*/
if (!(flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA))) {
CJointStereo_ApplyIS(
pAacDecoderChannelInfo,
GetScaleFactorBandOffsets(&pAacDecoderChannelInfo[L]->icsInfo,
pSamplingRateInfo),
GetWindowGroupLengthTable(&pAacDecoderChannelInfo[L]->icsInfo),
GetWindowGroups(&pAacDecoderChannelInfo[L]->icsInfo),
GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo[L]->icsInfo),
pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow ? 1
: 0);
if ((pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow ==
1) &&
(el_channels == 2)) {
CJointStereo_ApplyIS(
pAacDecoderChannelInfo,
GetScaleFactorBandOffsets(&pAacDecoderChannelInfo[L]->icsInfo,
pSamplingRateInfo),
GetWindowGroupLengthTable(&pAacDecoderChannelInfo[L]->icsInfo),
GetWindowGroups(&pAacDecoderChannelInfo[L]->icsInfo),
GetScaleFactorBandsTransmitted(
&pAacDecoderChannelInfo[L]->icsInfo));
}
}
} /* maybe_stereo */

View File

@ -478,15 +478,13 @@ void CJointStereo_ApplyMS(
\param pWindowGroupLength pointer to window group length array.
\param windowGroups number of window groups.
\param scaleFactorBandsTransmitted number of transmitted scalefactor bands.
\param CommonWindow common window bit.
\return none
*/
void CJointStereo_ApplyIS(CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
const short *pScaleFactorBandOffsets,
const UCHAR *pWindowGroupLength,
const int windowGroups,
const int scaleFactorBandsTransmitted,
const UINT CommonWindow);
const int scaleFactorBandsTransmitted);
/* aacdec_pns.cpp */
int CPns_IsPnsUsed(const CPnsData *pPnsData, const int group, const int band);

View File

@ -1177,8 +1177,7 @@ void CJointStereo_ApplyIS(CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
const SHORT *pScaleFactorBandOffsets,
const UCHAR *pWindowGroupLength,
const int windowGroups,
const int scaleFactorBandsTransmitted,
const UINT CommonWindow) {
const int scaleFactorBandsTransmitted) {
CJointStereoData *pJointStereoData =
&pAacDecoderChannelInfo[L]->pComData->jointStereoData;
@ -1228,7 +1227,7 @@ void CJointStereo_ApplyIS(CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
rightScale[band] = leftScale[band] + msb + 1;
if (CommonWindow && (pJointStereoData->MsUsed[band] & groupMask)) {
if (pJointStereoData->MsUsed[band] & groupMask) {
if (CodeBook[band] == INTENSITY_HCB) /* _NOT_ in-phase */
{
scale = -scale;

View File

@ -2488,7 +2488,7 @@ TRANSPORTDEC_ERROR DrmRawSdcAudioConfig_Parse(
switch (audioCoding) {
case 0: /* AAC */
if (coderField >> 2) {
if ((coderField >> 2) && (audioMode != 1)) {
self->m_aot = AOT_DRM_SURROUND; /* Set pseudo AOT for Drm Surround */
} else {
self->m_aot = AOT_DRM_AAC; /* Set pseudo AOT for Drm AAC */

View File

@ -126,7 +126,6 @@ static TRANSPORTDEC_ERROR CLatmDemux_ReadAudioMuxElement(
CSTpCallBacks *pTpDecCallbacks, CSAudioSpecificConfig *pAsc,
int *pfConfigFound) {
TRANSPORTDEC_ERROR ErrorStatus = TRANSPORTDEC_OK;
UCHAR applyAsc = pLatmDemux->applyAsc;
if (m_muxConfigPresent) {
pLatmDemux->m_useSameStreamMux = FDKreadBits(bs, 1);
@ -152,7 +151,12 @@ static TRANSPORTDEC_ERROR CLatmDemux_ReadAudioMuxElement(
goto bail;
}
if (pLatmDemux->newCfgHasAudioPreRoll) {
/* Allow flushing only when audioPreroll functionality is enabled in
* current and new config otherwise the new config can be applied
* immediately. */
if (pAsc->m_sc.m_usacConfig.element[0]
.extElement.usacExtElementHasAudioPreRoll &&
pLatmDemux->newCfgHasAudioPreRoll) {
pLatmDemux->newCfgHasAudioPreRoll = 0;
/* with audioPreRoll we must flush before applying new cfg */
pLatmDemux->applyAsc = 0;
@ -223,7 +227,7 @@ static TRANSPORTDEC_ERROR CLatmDemux_ReadAudioMuxElement(
bail:
if (ErrorStatus != TRANSPORTDEC_OK) {
pLatmDemux->applyAsc = applyAsc;
pLatmDemux->applyAsc = 1;
}
return (ErrorStatus);

View File

@ -1151,6 +1151,12 @@ static TRANSPORTDEC_ERROR synchronization(HANDLE_TRANSPORTDEC hTp,
&syncLayerFrameBits, &fConfigFound,
&headerBits);
if (TPDEC_IS_FATAL_ERROR(err)) {
/* Rewind - TPDEC_SYNCSKIP, in order to look for a synch one bit ahead
* next time. Ensure that the bit amount lands at a multiple of
* TPDEC_SYNCSKIP. */
FDKpushBiDirectional(
hBs, -headerBits + TPDEC_SYNCSKIP + (bitsAvail % TPDEC_SYNCSKIP));
goto bail;
}
}

View File

@ -698,6 +698,7 @@ SACDEC_ERROR mpegSurroundDecoder_Config(
INT coreSbrFrameLengthIndex, INT configBytes, const UCHAR configMode,
UCHAR *configChanged) {
SACDEC_ERROR err = MPS_OK;
SPATIAL_SPECIFIC_CONFIG spatialSpecificConfig;
switch (coreCodec) {
case AOT_DRM_USAC:
@ -705,7 +706,6 @@ SACDEC_ERROR mpegSurroundDecoder_Config(
if (configMode == AC_CM_DET_CFG_CHANGE) {
/* In config detection mode write spatial specific config parameters
* into temporarily allocated structure */
SPATIAL_SPECIFIC_CONFIG spatialSpecificConfig;
err = SpatialDecParseMps212Config(
hBs, &spatialSpecificConfig, samplingRate, coreCodec,
stereoConfigIndex, coreSbrFrameLengthIndex);
@ -718,9 +718,16 @@ SACDEC_ERROR mpegSurroundDecoder_Config(
break;
case AOT_ER_AAC_ELD:
case AOT_ER_AAC_LD:
err = SpatialDecParseSpecificConfig(
hBs, &pMpegSurroundDecoder->spatialSpecificConfigBackup, configBytes,
coreCodec);
if (configMode == AC_CM_DET_CFG_CHANGE) {
/* In config detection mode write spatial specific config parameters
* into temporarily allocated structure */
err = SpatialDecParseSpecificConfig(hBs, &spatialSpecificConfig,
configBytes, coreCodec);
} else {
err = SpatialDecParseSpecificConfig(
hBs, &pMpegSurroundDecoder->spatialSpecificConfigBackup,
configBytes, coreCodec);
}
break;
default:
err = MPS_UNSUPPORTED_FORMAT;

View File

@ -379,16 +379,22 @@ static UINT huff_enc_1D(HANDLE_FDK_BITSTREAM strm, const DATA_TYPE data_type,
switch (data_type) {
case t_CLD:
part0 = fdk_sacenc_huffPart0Tab.cld[in_data[0]];
pHuffTab = fdk_sacenc_huffCLDTab.h1D[dim1];
break;
case t_ICC:
part0 = fdk_sacenc_huffPart0Tab.icc[in_data[0]];
pHuffTab = fdk_sacenc_huffICCTab.h1D[dim1];
break;
}
if (p0_flag) {
switch (data_type) {
case t_CLD:
part0 = fdk_sacenc_huffPart0Tab.cld[in_data[0]];
break;
case t_ICC:
part0 = fdk_sacenc_huffPart0Tab.icc[in_data[0]];
break;
}
huffBits += FDKwriteBits(strm, HUFF_VALUE(part0), HUFF_LENGTH(part0));
offset = 1;
}

View File

@ -366,7 +366,7 @@ static FIXP_DBL addHighbandEnergies(
accu += (EnergiesM[slotOut][j] >> scale[0]);
}
}
nrgTotal = accu >> (scaleEnergies[1] - scale[1]);
nrgTotal = fAddSaturate(nrgTotal, accu >> (scaleEnergies[1] - scale[1]));
}
return (nrgTotal);