1
0
mirror of https://github.com/mstorsjo/fdk-aac.git synced 2024-12-12 08:26:11 +01:00

Merge "Prevent overflow in MPEG-D DRC _setSelectionDataInfo()." am: 652432830a

am: 692cb872b3

Change-Id: I04560b0c7b756b010cd4b929c74b6343adf53fcf
This commit is contained in:
Fraunhofer IIS FDK 2018-11-27 10:14:02 -08:00 committed by android-build-merger
commit d555cedc95

View File

@ -1006,15 +1006,23 @@ static DRCDEC_SELECTION_PROCESS_RETURN _preSelectionRequirement7(
return DRCDEC_SELECTION_PROCESS_NO_ERROR;
}
static void _setSelectionDataInfo(DRCDEC_SELECTION_DATA* pData,
FIXP_DBL loudness,
FIXP_DBL loudnessNormalizationGainDb,
FIXP_DBL loudnessNormalizationGainDbMax,
FIXP_DBL loudnessDeviationMax,
FIXP_DBL signalPeakLevel,
FIXP_DBL outputPeakLevelMax,
int applyAdjustment) {
FIXP_DBL adjustment = 0;
static void _setSelectionDataInfo(
DRCDEC_SELECTION_DATA* pData, FIXP_DBL loudness, /* e = 7 */
FIXP_DBL loudnessNormalizationGainDb, /* e = 7 */
FIXP_DBL loudnessNormalizationGainDbMax, /* e = 7 */
FIXP_DBL loudnessDeviationMax, /* e = 7 */
FIXP_DBL signalPeakLevel, /* e = 7 */
FIXP_DBL outputPeakLevelMax, /* e = 7 */
int applyAdjustment) {
FIXP_DBL adjustment = 0; /* e = 8 */
/* use e = 8 for all function parameters to prevent overflow */
loudness >>= 1;
loudnessNormalizationGainDb >>= 1;
loudnessNormalizationGainDbMax >>= 1;
loudnessDeviationMax >>= 1;
signalPeakLevel >>= 1;
outputPeakLevelMax >>= 1;
if (applyAdjustment) {
adjustment =
@ -1028,6 +1036,14 @@ static void _setSelectionDataInfo(DRCDEC_SELECTION_DATA* pData,
pData->outputLoudness = loudness + pData->loudnessNormalizationGainDbAdjusted;
pData->outputPeakLevel =
signalPeakLevel + pData->loudnessNormalizationGainDbAdjusted;
/* shift back to e = 7 using saturation */
pData->loudnessNormalizationGainDbAdjusted = SATURATE_LEFT_SHIFT(
pData->loudnessNormalizationGainDbAdjusted, 1, DFRACT_BITS);
pData->outputLoudness =
SATURATE_LEFT_SHIFT(pData->outputLoudness, 1, DFRACT_BITS);
pData->outputPeakLevel =
SATURATE_LEFT_SHIFT(pData->outputPeakLevel, 1, DFRACT_BITS);
}
static int _targetLoudnessInRange(