Merge "UBSAN overflow in FFT"
diff --git a/libMpegTPDec/src/tpdec_lib.cpp b/libMpegTPDec/src/tpdec_lib.cpp
index 1d8b7b3..2a40187 100644
--- a/libMpegTPDec/src/tpdec_lib.cpp
+++ b/libMpegTPDec/src/tpdec_lib.cpp
@@ -736,9 +736,9 @@
hTp->parser.latm.m_audioMuxLengthBytes > 0) {
int loasOffset;
- loasOffset = (hTp->parser.latm.m_audioMuxLengthBytes * 8 +
- FDKgetValidBits(hBs)) -
- hTp->globalFramePos;
+ loasOffset = ((INT)hTp->parser.latm.m_audioMuxLengthBytes * 8 +
+ (INT)FDKgetValidBits(hBs)) -
+ (INT)hTp->globalFramePos;
if (loasOffset != 0) {
FDKpushBiDirectional(hBs, loasOffset);
/* For ELD and other payloads there is an unknown amount of padding,
@@ -871,7 +871,7 @@
int fConfigFound = (pfConfigFound != NULL) ? *pfConfigFound : 0;
int startPos;
- startPos = FDKgetValidBits(hBs);
+ startPos = (INT)FDKgetValidBits(hBs);
switch (hTp->transportFmt) {
case TT_MP4_ADTS:
@@ -941,7 +941,7 @@
fTraverseMoreFrames = 0;
}
syncLayerFrameBits = (hTp->parser.adts.bs.frame_length << 3) -
- ((INT)startPos - (INT)FDKgetValidBits(hBs)) -
+ (startPos - (INT)FDKgetValidBits(hBs)) -
syncLength;
if (syncLayerFrameBits <= 0) {
err = TRANSPORTDEC_SYNC_ERROR;
@@ -952,7 +952,7 @@
break;
case TT_MP4_LOAS:
if (hTp->numberOfRawDataBlocks <= 0) {
- syncLayerFrameBits = FDKreadBits(hBs, 13);
+ syncLayerFrameBits = (INT)FDKreadBits(hBs, 13);
hTp->parser.latm.m_audioMuxLengthBytes = syncLayerFrameBits;
syncLayerFrameBits <<= 3;
}
@@ -974,7 +974,7 @@
hTp->numberOfRawDataBlocks =
CLatmDemux_GetNrOfSubFrames(&hTp->parser.latm);
if (hTp->transportFmt == TT_MP4_LOAS) {
- syncLayerFrameBits -= startPos - FDKgetValidBits(hBs) - (13);
+ syncLayerFrameBits -= startPos - (INT)FDKgetValidBits(hBs) - (13);
}
}
} else {
diff --git a/libSACdec/src/sac_dec_lib.cpp b/libSACdec/src/sac_dec_lib.cpp
index ebf9bee..5ae89d1 100644
--- a/libSACdec/src/sac_dec_lib.cpp
+++ b/libSACdec/src/sac_dec_lib.cpp
@@ -1232,7 +1232,7 @@
FDK_ASSERT(pMpegSurroundDecoder->pSpatialDec);
- mpsBsBits = FDKgetValidBits(hBs);
+ mpsBsBits = (INT)FDKgetValidBits(hBs);
sscParse = &pMpegSurroundDecoder
->spatialSpecificConfig[pMpegSurroundDecoder->bsFrameParse];
@@ -1308,14 +1308,14 @@
pMpegSurroundDecoder->spatialSpecificConfigBackup;
/* Parse spatial specific config */
- bitsRead = FDKgetValidBits(hMpsBsData);
+ bitsRead = (INT)FDKgetValidBits(hMpsBsData);
err = SpatialDecParseSpecificConfigHeader(
hMpsBsData,
&pMpegSurroundDecoder->spatialSpecificConfigBackup, coreCodec,
pMpegSurroundDecoder->upmixType);
- bitsRead = (bitsRead - FDKgetValidBits(hMpsBsData));
+ bitsRead = (bitsRead - (INT)FDKgetValidBits(hMpsBsData));
parseResult = ((err == MPS_OK) ? bitsRead : -bitsRead);
if (parseResult < 0) {
@@ -1429,7 +1429,7 @@
bail:
- *pMpsDataBits -= (mpsBsBits - FDKgetValidBits(hBs));
+ *pMpsDataBits -= (mpsBsBits - (INT)FDKgetValidBits(hBs));
return err;
}