Merge "DO NOT MERGE - Merge Android 10 into master"

This commit is contained in:
Xin Li 2019-09-05 16:53:26 +00:00 committed by Gerrit Code Review
commit d929f68a05
32 changed files with 4643 additions and 1352 deletions

View File

@ -30,7 +30,8 @@ cc_library_static {
"signed-integer-overflow", "signed-integer-overflow",
"bounds", "bounds",
], ],
cfi: true, // Enable CFI if this becomes a shared library.
// cfi: true,
}, },
shared_libs: [ shared_libs: [
"liblog", "liblog",

Binary file not shown.

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -741,66 +741,77 @@ typedef enum {
::CONCEAL_INTER. only some AOTs are ::CONCEAL_INTER. only some AOTs are
supported). \n */ supported). \n */
AAC_DRC_BOOST_FACTOR = AAC_DRC_BOOST_FACTOR =
0x0200, /*!< Dynamic Range Control: Scaling factor for boosting gain 0x0200, /*!< MPEG-4 / MPEG-D Dynamic Range Control (DRC): Scaling factor
values. Defines how the boosting DRC factors (conveyed in the for boosting gain values. Defines how the boosting DRC factors
bitstream) will be applied to the decoded signal. The valid (conveyed in the bitstream) will be applied to the decoded
values range from 0 (don't apply boost factors) to 127 (fully signal. The valid values range from 0 (don't apply boost
apply boost factors). Default value is 0. */ factors) to 127 (fully apply boost factors). Default value is 0
AAC_DRC_ATTENUATION_FACTOR = for MPEG-4 DRC and 127 for MPEG-D DRC. */
0x0201, /*!< Dynamic Range Control: Scaling factor for attenuating gain AAC_DRC_ATTENUATION_FACTOR = 0x0201, /*!< MPEG-4 / MPEG-D DRC: Scaling factor
values. Same as for attenuating gain values. Same as
::AAC_DRC_BOOST_FACTOR but for attenuating DRC factors. */ ::AAC_DRC_BOOST_FACTOR but for
attenuating DRC factors. */
AAC_DRC_REFERENCE_LEVEL = AAC_DRC_REFERENCE_LEVEL =
0x0202, /*!< Dynamic Range Control (DRC): Target reference level. Defines 0x0202, /*!< MPEG-4 / MPEG-D DRC: Target reference level / decoder target
the level below full-scale (quantized in steps of 0.25dB) to loudness.\n Defines the level below full-scale (quantized in
which the output audio signal will be normalized to by the DRC steps of 0.25dB) to which the output audio signal will be
module. The parameter controls loudness normalization for both normalized to by the DRC module.\n The parameter controls
MPEG-4 DRC and MPEG-D DRC. The valid values range from 40 (-10 loudness normalization for both MPEG-4 DRC and MPEG-D DRC. The
dBFS) to 127 (-31.75 dBFS). Any value smaller than 0 switches valid values range from 40 (-10 dBFS) to 127 (-31.75 dBFS).\n
off loudness normalization and MPEG-4 DRC. By default, loudness Example values:\n
normalization and MPEG-4 DRC is switched off. */ 124 (-31 dBFS) for audio/video receivers (AVR) or other
devices allowing audio playback with high dynamic range,\n 96
(-24 dBFS) for TV sets or equivalent devices (default),\n 64
(-16 dBFS) for mobile devices where the dynamic range of audio
playback is restricted.\n Any value smaller than 0 switches off
loudness normalization and MPEG-4 DRC. */
AAC_DRC_HEAVY_COMPRESSION = AAC_DRC_HEAVY_COMPRESSION =
0x0203, /*!< Dynamic Range Control: En-/Disable DVB specific heavy 0x0203, /*!< MPEG-4 DRC: En-/Disable DVB specific heavy compression (aka
compression (aka RF mode). If set to 1, the decoder will apply RF mode). If set to 1, the decoder will apply the compression
the compression values from the DVB specific ancillary data values from the DVB specific ancillary data field. At the same
field. At the same time the MPEG-4 Dynamic Range Control tool time the MPEG-4 Dynamic Range Control tool will be disabled. By
will be disabled. By default, heavy compression is disabled. */ default, heavy compression is disabled. */
AAC_DRC_DEFAULT_PRESENTATION_MODE = AAC_DRC_DEFAULT_PRESENTATION_MODE =
0x0204, /*!< Dynamic Range Control: Default presentation mode (DRC 0x0204, /*!< MPEG-4 DRC: Default presentation mode (DRC parameter
parameter handling). \n Defines the handling of the DRC handling). \n Defines the handling of the DRC parameters boost
parameters boost factor, attenuation factor and heavy factor, attenuation factor and heavy compression, if no
compression, if no presentation mode is indicated in the presentation mode is indicated in the bitstream.\n For options,
bitstream.\n For options, see see ::AAC_DRC_DEFAULT_PRESENTATION_MODE_OPTIONS.\n Default:
::AAC_DRC_DEFAULT_PRESENTATION_MODE_OPTIONS.\n Default:
::AAC_DRC_PARAMETER_HANDLING_DISABLED */ ::AAC_DRC_PARAMETER_HANDLING_DISABLED */
AAC_DRC_ENC_TARGET_LEVEL = AAC_DRC_ENC_TARGET_LEVEL =
0x0205, /*!< Dynamic Range Control: Encoder target level for light (i.e. 0x0205, /*!< MPEG-4 DRC: Encoder target level for light (i.e. not heavy)
not heavy) compression.\n If known, this declares the target compression.\n If known, this declares the target reference
reference level that was assumed at the encoder for calculation level that was assumed at the encoder for calculation of
of limiting gains. The valid values range from 0 (full-scale) limiting gains. The valid values range from 0 (full-scale) to
to 127 (31.75 dB below full-scale). This parameter is used only 127 (31.75 dB below full-scale). This parameter is used only
with ::AAC_DRC_PARAMETER_HANDLING_ENABLED and ignored with ::AAC_DRC_PARAMETER_HANDLING_ENABLED and ignored
otherwise.\n Default: 127 (worst-case assumption).\n */ otherwise.\n Default: 127 (worst-case assumption).\n */
AAC_UNIDRC_SET_EFFECT = 0x0206, /*!< MPEG-D DRC: Request a DRC effect type for
selection of a DRC set.\n Supported indices
are:\n -1: DRC off. Completely disables
MPEG-D DRC.\n 0: None (default). Disables
MPEG-D DRC, but automatically enables DRC
if necessary to prevent clipping.\n 1: Late
night\n 2: Noisy environment\n 3: Limited
playback range\n 4: Low playback level\n 5:
Dialog enhancement\n 6: General
compression. Used for generally enabling
MPEG-D DRC without particular request.\n */
AAC_UNIDRC_ALBUM_MODE =
0x0207, /*!< MPEG-D DRC: Enable album mode. 0: Disabled (default), 1:
Enabled.\n Disabled album mode leads to application of gain
sequences for fading in and out, if provided in the
bitstream.\n Enabled album mode makes use of dedicated album
loudness information, if provided in the bitstream.\n */
AAC_QMF_LOWPOWER = 0x0300, /*!< Quadrature Mirror Filter (QMF) Bank processing AAC_QMF_LOWPOWER = 0x0300, /*!< Quadrature Mirror Filter (QMF) Bank processing
mode. \n -1: Use internal default. Implies MPEG mode. \n -1: Use internal default. Implies MPEG
Surround partially complex accordingly. \n 0: Surround partially complex accordingly. \n 0:
Use complex QMF data mode. \n 1: Use real (low Use complex QMF data mode. \n 1: Use real (low
power) QMF data mode. \n */ power) QMF data mode. \n */
AAC_TPDEC_CLEAR_BUFFER = AAC_TPDEC_CLEAR_BUFFER =
0x0603, /*!< Clear internal bit stream buffer of transport layers. The 0x0603 /*!< Clear internal bit stream buffer of transport layers. The
decoder will start decoding at new data passed after this event decoder will start decoding at new data passed after this event
and any previous data is discarded. */ and any previous data is discarded. */
AAC_UNIDRC_SET_EFFECT = 0x0903 /*!< MPEG-D DRC: Request a DRC effect type for
selection of a DRC set.\n Supported indices
are:\n -1: DRC off. Completely disables
MPEG-D DRC.\n 0: None (default). Disables
MPEG-D DRC, but automatically enables DRC if
necessary to prevent clipping.\n 1: Late
night\n 2: Noisy environment\n 3: Limited
playback range\n 4: Low playback level\n 5:
Dialog enhancement\n 6: General compression.
Used for generally enabling MPEG-D DRC
without particular request.\n */
} AACDEC_PARAM; } AACDEC_PARAM;

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -174,9 +174,9 @@ void aacDecoder_drcInit(HANDLE_AAC_DRC self) {
pParams->usrCut = FL2FXCONST_DBL(0.0f); pParams->usrCut = FL2FXCONST_DBL(0.0f);
pParams->boost = FL2FXCONST_DBL(0.0f); pParams->boost = FL2FXCONST_DBL(0.0f);
pParams->usrBoost = FL2FXCONST_DBL(0.0f); pParams->usrBoost = FL2FXCONST_DBL(0.0f);
pParams->targetRefLevel = -1; pParams->targetRefLevel = 96;
pParams->expiryFrame = AACDEC_DRC_DFLT_EXPIRY_FRAMES; pParams->expiryFrame = AACDEC_DRC_DFLT_EXPIRY_FRAMES;
pParams->applyDigitalNorm = OFF; pParams->applyDigitalNorm = ON;
pParams->applyHeavyCompression = OFF; pParams->applyHeavyCompression = OFF;
pParams->usrApplyHeavyCompression = OFF; pParams->usrApplyHeavyCompression = OFF;

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -1815,6 +1815,9 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
self->useLdQmfTimeAlign = self->useLdQmfTimeAlign =
asc->m_sc.m_eldSpecificConfig.m_useLdQmfTimeAlign; asc->m_sc.m_eldSpecificConfig.m_useLdQmfTimeAlign;
} }
if (self->sbrEnabled != asc->m_sbrPresentFlag) {
ascChanged = 1;
}
} }
self->streamInfo.extAot = asc->m_extensionAudioObjectType; self->streamInfo.extAot = asc->m_extensionAudioObjectType;

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -119,8 +119,8 @@ amm-info@iis.fraunhofer.de
/* Decoder library info */ /* Decoder library info */
#define AACDECODER_LIB_VL0 3 #define AACDECODER_LIB_VL0 3
#define AACDECODER_LIB_VL1 0 #define AACDECODER_LIB_VL1 1
#define AACDECODER_LIB_VL2 0 #define AACDECODER_LIB_VL2 2
#define AACDECODER_LIB_TITLE "AAC Decoder Lib" #define AACDECODER_LIB_TITLE "AAC Decoder Lib"
#ifdef __ANDROID__ #ifdef __ANDROID__
#define AACDECODER_LIB_BUILD_DATE "" #define AACDECODER_LIB_BUILD_DATE ""
@ -823,11 +823,15 @@ LINKSPEC_CPP AAC_DECODER_ERROR aacDecoder_SetParam(
case AAC_DRC_ATTENUATION_FACTOR: case AAC_DRC_ATTENUATION_FACTOR:
/* DRC compression factor (where 0 is no and 127 is max compression) */ /* DRC compression factor (where 0 is no and 127 is max compression) */
errorStatus = aacDecoder_drcSetParam(hDrcInfo, DRC_CUT_SCALE, value); errorStatus = aacDecoder_drcSetParam(hDrcInfo, DRC_CUT_SCALE, value);
uniDrcErr = FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_COMPRESS,
value * (FL2FXCONST_DBL(0.5f / 127.0f)));
break; break;
case AAC_DRC_BOOST_FACTOR: case AAC_DRC_BOOST_FACTOR:
/* DRC boost factor (where 0 is no and 127 is max boost) */ /* DRC boost factor (where 0 is no and 127 is max boost) */
errorStatus = aacDecoder_drcSetParam(hDrcInfo, DRC_BOOST_SCALE, value); errorStatus = aacDecoder_drcSetParam(hDrcInfo, DRC_BOOST_SCALE, value);
uniDrcErr = FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_BOOST,
value * (FL2FXCONST_DBL(0.5f / 127.0f)));
break; break;
case AAC_DRC_REFERENCE_LEVEL: case AAC_DRC_REFERENCE_LEVEL:
@ -871,6 +875,11 @@ LINKSPEC_CPP AAC_DECODER_ERROR aacDecoder_SetParam(
uniDrcErr = FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_EFFECT_TYPE, uniDrcErr = FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_EFFECT_TYPE,
(FIXP_DBL)value); (FIXP_DBL)value);
break; break;
case AAC_UNIDRC_ALBUM_MODE:
uniDrcErr = FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_ALBUM_MODE,
(FIXP_DBL)value);
break;
case AAC_TPDEC_CLEAR_BUFFER: case AAC_TPDEC_CLEAR_BUFFER:
errTp = transportDec_SetParam(hTpDec, TPDEC_PARAM_RESET, 1); errTp = transportDec_SetParam(hTpDec, TPDEC_PARAM_RESET, 1);
self->streamInfo.numLostAccessUnits = 0; self->streamInfo.numLostAccessUnits = 0;
@ -1667,6 +1676,13 @@ aacDecoder_DecodeFrame(HANDLE_AACDECODER self, INT_PCM *pTimeData_extern,
reverseOutChannelMap[ch] = ch; reverseOutChannelMap[ch] = ch;
} }
/* Update sampleRate and frameSize. This may be necessary in case of
* implicit SBR signaling */
FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_SAMPLE_RATE,
self->streamInfo.sampleRate);
FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_FRAME_SIZE,
self->streamInfo.frameSize);
/* If SBR and/or MPS is active, the DRC gains are aligned to the QMF /* If SBR and/or MPS is active, the DRC gains are aligned to the QMF
domain signal before the QMF synthesis. Therefore the DRC gains domain signal before the QMF synthesis. Therefore the DRC gains
need to be delayed by the QMF synthesis delay. */ need to be delayed by the QMF synthesis delay. */

