aboutsummaryrefslogtreecommitdiffstats
path: root/libAACdec/src/aacdecoder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libAACdec/src/aacdecoder.cpp')
-rw-r--r--libAACdec/src/aacdecoder.cpp49
1 files changed, 24 insertions, 25 deletions
diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp
index f747b2d..6a0254d 100644
--- a/libAACdec/src/aacdecoder.cpp
+++ b/libAACdec/src/aacdecoder.cpp
@@ -1281,6 +1281,7 @@ LINKSPEC_CPP HANDLE_AACDECODER CAacDecoder_Open(
/* Set default frame delay */
aacDecoder_drcSetParam(self->hDrcInfo, DRC_BS_DELAY,
CConcealment_GetDelay(&self->concealCommonData));
+ self->workBufferCore1 = (FIXP_DBL *)GetWorkBufferCore1();
self->workBufferCore2 = GetWorkBufferCore2();
if (self->workBufferCore2 == NULL) goto bail;
@@ -1456,6 +1457,10 @@ LINKSPEC_CPP void CAacDecoder_Close(HANDLE_AACDECODER self) {
FreeDrcInfo(&self->hDrcInfo);
}
+ if (self->workBufferCore1 != NULL) {
+ FreeWorkBufferCore1((CWorkBufferCore1 **)&self->workBufferCore1);
+ }
+
/* Free WorkBufferCore2 */
if (self->workBufferCore2 != NULL) {
FreeWorkBufferCore2(&self->workBufferCore2);
@@ -1493,6 +1498,8 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
UCHAR downscaleFactor = self->downscaleFactor;
UCHAR downscaleFactorInBS = self->downscaleFactorInBS;
+ self->aacOutDataHeadroom = (3);
+
// set profile and check for supported aot
// leave profile on default (=-1) for all other supported MPEG-4 aot's except
// aot=2 (=AAC-LC)
@@ -2394,7 +2401,7 @@ bail:
}
LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
- HANDLE_AACDECODER self, const UINT flags, FIXP_PCM *pTimeData,
+ HANDLE_AACDECODER self, const UINT flags, PCM_DEC *pTimeData,
const INT timeDataSize, const int timeDataChannelOffset) {
AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK;
@@ -3170,10 +3177,8 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
FDKmemcpy(drcChMap, self->chMapping, (8) * sizeof(UCHAR));
}
- /* Turn on/off DRC modules level normalization in digital domain depending
- * on the limiter status. */
- aacDecoder_drcSetParam(self->hDrcInfo, APPLY_NORMALIZATION,
- (self->limiterEnableCurr) ? 0 : 1);
+ /* Turn off DRC modules level normalization in digital domain. */
+ aacDecoder_drcSetParam(self->hDrcInfo, APPLY_NORMALIZATION, 0);
/* deactivate legacy DRC in case uniDrc is active, i.e. uniDrc payload is
* present and one of DRC or Loudness Normalization is switched on */
@@ -3325,9 +3330,11 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
&pAacDecoderStaticChannelInfo->drcData);
}
}
+
/* The DRC module demands to be called with the gain field holding the
* gain scale. */
- self->extGain[0] = (FIXP_DBL)TDL_GAIN_SCALING;
+ self->extGain[0] = (FIXP_DBL)AACDEC_DRC_GAIN_SCALING;
+
/* DRC processing */
aacDecoder_drcApply(
self->hDrcInfo, self->hSbrDecoder, pAacDecoderChannelInfo,
@@ -3343,7 +3350,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
if (self->flushStatus && (self->flushCnt > 0) &&
!(flags & AACDEC_CONCEAL)) {
FDKmemclear(pTimeData + offset,
- sizeof(FIXP_PCM) * self->streamInfo.aacSamplesPerFrame);
+ sizeof(PCM_DEC) * self->streamInfo.aacSamplesPerFrame);
} else
switch (pAacDecoderChannelInfo->renderMode) {
case AACDEC_RENDER_IMDCT:
@@ -3355,7 +3362,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
!frameOk_butConceal),
pAacDecoderChannelInfo->pComStaticData->pWorkBufferCore1
->mdctOutTemp,
- self->elFlags[el], elCh);
+ self->aacOutDataHeadroom, self->elFlags[el], elCh);
self->extGainDelay = self->streamInfo.aacSamplesPerFrame;
break;
@@ -3376,7 +3383,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
&self->samplingRateInfo[streamIndex],
(self->frameOK && !(flags & AACDEC_CONCEAL) &&
!frameOk_butConceal),
- flags, self->flags[streamIndex]);
+ self->aacOutDataHeadroom, flags, self->flags[streamIndex]);
self->extGainDelay = self->streamInfo.aacSamplesPerFrame;
break;
@@ -3388,7 +3395,8 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
if (!CConceal_TDFading_Applied[c]) {
CConceal_TDFading_Applied[c] = CConcealment_TDFading(
self->streamInfo.aacSamplesPerFrame,
- &self->pAacDecoderStaticChannelInfo[c], pTimeData + offset, 0);
+ &self->pAacDecoderStaticChannelInfo[c], self->aacOutDataHeadroom,
+ pTimeData + offset, 0);
if (c + 1 < (8) && c < aacChannels - 1) {
/* update next TDNoise Seed to avoid muting in case of Parametric
* Stereo */
@@ -3409,27 +3417,18 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
* LR) */
if ((aacChannels == 2) && bsPseudoLr) {
int i, offset2;
- const FIXP_SGL invSqrt2 =
- FL2FXCONST_SGL(0.353553390593273f); /* scaled by -1 */
- FIXP_PCM *pTD = pTimeData;
+ const FIXP_SGL invSqrt2 = FL2FXCONST_SGL(0.707106781186547f);
+ PCM_DEC *pTD = pTimeData;
offset2 = timeDataChannelOffset;
for (i = 0; i < self->streamInfo.aacSamplesPerFrame; i++) {
- FIXP_DBL L = FX_PCM2FX_DBL(pTD[0]);
- FIXP_DBL R = FX_PCM2FX_DBL(pTD[offset2]);
+ FIXP_DBL L = PCM_DEC2FIXP_DBL(pTD[0]);
+ FIXP_DBL R = PCM_DEC2FIXP_DBL(pTD[offset2]);
L = fMult(L, invSqrt2);
R = fMult(R, invSqrt2);
-#if (SAMPLE_BITS == 16)
- pTD[0] = (FIXP_SGL)SATURATE_RIGHT_SHIFT(L + R + (FIXP_DBL)(1 << 14),
- 15, FRACT_BITS);
- pTD[offset2] = (FIXP_SGL)SATURATE_RIGHT_SHIFT(
- L - R + (FIXP_DBL)(1 << 14), 15, FRACT_BITS);
-#else
- pTD[0] = SATURATE_LEFT_SHIFT(FX_DBL2FX_PCM(L + R), 1, DFRACT_BITS);
- pTD[offset2] =
- SATURATE_LEFT_SHIFT(FX_DBL2FX_PCM(L - R), 1, DFRACT_BITS);
-#endif
+ pTD[0] = L + R;
+ pTD[offset2] = L - R;
pTD++;
}
}