From 0c2c08aef6849fdec71cae4d769c6cd3dd86303d Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 17 Apr 2020 15:08:00 +0200 Subject: [PATCH] Read uniDrcGainExtension element only if all DRC gain sequences are parsed correctly. Prevent error return during parsing of incomplete uniDrcGain() element. This fixes unnecessary concealment of frames for AAC in case a uniDrcGain() is provided, but the uniDrcConfig() element is not available. Bug: 176246647 Test: atest android.media.cts.DecoderTestAacFormat android.media.cts.DecoderTestXheAac android.media.cts.DecoderTestAacDrc Change-Id: I5ae343eaea481774c53240dbce4da0f4ff06cd1d --- libDRCdec/src/drcDec_reader.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libDRCdec/src/drcDec_reader.cpp b/libDRCdec/src/drcDec_reader.cpp index 367a352..b3ec187 100644 --- a/libDRCdec/src/drcDec_reader.cpp +++ b/libDRCdec/src/drcDec_reader.cpp @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- 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. 1. INTRODUCTION @@ -512,10 +512,13 @@ drcDec_readUniDrcGain(HANDLE_FDK_BITSTREAM hBs, fMin(tmpNNodes, (UCHAR)16) * sizeof(GAIN_NODE)); } - hUniDrcGain->uniDrcGainExtPresent = FDKreadBits(hBs, 1); - if (hUniDrcGain->uniDrcGainExtPresent == 1) { - err = _readUniDrcGainExtension(hBs, &(hUniDrcGain->uniDrcGainExtension)); - if (err) return err; + if (pCoef && (gainSequenceCount == + pCoef->gainSequenceCount)) { /* all sequences have been read */ + hUniDrcGain->uniDrcGainExtPresent = FDKreadBits(hBs, 1); + if (hUniDrcGain->uniDrcGainExtPresent == 1) { + err = _readUniDrcGainExtension(hBs, &(hUniDrcGain->uniDrcGainExtension)); + if (err) return err; + } } if (err == DE_OK && gainSequenceCount > 0) {