Merge changes Ib8b6973e,I19874768

* changes:
  Check number of core channels and SAC decoder input channels to avoid a channel mismatch.
  Revise bypass mode in SpatialDecApplyParameterSets() to prevent an assert in fDivNorm().
This commit is contained in:
TreeHugger Robot 2020-12-28 18:41:27 +00:00 committed by Android (Google) Code Review
commit 31608d9a1f
9 changed files with 95 additions and 49 deletions

View File

@ -385,21 +385,19 @@ static INT aacDecoder_SbrCallback(
return errTp; return errTp;
} }
static INT aacDecoder_SscCallback(void *handle, HANDLE_FDK_BITSTREAM hBs, static INT aacDecoder_SscCallback(
const AUDIO_OBJECT_TYPE coreCodec, void *handle, HANDLE_FDK_BITSTREAM hBs, const AUDIO_OBJECT_TYPE coreCodec,
const INT samplingRate, const INT frameSize, const INT samplingRate, const INT frameSize, const INT numChannels,
const INT stereoConfigIndex, const INT stereoConfigIndex, const INT coreSbrFrameLengthIndex,
const INT coreSbrFrameLengthIndex, const INT configBytes, const UCHAR configMode, UCHAR *configChanged) {
const INT configBytes, const UCHAR configMode,
UCHAR *configChanged) {
SACDEC_ERROR err; SACDEC_ERROR err;
TRANSPORTDEC_ERROR errTp; TRANSPORTDEC_ERROR errTp;
HANDLE_AACDECODER hAacDecoder = (HANDLE_AACDECODER)handle; HANDLE_AACDECODER hAacDecoder = (HANDLE_AACDECODER)handle;
err = mpegSurroundDecoder_Config( err = mpegSurroundDecoder_Config(
(CMpegSurroundDecoder *)hAacDecoder->pMpegSurroundDecoder, hBs, coreCodec, (CMpegSurroundDecoder *)hAacDecoder->pMpegSurroundDecoder, hBs, coreCodec,
samplingRate, frameSize, stereoConfigIndex, coreSbrFrameLengthIndex, samplingRate, frameSize, numChannels, stereoConfigIndex,
configBytes, configMode, configChanged); coreSbrFrameLengthIndex, configBytes, configMode, configChanged);
switch (err) { switch (err) {
case MPS_UNSUPPORTED_CONFIG: case MPS_UNSUPPORTED_CONFIG:

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten © Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -1242,7 +1242,7 @@ static INT aacenc_SbrCallback(void *self, HANDLE_FDK_BITSTREAM hBs,
INT aacenc_SscCallback(void *self, HANDLE_FDK_BITSTREAM hBs, INT aacenc_SscCallback(void *self, HANDLE_FDK_BITSTREAM hBs,
const AUDIO_OBJECT_TYPE coreCodec, const AUDIO_OBJECT_TYPE coreCodec,
const INT samplingRate, const INT frameSize, const INT samplingRate, const INT frameSize,
const INT stereoConfigIndex, const INT numChannels, const INT stereoConfigIndex,
const INT coreSbrFrameLengthIndex, const INT configBytes, const INT coreSbrFrameLengthIndex, const INT configBytes,
const UCHAR configMode, UCHAR *configChanged) { const UCHAR configMode, UCHAR *configChanged) {
HANDLE_AACENCODER hAacEncoder = (HANDLE_AACENCODER)self; HANDLE_AACENCODER hAacEncoder = (HANDLE_AACENCODER)self;

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten © Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -368,7 +368,7 @@ typedef INT (*cbCtrlCFGChange_t)(void *, const CCtrlCFGChange *);
typedef INT (*cbSsc_t)(void *, HANDLE_FDK_BITSTREAM, typedef INT (*cbSsc_t)(void *, HANDLE_FDK_BITSTREAM,
const AUDIO_OBJECT_TYPE coreCodec, const AUDIO_OBJECT_TYPE coreCodec,
const INT samplingRate, const INT frameSize, const INT samplingRate, const INT frameSize,
const INT stereoConfigIndex, const INT numChannels, const INT stereoConfigIndex,
const INT coreSbrFrameLengthIndex, const INT configBytes, const INT coreSbrFrameLengthIndex, const INT configBytes,
const UCHAR configMode, UCHAR *configChanged); const UCHAR configMode, UCHAR *configChanged);

View File

@ -1415,7 +1415,7 @@ static TRANSPORTDEC_ERROR EldSpecificConfig_Parse(CSAudioSpecificConfig *asc,
cb->cbSscData, hBs, asc->m_aot, cb->cbSscData, hBs, asc->m_aot,
asc->m_samplingFrequency << esc->m_sbrSamplingRate, asc->m_samplingFrequency << esc->m_sbrSamplingRate,
asc->m_samplesPerFrame << esc->m_sbrSamplingRate, asc->m_samplesPerFrame << esc->m_sbrSamplingRate,
1, /* stereoConfigIndex */ asc->m_channelConfiguration, 1, /* stereoConfigIndex */
-1, /* nTimeSlots: read from bitstream */ -1, /* nTimeSlots: read from bitstream */
eldExtLen, asc->configMode, &asc->SacConfigChanged); eldExtLen, asc->configMode, &asc->SacConfigChanged);
if (ErrorStatus != TRANSPORTDEC_OK) { if (ErrorStatus != TRANSPORTDEC_OK) {
@ -1827,6 +1827,8 @@ static TRANSPORTDEC_ERROR UsacRsv60DecoderConfig_Parse(
/* Mps212Config() ISO/IEC FDIS 23003-3 */ /* Mps212Config() ISO/IEC FDIS 23003-3 */
if (cb->cbSsc(cb->cbSscData, hBs, asc->m_aot, if (cb->cbSsc(cb->cbSscData, hBs, asc->m_aot,
asc->m_extensionSamplingFrequency, samplesPerFrame, asc->m_extensionSamplingFrequency, samplesPerFrame,
1, /* only downmix channels (residual channels are
not counted) */
usc->element[i].m_stereoConfigIndex, usc->element[i].m_stereoConfigIndex,
usc->m_coreSbrFrameLengthIndex, usc->m_coreSbrFrameLengthIndex,
0, /* don't know the length */ 0, /* don't know the length */
@ -2221,7 +2223,7 @@ TRANSPORTDEC_ERROR AudioSpecificConfig_Parse(
case AOT_MPEGS: case AOT_MPEGS:
if (cb->cbSsc != NULL) { if (cb->cbSsc != NULL) {
if (cb->cbSsc(cb->cbSscData, bs, self->m_aot, self->m_samplingFrequency, if (cb->cbSsc(cb->cbSscData, bs, self->m_aot, self->m_samplingFrequency,
self->m_samplesPerFrame, 1, self->m_samplesPerFrame, self->m_channelConfiguration, 1,
-1, /* nTimeSlots: read from bitstream */ -1, /* nTimeSlots: read from bitstream */
0, /* don't know the length */ 0, /* don't know the length */
self->configMode, &self->SacConfigChanged)) { self->configMode, &self->SacConfigChanged)) {
@ -2419,6 +2421,8 @@ static TRANSPORTDEC_ERROR Drm_xHEAACDecoderConfig(
cb->cbSscData, hBs, cb->cbSscData, hBs,
AOT_DRM_USAC, /* syntax differs from MPEG Mps212Config() */ AOT_DRM_USAC, /* syntax differs from MPEG Mps212Config() */
asc->m_extensionSamplingFrequency, samplesPerFrame, asc->m_extensionSamplingFrequency, samplesPerFrame,
1, /* only downmix channels (residual channels are not
counted) */
usc->element[elemIdx].m_stereoConfigIndex, usc->element[elemIdx].m_stereoConfigIndex,
usc->m_coreSbrFrameLengthIndex, 0, /* don't know the length */ usc->m_coreSbrFrameLengthIndex, 0, /* don't know the length */
asc->configMode, &asc->SacConfigChanged); asc->configMode, &asc->SacConfigChanged);

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten © Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -368,7 +368,7 @@ typedef INT (*cbCtrlCFGChange_t)(void *, const CCtrlCFGChange *);
typedef INT (*cbSsc_t)(void *, HANDLE_FDK_BITSTREAM, typedef INT (*cbSsc_t)(void *, HANDLE_FDK_BITSTREAM,
const AUDIO_OBJECT_TYPE coreCodec, const AUDIO_OBJECT_TYPE coreCodec,
const INT samplingRate, const INT frameSize, const INT samplingRate, const INT frameSize,
const INT stereoConfigIndex, const INT numChannels, const INT stereoConfigIndex,
const INT coreSbrFrameLengthIndex, const INT configBytes, const INT coreSbrFrameLengthIndex, const INT configBytes,
const UCHAR configMode, UCHAR *configChanged); const UCHAR configMode, UCHAR *configChanged);

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten © Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -795,7 +795,7 @@ static int transportEnc_writeELDSpecificConfig(HANDLE_FDK_BITSTREAM hBs,
const INT eldExtLen = const INT eldExtLen =
(cb->cbSsc(cb->cbSscData, NULL, config->aot, config->extSamplingRate, 0, (cb->cbSsc(cb->cbSscData, NULL, config->aot, config->extSamplingRate, 0,
0, 0, 0, 0, NULL) + 0, 0, 0, 0, 0, NULL) +
7) >> 7) >>
3; 3;
INT cnt = eldExtLen; INT cnt = eldExtLen;
@ -818,7 +818,7 @@ static int transportEnc_writeELDSpecificConfig(HANDLE_FDK_BITSTREAM hBs,
} }
cb->cbSsc(cb->cbSscData, hBs, config->aot, config->extSamplingRate, 0, 0, 0, cb->cbSsc(cb->cbSscData, hBs, config->aot, config->extSamplingRate, 0, 0, 0,
0, 0, NULL); 0, 0, 0, NULL);
} }
if (config->downscaleSamplingRate != 0 && if (config->downscaleSamplingRate != 0 &&

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten © Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -316,8 +316,8 @@ SACDEC_ERROR mpegSurroundDecoder_Init(
SACDEC_ERROR mpegSurroundDecoder_Config( SACDEC_ERROR mpegSurroundDecoder_Config(
CMpegSurroundDecoder *pMpegSurroundDecoder, HANDLE_FDK_BITSTREAM hBs, CMpegSurroundDecoder *pMpegSurroundDecoder, HANDLE_FDK_BITSTREAM hBs,
AUDIO_OBJECT_TYPE coreCodec, INT samplingRate, INT frameSize, AUDIO_OBJECT_TYPE coreCodec, INT samplingRate, INT frameSize,
INT stereoConfigIndex, INT coreSbrFrameLengthIndex, INT configBytes, INT numChannels, INT stereoConfigIndex, INT coreSbrFrameLengthIndex,
const UCHAR configMode, UCHAR *configChanged); INT configBytes, const UCHAR configMode, UCHAR *configChanged);
SACDEC_ERROR SACDEC_ERROR
mpegSurroundDecoder_ConfigureQmfDomain( mpegSurroundDecoder_ConfigureQmfDomain(

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten © Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -1098,6 +1098,28 @@ static void SpatialDecApplyBypass(spatialDec *self, FIXP_DBL **hybInputReal,
} }
} }
/**
* \brief Set internal error and reset error status
*
* \param self spatialDec handle.
* \param bypassMode pointer to bypassMode.
* \param err error status.
*
* \return error status.
*/
static SACDEC_ERROR SpatialDecSetInternalError(spatialDec *self,
int *bypassMode,
SACDEC_ERROR err) {
*bypassMode = 1;
if (self->errInt == MPS_OK) {
/* store internal error before it gets overwritten */
self->errInt = err;
}
return MPS_OK;
}
/******************************************************************************* /*******************************************************************************
Functionname: SpatialDecApplyParameterSets Functionname: SpatialDecApplyParameterSets
******************************************************************************* *******************************************************************************
@ -1118,7 +1140,7 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
const FDK_channelMapDescr *const mapDescr) { const FDK_channelMapDescr *const mapDescr) {
SACDEC_ERROR err = MPS_OK; SACDEC_ERROR err = MPS_OK;
FIXP_SGL alpha; FIXP_SGL alpha = FL2FXCONST_SGL(0.0);
int ts; int ts;
int ch; int ch;
@ -1141,20 +1163,22 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
ts++, ts_io++) { ts++, ts_io++) {
int currSlot = frame->paramSlot[ps]; int currSlot = frame->paramSlot[ps];
err = (currSlot < ts) ? MPS_WRONG_PARAMETERSETS : MPS_OK;
if (err != MPS_OK) {
err = SpatialDecSetInternalError(self, &bypassMode, err);
}
/* /*
* Get new parameter set * Get new parameter set
*/ */
if (ts == prevSlot + 1) { if (ts == prevSlot + 1) {
err = SpatialDecCalculateM1andM2(self, ps, if (bypassMode == 0) {
frame); /* input: ottCLD, ottICC, ... */ err = SpatialDecCalculateM1andM2(
self, ps, frame); /* input: ottCLD, ottICC, ... */
/* output: M1param(Real/Imag), M2(Real/Imag) */ /* output: M1param(Real/Imag), M2(Real/Imag) */
if (err != MPS_OK) { if (err != MPS_OK) {
bypassMode = 1; err = SpatialDecSetInternalError(self, &bypassMode, err);
if (self->errInt == MPS_OK) {
/* store internal error befor it gets overwritten */
self->errInt = err;
} }
err = MPS_OK;
} }
if ((ps == 0) && (self->bOverwriteM1M2prev != 0)) { if ((ps == 0) && (self->bOverwriteM1M2prev != 0)) {
@ -1168,13 +1192,16 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
self->bOverwriteM1M2prev = 0; self->bOverwriteM1M2prev = 0;
} }
if (bypassMode == 0) {
SpatialDecSmoothM1andM2( SpatialDecSmoothM1andM2(
self, frame, self, frame,
ps); /* input: M1param(Real/Imag)(Prev), M2(Real/Imag)(Prev) */ ps); /* input: M1param(Real/Imag)(Prev), M2(Real/Imag)(Prev) */
/* output: M1param(Real/Imag), M2(Real/Imag) */ } /* output: M1param(Real/Imag), M2(Real/Imag) */
} }
if (bypassMode == 0) {
alpha = FX_DBL2FX_SGL(fDivNorm(ts - prevSlot, currSlot - prevSlot)); alpha = FX_DBL2FX_SGL(fDivNorm(ts - prevSlot, currSlot - prevSlot));
}
switch (mode) { switch (mode) {
case INPUTMODE_QMF_SBR: case INPUTMODE_QMF_SBR:
@ -1182,15 +1209,17 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
self->bShareDelayWithSBR = 0; /* We got no hybrid delay */ self->bShareDelayWithSBR = 0; /* We got no hybrid delay */
else else
self->bShareDelayWithSBR = 1; self->bShareDelayWithSBR = 1;
SpatialDecFeedQMF(self, qmfInDataReal, qmfInDataImag, ts_io, bypassMode, SpatialDecFeedQMF(
self, qmfInDataReal, qmfInDataImag, ts_io, bypassMode,
self->qmfInputReal__FDK, self->qmfInputImag__FDK, self->qmfInputReal__FDK, self->qmfInputImag__FDK,
self->numInputChannels); (bypassMode) ? numInputChannels : self->numInputChannels);
break; break;
case INPUTMODE_TIME: case INPUTMODE_TIME:
self->bShareDelayWithSBR = 0; self->bShareDelayWithSBR = 0;
SpatialDecQMFAnalysis(self, inData, ts_io, bypassMode, SpatialDecQMFAnalysis(
self->qmfInputReal__FDK, self->qmfInputImag__FDK, self, inData, ts_io, bypassMode, self->qmfInputReal__FDK,
self->numInputChannels); self->qmfInputImag__FDK,
(bypassMode) ? numInputChannels : self->numInputChannels);
break; break;
default: default:
break; break;
@ -1360,7 +1389,7 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
} /* !self->tempShapeConfig == 1 */ } /* !self->tempShapeConfig == 1 */
} /* !bypassMode */ } /* !bypassMode */
if (self->phaseCoding == 1) { if ((self->phaseCoding == 1) && (bypassMode == 0)) {
/* only if bsPhaseCoding == 1 and bsResidualCoding == 0 */ /* only if bsPhaseCoding == 1 and bsResidualCoding == 0 */
SpatialDecApplyPhase( SpatialDecApplyPhase(

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten © Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -700,9 +700,10 @@ bail:
SACDEC_ERROR mpegSurroundDecoder_Config( SACDEC_ERROR mpegSurroundDecoder_Config(
CMpegSurroundDecoder *pMpegSurroundDecoder, HANDLE_FDK_BITSTREAM hBs, CMpegSurroundDecoder *pMpegSurroundDecoder, HANDLE_FDK_BITSTREAM hBs,
AUDIO_OBJECT_TYPE coreCodec, INT samplingRate, INT frameSize, AUDIO_OBJECT_TYPE coreCodec, INT samplingRate, INT frameSize,
INT stereoConfigIndex, INT coreSbrFrameLengthIndex, INT configBytes, INT numChannels, INT stereoConfigIndex, INT coreSbrFrameLengthIndex,
const UCHAR configMode, UCHAR *configChanged) { INT configBytes, const UCHAR configMode, UCHAR *configChanged) {
SACDEC_ERROR err = MPS_OK; SACDEC_ERROR err = MPS_OK;
INT nInputChannels;
SPATIAL_SPECIFIC_CONFIG spatialSpecificConfig; SPATIAL_SPECIFIC_CONFIG spatialSpecificConfig;
SPATIAL_SPECIFIC_CONFIG *pSsc = SPATIAL_SPECIFIC_CONFIG *pSsc =
&pMpegSurroundDecoder->spatialSpecificConfigBackup; &pMpegSurroundDecoder->spatialSpecificConfigBackup;
@ -716,12 +717,18 @@ SACDEC_ERROR mpegSurroundDecoder_Config(
err = SpatialDecParseMps212Config( err = SpatialDecParseMps212Config(
hBs, &spatialSpecificConfig, samplingRate, coreCodec, hBs, &spatialSpecificConfig, samplingRate, coreCodec,
stereoConfigIndex, coreSbrFrameLengthIndex); stereoConfigIndex, coreSbrFrameLengthIndex);
nInputChannels = spatialSpecificConfig.nInputChannels;
pSsc = &spatialSpecificConfig; pSsc = &spatialSpecificConfig;
} else { } else {
err = SpatialDecParseMps212Config( err = SpatialDecParseMps212Config(
hBs, &pMpegSurroundDecoder->spatialSpecificConfigBackup, hBs, &pMpegSurroundDecoder->spatialSpecificConfigBackup,
samplingRate, coreCodec, stereoConfigIndex, samplingRate, coreCodec, stereoConfigIndex,
coreSbrFrameLengthIndex); coreSbrFrameLengthIndex);
nInputChannels =
pMpegSurroundDecoder->spatialSpecificConfigBackup.nInputChannels;
}
if ((err == MPS_OK) && (numChannels != nInputChannels)) {
err = MPS_PARSE_ERROR;
} }
break; break;
case AOT_ER_AAC_ELD: case AOT_ER_AAC_ELD:
@ -731,11 +738,19 @@ SACDEC_ERROR mpegSurroundDecoder_Config(
* into temporarily allocated structure */ * into temporarily allocated structure */
err = SpatialDecParseSpecificConfig(hBs, &spatialSpecificConfig, err = SpatialDecParseSpecificConfig(hBs, &spatialSpecificConfig,
configBytes, coreCodec); configBytes, coreCodec);
nInputChannels = spatialSpecificConfig.nInputChannels;
pSsc = &spatialSpecificConfig; pSsc = &spatialSpecificConfig;
} else { } else {
err = SpatialDecParseSpecificConfig( err = SpatialDecParseSpecificConfig(
hBs, &pMpegSurroundDecoder->spatialSpecificConfigBackup, hBs, &pMpegSurroundDecoder->spatialSpecificConfigBackup,
configBytes, coreCodec); configBytes, coreCodec);
nInputChannels =
pMpegSurroundDecoder->spatialSpecificConfigBackup.nInputChannels;
}
/* check number of channels for channel_configuration > 0 */
if ((err == MPS_OK) && (numChannels > 0) &&
(numChannels != nInputChannels)) {
err = MPS_PARSE_ERROR;
} }
break; break;
default: default: