diff options
author | Fraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de> | 2018-12-20 15:52:46 +0100 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2019-01-03 10:25:40 -0500 |
commit | 5c54fa53876a92d4c7b923c5a6312f427cfc8c86 (patch) | |
tree | 91034718d6eb4b76b7961400707b93e964d95da9 /libSACdec/src | |
parent | 7884aefc84b56d7f805d8e84d378ab468274d3ff (diff) | |
download | fdk-aac-5c54fa53876a92d4c7b923c5a6312f427cfc8c86.tar.gz fdk-aac-5c54fa53876a92d4c7b923c5a6312f427cfc8c86.tar.bz2 fdk-aac-5c54fa53876a92d4c7b923c5a6312f427cfc8c86.zip |
Add AOT specific number of qmf bands sanity check in SpatialSpecificConfig()
Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc
Change-Id: Ic106c4371c5ac17cb832c7d9db042bcc9d1e7a09
Diffstat (limited to 'libSACdec/src')
-rw-r--r-- | libSACdec/src/sac_bitdec.cpp | 4 | ||||
-rw-r--r-- | libSACdec/src/sac_dec_lib.cpp | 138 |
2 files changed, 108 insertions, 34 deletions
diff --git a/libSACdec/src/sac_bitdec.cpp b/libSACdec/src/sac_bitdec.cpp index 1049c3d..883e1e8 100644 --- a/libSACdec/src/sac_bitdec.cpp +++ b/libSACdec/src/sac_bitdec.cpp @@ -517,6 +517,10 @@ SACDEC_ERROR SpatialDecParseSpecificConfig( pSpatialSpecificConfig->tempShapeConfig = (SPATIALDEC_TS_CONF)FDKreadBits(bitstream, 2); + if (pSpatialSpecificConfig->tempShapeConfig > 2) { + return MPS_PARSE_ERROR; /* reserved value */ + } + pSpatialSpecificConfig->decorrConfig = (SPATIALDEC_DECORR_CONF)FDKreadBits(bitstream, 2); if (pSpatialSpecificConfig->decorrConfig > 2) { diff --git a/libSACdec/src/sac_dec_lib.cpp b/libSACdec/src/sac_dec_lib.cpp index 7549e51..5792858 100644 --- a/libSACdec/src/sac_dec_lib.cpp +++ b/libSACdec/src/sac_dec_lib.cpp @@ -237,6 +237,11 @@ struct MpegSurroundDecoder { SPATIAL_DEC_CONFIG decConfig; }; +SACDEC_ERROR +static sscCheckOutOfBand(const SPATIAL_SPECIFIC_CONFIG *pSsc, + const INT coreCodec, const INT sampleRate, + const INT frameSize); + static SACDEC_ERROR sscParseCheck(const SPATIAL_SPECIFIC_CONFIG *pSsc); /** @@ -694,11 +699,13 @@ bail: **/ SACDEC_ERROR mpegSurroundDecoder_Config( CMpegSurroundDecoder *pMpegSurroundDecoder, HANDLE_FDK_BITSTREAM hBs, - AUDIO_OBJECT_TYPE coreCodec, INT samplingRate, INT stereoConfigIndex, - INT coreSbrFrameLengthIndex, INT configBytes, const UCHAR configMode, - UCHAR *configChanged) { + AUDIO_OBJECT_TYPE coreCodec, INT samplingRate, INT frameSize, + INT stereoConfigIndex, INT coreSbrFrameLengthIndex, INT configBytes, + const UCHAR configMode, UCHAR *configChanged) { SACDEC_ERROR err = MPS_OK; SPATIAL_SPECIFIC_CONFIG spatialSpecificConfig; + SPATIAL_SPECIFIC_CONFIG *pSsc = + &pMpegSurroundDecoder->spatialSpecificConfigBackup; switch (coreCodec) { case AOT_DRM_USAC: @@ -709,6 +716,7 @@ SACDEC_ERROR mpegSurroundDecoder_Config( err = SpatialDecParseMps212Config( hBs, &spatialSpecificConfig, samplingRate, coreCodec, stereoConfigIndex, coreSbrFrameLengthIndex); + pSsc = &spatialSpecificConfig; } else { err = SpatialDecParseMps212Config( hBs, &pMpegSurroundDecoder->spatialSpecificConfigBackup, @@ -723,6 +731,7 @@ SACDEC_ERROR mpegSurroundDecoder_Config( * into temporarily allocated structure */ err = SpatialDecParseSpecificConfig(hBs, &spatialSpecificConfig, configBytes, coreCodec); + pSsc = &spatialSpecificConfig; } else { err = SpatialDecParseSpecificConfig( hBs, &pMpegSurroundDecoder->spatialSpecificConfigBackup, @@ -738,14 +747,21 @@ SACDEC_ERROR mpegSurroundDecoder_Config( goto bail; } + err = sscCheckOutOfBand(pSsc, coreCodec, samplingRate, frameSize); + + if (err != MPS_OK) { + goto bail; + } + if (configMode & AC_CM_DET_CFG_CHANGE) { return err; } if (configMode & AC_CM_ALLOC_MEM) { if (*configChanged) { - if ((err = mpegSurroundDecoder_Open(&pMpegSurroundDecoder, - stereoConfigIndex, NULL))) { + err = mpegSurroundDecoder_Open(&pMpegSurroundDecoder, stereoConfigIndex, + NULL); + if (err) { return err; } } @@ -815,29 +831,9 @@ static MPEGS_OPMODE mpegSurroundOperationMode( * \return MPS_OK on sucess, and else on parse error. */ static SACDEC_ERROR sscParseCheck(const SPATIAL_SPECIFIC_CONFIG *pSsc) { - SACDEC_ERROR err = MPS_OK; - if (pSsc->samplingFreq > 96000) return MPS_PARSE_ERROR; if (pSsc->samplingFreq < 8000) return MPS_PARSE_ERROR; - switch (pSsc->freqRes) { - case SPATIALDEC_FREQ_RES_28: - case SPATIALDEC_FREQ_RES_20: - case SPATIALDEC_FREQ_RES_14: - case SPATIALDEC_FREQ_RES_10: - case SPATIALDEC_FREQ_RES_23: - case SPATIALDEC_FREQ_RES_15: - case SPATIALDEC_FREQ_RES_12: - case SPATIALDEC_FREQ_RES_9: - case SPATIALDEC_FREQ_RES_7: - case SPATIALDEC_FREQ_RES_5: - case SPATIALDEC_FREQ_RES_4: - break; - case SPATIALDEC_FREQ_RES_40: /* 40 doesn't exist in ISO/IEC 23003-1 */ - default: - return MPS_PARSE_ERROR; - } - if ((pSsc->treeConfig < 0) || (pSsc->treeConfig > 7)) { return MPS_PARSE_ERROR; } @@ -846,17 +842,9 @@ static SACDEC_ERROR sscParseCheck(const SPATIAL_SPECIFIC_CONFIG *pSsc) { return MPS_PARSE_ERROR; } - if (pSsc->tempShapeConfig == 3) { - return MPS_PARSE_ERROR; - } - - if (pSsc->decorrConfig == 3) { - return MPS_PARSE_ERROR; - } - /* now we are sure there were no parsing errors */ - return err; + return MPS_OK; } /** @@ -1024,6 +1012,11 @@ static SACDEC_ERROR sscCheckInBand(SPATIAL_SPECIFIC_CONFIG *pSsc, FDK_ASSERT(pSsc != NULL); + /* check ssc for parse errors */ + if (sscParseCheck(pSsc) != MPS_OK) { + err = MPS_PARSE_ERROR; + } + /* core fs and mps fs must match */ if (pSsc->samplingFreq != sampleRate) { err = MPS_PARSE_ERROR /* MPEGSDEC_SSC_PARSE_ERROR */; @@ -1094,6 +1087,83 @@ mpegSurroundDecoder_ConfigureQmfDomain( } /** + * \brief Check out-of-band config + * + * \param pSsc spatial specific config handle. + * \param coreCodec core codec. + * \param sampleRate sampling frequency. + * + * \return errorStatus + */ +SACDEC_ERROR +sscCheckOutOfBand(const SPATIAL_SPECIFIC_CONFIG *pSsc, const INT coreCodec, + const INT sampleRate, const INT frameSize) { + FDK_ASSERT(pSsc != NULL); + int qmfBands = 0; + + /* check ssc for parse errors */ + if (sscParseCheck(pSsc) != MPS_OK) { + return MPS_PARSE_ERROR; + } + + switch (coreCodec) { + case AOT_USAC: + case AOT_DRM_USAC: + /* ISO/IEC 23003-1:2007(E), Chapter 6.3.3, Support for lower and higher + * sampling frequencies */ + if (pSsc->samplingFreq >= 55426) { + return MPS_PARSE_ERROR; + } + break; + case AOT_ER_AAC_LD: + case AOT_ER_AAC_ELD: + /* core fs and mps fs must match */ + if (pSsc->samplingFreq != sampleRate) { + return MPS_PARSE_ERROR; + } + + /* ISO/IEC 14496-3:2009 FDAM 3: Chapter 1.5.2.3, Levels for the Low Delay + * AAC v2 profile */ + if (pSsc->samplingFreq > 48000) { + return MPS_PARSE_ERROR; + } + + qmfBands = mpegSurroundDecoder_GetNrOfQmfBands(pSsc, pSsc->samplingFreq); + switch (frameSize) { + case 480: + if (!((qmfBands == 32) && (pSsc->nTimeSlots == 15))) { + return MPS_PARSE_ERROR; + } + break; + case 960: + if (!((qmfBands == 64) && (pSsc->nTimeSlots == 15))) { + return MPS_PARSE_ERROR; + } + break; + case 512: + if (!(((qmfBands == 32) && (pSsc->nTimeSlots == 16)) || + ((qmfBands == 64) && (pSsc->nTimeSlots == 8)))) { + return MPS_PARSE_ERROR; + } + break; + case 1024: + if (!((qmfBands == 64) && (pSsc->nTimeSlots == 16))) { + return MPS_PARSE_ERROR; + } + break; + default: + return MPS_PARSE_ERROR; + } + break; + default: + return MPS_PARSE_ERROR; + break; + } + + return MPS_OK; +} + +/** * \brief Decode MPEG Surround frame. **/ int mpegSurroundDecoder_ParseNoHeader( |