From 6ab36997af5d5acda4f21d33031f4e45c85f96b7 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Tue, 2 Oct 2012 10:16:04 -0700 Subject: Bug 7170947 Update AAC codec From Fraunhofer: * AAC Decoder - Stick to the written MPEG standard instead of the MPEG reference software in terms of reference level normalization. Always set the program reference level equal to the target level. This disables level normalization using a default level for streams without embedded metadata. Modified file(s): libAACdec\src\aacdec_drc.cpp - Fix downmix channel assignment when using a WAV output channel ordering. Modified file(s): libPCMutils\src\pcmutils_lib.cpp - Retain signal accuracy and prevent LSB alteration when no level correction needs to be done. Modified file(s): libAACdec\src\aacdec_drc.h libAACdec\src\aacdec_drc.cpp libSBRdec\src\sbrdecoder.cpp libSBRdec\src\sbr_dec.cpp libSBRdec\src\sbrdec_drc.cpp - Align metadata processing with reference implementation. Modified file(s): libAACdec\src\aacdec_drc.h libAACdec\src\aacdecoder.cpp * AAC-Encoder - Prevent potential overflow in energy calculation after TNS processing. Modified file(s): libAACenc\src\band_nrg.cpp - Added saturation for number of relevant lines which are used in pe calculation. Modified file(s): libAACenc\src\line_pe.cpp - Removed obsolete files. Deleded file(s): libAACenc\src\tns_param.h libAACenc\src\tns_param.cpp * FDK-Library - Added x86 Count Leading Zeros intrinsic. Modified file(s): libFDK\include\clz.h Added file(s): libFDK\include\x86\clz_x86.h - Fixed compilation for MIPS GCC-4.4 and higher. Modified file(s): libFDK\include\mips\cplx_mul.h libFDK\include\mips\fixmul_mips.h Change-Id: I4be65f07f88d412224c7fddc3f054e8f451176cc --- libAACdec/src/aacdec_drc.cpp | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'libAACdec/src/aacdec_drc.cpp') diff --git a/libAACdec/src/aacdec_drc.cpp b/libAACdec/src/aacdec_drc.cpp index c660b83..ebc6975 100644 --- a/libAACdec/src/aacdec_drc.cpp +++ b/libAACdec/src/aacdec_drc.cpp @@ -220,8 +220,9 @@ AAC_DECODER_ERROR aacDecoder_drcSetParam ( else { /* ref_level must be between 0 and MAX_REFERENCE_LEVEL, inclusive */ self->digitalNorm = 1; - self->progRefLevel = AACDEC_DRC_DEFAULT_REF_LEVEL; self->params.targetRefLevel = value; + self->progRefLevel = (SCHAR)value; /* Set the program reference level equal to the target + level according to 4.5.2.7.3 of ISO/IEC 14496-3. */ } break; case APPLY_HEAVY_COMPRESSION: @@ -783,6 +784,7 @@ void aacDecoder_drcApply ( { int band, top, bin, numBands; int bottom = 0; + int modifyBins = 0; FIXP_DBL max_mantissa; INT max_exponent; @@ -937,6 +939,12 @@ void aacDecoder_drcApply ( if (fact_exponent[band] < max_exponent) { fact_mantissa[band] >>= max_exponent - fact_exponent[band]; } + if (fact_mantissa[band] != FL2FXCONST_DBL(0.5f)) { + modifyBins = 1; + } + } + if (max_exponent != 1) { + modifyBins = 1; } } @@ -948,23 +956,28 @@ void aacDecoder_drcApply ( { bottom = 0; - for (band = 0; band < numBands; band++) + if (!modifyBins) { + /* We don't have to modify the spectral bins because the fractional part of all factors is 0.5. + In order to keep accurancy we don't apply the factor but decrease the exponent instead. */ + max_exponent -= 1; + } else { - top = fixMin((int)( (pDrcChData->bandTop[band]+1)<<2 ), aacFrameSize); /* ... * DRC_BAND_MULT; */ + for (band = 0; band < numBands; band++) + { + top = fixMin((int)( (pDrcChData->bandTop[band]+1)<<2 ), aacFrameSize); /* ... * DRC_BAND_MULT; */ - for (bin = bottom; bin < top; bin++) { - pSpectralCoefficient[bin] = fMult(pSpectralCoefficient[bin], fact_mantissa[band]); - } + for (bin = bottom; bin < top; bin++) { + pSpectralCoefficient[bin] = fMult(pSpectralCoefficient[bin], fact_mantissa[band]); + } - bottom = top; + bottom = top; + } } /* above topmost DRC band gain factor is 1 */ if (max_exponent > 0) { - FIXP_DBL fact = FL2FXCONST_DBL(0.5f) >> (max_exponent - 1); - - for (bin = top; bin < aacFrameSize; bin++) { - pSpectralCoefficient[bin] = fMult(pSpectralCoefficient[bin], fact); + for (bin = bottom; bin < aacFrameSize; bin+=1) { + pSpectralCoefficient[bin] >>= max_exponent; } } @@ -980,12 +993,13 @@ void aacDecoder_drcApply ( } else { HANDLE_SBRDECODER hSbrDecoder = (HANDLE_SBRDECODER)pSbrDec; + UINT numBands = pDrcChData->numBands; /* feed factors into SBR decoder for application in QMF domain. */ sbrDecoder_drcFeedChannel ( hSbrDecoder, ch, - pDrcChData->numBands, + numBands, fact_mantissa, max_exponent, pDrcChData->drcInterpolationScheme, -- cgit v1.2.3