aboutsummaryrefslogtreecommitdiffstats
path: root/fdk-aac/libAACdec/src/aacdec_hcr.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2021-06-01 14:42:00 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2021-06-01 14:42:00 +0200
commite0835d4cbde8e3b61b0c965afcd41f8f4b7ac121 (patch)
treef49619fc806249da71afaf2ac14f99e088d24153 /fdk-aac/libAACdec/src/aacdec_hcr.cpp
parent5ad4acef6721a67b8156cd6f7b45ad59849ca09b (diff)
downloadODR-AudioEnc-e0835d4cbde8e3b61b0c965afcd41f8f4b7ac121.tar.gz
ODR-AudioEnc-e0835d4cbde8e3b61b0c965afcd41f8f4b7ac121.tar.bz2
ODR-AudioEnc-e0835d4cbde8e3b61b0c965afcd41f8f4b7ac121.zip
Update fdk to v2.0.2
Diffstat (limited to 'fdk-aac/libAACdec/src/aacdec_hcr.cpp')
-rw-r--r--fdk-aac/libAACdec/src/aacdec_hcr.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/fdk-aac/libAACdec/src/aacdec_hcr.cpp b/fdk-aac/libAACdec/src/aacdec_hcr.cpp
index 26fdd97..a7e9cce 100644
--- a/fdk-aac/libAACdec/src/aacdec_hcr.cpp
+++ b/fdk-aac/libAACdec/src/aacdec_hcr.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -137,7 +137,7 @@ static void DeriveNumberOfExtendedSortedSectionsInSets(
static INT DecodeEscapeSequence(HANDLE_FDK_BITSTREAM bs, const INT bsAnchor,
INT quantSpecCoef, INT *pLeftStartOfSegment,
SCHAR *pRemainingBitsInSegment,
- int *pNumDecodedBits);
+ int *pNumDecodedBits, UINT *errorWord);
static int DecodePCW_Sign(HANDLE_FDK_BITSTREAM bs, const INT bsAnchor,
UINT codebookDim, const SCHAR *pQuantVal,
@@ -1179,8 +1179,8 @@ static void DecodePCWs(HANDLE_FDK_BITSTREAM bs, H_HCR_INFO pHcr) {
bs, pHcr->decInOut.bitstreamAnchor,
pQuantizedSpectralCoefficients
[quantizedSpectralCoefficientsIdx],
- pLeftStartOfSegment, pRemainingBitsInSegment,
- &numDecodedBits);
+ pLeftStartOfSegment, pRemainingBitsInSegment, &numDecodedBits,
+ &pHcr->decInOut.errorLog);
}
quantizedSpectralCoefficientsIdx++;
if (quantizedSpectralCoefficientsIdx >= 1024) {
@@ -1195,8 +1195,8 @@ static void DecodePCWs(HANDLE_FDK_BITSTREAM bs, H_HCR_INFO pHcr) {
bs, pHcr->decInOut.bitstreamAnchor,
pQuantizedSpectralCoefficients
[quantizedSpectralCoefficientsIdx],
- pLeftStartOfSegment, pRemainingBitsInSegment,
- &numDecodedBits);
+ pLeftStartOfSegment, pRemainingBitsInSegment, &numDecodedBits,
+ &pHcr->decInOut.errorLog);
}
quantizedSpectralCoefficientsIdx++;
if (quantizedSpectralCoefficientsIdx >= 1024) {
@@ -1386,7 +1386,7 @@ value == 16, a escapeSequence is decoded in two steps:
static INT DecodeEscapeSequence(HANDLE_FDK_BITSTREAM bs, const INT bsAnchor,
INT quantSpecCoef, INT *pLeftStartOfSegment,
SCHAR *pRemainingBitsInSegment,
- int *pNumDecodedBits) {
+ int *pNumDecodedBits, UINT *errorWord) {
UINT i;
INT sign;
UINT escapeOnesCounter = 0;
@@ -1400,6 +1400,9 @@ static INT DecodeEscapeSequence(HANDLE_FDK_BITSTREAM bs, const INT bsAnchor,
FROM_LEFT_TO_RIGHT);
*pRemainingBitsInSegment -= 1;
*pNumDecodedBits += 1;
+ if (*pRemainingBitsInSegment < 0) {
+ return Q_VALUE_INVALID;
+ }
if (carryBit != 0) {
escapeOnesCounter += 1;
@@ -1416,6 +1419,9 @@ static INT DecodeEscapeSequence(HANDLE_FDK_BITSTREAM bs, const INT bsAnchor,
FROM_LEFT_TO_RIGHT);
*pRemainingBitsInSegment -= 1;
*pNumDecodedBits += 1;
+ if (*pRemainingBitsInSegment < 0) {
+ return Q_VALUE_INVALID;
+ }
escape_word <<= 1;
escape_word = escape_word | carryBit;
@@ -1423,11 +1429,12 @@ static INT DecodeEscapeSequence(HANDLE_FDK_BITSTREAM bs, const INT bsAnchor,
sign = (quantSpecCoef >= 0) ? 1 : -1;
- if (escapeOnesCounter > 30)
- escapeOnesCounter = 30;
-
- quantSpecCoef = sign * (((INT)1 << escapeOnesCounter) + escape_word);
-
+ if (escapeOnesCounter < 13) {
+ quantSpecCoef = sign * (((INT)1 << escapeOnesCounter) + escape_word);
+ } else {
+ *errorWord |= TOO_MANY_PCW_BODY_SIGN_ESC_BITS_DECODED;
+ quantSpecCoef = Q_VALUE_INVALID;
+ }
return quantSpecCoef;
}