View File

@ -1222,7 +1222,7 @@ AAC_DECODER_ERROR CLpdChannelStream_Read(
(INT)(samplingRate * PIT_MIN_12k8 + (FSCALE_DENOM / 2)) / FSCALE_DENOM - (INT)(samplingRate * PIT_MIN_12k8 + (FSCALE_DENOM / 2)) / FSCALE_DENOM -
(INT)PIT_MIN_12k8; (INT)PIT_MIN_12k8;
if ((samplingRate < FAC_FSCALE_MIN) || (samplingRate > FAC_FSCALE_MAX)) { if ((samplingRate < 6000) || (samplingRate > 24000)) {
error = AAC_DEC_PARSE_ERROR; error = AAC_DEC_PARSE_ERROR;
goto bail; goto bail;
} }

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -1761,6 +1761,10 @@ AACENC_ERROR aacEncEncode(const HANDLE_AACENCODER hAacEncoder,
hAacEncoder->inputBuffer + hAacEncoder->inputBuffer +
(hAacEncoder->inputBufferOffset + hAacEncoder->nSamplesRead) / (hAacEncoder->inputBufferOffset + hAacEncoder->nSamplesRead) /
hAacEncoder->aacConfig.nChannels; hAacEncoder->aacConfig.nChannels;
newSamples -=
(newSamples %
hAacEncoder->extParam
.nChannels); /* process multiple samples of input channels */
/* Copy new input samples to internal buffer */ /* Copy new input samples to internal buffer */
if (inBufDesc->bufElSizes[idx] == (INT)sizeof(INT_PCM)) { if (inBufDesc->bufElSizes[idx] == (INT)sizeof(INT_PCM)) {

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -591,13 +591,11 @@ static void FDKaacEnc_initAvoidHoleFlag(
if (sfbEn > avgEn) { if (sfbEn > avgEn) {
FIXP_DBL tmpMinSnrLdData; FIXP_DBL tmpMinSnrLdData;
if (psyOutChannel[ch]->lastWindowSequence == LONG_WINDOW) if (psyOutChannel[ch]->lastWindowSequence == LONG_WINDOW)
tmpMinSnrLdData = tmpMinSnrLdData = SnrLdFac + fixMax(avgEnLdData - sfbEnLdData,
fixMax(SnrLdFac + (FIXP_DBL)(avgEnLdData - sfbEnLdData), SnrLdMin1 - SnrLdFac);
(FIXP_DBL)SnrLdMin1);
else else
tmpMinSnrLdData = tmpMinSnrLdData = SnrLdFac + fixMax(avgEnLdData - sfbEnLdData,
fixMax(SnrLdFac + (FIXP_DBL)(avgEnLdData - sfbEnLdData), SnrLdMin3 - SnrLdFac);
(FIXP_DBL)SnrLdMin3);
qcOutChan->sfbMinSnrLdData[sfbGrp + sfb] = fixMin( qcOutChan->sfbMinSnrLdData[sfbGrp + sfb] = fixMin(
qcOutChan->sfbMinSnrLdData[sfbGrp + sfb], tmpMinSnrLdData); qcOutChan->sfbMinSnrLdData[sfbGrp + sfb], tmpMinSnrLdData);

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -661,6 +661,7 @@ void FDKaacEnc_IntensityStereoProcessing(
for (sfboffs = 0; sfboffs < maxSfbPerGroup; sfboffs++) { for (sfboffs = 0; sfboffs < maxSfbPerGroup; sfboffs++) {
INT sL, sR; INT sL, sR;
FIXP_DBL inv_n; FIXP_DBL inv_n;
INT mdct_spec_sf = MDCT_SPEC_SF;
msMask[sfb + sfboffs] = 0; msMask[sfb + sfboffs] = 0;
if (isMask[sfb + sfboffs] == 0) { if (isMask[sfb + sfboffs] == 0) {
@ -682,6 +683,12 @@ void FDKaacEnc_IntensityStereoProcessing(
} }
} }
if (sfbOffset[sfb + sfboffs + 1] - sfbOffset[sfb + sfboffs] >
1 << mdct_spec_sf) {
mdct_spec_sf++; /* This is for rare cases where the number of bins in a
scale factor band is > 64 */
}
inv_n = GetInvInt( inv_n = GetInvInt(
(sfbOffset[sfb + sfboffs + 1] - sfbOffset[sfb + sfboffs]) >> (sfbOffset[sfb + sfboffs + 1] - sfbOffset[sfb + sfboffs]) >>
1); // scaled with 2 to compensate fMultDiv2() in subsequent loop 1); // scaled with 2 to compensate fMultDiv2() in subsequent loop
@ -707,11 +714,11 @@ void FDKaacEnc_IntensityStereoProcessing(
j++) { j++) {
d = ((mdctSpectrumLeft[j] << s0) >> 1) - d = ((mdctSpectrumLeft[j] << s0) >> 1) -
((mdctSpectrumRight[j] << s0) >> 1); ((mdctSpectrumRight[j] << s0) >> 1);
ed += fMultDiv2(d, d) >> (MDCT_SPEC_SF - 1); ed += fMultDiv2(d, d) >> (mdct_spec_sf - 1);
} }
msMask[sfb + sfboffs] = 1; msMask[sfb + sfboffs] = 1;
tmp = fDivNorm(sfbEnergyLeft[sfb + sfboffs], ed, &s1); tmp = fDivNorm(sfbEnergyLeft[sfb + sfboffs], ed, &s1);
s2 = (s1) + (2 * s0) - 2 - MDCT_SPEC_SF; s2 = (s1) + (2 * s0) - 2 - mdct_spec_sf;
if (s2 & 1) { if (s2 & 1) {
tmp = tmp >> 1; tmp = tmp >> 1;
s2 = s2 + 1; s2 = s2 + 1;
@ -748,12 +755,12 @@ void FDKaacEnc_IntensityStereoProcessing(
s = ((mdctSpectrumLeft[j] << s0) >> 1) + s = ((mdctSpectrumLeft[j] << s0) >> 1) +
((mdctSpectrumRight[j] << s0) >> 1); ((mdctSpectrumRight[j] << s0) >> 1);
es += fMultDiv2(s, s) >> es += fMultDiv2(s, s) >>
(MDCT_SPEC_SF - (mdct_spec_sf -
1); // scaled 2*(mdctScale - s0 + 1) + MDCT_SPEC_SF 1); // scaled 2*(mdctScale - s0 + 1) + mdct_spec_sf
} }
msMask[sfb + sfboffs] = 0; msMask[sfb + sfboffs] = 0;
tmp = fDivNorm(sfbEnergyLeft[sfb + sfboffs], es, &s1); tmp = fDivNorm(sfbEnergyLeft[sfb + sfboffs], es, &s1);
s2 = (s1) + (2 * s0) - 2 - MDCT_SPEC_SF; s2 = (s1) + (2 * s0) - 2 - mdct_spec_sf;
if (s2 & 1) { if (s2 & 1) {
tmp = tmp >> 1; tmp = tmp >> 1;
s2 = s2 + 1; s2 = s2 + 1;

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -134,6 +134,7 @@ typedef enum {
DRC_DEC_EFFECT_TYPE, DRC_DEC_EFFECT_TYPE,
DRC_DEC_EFFECT_TYPE_FALLBACK_CODE, DRC_DEC_EFFECT_TYPE_FALLBACK_CODE,
DRC_DEC_LOUDNESS_MEASUREMENT_METHOD, DRC_DEC_LOUDNESS_MEASUREMENT_METHOD,
DRC_DEC_ALBUM_MODE,
/* set only system (not user) parameters */ /* set only system (not user) parameters */
DRC_DEC_DOWNMIX_ID, DRC_DEC_DOWNMIX_ID,
DRC_DEC_TARGET_CHANNEL_COUNT_REQUESTED, /**< number of output channels DRC_DEC_TARGET_CHANNEL_COUNT_REQUESTED, /**< number of output channels
@ -141,6 +142,8 @@ typedef enum {
choosing an appropriate choosing an appropriate
downmixInstruction */ downmixInstruction */
DRC_DEC_BASE_CHANNEL_COUNT, DRC_DEC_BASE_CHANNEL_COUNT,
DRC_DEC_FRAME_SIZE,
DRC_DEC_SAMPLE_RATE,
/* get only system parameters */ /* get only system parameters */
DRC_DEC_IS_MULTIBAND_DRC_1, DRC_DEC_IS_MULTIBAND_DRC_1,
DRC_DEC_IS_MULTIBAND_DRC_2, DRC_DEC_IS_MULTIBAND_DRC_2,

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -173,13 +173,11 @@ static int isResetNeeded(HANDLE_DRC_DECODER hDrcDec,
return resetNeeded; return resetNeeded;
} }
static DRC_DEC_ERROR startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) { static void startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) {
DRC_ERROR dErr = DE_OK;
DRCDEC_SELECTION_PROCESS_RETURN sErr = DRCDEC_SELECTION_PROCESS_NO_ERROR;
int uniDrcConfigHasChanged = 0; int uniDrcConfigHasChanged = 0;
SEL_PROC_OUTPUT oldSelProcOutput = hDrcDec->selProcOutput; SEL_PROC_OUTPUT oldSelProcOutput = hDrcDec->selProcOutput;
if (!hDrcDec->status) return DRC_DEC_NOT_READY; if (!hDrcDec->status) return;
if (hDrcDec->functionalRange & DRC_DEC_SELECTION) { if (hDrcDec->functionalRange & DRC_DEC_SELECTION) {
uniDrcConfigHasChanged = hDrcDec->uniDrcConfig.diff; uniDrcConfigHasChanged = hDrcDec->uniDrcConfig.diff;
@ -189,10 +187,9 @@ static DRC_DEC_ERROR startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) {
*/ */
hDrcDec->selProcOutput.numSelectedDrcSets = 0; hDrcDec->selProcOutput.numSelectedDrcSets = 0;
sErr = drcDec_SelectionProcess_Process( drcDec_SelectionProcess_Process(
hDrcDec->hSelectionProc, &(hDrcDec->uniDrcConfig), hDrcDec->hSelectionProc, &(hDrcDec->uniDrcConfig),
&(hDrcDec->loudnessInfoSet), &(hDrcDec->selProcOutput)); &(hDrcDec->loudnessInfoSet), &(hDrcDec->selProcOutput));
if (sErr) return DRC_DEC_OK;
hDrcDec->selProcInputDiff = 0; hDrcDec->selProcInputDiff = 0;
hDrcDec->uniDrcConfig.diff = 0; hDrcDec->uniDrcConfig.diff = 0;
@ -202,15 +199,12 @@ static DRC_DEC_ERROR startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) {
if (hDrcDec->functionalRange & DRC_DEC_GAIN) { if (hDrcDec->functionalRange & DRC_DEC_GAIN) {
if (isResetNeeded(hDrcDec, oldSelProcOutput) || uniDrcConfigHasChanged) { if (isResetNeeded(hDrcDec, oldSelProcOutput) || uniDrcConfigHasChanged) {
dErr =
drcDec_GainDecoder_Config(hDrcDec->hGainDec, &(hDrcDec->uniDrcConfig), drcDec_GainDecoder_Config(hDrcDec->hGainDec, &(hDrcDec->uniDrcConfig),
hDrcDec->selProcOutput.numSelectedDrcSets, hDrcDec->selProcOutput.numSelectedDrcSets,
hDrcDec->selProcOutput.selectedDrcSetIds, hDrcDec->selProcOutput.selectedDrcSetIds,
hDrcDec->selProcOutput.selectedDownmixIds); hDrcDec->selProcOutput.selectedDownmixIds);
if (dErr) return DRC_DEC_OK;
} }
} }
return DRC_DEC_OK;
} }
DRC_DEC_ERROR DRC_DEC_ERROR
@ -342,7 +336,13 @@ FDK_drcDec_Init(HANDLE_DRC_DECODER hDrcDec, const int frameSize,
} }
if (hDrcDec->functionalRange & DRC_DEC_GAIN) { if (hDrcDec->functionalRange & DRC_DEC_GAIN) {
dErr = drcDec_GainDecoder_Init(hDrcDec->hGainDec, frameSize, sampleRate); dErr = drcDec_GainDecoder_SetParam(hDrcDec->hGainDec, GAIN_DEC_FRAME_SIZE,
frameSize);
if (dErr) return DRC_DEC_NOT_OK;
dErr = drcDec_GainDecoder_SetParam(hDrcDec->hGainDec, GAIN_DEC_SAMPLE_RATE,
sampleRate);
if (dErr) return DRC_DEC_NOT_OK;
dErr = drcDec_GainDecoder_Init(hDrcDec->hGainDec);
if (dErr) return DRC_DEC_NOT_OK; if (dErr) return DRC_DEC_NOT_OK;
} }
@ -383,14 +383,30 @@ DRC_DEC_ERROR
FDK_drcDec_SetParam(HANDLE_DRC_DECODER hDrcDec, FDK_drcDec_SetParam(HANDLE_DRC_DECODER hDrcDec,
const DRC_DEC_USERPARAM requestType, const DRC_DEC_USERPARAM requestType,
const FIXP_DBL requestValue) { const FIXP_DBL requestValue) {
DRC_ERROR dErr = DE_OK;
DRCDEC_SELECTION_PROCESS_RETURN sErr = DRCDEC_SELECTION_PROCESS_NO_ERROR; DRCDEC_SELECTION_PROCESS_RETURN sErr = DRCDEC_SELECTION_PROCESS_NO_ERROR;
int invalidParameter = 0;
if (hDrcDec == NULL) return DRC_DEC_NOT_OPENED; if (hDrcDec == NULL) return DRC_DEC_NOT_OPENED;
if (hDrcDec->functionalRange == DRC_DEC_GAIN) if (hDrcDec->functionalRange & DRC_DEC_GAIN) {
return DRC_DEC_NOT_OK; /* not supported for DRC_DEC_GAIN. All parameters are switch (requestType) {
handed over to selection process lib. */ case DRC_DEC_SAMPLE_RATE:
dErr = drcDec_GainDecoder_SetParam(
hDrcDec->hGainDec, GAIN_DEC_SAMPLE_RATE, (int)requestValue);
if (dErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_FRAME_SIZE:
dErr = drcDec_GainDecoder_SetParam(
hDrcDec->hGainDec, GAIN_DEC_FRAME_SIZE, (int)requestValue);
if (dErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
default:
invalidParameter |= DRC_DEC_GAIN;
}
}
if (hDrcDec->functionalRange & DRC_DEC_SELECTION) {
switch (requestType) { switch (requestType) {
case DRC_DEC_BOOST: case DRC_DEC_BOOST:
sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc, sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc,
@ -423,15 +439,15 @@ FDK_drcDec_SetParam(HANDLE_DRC_DECODER hDrcDec,
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break; break;
case DRC_DEC_DOWNMIX_ID: case DRC_DEC_DOWNMIX_ID:
sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc, sErr = drcDec_SelectionProcess_SetParam(
SEL_PROC_DOWNMIX_ID, requestValue, hDrcDec->hSelectionProc, SEL_PROC_DOWNMIX_ID, requestValue,
&(hDrcDec->selProcInputDiff)); &(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break; break;
case DRC_DEC_TARGET_CHANNEL_COUNT_REQUESTED: case DRC_DEC_TARGET_CHANNEL_COUNT_REQUESTED:
sErr = drcDec_SelectionProcess_SetParam( sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_TARGET_CHANNEL_COUNT, requestValue, hDrcDec->hSelectionProc, SEL_PROC_TARGET_CHANNEL_COUNT,
&(hDrcDec->selProcInputDiff)); requestValue, &(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break; break;
case DRC_DEC_BASE_CHANNEL_COUNT: case DRC_DEC_BASE_CHANNEL_COUNT:
@ -446,9 +462,19 @@ FDK_drcDec_SetParam(HANDLE_DRC_DECODER hDrcDec,
requestValue, &(hDrcDec->selProcInputDiff)); requestValue, &(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break; break;
case DRC_DEC_ALBUM_MODE:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_ALBUM_MODE, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
default: default:
return DRC_DEC_INVALID_PARAM; invalidParameter |= DRC_DEC_SELECTION;
} }
}
if (invalidParameter == hDrcDec->functionalRange)
return DRC_DEC_INVALID_PARAM;
/* All parameters need a new start of the selection process */ /* All parameters need a new start of the selection process */
startSelectionProcess(hDrcDec); startSelectionProcess(hDrcDec);
@ -721,9 +747,9 @@ FDK_drcDec_ReadUniDrc(HANDLE_DRC_DECODER hDrcDec,
drcDec_GainDecoder_GetFrameSize(hDrcDec->hGainDec), drcDec_GainDecoder_GetFrameSize(hDrcDec->hGainDec),
drcDec_GainDecoder_GetDeltaTminDefault(hDrcDec->hGainDec), drcDec_GainDecoder_GetDeltaTminDefault(hDrcDec->hGainDec),
&(hDrcDec->uniDrcGain)); &(hDrcDec->uniDrcGain));
if (dErr) return DRC_DEC_NOT_OK;
startSelectionProcess(hDrcDec); startSelectionProcess(hDrcDec);
if (dErr) return DRC_DEC_NOT_OK;
hDrcDec->status = DRC_DEC_NEW_GAIN_PAYLOAD; hDrcDec->status = DRC_DEC_NEW_GAIN_PAYLOAD;

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -170,11 +170,10 @@ drcDec_GainDecoder_Open(HANDLE_DRC_GAIN_DECODER* phGainDec) {
} }
DRC_ERROR DRC_ERROR
drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize, drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec) {
const int sampleRate) {
DRC_ERROR err = DE_OK; DRC_ERROR err = DE_OK;
err = initGainDec(hGainDec, frameSize, sampleRate); err = initGainDec(hGainDec);
if (err) return err; if (err) return err;
initDrcGainBuffers(hGainDec->frameSize, &hGainDec->drcGainBuffers); initDrcGainBuffers(hGainDec->frameSize, &hGainDec->drcGainBuffers);
@ -182,6 +181,25 @@ drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize,
return err; return err;
} }
DRC_ERROR
drcDec_GainDecoder_SetParam(HANDLE_DRC_GAIN_DECODER hGainDec,
const GAIN_DEC_PARAM paramType,
const int paramValue) {
switch (paramType) {
case GAIN_DEC_FRAME_SIZE:
if (paramValue < 0) return DE_PARAM_OUT_OF_RANGE;
hGainDec->frameSize = paramValue;
break;
case GAIN_DEC_SAMPLE_RATE:
if (paramValue < 0) return DE_PARAM_OUT_OF_RANGE;
hGainDec->deltaTminDefault = getDeltaTmin(paramValue);
break;
default:
return DE_PARAM_INVALID;
}
return DE_OK;
}
DRC_ERROR DRC_ERROR
drcDec_GainDecoder_SetCodecDependentParameters( drcDec_GainDecoder_SetCodecDependentParameters(
HANDLE_DRC_GAIN_DECODER hGainDec, const DELAY_MODE delayMode, HANDLE_DRC_GAIN_DECODER hGainDec, const DELAY_MODE delayMode,

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -134,6 +134,8 @@ typedef enum {
GAIN_DEC_DRC2_DRC3 GAIN_DEC_DRC2_DRC3
} GAIN_DEC_LOCATION; } GAIN_DEC_LOCATION;
typedef enum { GAIN_DEC_FRAME_SIZE, GAIN_DEC_SAMPLE_RATE } GAIN_DEC_PARAM;
typedef struct { typedef struct {
FIXP_DBL gainLin; /* e = 7 */ FIXP_DBL gainLin; /* e = 7 */
SHORT time; SHORT time;
@ -195,8 +197,12 @@ DRC_ERROR
drcDec_GainDecoder_Open(HANDLE_DRC_GAIN_DECODER* phGainDec); drcDec_GainDecoder_Open(HANDLE_DRC_GAIN_DECODER* phGainDec);
DRC_ERROR DRC_ERROR
drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize, drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec);
const int sampleRate);
DRC_ERROR
drcDec_GainDecoder_SetParam(HANDLE_DRC_GAIN_DECODER hGainDec,
const GAIN_DEC_PARAM paramType,
const int paramValue);
DRC_ERROR DRC_ERROR
drcDec_GainDecoder_SetCodecDependentParameters( drcDec_GainDecoder_SetCodecDependentParameters(

View File

@ -185,10 +185,18 @@ drcDec_readUniDrc(HANDLE_FDK_BITSTREAM hBs, HANDLE_UNI_DRC_CONFIG hUniDrcConfig,
uniDrcConfigPresent = FDKreadBits(hBs, 1); uniDrcConfigPresent = FDKreadBits(hBs, 1);
if (uniDrcConfigPresent) { if (uniDrcConfigPresent) {
err = drcDec_readUniDrcConfig(hBs, hUniDrcConfig); err = drcDec_readUniDrcConfig(hBs, hUniDrcConfig);
if (err) return err; if (err) {
/* clear config, if parsing error occured */
FDKmemclear(hUniDrcConfig, sizeof(UNI_DRC_CONFIG));
hUniDrcConfig->diff = 1;
}
} }
err = drcDec_readLoudnessInfoSet(hBs, hLoudnessInfoSet); err = drcDec_readLoudnessInfoSet(hBs, hLoudnessInfoSet);
if (err) return err; if (err) {
/* clear config, if parsing error occured */
FDKmemclear(hLoudnessInfoSet, sizeof(LOUDNESS_INFO_SET));
hLoudnessInfoSet->diff = 1;
}
} }
if (hUniDrcGain != NULL) { if (hUniDrcGain != NULL) {
@ -1130,7 +1138,7 @@ static DRC_ERROR _readDrcCoefficientsUniDrc(HANDLE_FDK_BITSTREAM hBs,
drcCharacteristicLeftPresent = FDKreadBits(hBs, 1); drcCharacteristicLeftPresent = FDKreadBits(hBs, 1);
if (drcCharacteristicLeftPresent) { if (drcCharacteristicLeftPresent) {
pCoef->characteristicLeftCount = FDKreadBits(hBs, 4); pCoef->characteristicLeftCount = FDKreadBits(hBs, 4);
if ((pCoef->characteristicLeftCount + 1) > 8) return DE_MEMORY_ERROR; if ((pCoef->characteristicLeftCount + 1) > 16) return DE_MEMORY_ERROR;
for (i = 0; i < pCoef->characteristicLeftCount; i++) { for (i = 0; i < pCoef->characteristicLeftCount; i++) {
err = _readCustomDrcCharacteristic( err = _readCustomDrcCharacteristic(
hBs, CS_LEFT, &(pCoef->characteristicLeftFormat[i + 1]), hBs, CS_LEFT, &(pCoef->characteristicLeftFormat[i + 1]),
@ -1141,7 +1149,7 @@ static DRC_ERROR _readDrcCoefficientsUniDrc(HANDLE_FDK_BITSTREAM hBs,
drcCharacteristicRightPresent = FDKreadBits(hBs, 1); drcCharacteristicRightPresent = FDKreadBits(hBs, 1);
if (drcCharacteristicRightPresent) { if (drcCharacteristicRightPresent) {
pCoef->characteristicRightCount = FDKreadBits(hBs, 4); pCoef->characteristicRightCount = FDKreadBits(hBs, 4);
if ((pCoef->characteristicRightCount + 1) > 8) return DE_MEMORY_ERROR; if ((pCoef->characteristicRightCount + 1) > 16) return DE_MEMORY_ERROR;
for (i = 0; i < pCoef->characteristicRightCount; i++) { for (i = 0; i < pCoef->characteristicRightCount; i++) {
err = _readCustomDrcCharacteristic( err = _readCustomDrcCharacteristic(
hBs, CS_RIGHT, &(pCoef->characteristicRightFormat[i + 1]), hBs, CS_RIGHT, &(pCoef->characteristicRightFormat[i + 1]),

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -555,6 +555,11 @@ drcDec_SelectionProcess_SetParam(HANDLE_DRC_SELECTION_PROCESS hInstance,
diff |= _compAssign(&pSelProcInput->loudnessMeasurementMethod, diff |= _compAssign(&pSelProcInput->loudnessMeasurementMethod,
requestValueInt); requestValueInt);
break; break;
case SEL_PROC_ALBUM_MODE:
if ((requestValueInt < 0) || (requestValueInt > 1))
return DRCDEC_SELECTION_PROCESS_PARAM_OUT_OF_RANGE;
diff |= _compAssign(&pSelProcInput->albumMode, requestValueInt);
break;
case SEL_PROC_DOWNMIX_ID: case SEL_PROC_DOWNMIX_ID:
diff |= diff |=
_compAssign(&pSelProcInput->targetConfigRequestType, TCRT_DOWNMIX_ID); _compAssign(&pSelProcInput->targetConfigRequestType, TCRT_DOWNMIX_ID);
@ -598,14 +603,21 @@ drcDec_SelectionProcess_SetParam(HANDLE_DRC_SELECTION_PROCESS hInstance,
if ((requestValue < (FIXP_DBL)0) || if ((requestValue < (FIXP_DBL)0) ||
(requestValue > FL2FXCONST_DBL(1.0f / (float)(1 << 1)))) (requestValue > FL2FXCONST_DBL(1.0f / (float)(1 << 1))))
return DRCDEC_SELECTION_PROCESS_PARAM_OUT_OF_RANGE; return DRCDEC_SELECTION_PROCESS_PARAM_OUT_OF_RANGE;
diff |= _compAssign(&pSelProcInput->boost, FX_DBL2FX_SGL(requestValue)); diff |= _compAssign(
&pSelProcInput->boost,
FX_DBL2FX_SGL(
requestValue +
(FIXP_DBL)(1 << 15))); /* convert to FIXP_SGL with rounding */
break; break;
case SEL_PROC_COMPRESS: case SEL_PROC_COMPRESS:
if ((requestValue < (FIXP_DBL)0) || if ((requestValue < (FIXP_DBL)0) ||
(requestValue > FL2FXCONST_DBL(1.0f / (float)(1 << 1)))) (requestValue > FL2FXCONST_DBL(1.0f / (float)(1 << 1))))
return DRCDEC_SELECTION_PROCESS_PARAM_OUT_OF_RANGE; return DRCDEC_SELECTION_PROCESS_PARAM_OUT_OF_RANGE;
diff |= diff |= _compAssign(
_compAssign(&pSelProcInput->compress, FX_DBL2FX_SGL(requestValue)); &pSelProcInput->compress,
FX_DBL2FX_SGL(
requestValue +
(FIXP_DBL)(1 << 15))); /* convert to FIXP_SGL with rounding */
break; break;
default: default:
return DRCDEC_SELECTION_PROCESS_INVALID_PARAM; return DRCDEC_SELECTION_PROCESS_INVALID_PARAM;
@ -2173,6 +2185,9 @@ static DRCDEC_SELECTION_PROCESS_RETURN _selectDownmixMatrix(
if (hSelProcOutput->activeDownmixId != 0) { if (hSelProcOutput->activeDownmixId != 0) {
for (i = 0; i < hUniDrcConfig->downmixInstructionsCount; i++) { for (i = 0; i < hUniDrcConfig->downmixInstructionsCount; i++) {
DOWNMIX_INSTRUCTIONS* pDown = &(hUniDrcConfig->downmixInstructions[i]); DOWNMIX_INSTRUCTIONS* pDown = &(hUniDrcConfig->downmixInstructions[i]);
if (pDown->targetChannelCount > 8) {
continue;
}
if (hSelProcOutput->activeDownmixId == pDown->downmixId) { if (hSelProcOutput->activeDownmixId == pDown->downmixId) {
hSelProcOutput->targetChannelCount = pDown->targetChannelCount; hSelProcOutput->targetChannelCount = pDown->targetChannelCount;
@ -2825,6 +2840,8 @@ static int _downmixCoefficientsArePresent(HANDLE_UNI_DRC_CONFIG hUniDrcConfig,
for (i = 0; i < hUniDrcConfig->downmixInstructionsCount; i++) { for (i = 0; i < hUniDrcConfig->downmixInstructionsCount; i++) {
if (hUniDrcConfig->downmixInstructions[i].downmixId == downmixId) { if (hUniDrcConfig->downmixInstructions[i].downmixId == downmixId) {
if (hUniDrcConfig->downmixInstructions[i].downmixCoefficientsPresent) { if (hUniDrcConfig->downmixInstructions[i].downmixCoefficientsPresent) {
if (hUniDrcConfig->downmixInstructions[i].targetChannelCount > 8)
return 0;
*pIndex = i; *pIndex = i;
return 1; return 1;
} }

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -146,6 +146,7 @@ typedef enum {
SEL_PROC_EFFECT_TYPE, SEL_PROC_EFFECT_TYPE,
SEL_PROC_EFFECT_TYPE_FALLBACK_CODE, SEL_PROC_EFFECT_TYPE_FALLBACK_CODE,
SEL_PROC_LOUDNESS_MEASUREMENT_METHOD, SEL_PROC_LOUDNESS_MEASUREMENT_METHOD,
SEL_PROC_ALBUM_MODE,
SEL_PROC_DOWNMIX_ID, SEL_PROC_DOWNMIX_ID,
SEL_PROC_TARGET_LAYOUT, SEL_PROC_TARGET_LAYOUT,
SEL_PROC_TARGET_CHANNEL_COUNT, SEL_PROC_TARGET_CHANNEL_COUNT,

View File

@ -249,11 +249,11 @@ typedef struct {
UCHAR drcFrameSizePresent; UCHAR drcFrameSizePresent;
USHORT drcFrameSize; USHORT drcFrameSize;
UCHAR characteristicLeftCount; UCHAR characteristicLeftCount;
UCHAR characteristicLeftFormat[8]; UCHAR characteristicLeftFormat[16];
CUSTOM_DRC_CHAR customCharacteristicLeft[8]; CUSTOM_DRC_CHAR customCharacteristicLeft[16];
UCHAR characteristicRightCount; UCHAR characteristicRightCount;
UCHAR characteristicRightFormat[8]; UCHAR characteristicRightFormat[16];
CUSTOM_DRC_CHAR customCharacteristicRight[8]; CUSTOM_DRC_CHAR customCharacteristicRight[16];
UCHAR UCHAR
gainSequenceCount; /* unsaturated value, i.e. as provided in bitstream */ gainSequenceCount; /* unsaturated value, i.e. as provided in bitstream */
UCHAR gainSetCount; /* saturated to 12 */ UCHAR gainSetCount; /* saturated to 12 */

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -184,24 +184,11 @@ static DRC_ERROR _generateDrcInstructionsDerivedData(
} }
DRC_ERROR DRC_ERROR
initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize, initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec) {
const int sampleRate) {
int i, j, k; int i, j, k;
if (frameSize < 1) { /* sanity check */
return DE_NOT_OK; if (hGainDec->deltaTminDefault > hGainDec->frameSize) return DE_NOT_OK;
}
hGainDec->frameSize = frameSize;
if (hGainDec->frameSize * 1000 < sampleRate) {
return DE_NOT_OK;
}
hGainDec->deltaTminDefault = getDeltaTmin(sampleRate);
if (hGainDec->deltaTminDefault > hGainDec->frameSize) {
return DE_NOT_OK;
}
for (i = 0; i < MAX_ACTIVE_DRCS; i++) { for (i = 0; i < MAX_ACTIVE_DRCS; i++) {
for (j = 0; j < 8; j++) { for (j = 0; j < 8; j++) {
@ -336,9 +323,11 @@ initActiveDrcOffset(HANDLE_DRC_GAIN_DECODER hGainDec) {
for (a = 0; a < hGainDec->nActiveDrcs; a++) { for (a = 0; a < hGainDec->nActiveDrcs; a++) {
hGainDec->activeDrc[a].activeDrcOffset = accGainElementCount; hGainDec->activeDrc[a].activeDrcOffset = accGainElementCount;
accGainElementCount += hGainDec->activeDrc[a].gainElementCount; accGainElementCount += hGainDec->activeDrc[a].gainElementCount;
if (accGainElementCount > 12) {
hGainDec->nActiveDrcs = a;
return DE_NOT_OK;
}
} }
if (accGainElementCount > 12) return DE_NOT_OK;
return DE_OK; return DE_OK;
} }

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -104,8 +104,7 @@ amm-info@iis.fraunhofer.de
#define DRCGAINDEC_INIT_H #define DRCGAINDEC_INIT_H
DRC_ERROR DRC_ERROR
initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize, initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec);
const int sampleRate);
void initDrcGainBuffers(const int frameSize, DRC_GAIN_BUFFERS* drcGainBuffers); void initDrcGainBuffers(const int frameSize, DRC_GAIN_BUFFERS* drcGainBuffers);

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -123,7 +123,7 @@ void scaleValues(FIXP_DBL *dst, const FIXP_DBL *src, INT len, INT scalefactor);
#if (SAMPLE_BITS == 16) #if (SAMPLE_BITS == 16)
void scaleValues(FIXP_PCM *dst, const FIXP_DBL *src, INT len, INT scalefactor); void scaleValues(FIXP_PCM *dst, const FIXP_DBL *src, INT len, INT scalefactor);
#endif #endif
void scaleValues(FIXP_PCM *dst, const FIXP_SGL *src, INT len, INT scalefactor); void scaleValues(FIXP_SGL *dst, const FIXP_SGL *src, INT len, INT scalefactor);
void scaleCplxValues(FIXP_DBL *r_dst, FIXP_DBL *i_dst, const FIXP_DBL *r_src, void scaleCplxValues(FIXP_DBL *r_dst, FIXP_DBL *i_dst, const FIXP_DBL *r_src,
const FIXP_DBL *i_src, INT len, INT scalefactor); const FIXP_DBL *i_src, INT len, INT scalefactor);
void scaleValuesWithFactor(FIXP_DBL *vector, FIXP_DBL factor, INT len, void scaleValuesWithFactor(FIXP_DBL *vector, FIXP_DBL factor, INT len,

View File

@ -274,7 +274,7 @@ TRANSPORTDEC_ERROR transportDec_OutOfBandConfig(HANDLE_TRANSPORTDEC hTp,
UCHAR configChanged = 0; UCHAR configChanged = 0;
UCHAR configMode = AC_CM_DET_CFG_CHANGE; UCHAR configMode = AC_CM_DET_CFG_CHANGE;
UCHAR tmpConf[1024]; UCHAR tmpConf[1024] = {0};
if (length > 1024) { if (length > 1024) {
return TRANSPORTDEC_UNSUPPORTED_FORMAT; return TRANSPORTDEC_UNSUPPORTED_FORMAT;
} }

View File

@ -1457,7 +1457,7 @@ static SACDEC_ERROR mapIndexData(
FIXP_DBL (*pOttVsTotDb1)[MAX_PARAMETER_SETS][MAX_PARAMETER_BANDS], FIXP_DBL (*pOttVsTotDb1)[MAX_PARAMETER_SETS][MAX_PARAMETER_BANDS],
FIXP_DBL (*pOttVsTotDb2)[MAX_PARAMETER_SETS][MAX_PARAMETER_BANDS]) { FIXP_DBL (*pOttVsTotDb2)[MAX_PARAMETER_SETS][MAX_PARAMETER_BANDS]) {
int aParamSlots[MAX_PARAMETER_SETS]; int aParamSlots[MAX_PARAMETER_SETS];
int aInterpolate[MAX_PARAMETER_SETS]; int aInterpolate[MAX_PARAMETER_SETS] = {0};
int dataSets; int dataSets;
int aMap[MAX_PARAMETER_BANDS + 1]; int aMap[MAX_PARAMETER_BANDS + 1];
@ -1562,6 +1562,7 @@ static SACDEC_ERROR mapIndexData(
i2 = i; i2 = i;
while (aInterpolate[i2] == 1) { while (aInterpolate[i2] == 1) {
i2++; i2++;
if (i2 >= MAX_PARAMETER_SETS) return MPS_WRONG_PARAMETERSETS;
} }
x1 = paramSlot[i1]; x1 = paramSlot[i1];
xi = paramSlot[i]; xi = paramSlot[i];

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -474,80 +474,6 @@ static const FIXP_DBL CLD_m[N_CLD] = {
FL2FXCONST_DBL(0.888178419700125), FL2FXCONST_DBL(0.888178419700125),
}; };
static FIXP_DBL dequantIPD_CLD_ICC_splitAngle__FDK_Function(INT ipdIdx,
INT cldIdx,
INT iccIdx) {
FIXP_DBL cld;
SpatialDequantGetCLD2Values(cldIdx, &cld);
/*const FIXP_DBL one_m = (FIXP_DBL)MAXVAL_DBL;
const int one_e = 0;*/
const FIXP_DBL one_m = FL2FXCONST_DBL(0.5f);
const int one_e = 1;
/* iidLin = sqrt(cld); */
FIXP_DBL iidLin_m = sqrt_CLD_m[cldIdx];
int iidLin_e = sqrt_CLD_e[cldIdx];
/* iidLin2 = cld; */
FIXP_DBL iidLin2_m = CLD_m[cldIdx];
int iidLin2_e = sqrt_CLD_e[cldIdx] << 1;
/* iidLin21 = iidLin2 + 1.0f; */
int iidLin21_e;
FIXP_DBL iidLin21_m =
fAddNorm(iidLin2_m, iidLin2_e, one_m, one_e, &iidLin21_e);
/* iidIcc2 = iidLin * icc * 2.0f; */
FIXP_CFG icc = dequantICC__FDK[iccIdx];
FIXP_DBL temp1_m, temp1c_m;
int temp1_e, temp1c_e;
temp1_m = fMult(iidLin_m, icc);
temp1_e = iidLin_e + 1;
FIXP_DBL cosIpd, sinIpd;
cosIpd = COS_IPD(ipdIdx);
sinIpd = SIN_IPD(ipdIdx);
temp1c_m = fMult(temp1_m, cosIpd);
temp1c_e = temp1_e; //+cosIpd_e;
int temp2_e, temp3_e, inv_temp3_e, ratio_e;
FIXP_DBL temp2_m =
fAddNorm(iidLin21_m, iidLin21_e, temp1c_m, temp1c_e, &temp2_e);
FIXP_DBL temp3_m =
fAddNorm(iidLin21_m, iidLin21_e, temp1_m, temp1_e, &temp3_e);
/* calculate 1/temp3 needed later */
inv_temp3_e = temp3_e;
FIXP_DBL inv_temp3_m = invFixp(temp3_m, &inv_temp3_e);
FIXP_DBL ratio_m =
fAddNorm(fMult(inv_temp3_m, temp2_m), (inv_temp3_e + temp2_e),
FL2FXCONST_DBL(1e-9f), 0, &ratio_e);
int weight2_e, tempb_atan2_e;
FIXP_DBL weight2_m =
fPow(ratio_m, ratio_e, FL2FXCONST_DBL(0.5f), -1, &weight2_e);
/* atan2(w2*sinIpd, w1*iidLin + w2*cosIpd) = atan2(w2*sinIpd, (2 - w2)*iidLin
* + w2*cosIpd) = atan2(w2*sinIpd, 2*iidLin + w2*(cosIpd - iidLin)); */
/* tmpa_atan2 = w2*sinIpd; tmpb_atan2 = 2*iidLin + w2*(cosIpd - iidLin); */
FIXP_DBL tempb_atan2_m = iidLin_m;
tempb_atan2_e = iidLin_e + 1;
int add_tmp1_e = 0;
FIXP_DBL add_tmp1_m = fAddNorm(cosIpd, 0, -iidLin_m, iidLin_e, &add_tmp1_e);
FIXP_DBL add_tmp2_m = fMult(add_tmp1_m, weight2_m);
int add_tmp2_e = add_tmp1_e + weight2_e;
tempb_atan2_m = fAddNorm(tempb_atan2_m, tempb_atan2_e, add_tmp2_m, add_tmp2_e,
&tempb_atan2_e);
FIXP_DBL tempa_atan2_m = fMult(weight2_m, sinIpd);
int tempa_atan2_e = weight2_e; // + sinIpd_e;
if (tempa_atan2_e > tempb_atan2_e) {
tempb_atan2_m = (tempb_atan2_m >> (tempa_atan2_e - tempb_atan2_e));
tempb_atan2_e = tempa_atan2_e;
} else if (tempb_atan2_e > tempa_atan2_e) {
tempa_atan2_m = (tempa_atan2_m >> (tempb_atan2_e - tempa_atan2_e));
}
return fixp_atan2(tempa_atan2_m, tempb_atan2_m);
}
static void calculateOpd(spatialDec* self, INT ottBoxIndx, INT parameterSetIndx, static void calculateOpd(spatialDec* self, INT ottBoxIndx, INT parameterSetIndx,
FIXP_DBL opd[MAX_PARAMETER_BANDS]) { FIXP_DBL opd[MAX_PARAMETER_BANDS]) {
INT band; INT band;
@ -563,12 +489,12 @@ static void calculateOpd(spatialDec* self, INT ottBoxIndx, INT parameterSetIndx,
SpatialDequantGetCLD2Values(idxCld, &cld); SpatialDequantGetCLD2Values(idxCld, &cld);
/* ipd(idxIpd==8) == PI */ /* ipd(idxIpd==8) == PI */
if ((cld == FL2FXCONST_DBL(0.0f)) && (idxIpd == 8)) { if (((cld == FL2FXCONST_DBL(0.0f)) && (idxIpd == 8)) || (idxIpd == 0)) {
opd[2 * band] = FL2FXCONST_DBL(0.0f); opd[2 * band] = FL2FXCONST_DBL(0.0f);
} else { } else {
opd[2 * band] = (dequantIPD_CLD_ICC_splitAngle__FDK_Function( FDK_ASSERT(idxIpd > 0);
idxIpd, idxCld, idxIcc) >> opd[2 * band] =
(IPD_SCALE - AT2O_SF)); dequantIPD_CLD_ICC_splitAngle__FDK[idxIpd - 1][idxCld][idxIcc];
} }
opd[2 * band + 1] = opd[2 * band] - ipd; opd[2 * band + 1] = opd[2 * band] - ipd;
} }

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -200,6 +200,7 @@ static void SpatialDecClearFrameData(
/* parameter smoothing tool set to off */ /* parameter smoothing tool set to off */
bsFrame->bsSmoothMode[0] = 0; bsFrame->bsSmoothMode[0] = 0;
initParameterSmoothing(self);
/* reset residual data */ /* reset residual data */
{ {

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -147,7 +147,7 @@ amm-info@iis.fraunhofer.de
#define CLIP_PROTECT_GAIN_1(x) FL2FXCONST_CFG(((x) / (float)(1 << 1))) #define CLIP_PROTECT_GAIN_1(x) FL2FXCONST_CFG(((x) / (float)(1 << 1)))
#define CLIP_PROTECT_GAIN_2(x) FL2FXCONST_CFG(((x) / (float)(1 << 2))) #define CLIP_PROTECT_GAIN_2(x) FL2FXCONST_CFG(((x) / (float)(1 << 2)))
#define SF_CLD_C1C2 (8) #define SF_CLD_C1C2 (9)
extern const FIXP_CFG dequantCPC__FDK[]; extern const FIXP_CFG dequantCPC__FDK[];
extern const FIXP_CFG dequantICC__FDK[8]; extern const FIXP_CFG dequantICC__FDK[8];
@ -160,6 +160,7 @@ extern const FIXP_CFG dequantCLD__FDK[31];
(FL2FXCONST_DBL(3.1415926535897932f / (float)(1 << (IPD_SCALE - 1)))) (FL2FXCONST_DBL(3.1415926535897932f / (float)(1 << (IPD_SCALE - 1))))
extern const FIXP_CFG dequantIPD__FDK[16]; extern const FIXP_CFG dequantIPD__FDK[16];
extern const FIXP_DBL dequantIPD_CLD_ICC_splitAngle__FDK[15][31][8];
extern const FIXP_CFG H11_nc[31][8]; extern const FIXP_CFG H11_nc[31][8];
extern const FIXP_CFG H12_nc[31][8]; extern const FIXP_CFG H12_nc[31][8];

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -493,7 +493,7 @@ static void mapSineFlags(
} }
} }
#define INTER_TES_SF_CHANGE 3 #define INTER_TES_SF_CHANGE 4
typedef struct { typedef struct {
FIXP_DBL subsample_power_low[(((1024) / (32) * (4) / 2) + (3 * (4)))]; FIXP_DBL subsample_power_low[(((1024) / (32) * (4) / 2) + (3 * (4)))];
@ -2325,7 +2325,15 @@ static void calcSubbandGain(
} }
/* gain = nrgRef / B */ /* gain = nrgRef / B */
FDK_divide_MantExp(nrgRef, nrgRef_e, b, b_e, ptrNrgGain, ptrNrgGain_e); INT result_exp = 0;
*ptrNrgGain = fDivNorm(nrgRef, b, &result_exp);
*ptrNrgGain_e = (SCHAR)result_exp + (nrgRef_e - b_e);
/* There could be a one bit diffs. This is important to compensate,
because later in the code values are compared by exponent only. */
int headroom = CountLeadingBits(*ptrNrgGain);
*ptrNrgGain <<= headroom;
*ptrNrgGain_e -= headroom;
} }
} }
@ -2431,8 +2439,7 @@ static void adjustTimeSlot_EldGrid(
sbNoise = *pNoiseLevel++; sbNoise = *pNoiseLevel++;
if (((INT)sineLevel_curr | noNoiseFlag) == 0) { if (((INT)sineLevel_curr | noNoiseFlag) == 0) {
signalReal += signalReal +=
(fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[phaseIndex][0], sbNoise) fMult(FDK_sbrDecoder_sbr_randomPhase[phaseIndex][0], sbNoise);
<< 4);
} }
signalReal += sineLevel_curr * p_harmonicPhase[0]; signalReal += sineLevel_curr * p_harmonicPhase[0];
signalReal = signalReal =
@ -2466,8 +2473,7 @@ static void adjustTimeSlot_EldGrid(
sbNoise = *pNoiseLevel++; sbNoise = *pNoiseLevel++;
if (((INT)sineLevel_curr | noNoiseFlag) == 0) { if (((INT)sineLevel_curr | noNoiseFlag) == 0) {
signalReal += signalReal +=
(fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[phaseIndex][0], sbNoise) fMult(FDK_sbrDecoder_sbr_randomPhase[phaseIndex][0], sbNoise);
<< 4);
} }
signalReal += sineLevel_curr * p_harmonicPhase[0]; signalReal += sineLevel_curr * p_harmonicPhase[0];
*ptrReal++ = signalReal; *ptrReal++ = signalReal;
@ -2527,8 +2533,7 @@ static void adjustTimeSlotLC(
else if (!noNoiseFlag) else if (!noNoiseFlag)
/* Add noisefloor to the amplified signal */ /* Add noisefloor to the amplified signal */
signalReal += signalReal +=
(fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], pNoiseLevel[0]) fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], pNoiseLevel[0]);
<< 4);
{ {
if (!(harmIndex & 0x1)) { if (!(harmIndex & 0x1)) {
@ -2575,9 +2580,8 @@ static void adjustTimeSlotLC(
!noNoiseFlag) { !noNoiseFlag) {
/* Add noisefloor to the amplified signal */ /* Add noisefloor to the amplified signal */
index &= (SBR_NF_NO_RANDOM_VAL - 1); index &= (SBR_NF_NO_RANDOM_VAL - 1);
signalReal += (fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], signalReal +=
pNoiseLevel[0]) fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], pNoiseLevel[0]);
<< 4);
} }
/* The next multiplication constitutes the actual envelope adjustment of /* The next multiplication constitutes the actual envelope adjustment of
@ -2602,9 +2606,8 @@ static void adjustTimeSlotLC(
else if (!noNoiseFlag) { else if (!noNoiseFlag) {
/* Add noisefloor to the amplified signal */ /* Add noisefloor to the amplified signal */
index &= (SBR_NF_NO_RANDOM_VAL - 1); index &= (SBR_NF_NO_RANDOM_VAL - 1);
signalReal += (fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], signalReal +=
pNoiseLevel[0]) fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], pNoiseLevel[0]);
<< 4);
} }
pNoiseLevel++; pNoiseLevel++;
@ -2633,10 +2636,8 @@ static void adjustTimeSlotLC(
else if (!noNoiseFlag) { else if (!noNoiseFlag) {
/* Add noisefloor to the amplified signal */ /* Add noisefloor to the amplified signal */
index &= (SBR_NF_NO_RANDOM_VAL - 1); index &= (SBR_NF_NO_RANDOM_VAL - 1);
signalReal = signalReal = signalReal + fMult(FDK_sbrDecoder_sbr_randomPhase[index][0],
signalReal + pNoiseLevel[0]);
(fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], pNoiseLevel[0])
<< 4);
} }
if (!(harmIndex & 0x1)) { if (!(harmIndex & 0x1)) {
@ -2741,11 +2742,9 @@ static void adjustTimeSlotHQ_GainAndNoise(
/* Add noisefloor to the amplified signal */ /* Add noisefloor to the amplified signal */
index &= (SBR_NF_NO_RANDOM_VAL - 1); index &= (SBR_NF_NO_RANDOM_VAL - 1);
noiseReal = noiseReal =
fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise) fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise);
<< 4;
noiseImag = noiseImag =
fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise) fMult(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise);
<< 4;
*ptrReal++ = (signalReal + noiseReal); *ptrReal++ = (signalReal + noiseReal);
*ptrImag++ = (signalImag + noiseImag); *ptrImag++ = (signalImag + noiseImag);
} }
@ -2763,13 +2762,12 @@ static void adjustTimeSlotHQ_GainAndNoise(
smoothedNoise = noiseLevel[k]; smoothedNoise = noiseLevel[k];
index &= (SBR_NF_NO_RANDOM_VAL - 1); index &= (SBR_NF_NO_RANDOM_VAL - 1);
noiseReal = noiseReal =
fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise); fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise);
noiseImag = noiseImag =
fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise); fMult(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise);
/* FDK_sbrDecoder_sbr_randomPhase is downscaled by 2^3 */ signalReal += noiseReal;
signalReal += noiseReal << 4; signalImag += noiseImag;
signalImag += noiseImag << 4;
} }
*ptrReal++ = signalReal; *ptrReal++ = signalReal;
*ptrImag++ = signalImag; *ptrImag++ = signalImag;
@ -2944,13 +2942,10 @@ static void adjustTimeSlotHQ(
} else { } else {
/* Add noisefloor to the amplified signal */ /* Add noisefloor to the amplified signal */
index &= (SBR_NF_NO_RANDOM_VAL - 1); index &= (SBR_NF_NO_RANDOM_VAL - 1);
/* FDK_sbrDecoder_sbr_randomPhase is downscaled by 2^3 */
noiseReal = noiseReal =
fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise) fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise);
<< 4;
noiseImag = noiseImag =
fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise) fMult(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise);
<< 4;
*ptrReal++ = (signalReal + noiseReal); *ptrReal++ = (signalReal + noiseReal);
*ptrImag++ = (signalImag + noiseImag); *ptrImag++ = (signalImag + noiseImag);
} }
@ -2992,14 +2987,13 @@ static void adjustTimeSlotHQ(
/* Add noisefloor to the amplified signal */ /* Add noisefloor to the amplified signal */
smoothedNoise = noiseLevel[k]; smoothedNoise = noiseLevel[k];
index &= (SBR_NF_NO_RANDOM_VAL - 1); index &= (SBR_NF_NO_RANDOM_VAL - 1);
noiseReal = fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], noiseReal =
smoothedNoise); fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise);
noiseImag = fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][1], noiseImag =
smoothedNoise); fMult(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise);
/* FDK_sbrDecoder_sbr_randomPhase is downscaled by 2^3 */ signalReal += noiseReal;
signalReal += noiseReal << 4; signalImag += noiseImag;
signalImag += noiseImag << 4;
} }
} }
*ptrReal++ = signalReal; *ptrReal++ = signalReal;

View File

@ -1152,6 +1152,10 @@ static int generateFixFixOnly(FRAME_INFO *hSbrFrameInfo, int tranPosInternal,
int nEnv, i, tranIdx; int nEnv, i, tranIdx;
const int *pTable; const int *pTable;
if (tranPosInternal >= numberTimeSlots) {
return 0;
}
switch (numberTimeSlots) { switch (numberTimeSlots) {
case 8: case 8:
pTable = FDK_sbrDecoder_envelopeTable_8[tranPosInternal]; pTable = FDK_sbrDecoder_envelopeTable_8[tranPosInternal];

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -446,8 +446,26 @@ void lppTransposer(
pSettings->nCols) + pSettings->nCols) +
lowBandShift); lowBandShift);
} }
dynamicScale = fixMax(
0, dynamicScale - 1); /* one additional bit headroom to prevent -1.0 */ if (dynamicScale == 0) {
/* In this special case the available headroom bits as well as
ovLowBandShift and lowBandShift are zero. The spectrum is limited to
prevent -1.0, so negative values for dynamicScale can be avoided. */
for (i = 0; i < (LPC_ORDER + pSettings->overlap + pSettings->nCols);
i++) {
lowBandReal[i] = fixMax(lowBandReal[i], (FIXP_DBL)0x80000001);
}
if (!useLP) {
for (i = 0; i < (LPC_ORDER + pSettings->overlap + pSettings->nCols);
i++) {
lowBandImag[i] = fixMax(lowBandImag[i], (FIXP_DBL)0x80000001);
}
}
} else {
dynamicScale =
fixMax(0, dynamicScale -
1); /* one additional bit headroom to prevent -1.0 */
}
/* /*
Scale temporal QMF buffer. Scale temporal QMF buffer.

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -871,11 +871,10 @@ INT sbrDecoder_Header(HANDLE_SBRDECODER self, HANDLE_FDK_BITSTREAM hBs,
if (sbrError == SBRDEC_OK) { if (sbrError == SBRDEC_OK) {
hSbrHeader->syncState = SBR_HEADER; hSbrHeader->syncState = SBR_HEADER;
hSbrHeader->status |= SBRDEC_HDR_STAT_UPDATE; hSbrHeader->status |= SBRDEC_HDR_STAT_UPDATE;
} else {
hSbrHeader->syncState = SBR_NOT_INITIALIZED;
hSbrHeader->status = HEADER_ERROR;
} }
/* else {
Since we already have overwritten the old SBR header the only way out
is UPSAMPLING! This will be prepared in the next step.
} */
} }
} }
} }