Merge remote-tracking branch 'aosp/master'

This commit is contained in:
Martin Storsjo 2019-10-08 14:53:07 +03:00
commit e365f4f278
32 changed files with 4644 additions and 1353 deletions

View File

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

Binary file not shown.

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -746,66 +746,77 @@ typedef enum {
::CONCEAL_INTER. only some AOTs are
supported). \n */
AAC_DRC_BOOST_FACTOR =
0x0200, /*!< Dynamic Range Control: Scaling factor for boosting gain
values. Defines how the boosting DRC factors (conveyed in the
bitstream) will be applied to the decoded signal. The valid
values range from 0 (don't apply boost factors) to 127 (fully
apply boost factors). Default value is 0. */
AAC_DRC_ATTENUATION_FACTOR =
0x0201, /*!< Dynamic Range Control: Scaling factor for attenuating gain
values. Same as
::AAC_DRC_BOOST_FACTOR but for attenuating DRC factors. */
0x0200, /*!< MPEG-4 / MPEG-D Dynamic Range Control (DRC): Scaling factor
for boosting gain values. Defines how the boosting DRC factors
(conveyed in the bitstream) will be applied to the decoded
signal. The valid values range from 0 (don't apply boost
factors) to 127 (fully apply boost factors). Default value is 0
for MPEG-4 DRC and 127 for MPEG-D DRC. */
AAC_DRC_ATTENUATION_FACTOR = 0x0201, /*!< MPEG-4 / MPEG-D DRC: Scaling factor
for attenuating gain values. Same as
::AAC_DRC_BOOST_FACTOR but for
attenuating DRC factors. */
AAC_DRC_REFERENCE_LEVEL =
0x0202, /*!< Dynamic Range Control (DRC): Target reference level. Defines
the level below full-scale (quantized in steps of 0.25dB) to
which the output audio signal will be normalized to by the DRC
module. The parameter controls loudness normalization for both
MPEG-4 DRC and MPEG-D DRC. The valid values range from 40 (-10
dBFS) to 127 (-31.75 dBFS). Any value smaller than 0 switches
off loudness normalization and MPEG-4 DRC. By default, loudness
normalization and MPEG-4 DRC is switched off. */
0x0202, /*!< MPEG-4 / MPEG-D DRC: Target reference level / decoder target
loudness.\n Defines the level below full-scale (quantized in
steps of 0.25dB) to which the output audio signal will be
normalized to by the DRC module.\n The parameter controls
loudness normalization for both MPEG-4 DRC and MPEG-D DRC. The
valid values range from 40 (-10 dBFS) to 127 (-31.75 dBFS).\n
Example values:\n
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 =
0x0203, /*!< Dynamic Range Control: En-/Disable DVB specific heavy
compression (aka RF mode). If set to 1, the decoder will apply
the compression values from the DVB specific ancillary data
field. At the same time the MPEG-4 Dynamic Range Control tool
will be disabled. By default, heavy compression is disabled. */
0x0203, /*!< MPEG-4 DRC: En-/Disable DVB specific heavy compression (aka
RF mode). If set to 1, the decoder will apply the compression
values from the DVB specific ancillary data field. At the same
time the MPEG-4 Dynamic Range Control tool will be disabled. By
default, heavy compression is disabled. */
AAC_DRC_DEFAULT_PRESENTATION_MODE =
0x0204, /*!< Dynamic Range Control: Default presentation mode (DRC
parameter handling). \n Defines the handling of the DRC
parameters boost factor, attenuation factor and heavy
compression, if no presentation mode is indicated in the
bitstream.\n For options, see
::AAC_DRC_DEFAULT_PRESENTATION_MODE_OPTIONS.\n Default:
0x0204, /*!< MPEG-4 DRC: Default presentation mode (DRC parameter
handling). \n Defines the handling of the DRC parameters boost
factor, attenuation factor and heavy compression, if no
presentation mode is indicated in the bitstream.\n For options,
see ::AAC_DRC_DEFAULT_PRESENTATION_MODE_OPTIONS.\n Default:
::AAC_DRC_PARAMETER_HANDLING_DISABLED */
AAC_DRC_ENC_TARGET_LEVEL =
0x0205, /*!< Dynamic Range Control: Encoder target level for light (i.e.
not heavy) compression.\n If known, this declares the target
reference level that was assumed at the encoder for calculation
of limiting gains. The valid values range from 0 (full-scale)
to 127 (31.75 dB below full-scale). This parameter is used only
0x0205, /*!< MPEG-4 DRC: Encoder target level for light (i.e. not heavy)
compression.\n If known, this declares the target reference
level that was assumed at the encoder for calculation of
limiting gains. The valid values range from 0 (full-scale) to
127 (31.75 dB below full-scale). This parameter is used only
with ::AAC_DRC_PARAMETER_HANDLING_ENABLED and ignored
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
mode. \n -1: Use internal default. Implies MPEG
Surround partially complex accordingly. \n 0:
Use complex QMF data mode. \n 1: Use real (low
power) QMF data mode. \n */
AAC_TPDEC_CLEAR_BUFFER =
0x0603, /*!< Clear internal bit stream buffer of transport layers. The
decoder will start decoding at new data passed after this event
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 */
0x0603 /*!< Clear internal bit stream buffer of transport layers. The
decoder will start decoding at new data passed after this event
and any previous data is discarded. */
} AACDEC_PARAM;

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -174,9 +174,9 @@ void aacDecoder_drcInit(HANDLE_AAC_DRC self) {
pParams->usrCut = FL2FXCONST_DBL(0.0f);
pParams->boost = FL2FXCONST_DBL(0.0f);
pParams->usrBoost = FL2FXCONST_DBL(0.0f);
pParams->targetRefLevel = -1;
pParams->targetRefLevel = 96;
pParams->expiryFrame = AACDEC_DRC_DFLT_EXPIRY_FRAMES;
pParams->applyDigitalNorm = OFF;
pParams->applyDigitalNorm = ON;
pParams->applyHeavyCompression = OFF;
pParams->usrApplyHeavyCompression = OFF;

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -1815,6 +1815,9 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
self->useLdQmfTimeAlign =
asc->m_sc.m_eldSpecificConfig.m_useLdQmfTimeAlign;
}
if (self->sbrEnabled != asc->m_sbrPresentFlag) {
ascChanged = 1;
}
}
self->streamInfo.extAot = asc->m_extensionAudioObjectType;

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -119,8 +119,8 @@ amm-info@iis.fraunhofer.de
/* Decoder library info */
#define AACDECODER_LIB_VL0 3
#define AACDECODER_LIB_VL1 0
#define AACDECODER_LIB_VL2 0
#define AACDECODER_LIB_VL1 1
#define AACDECODER_LIB_VL2 2
#define AACDECODER_LIB_TITLE "AAC Decoder Lib"
#ifdef __ANDROID__
#define AACDECODER_LIB_BUILD_DATE ""
@ -823,11 +823,15 @@ LINKSPEC_CPP AAC_DECODER_ERROR aacDecoder_SetParam(
case AAC_DRC_ATTENUATION_FACTOR:
/* DRC compression factor (where 0 is no and 127 is max compression) */
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;
case AAC_DRC_BOOST_FACTOR:
/* DRC boost factor (where 0 is no and 127 is max boost) */
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;
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,
(FIXP_DBL)value);
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:
errTp = transportDec_SetParam(hTpDec, TPDEC_PARAM_RESET, 1);
self->streamInfo.numLostAccessUnits = 0;
@ -1669,6 +1678,13 @@ aacDecoder_DecodeFrame(HANDLE_AACDECODER self, INT_PCM *pTimeData_extern,
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
domain signal before the QMF synthesis. Therefore the DRC gains
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)PIT_MIN_12k8;
if ((samplingRate < FAC_FSCALE_MIN) || (samplingRate > FAC_FSCALE_MAX)) {
if ((samplingRate < 6000) || (samplingRate > 24000)) {
error = AAC_DEC_PARSE_ERROR;
goto bail;
}

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -1761,6 +1761,10 @@ AACENC_ERROR aacEncEncode(const HANDLE_AACENCODER hAacEncoder,
hAacEncoder->inputBuffer +
(hAacEncoder->inputBufferOffset + hAacEncoder->nSamplesRead) /
hAacEncoder->aacConfig.nChannels;
newSamples -=
(newSamples %
hAacEncoder->extParam
.nChannels); /* process multiple samples of input channels */
/* Copy new input samples to internal buffer */
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
© 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.
1. INTRODUCTION
@ -591,13 +591,11 @@ static void FDKaacEnc_initAvoidHoleFlag(
if (sfbEn > avgEn) {
FIXP_DBL tmpMinSnrLdData;
if (psyOutChannel[ch]->lastWindowSequence == LONG_WINDOW)
tmpMinSnrLdData =
fixMax(SnrLdFac + (FIXP_DBL)(avgEnLdData - sfbEnLdData),
(FIXP_DBL)SnrLdMin1);
tmpMinSnrLdData = SnrLdFac + fixMax(avgEnLdData - sfbEnLdData,
SnrLdMin1 - SnrLdFac);
else
tmpMinSnrLdData =
fixMax(SnrLdFac + (FIXP_DBL)(avgEnLdData - sfbEnLdData),
(FIXP_DBL)SnrLdMin3);
tmpMinSnrLdData = SnrLdFac + fixMax(avgEnLdData - sfbEnLdData,
SnrLdMin3 - SnrLdFac);
qcOutChan->sfbMinSnrLdData[sfbGrp + sfb] = fixMin(
qcOutChan->sfbMinSnrLdData[sfbGrp + sfb], tmpMinSnrLdData);

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -661,6 +661,7 @@ void FDKaacEnc_IntensityStereoProcessing(
for (sfboffs = 0; sfboffs < maxSfbPerGroup; sfboffs++) {
INT sL, sR;
FIXP_DBL inv_n;
INT mdct_spec_sf = MDCT_SPEC_SF;
msMask[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(
(sfbOffset[sfb + sfboffs + 1] - sfbOffset[sfb + sfboffs]) >>
1); // scaled with 2 to compensate fMultDiv2() in subsequent loop
@ -707,11 +714,11 @@ void FDKaacEnc_IntensityStereoProcessing(
j++) {
d = ((mdctSpectrumLeft[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;
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) {
tmp = tmp >> 1;
s2 = s2 + 1;
@ -747,13 +754,13 @@ void FDKaacEnc_IntensityStereoProcessing(
j++) {
s = ((mdctSpectrumLeft[j] << s0) >> 1) +
((mdctSpectrumRight[j] << s0) >> 1);
es = fAddSaturate(es, fMultDiv2(s, s) >>
(MDCT_SPEC_SF -
1)); // scaled 2*(mdctScale - s0 + 1) + MDCT_SPEC_SF
es += fMultDiv2(s, s) >>
(mdct_spec_sf -
1); // scaled 2*(mdctScale - s0 + 1) + mdct_spec_sf
}
msMask[sfb + sfboffs] = 0;
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) {
tmp = tmp >> 1;
s2 = s2 + 1;

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -134,6 +134,7 @@ typedef enum {
DRC_DEC_EFFECT_TYPE,
DRC_DEC_EFFECT_TYPE_FALLBACK_CODE,
DRC_DEC_LOUDNESS_MEASUREMENT_METHOD,
DRC_DEC_ALBUM_MODE,
/* set only system (not user) parameters */
DRC_DEC_DOWNMIX_ID,
DRC_DEC_TARGET_CHANNEL_COUNT_REQUESTED, /**< number of output channels
@ -141,6 +142,8 @@ typedef enum {
choosing an appropriate
downmixInstruction */
DRC_DEC_BASE_CHANNEL_COUNT,
DRC_DEC_FRAME_SIZE,
DRC_DEC_SAMPLE_RATE,
/* get only system parameters */
DRC_DEC_IS_MULTIBAND_DRC_1,
DRC_DEC_IS_MULTIBAND_DRC_2,

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -173,13 +173,11 @@ static int isResetNeeded(HANDLE_DRC_DECODER hDrcDec,
return resetNeeded;
}
static DRC_DEC_ERROR startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) {
DRC_ERROR dErr = DE_OK;
DRCDEC_SELECTION_PROCESS_RETURN sErr = DRCDEC_SELECTION_PROCESS_NO_ERROR;
static void startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) {
int uniDrcConfigHasChanged = 0;
SEL_PROC_OUTPUT oldSelProcOutput = hDrcDec->selProcOutput;
if (!hDrcDec->status) return DRC_DEC_NOT_READY;
if (!hDrcDec->status) return;
if (hDrcDec->functionalRange & DRC_DEC_SELECTION) {
uniDrcConfigHasChanged = hDrcDec->uniDrcConfig.diff;
@ -189,10 +187,9 @@ static DRC_DEC_ERROR startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) {
*/
hDrcDec->selProcOutput.numSelectedDrcSets = 0;
sErr = drcDec_SelectionProcess_Process(
drcDec_SelectionProcess_Process(
hDrcDec->hSelectionProc, &(hDrcDec->uniDrcConfig),
&(hDrcDec->loudnessInfoSet), &(hDrcDec->selProcOutput));
if (sErr) return DRC_DEC_OK;
hDrcDec->selProcInputDiff = 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 (isResetNeeded(hDrcDec, oldSelProcOutput) || uniDrcConfigHasChanged) {
dErr =
drcDec_GainDecoder_Config(hDrcDec->hGainDec, &(hDrcDec->uniDrcConfig),
hDrcDec->selProcOutput.numSelectedDrcSets,
hDrcDec->selProcOutput.selectedDrcSetIds,
hDrcDec->selProcOutput.selectedDownmixIds);
if (dErr) return DRC_DEC_OK;
drcDec_GainDecoder_Config(hDrcDec->hGainDec, &(hDrcDec->uniDrcConfig),
hDrcDec->selProcOutput.numSelectedDrcSets,
hDrcDec->selProcOutput.selectedDrcSetIds,
hDrcDec->selProcOutput.selectedDownmixIds);
}
}
return DRC_DEC_OK;
}
DRC_DEC_ERROR
@ -342,7 +336,13 @@ FDK_drcDec_Init(HANDLE_DRC_DECODER hDrcDec, const int frameSize,
}
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;
}
@ -383,73 +383,99 @@ DRC_DEC_ERROR
FDK_drcDec_SetParam(HANDLE_DRC_DECODER hDrcDec,
const DRC_DEC_USERPARAM requestType,
const FIXP_DBL requestValue) {
DRC_ERROR dErr = DE_OK;
DRCDEC_SELECTION_PROCESS_RETURN sErr = DRCDEC_SELECTION_PROCESS_NO_ERROR;
int invalidParameter = 0;
if (hDrcDec == NULL) return DRC_DEC_NOT_OPENED;
if (hDrcDec->functionalRange == DRC_DEC_GAIN)
return DRC_DEC_NOT_OK; /* not supported for DRC_DEC_GAIN. All parameters are
handed over to selection process lib. */
switch (requestType) {
case DRC_DEC_BOOST:
sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc,
SEL_PROC_BOOST, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_COMPRESS:
sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc,
SEL_PROC_COMPRESS, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_LOUDNESS_NORMALIZATION_ON:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_LOUDNESS_NORMALIZATION_ON,
requestValue, &(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_TARGET_LOUDNESS:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_TARGET_LOUDNESS, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_EFFECT_TYPE:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_EFFECT_TYPE, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_DOWNMIX_ID:
sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc,
SEL_PROC_DOWNMIX_ID, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_TARGET_CHANNEL_COUNT_REQUESTED:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_TARGET_CHANNEL_COUNT, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_BASE_CHANNEL_COUNT:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_BASE_CHANNEL_COUNT, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_NOT_OK;
break;
case DRC_DEC_LOUDNESS_MEASUREMENT_METHOD:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_LOUDNESS_MEASUREMENT_METHOD,
requestValue, &(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
default:
return DRC_DEC_INVALID_PARAM;
if (hDrcDec->functionalRange & DRC_DEC_GAIN) {
switch (requestType) {
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) {
case DRC_DEC_BOOST:
sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc,
SEL_PROC_BOOST, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_COMPRESS:
sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc,
SEL_PROC_COMPRESS, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_LOUDNESS_NORMALIZATION_ON:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_LOUDNESS_NORMALIZATION_ON,
requestValue, &(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_TARGET_LOUDNESS:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_TARGET_LOUDNESS, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_EFFECT_TYPE:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_EFFECT_TYPE, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_DOWNMIX_ID:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_DOWNMIX_ID, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_TARGET_CHANNEL_COUNT_REQUESTED:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_TARGET_CHANNEL_COUNT,
requestValue, &(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
break;
case DRC_DEC_BASE_CHANNEL_COUNT:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_BASE_CHANNEL_COUNT, requestValue,
&(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_NOT_OK;
break;
case DRC_DEC_LOUDNESS_MEASUREMENT_METHOD:
sErr = drcDec_SelectionProcess_SetParam(
hDrcDec->hSelectionProc, SEL_PROC_LOUDNESS_MEASUREMENT_METHOD,
requestValue, &(hDrcDec->selProcInputDiff));
if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
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:
invalidParameter |= DRC_DEC_SELECTION;
}
}
if (invalidParameter == hDrcDec->functionalRange)
return DRC_DEC_INVALID_PARAM;
/* All parameters need a new start of the selection process */
startSelectionProcess(hDrcDec);
@ -721,9 +747,9 @@ FDK_drcDec_ReadUniDrc(HANDLE_DRC_DECODER hDrcDec,
drcDec_GainDecoder_GetFrameSize(hDrcDec->hGainDec),
drcDec_GainDecoder_GetDeltaTminDefault(hDrcDec->hGainDec),
&(hDrcDec->uniDrcGain));
if (dErr) return DRC_DEC_NOT_OK;
startSelectionProcess(hDrcDec);
if (dErr) return DRC_DEC_NOT_OK;
hDrcDec->status = DRC_DEC_NEW_GAIN_PAYLOAD;

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -170,11 +170,10 @@ drcDec_GainDecoder_Open(HANDLE_DRC_GAIN_DECODER* phGainDec) {
}
DRC_ERROR
drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize,
const int sampleRate) {
drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec) {
DRC_ERROR err = DE_OK;
err = initGainDec(hGainDec, frameSize, sampleRate);
err = initGainDec(hGainDec);
if (err) return err;
initDrcGainBuffers(hGainDec->frameSize, &hGainDec->drcGainBuffers);
@ -182,6 +181,25 @@ drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize,
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
drcDec_GainDecoder_SetCodecDependentParameters(
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
© 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.
1. INTRODUCTION
@ -134,6 +134,8 @@ typedef enum {
GAIN_DEC_DRC2_DRC3
} GAIN_DEC_LOCATION;
typedef enum { GAIN_DEC_FRAME_SIZE, GAIN_DEC_SAMPLE_RATE } GAIN_DEC_PARAM;
typedef struct {
FIXP_DBL gainLin; /* e = 7 */
SHORT time;
@ -195,8 +197,12 @@ DRC_ERROR
drcDec_GainDecoder_Open(HANDLE_DRC_GAIN_DECODER* phGainDec);
DRC_ERROR
drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize,
const int sampleRate);
drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec);
DRC_ERROR
drcDec_GainDecoder_SetParam(HANDLE_DRC_GAIN_DECODER hGainDec,
const GAIN_DEC_PARAM paramType,
const int paramValue);
DRC_ERROR
drcDec_GainDecoder_SetCodecDependentParameters(

View File

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

View File

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

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -146,6 +146,7 @@ typedef enum {
SEL_PROC_EFFECT_TYPE,
SEL_PROC_EFFECT_TYPE_FALLBACK_CODE,
SEL_PROC_LOUDNESS_MEASUREMENT_METHOD,
SEL_PROC_ALBUM_MODE,
SEL_PROC_DOWNMIX_ID,
SEL_PROC_TARGET_LAYOUT,
SEL_PROC_TARGET_CHANNEL_COUNT,

View File

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

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -184,24 +184,11 @@ static DRC_ERROR _generateDrcInstructionsDerivedData(
}
DRC_ERROR
initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize,
const int sampleRate) {
initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec) {
int i, j, k;
if (frameSize < 1) {
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;
}
/* sanity check */
if (hGainDec->deltaTminDefault > hGainDec->frameSize) return DE_NOT_OK;
for (i = 0; i < MAX_ACTIVE_DRCS; i++) {
for (j = 0; j < 8; j++) {
@ -336,9 +323,11 @@ initActiveDrcOffset(HANDLE_DRC_GAIN_DECODER hGainDec) {
for (a = 0; a < hGainDec->nActiveDrcs; a++) {
hGainDec->activeDrc[a].activeDrcOffset = accGainElementCount;
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;
}

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -104,8 +104,7 @@ amm-info@iis.fraunhofer.de
#define DRCGAINDEC_INIT_H
DRC_ERROR
initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize,
const int sampleRate);
initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec);
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
© 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.
1. INTRODUCTION
@ -123,7 +123,7 @@ void scaleValues(FIXP_DBL *dst, const FIXP_DBL *src, INT len, INT scalefactor);
#if (SAMPLE_BITS == 16)
void scaleValues(FIXP_PCM *dst, const FIXP_DBL *src, INT len, INT scalefactor);
#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,
const FIXP_DBL *i_src, INT len, INT scalefactor);
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 configMode = AC_CM_DET_CFG_CHANGE;
UCHAR tmpConf[1024];
UCHAR tmpConf[1024] = {0};
if (length > 1024) {
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 (*pOttVsTotDb2)[MAX_PARAMETER_SETS][MAX_PARAMETER_BANDS]) {
int aParamSlots[MAX_PARAMETER_SETS];
int aInterpolate[MAX_PARAMETER_SETS];
int aInterpolate[MAX_PARAMETER_SETS] = {0};
int dataSets;
int aMap[MAX_PARAMETER_BANDS + 1];
@ -1562,6 +1562,7 @@ static SACDEC_ERROR mapIndexData(
i2 = i;
while (aInterpolate[i2] == 1) {
i2++;
if (i2 >= MAX_PARAMETER_SETS) return MPS_WRONG_PARAMETERSETS;
}
x1 = paramSlot[i1];
xi = paramSlot[i];

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -474,80 +474,6 @@ static const FIXP_DBL CLD_m[N_CLD] = {
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,
FIXP_DBL opd[MAX_PARAMETER_BANDS]) {
INT band;
@ -563,12 +489,12 @@ static void calculateOpd(spatialDec* self, INT ottBoxIndx, INT parameterSetIndx,
SpatialDequantGetCLD2Values(idxCld, &cld);
/* 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);
} else {
opd[2 * band] = (dequantIPD_CLD_ICC_splitAngle__FDK_Function(
idxIpd, idxCld, idxIcc) >>
(IPD_SCALE - AT2O_SF));
FDK_ASSERT(idxIpd > 0);
opd[2 * band] =
dequantIPD_CLD_ICC_splitAngle__FDK[idxIpd - 1][idxCld][idxIcc];
}
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
© 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.
1. INTRODUCTION
@ -200,6 +200,7 @@ static void SpatialDecClearFrameData(
/* parameter smoothing tool set to off */
bsFrame->bsSmoothMode[0] = 0;
initParameterSmoothing(self);
/* 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
© 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.
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_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 dequantICC__FDK[8];
@ -160,6 +160,7 @@ extern const FIXP_CFG dequantCLD__FDK[31];
(FL2FXCONST_DBL(3.1415926535897932f / (float)(1 << (IPD_SCALE - 1))))
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 H12_nc[31][8];

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -493,7 +493,7 @@ static void mapSineFlags(
}
}
#define INTER_TES_SF_CHANGE 3
#define INTER_TES_SF_CHANGE 4
typedef struct {
FIXP_DBL subsample_power_low[(((1024) / (32) * (4) / 2) + (3 * (4)))];
@ -2325,7 +2325,15 @@ static void calcSubbandGain(
}
/* 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++;
if (((INT)sineLevel_curr | noNoiseFlag) == 0) {
signalReal +=
(fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[phaseIndex][0], sbNoise)
<< 4);
fMult(FDK_sbrDecoder_sbr_randomPhase[phaseIndex][0], sbNoise);
}
signalReal += sineLevel_curr * p_harmonicPhase[0];
signalReal =
@ -2466,8 +2473,7 @@ static void adjustTimeSlot_EldGrid(
sbNoise = *pNoiseLevel++;
if (((INT)sineLevel_curr | noNoiseFlag) == 0) {
signalReal +=
(fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[phaseIndex][0], sbNoise)
<< 4);
fMult(FDK_sbrDecoder_sbr_randomPhase[phaseIndex][0], sbNoise);
}
signalReal += sineLevel_curr * p_harmonicPhase[0];
*ptrReal++ = signalReal;
@ -2527,8 +2533,7 @@ static void adjustTimeSlotLC(
else if (!noNoiseFlag)
/* Add noisefloor to the amplified signal */
signalReal +=
(fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], pNoiseLevel[0])
<< 4);
fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], pNoiseLevel[0]);
{
if (!(harmIndex & 0x1)) {
@ -2575,9 +2580,8 @@ static void adjustTimeSlotLC(
!noNoiseFlag) {
/* Add noisefloor to the amplified signal */
index &= (SBR_NF_NO_RANDOM_VAL - 1);
signalReal += (fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0],
pNoiseLevel[0])
<< 4);
signalReal +=
fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], pNoiseLevel[0]);
}
/* The next multiplication constitutes the actual envelope adjustment of
@ -2602,9 +2606,8 @@ static void adjustTimeSlotLC(
else if (!noNoiseFlag) {
/* Add noisefloor to the amplified signal */
index &= (SBR_NF_NO_RANDOM_VAL - 1);
signalReal += (fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0],
pNoiseLevel[0])
<< 4);
signalReal +=
fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], pNoiseLevel[0]);
}
pNoiseLevel++;
@ -2633,10 +2636,8 @@ static void adjustTimeSlotLC(
else if (!noNoiseFlag) {
/* Add noisefloor to the amplified signal */
index &= (SBR_NF_NO_RANDOM_VAL - 1);
signalReal =
signalReal +
(fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], pNoiseLevel[0])
<< 4);
signalReal = signalReal + fMult(FDK_sbrDecoder_sbr_randomPhase[index][0],
pNoiseLevel[0]);
}
if (!(harmIndex & 0x1)) {
@ -2741,11 +2742,9 @@ static void adjustTimeSlotHQ_GainAndNoise(
/* Add noisefloor to the amplified signal */
index &= (SBR_NF_NO_RANDOM_VAL - 1);
noiseReal =
fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise)
<< 4;
fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise);
noiseImag =
fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise)
<< 4;
fMult(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise);
*ptrReal++ = (signalReal + noiseReal);
*ptrImag++ = (signalImag + noiseImag);
}
@ -2763,13 +2762,12 @@ static void adjustTimeSlotHQ_GainAndNoise(
smoothedNoise = noiseLevel[k];
index &= (SBR_NF_NO_RANDOM_VAL - 1);
noiseReal =
fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise);
fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise);
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 << 4;
signalImag += noiseImag << 4;
signalReal += noiseReal;
signalImag += noiseImag;
}
*ptrReal++ = signalReal;
*ptrImag++ = signalImag;
@ -2944,13 +2942,10 @@ static void adjustTimeSlotHQ(
} else {
/* Add noisefloor to the amplified signal */
index &= (SBR_NF_NO_RANDOM_VAL - 1);
/* FDK_sbrDecoder_sbr_randomPhase is downscaled by 2^3 */
noiseReal =
fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise)
<< 4;
fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise);
noiseImag =
fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise)
<< 4;
fMult(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise);
*ptrReal++ = (signalReal + noiseReal);
*ptrImag++ = (signalImag + noiseImag);
}
@ -2992,14 +2987,13 @@ static void adjustTimeSlotHQ(
/* Add noisefloor to the amplified signal */
smoothedNoise = noiseLevel[k];
index &= (SBR_NF_NO_RANDOM_VAL - 1);
noiseReal = fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][0],
smoothedNoise);
noiseImag = fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[index][1],
smoothedNoise);
noiseReal =
fMult(FDK_sbrDecoder_sbr_randomPhase[index][0], smoothedNoise);
noiseImag =
fMult(FDK_sbrDecoder_sbr_randomPhase[index][1], smoothedNoise);
/* FDK_sbrDecoder_sbr_randomPhase is downscaled by 2^3 */
signalReal += noiseReal << 4;
signalImag += noiseImag << 4;
signalReal += noiseReal;
signalImag += noiseImag;
}
}
*ptrReal++ = signalReal;

View File

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

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
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.
1. INTRODUCTION
@ -446,8 +446,26 @@ void lppTransposer(
pSettings->nCols) +
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.

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
© 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.
1. INTRODUCTION
@ -871,11 +871,10 @@ INT sbrDecoder_Header(HANDLE_SBRDECODER self, HANDLE_FDK_BITSTREAM hBs,
if (sbrError == SBRDEC_OK) {
hSbrHeader->syncState = SBR_HEADER;
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.
} */
}
}
}