Merge remote-tracking branch 'aosp/kitkat-release' into kitkat-merge

Conflicts:
	libAACenc/src/quantize.cpp
This commit is contained in:
Martin Storsjo 2013-11-01 10:46:40 +02:00
commit 321233ee92
306 changed files with 8888 additions and 7957 deletions

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -504,7 +504,8 @@ typedef struct
INT aacSamplesPerFrame; /*!< Samples per frame for the AAC core (from ASC). \n
1024 or 960 for AAC-LC \n
512 or 480 for AAC-LD and AAC-ELD */
INT aacNumChannels; /*!< The number of audio channels after AAC core processing (before PS or MPS processing).
CAUTION: This are not the final number of output channels! */
AUDIO_OBJECT_TYPE extAot; /*!< Extension Audio Object Type (from ASC) */
INT extSamplingRate; /*!< Extension sampling rate in Hz (from ASC) */

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -135,10 +135,13 @@ void aacDecoder_drcInit (
/* init params */
pParams = &self->params;
pParams->bsDelayEnable = 0;
pParams->cut = FL2FXCONST_DBL(0.0f);
pParams->boost = FL2FXCONST_DBL(0.0f);
pParams->cut = FL2FXCONST_DBL(0.0f);
pParams->usrCut = FL2FXCONST_DBL(0.0f);
pParams->boost = FL2FXCONST_DBL(0.0f);
pParams->usrBoost = FL2FXCONST_DBL(0.0f);
pParams->targetRefLevel = AACDEC_DRC_DEFAULT_REF_LEVEL;
pParams->expiryFrame = AACDEC_DRC_DFLT_EXPIRY_FRAMES;
pParams->applyHeavyCompression = 0;
/* initial program ref level = target ref level */
self->progRefLevel = pParams->targetRefLevel;
@ -193,7 +196,9 @@ AAC_DECODER_ERROR aacDecoder_drcSetParam (
if (self == NULL) {
return AAC_DEC_INVALID_HANDLE;
}
self->params.cut = (FIXP_DBL)((INT)(DRC_PARAM_QUANT_STEP>>DRC_PARAM_SCALE) * (INT)value);
self->params.usrCut = (FIXP_DBL)((INT)(DRC_PARAM_QUANT_STEP>>DRC_PARAM_SCALE) * (INT)value);
if (self->params.applyHeavyCompression == 0)
self->params.cut = self->params.usrCut;
break;
case DRC_BOOST_SCALE:
/* set boost factor */
@ -204,7 +209,9 @@ AAC_DECODER_ERROR aacDecoder_drcSetParam (
if (self == NULL) {
return AAC_DEC_INVALID_HANDLE;
}
self->params.boost = (FIXP_DBL)((INT)(DRC_PARAM_QUANT_STEP>>DRC_PARAM_SCALE) * (INT)value);
self->params.usrBoost = (FIXP_DBL)((INT)(DRC_PARAM_QUANT_STEP>>DRC_PARAM_SCALE) * (INT)value);
if (self->params.applyHeavyCompression == 0)
self->params.boost = self->params.usrBoost;
break;
case TARGET_REF_LEVEL:
if ( value > MAX_REFERENCE_LEVEL
@ -220,9 +227,11 @@ AAC_DECODER_ERROR aacDecoder_drcSetParam (
else {
/* ref_level must be between 0 and MAX_REFERENCE_LEVEL, inclusive */
self->digitalNorm = 1;
self->params.targetRefLevel = value;
self->progRefLevel = (SCHAR)value; /* Set the program reference level equal to the target
level according to 4.5.2.7.3 of ISO/IEC 14496-3. */
if (self->params.targetRefLevel != (SCHAR)value) {
self->params.targetRefLevel = (SCHAR)value;
self->progRefLevel = (SCHAR)value; /* Always set the program reference level equal to the
target level according to 4.5.2.7.3 of ISO/IEC 14496-3. */
}
}
break;
case APPLY_HEAVY_COMPRESSION:
@ -232,7 +241,19 @@ AAC_DECODER_ERROR aacDecoder_drcSetParam (
if (self == NULL) {
return AAC_DEC_INVALID_HANDLE;
}
self->params.applyHeavyCompression = (UCHAR)value;
if (self->params.applyHeavyCompression != (UCHAR)value) {
if (value == 1) {
/* Disable scaling of DRC values by setting the max values */
self->params.boost = FL2FXCONST_DBL(1.0f/(float)(1<<DRC_PARAM_SCALE));
self->params.cut = FL2FXCONST_DBL(1.0f/(float)(1<<DRC_PARAM_SCALE));
} else {
/* Restore the user params */
self->params.boost = self->params.usrBoost;
self->params.cut = self->params.usrCut;
}
/* Store new parameter value */
self->params.applyHeavyCompression = (UCHAR)value;
}
break;
case DRC_BS_DELAY:
if (value < 0 || value > 1) {
@ -473,7 +494,7 @@ static int aacDecoder_drcParse (
}
}
else {
pDrcBs->channelData.bandTop[0] = 255;
pDrcBs->channelData.bandTop[0] = (1024 >> 2) - 1; /* ... comprising the whole spectrum. */;
}
pDrcBs->channelData.numBands = numBands;
@ -627,10 +648,17 @@ static int aacDecoder_drcExtractAndMap (
{
CDrcPayload threadBs[MAX_DRC_THREADS];
CDrcPayload *validThreadBs[MAX_DRC_THREADS];
CDrcParams *pParams;
UINT backupBsPosition;
int i, thread, validThreads = 0;
int numExcludedChns[MAX_DRC_THREADS];
FDK_ASSERT(self != NULL);
FDK_ASSERT(hBs != NULL);
FDK_ASSERT(pAacDecoderStaticChannelInfo != NULL);
pParams = &self->params;
self->numThreads = 0;
backupBsPosition = FDKgetValidBits(hBs);
@ -752,6 +780,7 @@ static int aacDecoder_drcExtractAndMap (
*/
if (pThreadBs->progRefLevel >= 0) {
self->progRefLevel = pThreadBs->progRefLevel;
self->prlExpiryCount = 0; /* Got a new value -> Reset counter */
}
/* SCE, CPE and LFE */
@ -769,6 +798,14 @@ static int aacDecoder_drcExtractAndMap (
/* CCEs not supported by now */
}
/* Increment and check expiry counter for the program reference level: */
if ( (pParams->expiryFrame > 0)
&& (self->prlExpiryCount++ > pParams->expiryFrame) )
{ /* The program reference level is too old, so set it back to the target level. */
self->progRefLevel = pParams->targetRefLevel;
self->prlExpiryCount = 0;
}
return 0;
}

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -143,6 +143,16 @@ int aacDecoder_drcProlog (
UCHAR channelMapping[],
int numChannels );
/**
* \brief Apply DRC. If SBR is present, DRC data is handed over to the SBR decoder.
* \param self AAC decoder instance
* \param pSbrDec pointer to SBR decoder instance
* \param pAacDecoderChannelInfo AAC decoder channel instance to be processed
* \param pDrcDat DRC channel data
* \param ch channel index
* \param aacFrameSize AAC frame size
* \param bSbrPresent flag indicating that SBR is present, in which case DRC is handed over to the SBR instance pSbrDec
*/
void aacDecoder_drcApply (
HANDLE_AAC_DRC self,
void *pSbrDec,

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -132,8 +132,10 @@ typedef struct
typedef struct
{
FIXP_DBL cut;
FIXP_DBL boost;
FIXP_DBL cut; /* The attenuation scale factor currently used. */
FIXP_DBL usrCut; /* The latest attenuation scale factor set by user. */
FIXP_DBL boost; /* The boost scale factor currently used. */
FIXP_DBL usrBoost; /* The latest boost scale factor set by user. */
UINT expiryFrame;
SCHAR targetRefLevel;
@ -154,6 +156,8 @@ typedef struct
USHORT numThreads; /* The number of DRC data threads extracted from the found payload elements */
SCHAR progRefLevel; /* Program reference level for all channels */
UINT prlExpiryCount; /* Counter that can be used to monitor the life time of the program reference level. */
UCHAR dvbAncDataAvailable; /* Flag that indicates whether DVB ancillary data is present or not */
UINT dvbAncDataPosition; /* Used to store the DVB ancillary data payload position in the bitstream (only one per frame) */
UINT drcPayloadPosition[MAX_DRC_THREADS]; /* Used to store the DRC payload positions in the bitstream */

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -183,7 +183,7 @@ void CAacDecoder_SyncQmfMode(HANDLE_AACDECODER self)
if ( self->qmfModeCurr == NOT_DEFINED )
{
if ( (IS_LOWDELAY(self->streamInfo.aot) && (self->flags & AC_MPS_PRESENT))
|| ( (self->ascChannels == 1)
|| ( (self->streamInfo.aacNumChannels == 1)
&& ( (CAN_DO_PS(self->streamInfo.aot) && !(self->flags & AC_MPS_PRESENT))
|| ( IS_USAC(self->streamInfo.aot) && (self->flags & AC_MPS_PRESENT)) ) ) )
{
@ -196,7 +196,7 @@ void CAacDecoder_SyncQmfMode(HANDLE_AACDECODER self)
/* Set SBR to current QMF mode. Error does not matter. */
sbrDecoder_SetParam(self->hSbrDecoder, SBR_QMF_MODE, (self->qmfModeCurr == MODE_LP));
self->psPossible = ((CAN_DO_PS(self->streamInfo.aot) && self->aacChannels == 1 && ! (self->flags & AC_MPS_PRESENT))) && self->qmfModeCurr == MODE_HQ ;
self->psPossible = ((CAN_DO_PS(self->streamInfo.aot) && self->streamInfo.aacNumChannels == 1 && ! (self->flags & AC_MPS_PRESENT))) && self->qmfModeCurr == MODE_HQ ;
FDK_ASSERT( ! ( (self->flags & AC_MPS_PRESENT) && self->psPossible ) );
}
@ -373,7 +373,7 @@ static AAC_DECODER_ERROR CDataStreamElement_Read (
{
INT readBits, dataBits = count<<3;
/* Move to the beginning of the data junk */
FDKpushBack(bs, dataStart-FDKgetValidBits(bs));
@ -394,23 +394,26 @@ static AAC_DECODER_ERROR CDataStreamElement_Read (
\brief Read Program Config Element
\bs Bitstream Handle
\count Pointer to program config element.
\pTp Transport decoder handle for CRC handling
\pce Pointer to PCE buffer
\channelConfig Current channel configuration
\alignAnchor Anchor for byte alignment
\return Error code
\return PCE status (-1: fail, 0: no new PCE, 1: PCE updated, 2: PCE updated need re-config).
*/
static AAC_DECODER_ERROR CProgramConfigElement_Read (
static int CProgramConfigElement_Read (
HANDLE_FDK_BITSTREAM bs,
HANDLE_TRANSPORTDEC pTp,
CProgramConfig *pce,
UINT channelConfig,
UINT alignAnchor )
const UINT channelConfig,
const UINT alignAnchor )
{
AAC_DECODER_ERROR error = AAC_DEC_OK;
int pceStatus = 0;
int crcReg;
/* read PCE to temporal buffer first */
C_ALLOC_SCRATCH_START(tmpPce, CProgramConfig, 1);
CProgramConfig_Init(tmpPce);
CProgramConfig_Reset(tmpPce);
@ -421,22 +424,43 @@ static AAC_DECODER_ERROR CProgramConfigElement_Read (
transportDec_CrcEndReg(pTp, crcReg);
if ( CProgramConfig_IsValid(tmpPce)
&& ( (channelConfig == 6 && (tmpPce->NumChannels == 6))
|| (channelConfig == 5 && (tmpPce->NumChannels == 5))
|| (channelConfig == 0 && (tmpPce->NumChannels == pce->NumChannels)) )
&& (tmpPce->NumFrontChannelElements == 2)
&& (tmpPce->NumSideChannelElements == 0)
&& (tmpPce->NumBackChannelElements == 1)
&& (tmpPce->Profile == 1) )
{ /* Copy the complete PCE including metadata. */
FDKmemcpy(pce, tmpPce, sizeof(CProgramConfig));
{
if ( !pce->isValid && (channelConfig > 0) ) {
/* Create a standard channel config PCE to compare with */
CProgramConfig_GetDefault( pce, channelConfig );
}
if (pce->isValid) {
/* Compare the new and the old PCE (tags ignored) */
switch ( CProgramConfig_Compare( pce, tmpPce ) )
{
case 1: /* Channel configuration not changed. Just new metadata. */
FDKmemcpy(pce, tmpPce, sizeof(CProgramConfig)); /* Store the complete PCE */
pceStatus = 1; /* New PCE but no change of config */
break;
case 2: /* The number of channels are identical but not the config */
if (channelConfig == 0) {
FDKmemcpy(pce, tmpPce, sizeof(CProgramConfig)); /* Store the complete PCE */
pceStatus = 2; /* Decoder needs re-configuration */
}
break;
case -1: /* The channel configuration is completely different */
pceStatus = -1; /* Not supported! */
break;
case 0: /* Nothing to do because PCE matches the old one exactly. */
default:
/* pceStatus = 0; */
break;
}
}
}
C_ALLOC_SCRATCH_END(tmpPce, CProgramConfig, 1);
return error;
return pceStatus;
}
#endif
#endif /* TP_PCE_ENABLE */
/*!
\brief Parse Extension Payload
@ -591,7 +615,7 @@ AAC_DECODER_ERROR CAacDecoder_ExtPayloadParse (HANDLE_AACDECODER self,
{ /* ... created to circumvent the missing length in ER-Syntax. */
int bitCnt, len = FDKreadBits(hBs, 4);
*count -= 4;
if (len == 15) {
int add_len = FDKreadBits(hBs, 8);
*count -= 8;
@ -609,9 +633,7 @@ AAC_DECODER_ERROR CAacDecoder_ExtPayloadParse (HANDLE_AACDECODER self,
/* Check NOTE 2: The extension_payload() included here must
not have extension_type == EXT_DATA_LENGTH. */
error = AAC_DEC_PARSE_ERROR;
goto bail;
}
else {
} else {
/* rewind and call myself again. */
FDKpushBack(hBs, 4);
@ -622,7 +644,7 @@ AAC_DECODER_ERROR CAacDecoder_ExtPayloadParse (HANDLE_AACDECODER self,
&bitCnt,
previous_element,
elIndex,
1 ); /* Treat same as fill element */
0 );
*count -= len - bitCnt;
}
@ -754,8 +776,12 @@ LINKSPEC_CPP void CAacDecoder_Close(HANDLE_AACDECODER self)
for (ch=0; ch<(6); ch++) {
if (self->pAacDecoderStaticChannelInfo[ch] != NULL) {
FreeOverlapBuffer (&self->pAacDecoderStaticChannelInfo[ch]->pOverlapBuffer);
FreeAacDecoderStaticChannelInfo (&self->pAacDecoderStaticChannelInfo[ch]);
if (self->pAacDecoderStaticChannelInfo[ch]->pOverlapBuffer != NULL) {
FreeOverlapBuffer (&self->pAacDecoderStaticChannelInfo[ch]->pOverlapBuffer);
}
if (self->pAacDecoderStaticChannelInfo[ch] != NULL) {
FreeAacDecoderStaticChannelInfo (&self->pAacDecoderStaticChannelInfo[ch]);
}
}
if (self->pAacDecoderChannelInfo[ch] != NULL) {
FreeAacDecoderChannelInfo (&self->pAacDecoderChannelInfo[ch]);
@ -768,8 +794,12 @@ LINKSPEC_CPP void CAacDecoder_Close(HANDLE_AACDECODER self)
FreeDrcInfo(&self->hDrcInfo);
}
FreeWorkBufferCore1 (&self->aacCommonData.workBufferCore1);
FreeWorkBufferCore2 (&self->aacCommonData.workBufferCore2);
if (self->aacCommonData.workBufferCore1 != NULL) {
FreeWorkBufferCore1 (&self->aacCommonData.workBufferCore1);
}
if (self->aacCommonData.workBufferCore2 != NULL) {
FreeWorkBufferCore2 (&self->aacCommonData.workBufferCore2);
}
FreeAacDecoder ( &self);
}
@ -994,12 +1024,14 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self, const CS
CPns_InitPns(&self->pAacDecoderChannelInfo[ch]->data.aac.PnsData, &self->aacCommonData.pnsInterChannelData, &self->aacCommonData.pnsCurrentSeed, self->aacCommonData.pnsRandomSeed);
}
if (ascChannels > self->aacChannels)
{
/* Make allocated channel count persistent in decoder context. */
self->aacChannels = ascChannels;
}
HcrInitRom(&self->aacCommonData.overlay.aac.erHcrInfo);
setHcrType(&self->aacCommonData.overlay.aac.erHcrInfo, ID_SCE);
/* Make allocated channel count persistent in decoder context. */
self->aacChannels = ascChannels;
}
/* Make amount of signalled channels persistent in decoder context. */
@ -1009,8 +1041,10 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self, const CS
/* Update structures */
if (ascChanged) {
/* Things to be done for each channel, which do not involved allocating memory. */
for (ch = 0; ch < ascChannels; ch++) {
/* Things to be done for each channel, which do not involve allocating memory.
Doing these things only on the channels needed for the current configuration
(ascChannels) could lead to memory access violation later (error concealment). */
for (ch = 0; ch < self->aacChannels; ch++) {
switch (self->streamInfo.aot) {
case AOT_ER_AAC_ELD:
case AOT_ER_AAC_LD:
@ -1241,10 +1275,10 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
else {
self->frameOK = 0;
}
/* Create SBR element for SBR for upsampling. */
if ( (type == ID_LFE)
&& ( (self->flags & AC_SBR_PRESENT)
|| (self->sbrEnabled == 1) ) )
/* Create SBR element for SBR for upsampling for LFE elements,
and if SBR was explicitly signaled, because the first frame(s)
may not contain SBR payload (broken encoder, bit errors). */
if ( (self->flags & AC_SBR_PRESENT) || (self->sbrEnabled == 1) )
{
SBR_ERROR sbrError;
@ -1254,7 +1288,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
self->streamInfo.extSamplingRate,
self->streamInfo.aacSamplesPerFrame,
self->streamInfo.aot,
ID_LFE,
type,
previous_element_index
);
if (sbrError != SBRDEC_OK) {
@ -1394,26 +1428,34 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
#ifdef TP_PCE_ENABLE
case ID_PCE:
if ( CProgramConfigElement_Read( bs,
{
int result = CProgramConfigElement_Read(
bs,
self->hInput,
pce,
self->streamInfo.channelConfig,
auStartAnchor ) )
{ /* Built element table */
int elIdx = CProgramConfig_GetElementTable(pce, self->elements, 7);
/* Reset the remaining tabs */
for ( ; elIdx<7; elIdx++) {
self->elements[elIdx] = ID_NONE;
}
/* Make new number of channel persistant */
self->ascChannels = pce->NumChannels;
/* If PCE is not first element conceal this frame to avoid inconsistencies */
if ( element_count != 0 ) {
auStartAnchor );
if ( result < 0 ) {
/* Something went wrong */
ErrorStatus = AAC_DEC_PARSE_ERROR;
self->frameOK = 0;
}
else if ( result > 1 ) {
/* Built element table */
int elIdx = CProgramConfig_GetElementTable(pce, self->elements, 7);
/* Reset the remaining tabs */
for ( ; elIdx<7; elIdx++) {
self->elements[elIdx] = ID_NONE;
}
/* Make new number of channel persistant */
self->ascChannels = pce->NumChannels;
/* If PCE is not first element conceal this frame to avoid inconsistencies */
if ( element_count != 0 ) {
self->frameOK = 0;
}
}
pceRead = (result>=0) ? 1 : 0;
}
pceRead = 1;
break;
#endif /* TP_PCE_ENABLE */
@ -1573,7 +1615,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
}
/* Update number of output channels */
self->streamInfo.numChannels = aacChannels;
self->streamInfo.aacNumChannels = aacChannels;
#ifdef TP_PCE_ENABLE
if (pceRead == 1 && CProgramConfig_IsValid(pce)) {

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -109,8 +109,8 @@ amm-info@iis.fraunhofer.de
/* Decoder library info */
#define AACDECODER_LIB_VL0 2
#define AACDECODER_LIB_VL1 4
#define AACDECODER_LIB_VL2 7
#define AACDECODER_LIB_VL1 5
#define AACDECODER_LIB_VL2 5
#define AACDECODER_LIB_TITLE "AAC Decoder Lib"
#define AACDECODER_LIB_BUILD_DATE __DATE__
#define AACDECODER_LIB_BUILD_TIME __TIME__
@ -261,7 +261,7 @@ setConcealMethod ( const HANDLE_AACDECODER self, /*!< Handle of the decoder i
HANDLE_SBRDECODER hSbrDec = NULL;
HANDLE_AAC_DRC hDrcInfo = NULL;
HANDLE_PCM_DOWNMIX hPcmDmx = NULL;
CConcealmentMethod backupMethod;
CConcealmentMethod backupMethod = ConcealMethodNone;
int backupDelay = 0;
int bsDelay = 0;
@ -396,11 +396,15 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode
AAC_DECODER_ERROR errorStatus = AAC_DEC_OK;
CConcealParams *pConcealData = NULL;
HANDLE_AAC_DRC hDrcInfo = NULL;
HANDLE_PCM_DOWNMIX hPcmDmx = NULL;
/* check decoder handle */
if (self != NULL) {
pConcealData = &self->concealCommonData;
hDrcInfo = self->hDrcInfo;
hPcmDmx = self->hPcmUtils;
} else {
errorStatus = AAC_DEC_INVALID_HANDLE;
}
/* configure the subsystems */
@ -417,11 +421,14 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode
break;
case AAC_PCM_OUTPUT_CHANNELS:
if (value < -1 || value > (6)) {
return AAC_DEC_SET_PARAM_FAIL;
}
{
PCMDMX_ERROR err;
err = pcmDmx_SetParam (
self->hPcmUtils,
hPcmDmx,
NUMBER_OF_OUTPUT_CHANNELS,
value );
@ -441,7 +448,7 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode
PCMDMX_ERROR err;
err = pcmDmx_SetParam (
self->hPcmUtils,
hPcmDmx,
DUAL_CHANNEL_DOWNMIX_MODE,
value );
@ -459,10 +466,14 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode
case AAC_PCM_OUTPUT_CHANNEL_MAPPING:
switch (value) {
case 0:
self->channelOutputMapping = channelMappingTablePassthrough;
if (self != NULL) {
self->channelOutputMapping = channelMappingTablePassthrough;
}
break;
case 1:
self->channelOutputMapping = channelMappingTableWAV;
if (self != NULL) {
self->channelOutputMapping = channelMappingTableWAV;
}
break;
default:
errorStatus = AAC_DEC_SET_PARAM_FAIL;
@ -472,6 +483,9 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode
case AAC_QMF_LOWPOWER:
if (value < -1 || value > 1) {
return AAC_DEC_SET_PARAM_FAIL;
}
if (self == NULL) {
return AAC_DEC_INVALID_HANDLE;
}
@ -794,8 +808,8 @@ LINKSPEC_CPP AAC_DECODER_ERROR aacDecoder_DecodeFrame(
/* Export data into streaminfo structure */
self->streamInfo.sampleRate = self->streamInfo.aacSampleRate;
self->streamInfo.frameSize = self->streamInfo.aacSamplesPerFrame;
self->streamInfo.numChannels = self->aacChannels;
}
self->streamInfo.numChannels = self->streamInfo.aacNumChannels;
@ -832,7 +846,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR aacDecoder_DecodeFrame(
pTimeData,
&self->streamInfo.numChannels,
&self->streamInfo.sampleRate,
self->channelOutputMapping[self->aacChannels-1],
self->channelOutputMapping[self->streamInfo.numChannels-1],
interleaved,
self->frameOK,
&self->psPossible);

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -589,7 +589,6 @@ AAC_DECODER_ERROR CBlock_ReadSpectralData(HANDLE_FDK_BITSTREAM bs,
{
H_HCR_INFO hHcr = &pAacDecoderChannelInfo->pComData->overlay.aac.erHcrInfo;
int hcrStatus = 0;
int hcrConcealWholeFrame = 0;
/* advanced Huffman decoding starts here (HCR decoding :) */
if ( pAacDecoderChannelInfo->pDynData->specificTo.aac.lenOfReorderedSpectralData != 0 ) {
@ -598,24 +597,19 @@ AAC_DECODER_ERROR CBlock_ReadSpectralData(HANDLE_FDK_BITSTREAM bs,
hcrStatus = HcrInit(hHcr, pAacDecoderChannelInfo, pSamplingRateInfo, bs);
if (hcrStatus != 0) {
#if HCR_ERROR_CONCEALMENT
hcrConcealWholeFrame = 1;
return AAC_DEC_DECODE_FRAME_ERROR; /* concealment is muting in the first step, therefore return now */
// hcr decoding is not skipped because of returning above
#else
return AAC_DEC_DECODE_FRAME_ERROR;
#endif
}
/* HCR decoding short */
hcrStatus = HcrDecoder(hHcr, pAacDecoderChannelInfo, pSamplingRateInfo, bs);
if (hcrStatus != 0) {
#if HCR_ERROR_CONCEALMENT
HcrMuteErroneousLines(hHcr);
HcrMuteErroneousLines(hHcr);
#else
return AAC_DEC_DECODE_FRAME_ERROR;
return AAC_DEC_DECODE_FRAME_ERROR;
#endif /* HCR_ERROR_CONCEALMENT */
}
FDKpushFor (bs, pAacDecoderChannelInfo->pDynData->specificTo.aac.lenOfReorderedSpectralData);
}

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -441,7 +441,7 @@ AAC_DECODER_ERROR
/* set confort noise level which will be inserted while in state 'muting' */
if (comfNoiseLevel != AACDEC_CONCEAL_PARAM_NOT_SPECIFIED) {
if ( (comfNoiseLevel < 0)
if ( (comfNoiseLevel < -1)
|| (comfNoiseLevel > 127) ) {
return AAC_DEC_SET_PARAM_FAIL;
}
@ -1527,8 +1527,13 @@ static void
{
case ConcealState_Ok:
if (!frameOk) {
/* change to state SINGLE-FRAME-LOSS */
pConcealmentInfo->concealState = ConcealState_Single;
if (pConcealCommonData->numFadeOutFrames > 0) {
/* change to state SINGLE-FRAME-LOSS */
pConcealmentInfo->concealState = ConcealState_Single;
} else {
/* change to state MUTE */
pConcealmentInfo->concealState = ConcealState_Mute;
}
pConcealmentInfo->cntFadeFrames = 0;
pConcealmentInfo->cntValidFrames = 0;
}
@ -1561,11 +1566,16 @@ static void
case ConcealState_FadeOut:
pConcealmentInfo->cntFadeFrames += 1; /* used to address the fade-out factors */
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
/* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames-1,
0 /* FadeOut -> FadeIn */);
if (pConcealCommonData->numFadeInFrames > 0) {
/* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames-1,
0 /* FadeOut -> FadeIn */);
} else {
/* change to state OK */
pConcealmentInfo->concealState = ConcealState_Ok;
}
} else {
if (pConcealmentInfo->cntFadeFrames >= pConcealCommonData->numFadeOutFrames) {
/* change to state MUTE */
@ -1576,9 +1586,14 @@ static void
case ConcealState_Mute:
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
/* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1;
if (pConcealCommonData->numFadeInFrames > 0) {
/* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1;
} else {
/* change to state OK */
pConcealmentInfo->concealState = ConcealState_Ok;
}
}
break;
@ -1590,11 +1605,16 @@ static void
pConcealmentInfo->concealState = ConcealState_Ok;
}
} else {
/* change to state FADE-OUT */
pConcealmentInfo->concealState = ConcealState_FadeOut;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames+1,
1 /* FadeIn -> FadeOut */);
if (pConcealCommonData->numFadeOutFrames > 0) {
/* change to state FADE-OUT */
pConcealmentInfo->concealState = ConcealState_FadeOut;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames+1,
1 /* FadeIn -> FadeOut */);
} else {
/* change to state MUTE */
pConcealmentInfo->concealState = ConcealState_Mute;
}
}
break;
@ -1625,8 +1645,13 @@ static void
case ConcealState_Ok:
if (!(pConcealmentInfo->prevFrameOk[1] ||
(pConcealmentInfo->prevFrameOk[0] && !pConcealmentInfo->prevFrameOk[1] && frameOk))) {
/* Fade out only if the energy interpolation algorithm can not be applied! */
pConcealmentInfo->concealState = ConcealState_FadeOut;
if (pConcealCommonData->numFadeOutFrames > 0) {
/* Fade out only if the energy interpolation algorithm can not be applied! */
pConcealmentInfo->concealState = ConcealState_FadeOut;
} else {
/* change to state MUTE */
pConcealmentInfo->concealState = ConcealState_Mute;
}
pConcealmentInfo->cntFadeFrames = 0;
pConcealmentInfo->cntValidFrames = 0;
}
@ -1640,11 +1665,16 @@ static void
pConcealmentInfo->cntFadeFrames += 1;
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
/* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames-1,
0 /* FadeOut -> FadeIn */);
if (pConcealCommonData->numFadeInFrames > 0) {
/* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames-1,
0 /* FadeOut -> FadeIn */);
} else {
/* change to state OK */
pConcealmentInfo->concealState = ConcealState_Ok;
}
} else {
if (pConcealmentInfo->cntFadeFrames >= pConcealCommonData->numFadeOutFrames) {
/* change to state MUTE */
@ -1655,9 +1685,14 @@ static void
case ConcealState_Mute:
if (pConcealmentInfo->cntValidFrames > pConcealCommonData->numMuteReleaseFrames) {
/* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1;
if (pConcealCommonData->numFadeInFrames > 0) {
/* change to state FADE-IN */
pConcealmentInfo->concealState = ConcealState_FadeIn;
pConcealmentInfo->cntFadeFrames = pConcealCommonData->numFadeInFrames - 1;
} else {
/* change to state OK */
pConcealmentInfo->concealState = ConcealState_Ok;
}
}
break;
@ -1670,11 +1705,16 @@ static void
pConcealmentInfo->concealState = ConcealState_Ok;
}
} else {
/* change to state FADE-OUT */
pConcealmentInfo->concealState = ConcealState_FadeOut;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames+1,
1 /* FadeIn -> FadeOut */);
if (pConcealCommonData->numFadeOutFrames > 0) {
/* change to state FADE-OUT */
pConcealmentInfo->concealState = ConcealState_FadeOut;
pConcealmentInfo->cntFadeFrames = findEquiFadeFrame( pConcealCommonData,
pConcealmentInfo->cntFadeFrames+1,
1 /* FadeIn -> FadeOut */);
} else {
/* change to state MUTE */
pConcealmentInfo->concealState = ConcealState_Mute;
}
}
break;
} /* End switch(pConcealmentInfo->concealState) */

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -316,7 +316,8 @@ if the parameter was not set from extern. The bitrate depends on the number of e
channels and sampling rate and is determined as follows.
\code
AAC-LC (AOT_AAC_LC): 1.5 bits per sample
HE-AAC (AOT_SBR): 0.625 bits per sample
HE-AAC (AOT_SBR): 0.625 bits per sample (dualrate sbr)
HE-AAC (AOT_SBR): 1.125 bits per sample (downsampled sbr)
HE-AAC v2 (AOT_PS): 0.5 bits per sample
\endcode
@ -341,6 +342,33 @@ increase which might be significant. If workload is not an issue in the applicat
we recommended to activate this feature.
\code aacEncoder_SetParam(hAacEncoder, AACENC_AFTERBURNER, 1); \endcode
\subsection encELD ELD Auto Configuration Mode
For ELD configuration a so called auto configurator is available which configures SBR and the SBR ratio by itself.
The configurator is used when the encoder parameter ::AACENC_SBR_MODE and ::AACENC_SBR_RATIO are not set explicitely.
Based on sampling rate and chosen bitrate per channel a reasonable SBR configuration will be used.
\verbatim
------------------------------------------------------------
Sampling Rate | Channel Bitrate | SBR | SBR Ratio
-----------------+-----------------+------+-----------------
]min, 16] kHz | min - 27999 | on | downsampled SBR
| 28000 - max | off | ---
-----------------+-----------------+------+-----------------
]16 - 24] kHz | min - 39999 | on | downsampled SBR
| 40000 - max | off | ---
-----------------+-----------------+------+-----------------
]24 - 32] kHz | min - 27999 | on | dualrate SBR
| 28000 - 55999 | on | downsampled SBR
| 56000 - max | off | ---
-----------------+-----------------+------+-----------------
]32 - 44.1] kHz | min - 63999 | on | dualrate SBR
| 64000 - max | off | ---
-----------------+-----------------+------+-----------------
]44.1 - 48] kHz | min - 63999 | on | dualrate SBR
| 64000 - max | off | ---
------------------------------------------------------------
\endverbatim
\section audiochCfg Audio Channel Configuration
The MPEG standard refers often to the so-called Channel Configuration. This Channel Configuration is used for a fixed Channel
@ -349,16 +377,20 @@ For user defined Configurations the Channel Configuration is set to 0 and the Ch
Program Config Element. The present Encoder implementation does not allow the user to configure this Channel Configuration from
extern. The Encoder implementation supports fixed Channel Modes which are mapped to Channel Configuration as follow.
\verbatim
--------------------------------------------------------------------
ChannelMode | ChCfg | front_El | side_El | back_El | lfe_El
-----------------+--------+----------+----------+----------+--------
MODE_1 | 1 | SCE | | |
MODE_2 | 2 | CPE | | |
MODE_1_2 | 3 | SCE, CPE | | |
MODE_1_2_1 | 4 | SCE, CPE | | SCE |
MODE_1_2_2 | 5 | SCE, CPE | | CPE |
MODE_1_2_2_1 | 6 | SCE, CPE | | CPE | LFE
--------------------------------------------------------------------
-------------------------------------------------------------------------------
ChannelMode | ChCfg | front_El | side_El | back_El | lfe_El
-----------------------+--------+---------------+----------+----------+--------
MODE_1 | 1 | SCE | | |
MODE_2 | 2 | CPE | | |
MODE_1_2 | 3 | SCE, CPE | | |
MODE_1_2_1 | 4 | SCE, CPE | | SCE |
MODE_1_2_2 | 5 | SCE, CPE | | CPE |
MODE_1_2_2_1 | 6 | SCE, CPE | | CPE | LFE
MODE_1_2_2_2_1 | 7 | SCE, CPE, CPE | | CPE | LFE
-----------------------+--------+---------------+----------+----------+--------
MODE_7_1_REAR_SURROUND | 0 | SCE, CPE | | CPE, CPE | LFE
MODE_7_1_FRONT_CENTER | 0 | SCE, CPE, CPE | | CPE | LFE
-------------------------------------------------------------------------------
- SCE: Single Channel Element.
- CPE: Channel Pair.
- SCE: Low Frequency Element.
@ -374,16 +406,20 @@ Beside the Channel Element assignment the Channel Modes are resposible for audio
of the audio data depends on the selected ::AACENC_CHANNELORDER which can be MPEG or WAV like order.\n
Following Table describes the complete channel mapping for both Channel Order configurations.
\verbatim
---------------------------------------------------------------------------------
ChannelMode | MPEG-Channelorder | WAV-Channelorder
-----------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---
MODE_1 | 0 | | | | | | | | 0 | | | | | | |
MODE_2 | 0 | 1 | | | | | | | 0 | 1 | | | | | |
MODE_1_2 | 0 | 1 | 2 | | | | | | 2 | 0 | 1 | | | | |
MODE_1_2_1 | 0 | 1 | 2 | 3 | | | | | 2 | 0 | 1 | 3 | | | |
MODE_1_2_2 | 0 | 1 | 2 | 3 | 4 | | | | 2 | 0 | 1 | 3 | 4 | | |
MODE_1_2_2_1 | 0 | 1 | 2 | 3 | 4 | 5 | | | 2 | 0 | 1 | 4 | 5 | 3 | |
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
ChannelMode | MPEG-Channelorder | WAV-Channelorder
-----------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---
MODE_1 | 0 | | | | | | | | 0 | | | | | | |
MODE_2 | 0 | 1 | | | | | | | 0 | 1 | | | | | |
MODE_1_2 | 0 | 1 | 2 | | | | | | 2 | 0 | 1 | | | | |
MODE_1_2_1 | 0 | 1 | 2 | 3 | | | | | 2 | 0 | 1 | 3 | | | |
MODE_1_2_2 | 0 | 1 | 2 | 3 | 4 | | | | 2 | 0 | 1 | 3 | 4 | | |
MODE_1_2_2_1 | 0 | 1 | 2 | 3 | 4 | 5 | | | 2 | 0 | 1 | 4 | 5 | 3 | |
MODE_1_2_2_2_1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 2 | 6 | 7 | 0 | 1 | 4 | 5 | 3
-----------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---
MODE_7_1_REAR_SURROUND | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 2 | 0 | 1 | 6 | 7 | 4 | 5 | 3
MODE_7_1_FRONT_CENTER | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 2 | 6 | 7 | 0 | 1 | 4 | 5 | 3
---------------------------------------------------------------------------------------
\endverbatim
The denoted mapping is important for correct audio channel assignment when using MPEG or WAV ordering. The incoming audio
@ -416,8 +452,9 @@ determines the maximum allowed bitrate for AAC-LC. For HE-AAC and HE-AAC v2 a li
look-up table is used.
A good working point in terms of audio quality, sampling rate and bitrate, is at 1 to 1.5
bits/audio sample for AAC-LC, 0.625 bits/audio sample for HE-AAC and 0.5 bits/audio sample
for HE-AAC v2. For example for one channel with a sampling frequency of 48 kHz, the range from
bits/audio sample for AAC-LC, 0.625 bits/audio sample for dualrate HE-AAC, 1.125 bits/audio sample
for downsampled HE-AAC and 0.5 bits/audio sample for HE-AAC v2.
For example for one channel with a sampling frequency of 48 kHz, the range from
48 kbit/s to 72 kbit/s achieves reasonable audio quality for AAC-LC.
For HE-AAC and HE-AAC v2 the lowest possible audio input sampling frequency is 16 kHz because then the
@ -434,7 +471,7 @@ quality at that bitrate than HE-AAC or HE-AAC v2.
The following table provides an overview of recommended encoder configuration parameters
which we determined by virtue of numerous listening tests.
\subsection reommendedConfigLC AAC-LC, HE-AAC, HE-AACv2.
\subsection reommendedConfigLC AAC-LC, HE-AAC, HE-AACv2 in Dualrate SBR mode.
\verbatim
-----------------------------------------------------------------------------------
Audio Object Type | Bit Rate Range | Supported | Preferred | No. of
@ -457,8 +494,8 @@ AAC LC + SBR | 64000 - 128000 | 32.00, 44.10, 48.00 | 48.00 |
-------------------+------------------+-----------------------+------------+-------
AAC LC + SBR | 64000 - 69999 | 32.00, 44.10, 48.00 | 32.00 | 5, 5.1
AAC LC + SBR | 70000 - 159999 | 32.00, 44.10, 48.00 | 44.10 | 5, 5.1
AAC LC + SBR | 160000 - 319999 | 32.00, 44.10, 48.00 | 48.00 | 5, 5.1
AAC LC + SBR | 320000 - 640000 | 64.00, 88.20, 96.00 | 96.00 | 5, 5.1
AAC LC + SBR | 160000 - 245999 | 32.00, 44.10, 48.00 | 48.00 | 5
AAC LC + SBR | 160000 - 265999 | 32.00, 44.10, 48.00 | 48.00 | 5.1
-------------------+------------------+-----------------------+------------+-------
AAC LC | 8000 - 15999 | 11.025, 12.00, 16.00 | 12.00 | 1
AAC LC | 16000 - 23999 | 16.00 | 16.00 | 1
@ -481,7 +518,7 @@ AAC LC | 280000 - 800000 | 32.00, 44.10, 48.00 | 44.10 | 5,
-----------------------------------------------------------------------------------
\endverbatim \n
\subsection reommendedConfigLD AAC-LD, AAC-ELD, AAC-ELD with SBR.
\subsection reommendedConfigLD AAC-LD, AAC-ELD, AAC-ELD with SBR in Dualrate SBR mode.
\verbatim
-----------------------------------------------------------------------------------
Audio Object Type | Bit Rate Range | Supported | Preferred | No. of
@ -489,18 +526,20 @@ Audio Object Type | Bit Rate Range | Supported | Preferred | No.
| | [kHz] | Rate |
| | | [kHz] |
-------------------+------------------+-----------------------+------------+-------
ELD + SBR | 16000 - 24999 | 32.00 - 44.10 | 32.00 | 1
ELD + SBR | 18000 - 24999 | 32.00 - 44.10 | 32.00 | 1
ELD + SBR | 25000 - 31999 | 32.00 - 48.00 | 32.00 | 1
ELD + SBR | 32000 - 64000 | 32.00 - 48.00 | 48.00 | 1
-------------------+------------------+-----------------------+------------+-------
ELD + SBR | 32000 - 51999 | 32.00 - 48.00 | 44.10 | 2
ELD + SBR | 52000 - 128000 | 32.00 - 48.00 | 48.00 | 2
-------------------+------------------+-----------------------+------------+-------
ELD + SBR | 72000 - 192000 | 44.10 - 48.00 | 48.00 | 3
ELD + SBR | 72000 - 160000 | 44.10 - 48.00 | 48.00 | 3
-------------------+------------------+-----------------------+------------+-------
ELD + SBR | 96000 - 256000 | 44.10 - 48.00 | 48.00 | 4
ELD + SBR | 96000 - 212000 | 44.10 - 48.00 | 48.00 | 4
-------------------+------------------+-----------------------+------------+-------
ELD + SBR | 120000 - 320000 | 44.10 - 48.00 | 48.00 | 5
ELD + SBR | 120000 - 246000 | 44.10 - 48.00 | 48.00 | 5
-------------------+------------------+-----------------------+------------+-------
ELD + SBR | 120000 - 266000 | 44.10 - 48.00 | 48.00 | 5.1
-------------------+------------------+-----------------------+------------+-------
LD, ELD | 16000 - 19999 | 16.00 - 24.00 | 16.00 | 1
LD, ELD | 20000 - 39999 | 16.00 - 32.00 | 24.00 | 1
@ -531,13 +570,33 @@ LD, ELD | 340000 - 960000 | 44.10 - 48.00 | 48.00 |
-----------------------------------------------------------------------------------
\endverbatim \n
\subsection reommendedConfigELD AAC-ELD with SBR in Downsampled SBR mode.
\verbatim
-----------------------------------------------------------------------------------
Audio Object Type | Bit Rate Range | Supported | Preferred | No. of
| [bit/s] | Sampling Rates | Sampl. | Chan.
| | [kHz] | Rate |
| | | [kHz] |
-------------------+------------------+-----------------------+------------+-------
ELD + SBR | 18000 - 24999 | 16.00 - 22.05 | 22.05 | 1
(downsampled SBR) | 25000 - 35999 | 22.05 - 32.00 | 24.00 | 1
| 36000 - 64000 | 32.00 - 48.00 | 32.00 | 1
-----------------------------------------------------------------------------------
\endverbatim \n
\page ENCODERBEHAVIOUR Encoder Behaviour
\section BEHAVIOUR_BANDWIDTH Bandwidth
The FDK AAC encoder usually does not use the full frequency range of the input signal, but restricts the bandwidth
according to certain library-internal settings. They can be changed in the table "bandWidthTable" in the
file bandwidth.cpp (if available), or via command-line argument "-w" (see chapter \ref CommandLineUsage).
file bandwidth.cpp (if available).
The encoder API provides the ::AACENC_BANDWIDTH parameter to adjust the bandwidth explicitly.
\code
aacEncoder_SetParam(hAacEncoder, AACENC_BANDWIDTH, value);
\endcode
However it is not recommended to change these settings, because they are based on numerious listening
tests and careful tweaks to ensure the best overall encoding quality.
@ -638,7 +697,6 @@ an MPEG-2 AOT is choosen since PNS is an MPEG-4 AAC feature.
If SBR is activated, the encoder automatically deactivates PNS internally. If TNS is disabled but PNS is allowed,
the encoder deactivates PNS calculation internally.
*/
#ifndef _AAC_ENC_LIB_H_
@ -858,8 +916,9 @@ typedef enum
AACENC_SAMPLERATE = 0x0103, /*!< Audio input data sampling rate. Encoder supports following sampling rates:
8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000 */
AACENC_SBR_MODE = 0x0104, /*!< Configure SBR independently of the chosen Audio Object Type ::AUDIO_OBJECT_TYPE:.
This parameter is only available for ELD.
AACENC_SBR_MODE = 0x0104, /*!< Configure SBR independently of the chosen Audio Object Type ::AUDIO_OBJECT_TYPE.
This parameter is for ELD audio object type only.
- -1: Use ELD SBR auto configurator (default).
- 0: Disable Spectral Band Replication.
- 1: Enable Spectral Band Replication. */
@ -869,12 +928,21 @@ typedef enum
- 480: Optional length in LD/ELD configuration. */
AACENC_CHANNELMODE = 0x0106, /*!< Set explicit channel mode. Channel mode must match with number of input channels.
- 1-6: MPEG channel modes supported, see ::CHANNEL_MODE in FDK_audio.h. */
- 1-7 and 33,34: MPEG channel modes supported, see ::CHANNEL_MODE in FDK_audio.h. */
AACENC_CHANNELORDER = 0x0107, /*!< Input audio data channel ordering scheme:
- 0: MPEG channel ordering (e. g. 5.1: C, L, R, SL, SR, LFE). (default)
- 1: WAVE file format channel ordering (e. g. 5.1: L, R, C, LFE, SL, SR). */
AACENC_SBR_RATIO = 0x0108, /*!< Controls activation of downsampled SBR. With downsampled SBR, the delay will be
shorter. On the other hand, for achieving the same quality level, downsampled SBR
needs more bits than dual-rate SBR.
With downsampled SBR, the AAC encoder will work at the same sampling rate as the
SBR encoder (single rate).
Downsampled SBR is supported for AAC-ELD and HE-AACv1.
- 1: Downsampled SBR (default for ELD).
- 2: Dual-rate SBR (default for HE-AAC). */
AACENC_AFTERBURNER = 0x0200, /*!< This parameter controls the use of the afterburner feature.
The afterburner is a type of analysis by synthesis algorithm which increases the
audio quality but also the required processing power. It is recommended to always
@ -906,14 +974,50 @@ typedef enum
- n: Frame count period. */
AACENC_SIGNALING_MODE = 0x0302, /*!< Signaling mode of the extension AOT:
- 0: Implicit backward compatible signaling. (default)
- 1: Explicit SBR and implicit PS signaling.
- 2: Explicit hierarchical signaling.
- 0: Implicit backward compatible signaling (default for non-MPEG-4 based
AOT's and for the transport formats ADIF and ADTS)
- A stream that uses implicit signaling can be decoded by every AAC decoder, even AAC-LC-only decoders
- An AAC-LC-only decoder will only decode the low-frequency part of the stream, resulting in a band-limited output
- This method works with all transport formats
- This method does not work with downsampled SBR
- 1: Explicit backward compatible signaling
- A stream that uses explicit backward compatible signaling can be decoded by every AAC decoder, even AAC-LC-only decoders
- An AAC-LC-only decoder will only decode the low-frequency part of the stream, resulting in a band-limited output
- A decoder not capable of decoding PS will only decode the AAC-LC+SBR part.
If the stream contained PS, the result will be a a decoded mono downmix
- This method does not work with ADIF or ADTS. For LOAS/LATM, it only works with AudioMuxVersion==1
- This method does work with downsampled SBR
- 2: Explicit hierarchical signaling (default for MPEG-4 based AOT's and for all transport formats excluding ADIF and ADTS)
- A stream that uses explicit hierarchical signaling can be decoded only by HE-AAC decoders
- An AAC-LC-only decoder will not decode a stream that uses explicit hierarchical signaling
- A decoder not capable of decoding PS will not decode the stream at all if it contained PS
- This method does not work with ADIF or ADTS. It works with LOAS/LATM and the MPEG-4 File format
- This method does work with downsampled SBR
The use of backward-compatible implicit signaling is recommended if the user specically
aims at preserving compatibility with decoders only capable of decoding AAC-LC. Otherwise
use non-backward-compatible explicit signaling.
Bitstream formats ADTS and ADIF can only do implicit signaling. */
For making sure that the listener always experiences the best audio quality,
explicit hierarchical signaling should be used.
This makes sure that only a full HE-AAC-capable decoder will decode those streams.
The audio is played at full bandwidth.
For best backwards compatibility, it is recommended to encode with implicit SBR signaling.
A decoder capable of AAC-LC only will then only decode the AAC part, which means the decoded
audio will sound band-limited.
For MPEG-2 transport types (ADTS,ADIF), only implicit signaling is possible.
For LOAS and LATM, explicit backwards compatible signaling only works together with AudioMuxVersion==1.
The reason is that, for explicit backwards compatible signaling, additional information will be appended to the ASC.
A decoder that is only capable of decoding AAC-LC will skip this part.
Nevertheless, for jumping to the end of the ASC, it needs to know the ASC length.
Transmitting the length of the ASC is a feature of AudioMuxVersion==1, it is not possible to transmit the
length of the ASC with AudioMuxVersion==0, therefore an AAC-LC-only decoder will not be able to parse a
LOAS/LATM stream that was being encoded with AudioMuxVersion==0.
For downsampled SBR, explicit signaling is mandatory. The reason for this is that the
extension sampling frequency (which is in case of SBR the sampling frequqncy of the SBR part)
can only be signaled in explicit mode.
For AAC-ELD, the SBR information is transmitted in the ELDSpecific Config, which is part of the
AudioSpecificConfig. Therefore, the settings here will have no effect on AAC-ELD.*/
AACENC_TPSUBFRAMES = 0x0303, /*!< Number of sub frames in a transport frame for LOAS/LATM or ADTS (default 1).
- ADTS: Maximum number of sub frames restricted to 4.

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
Š Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
Š Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -89,7 +89,7 @@ amm-info@iis.fraunhofer.de
******************************************************************************/
/*!
\file
\brief Memory layout
\brief Memory layout
\author Markus Lohwasser
*/
@ -119,12 +119,12 @@ C_ALLOC_MEM (Ram_aacEnc_AacEncoder, AAC_ENC, 1)
PsyInputBuffer.
*/
C_ALLOC_MEM2 (Ram_aacEnc_PsyElement, PSY_ELEMENT, 1, (6))
C_ALLOC_MEM2 (Ram_aacEnc_PsyElement, PSY_ELEMENT, 1, (8))
C_ALLOC_MEM (Ram_aacEnc_PsyInternal, PSY_INTERNAL, 1)
C_ALLOC_MEM2 (Ram_aacEnc_PsyStatic, PSY_STATIC, 1, (6))
C_ALLOC_MEM2 (Ram_aacEnc_PsyStatic, PSY_STATIC, 1, (8))
C_ALLOC_MEM2 (Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (6))
C_ALLOC_MEM2 (Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (8))
PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic (int n, UCHAR* dynamic_RAM) {
FDK_ASSERT(dynamic_RAM!=0);
@ -139,8 +139,8 @@ C_ALLOC_MEM2 (Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (6))
*/
C_ALLOC_MEM2 (Ram_aacEnc_PsyOut, PSY_OUT, 1, (1))
C_ALLOC_MEM2 (Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT, 1, (1)*(6))
C_ALLOC_MEM2 (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1)*(6))
C_ALLOC_MEM2 (Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT, 1, (1)*(8))
C_ALLOC_MEM2 (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1)*(8))
/*
@ -155,8 +155,8 @@ C_ALLOC_MEM2 (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1)*(6))
C_ALLOC_MEM (Ram_aacEnc_QCstate, QC_STATE, 1)
C_ALLOC_MEM (Ram_aacEnc_AdjustThreshold, ADJ_THR_STATE, 1)
C_ALLOC_MEM2 (Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT, 1, (6))
C_ALLOC_MEM2 (Ram_aacEnc_ElementBits, ELEMENT_BITS, 1, (6))
C_ALLOC_MEM2 (Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT, 1, (8))
C_ALLOC_MEM2 (Ram_aacEnc_ElementBits, ELEMENT_BITS, 1, (8))
C_ALLOC_MEM (Ram_aacEnc_BitCntrState, BITCNTR_STATE, 1)
INT *GetRam_aacEnc_BitLookUp(int n, UCHAR* dynamic_RAM) {
@ -175,7 +175,7 @@ C_ALLOC_MEM (Ram_aacEnc_BitCntrState, BITCNTR_STATE, 1)
*/
C_ALLOC_MEM2 (Ram_aacEnc_QCout, QC_OUT, 1, (1))
C_ALLOC_MEM2 (Ram_aacEnc_QCelement, QC_OUT_ELEMENT, 1, (1)*(6))
C_ALLOC_MEM2 (Ram_aacEnc_QCelement, QC_OUT_ELEMENT, (1), (8))
QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel (int n, UCHAR* dynamic_RAM) {
FDK_ASSERT(dynamic_RAM!=0);
return ((QC_OUT_CHANNEL*) (dynamic_RAM + P_BUF_0 + n*sizeof(QC_OUT_CHANNEL)));

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -118,7 +118,7 @@ amm-info@iis.fraunhofer.de
*/
/* define hBitstream size: max AAC framelength is 6144 bits/channel */
/*#define BUFFER_BITSTR_SIZE ((6400*(6)/bbWordSize) +((bbWordSize - 1) / bbWordSize))*/
/*#define BUFFER_BITSTR_SIZE ((6400*(8)/bbWordSize) +((bbWordSize - 1) / bbWordSize))*/
struct AAC_ENC {
@ -173,7 +173,7 @@ struct AAC_ENC {
++++++++++++++++++++++++++++++++++++++++++++
*/
#define BUF_SIZE_0 ( ALIGN_SIZE(sizeof(QC_OUT_CHANNEL)*(6)) )
#define BUF_SIZE_0 ( ALIGN_SIZE(sizeof(QC_OUT_CHANNEL)*(8)) )
#define BUF_SIZE_1 ( ALIGN_SIZE(maxSize(sizeof(PSY_DYNAMIC), \
(BIT_LOOK_UP_SIZE+MERGE_GAIN_LOOK_UP_SIZE))) )

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -393,7 +393,7 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc,
/******************* sanity checks *******************/
/* check config structure */
if (config->nChannels < 1 || config->nChannels > (6)) {
if (config->nChannels < 1 || config->nChannels > (8)) {
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
}
@ -558,6 +558,13 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc,
qcInit.channelMapping = &hAacEnc->channelMapping;
qcInit.sceCpe = 0;
if ((config->bitrateMode>=1) && (config->bitrateMode<=5)) {
qcInit.averageBits = (averageBitsPerFrame+7)&~7;
qcInit.bitRes = MIN_BUFSIZE_PER_EFF_CHAN*cm->nChannelsEff;
qcInit.maxBits = MIN_BUFSIZE_PER_EFF_CHAN*cm->nChannelsEff;
qcInit.minBits = 0;
}
else
{
int maxBitres;
qcInit.averageBits = (averageBitsPerFrame+7)&~7;
@ -571,6 +578,8 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc,
qcInit.minBits = (config->minBitsPerFrame!=-1) ? fixMax(qcInit.minBits, config->minBitsPerFrame) : qcInit.minBits;
}
qcInit.sampleRate = config->sampleRate;
qcInit.advancedBitsToPe = isLowDelay(config->audioObjectType) ? 1 : 0 ;
qcInit.nSubFrames = config->nSubFrames;
qcInit.padding.paddingRest = config->sampleRate;

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -113,7 +113,7 @@ typedef enum {
/* initialization errors */
aac_enc_init_error_start = 0x2000,
AAC_ENC_INVALID_HANDLE = 0x2020, /*!< The handle passed to the function call was invalid (probably NULL). */
AAC_ENC_INVALID_FRAME_LENGTH = 0x2080, /*!< Invalid frame length (must be 1024 or 960). */
AAC_ENC_INVALID_FRAME_LENGTH = 0x2080, /*!< Invalid frame length. */
AAC_ENC_INVALID_N_CHANNELS = 0x20e0, /*!< Invalid amount of audio input channels. */
AAC_ENC_INVALID_SFB_TABLE = 0x2140, /*!< Internal encoder error. */
@ -154,7 +154,7 @@ typedef enum {
#define ANC_DATA_BUFFERSIZE 1024 /* ancBuffer size */
#define MAX_TOTAL_EXT_PAYLOADS (((6) * (1)) + (2+2))
#define MAX_TOTAL_EXT_PAYLOADS (((8) * (1)) + (2+2))
typedef enum {
@ -205,6 +205,8 @@ struct AACENC_CONFIG {
INT maxBitsPerFrame; /* maximum number of bits in AU */
INT bitreservoir; /* size of bitreservoir */
UINT sbrRatio; /* sbr sampling rate ratio: dual- or single-rate */
UCHAR useTns; /* flag: use temporal noise shaping */
UCHAR usePns; /* flag: use perceptual noise substitution */
UCHAR useIS; /* flag: use intensity coding */

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -97,8 +97,8 @@ amm-info@iis.fraunhofer.de
/* Encoder library info */
#define AACENCODER_LIB_VL0 3
#define AACENCODER_LIB_VL1 3
#define AACENCODER_LIB_VL2 3
#define AACENCODER_LIB_VL1 4
#define AACENCODER_LIB_VL2 12
#define AACENCODER_LIB_TITLE "AAC Encoder"
#define AACENCODER_LIB_BUILD_DATE __DATE__
#define AACENCODER_LIB_BUILD_TIME __TIME__
@ -118,10 +118,12 @@ amm-info@iis.fraunhofer.de
#define SBL(fl) (fl/8) /*!< Short block length (hardcoded to 8 short blocks per long block) */
#define BSLA(fl) (4*SBL(fl)+SBL(fl)/2) /*!< AAC block switching look-ahead */
#define DELAY_AAC(fl) (fl+BSLA(fl)) /*!< MDCT + blockswitching */
#define DELAY_AACELD(fl) ( (fl) + ((fl)/2) ) /*!< ELD FB delay */
#define DELAY_AACELD(fl) ((fl)/2) /*!< ELD FB delay (no framing delay included) */
#define INPUTBUFFER_SIZE (1537+100+2048)
#define DEFAULT_HEADER_PERIOD_REPETITION_RATE 10 /*!< Default header repetition rate used in transport library and for SBR header. */
////////////////////////////////////////////////////////////////////////////////////
/**
* Flags to characterize encoder modules to be supported in present instance.
@ -164,7 +166,8 @@ typedef struct {
UCHAR userMetaDataMode; /*!< Meta data library configuration. */
UCHAR userSbrEnabled;
UCHAR userSbrEnabled; /*!< Enable SBR for ELD. */
UINT userSbrRatio; /*!< SBR sampling rate ratio. Dual- or single-rate. */
} USER_PARAM;
@ -212,8 +215,8 @@ struct AACENCODER
AACENC_EXT_PAYLOAD extPayload [MAX_TOTAL_EXT_PAYLOADS];
/* Extension payload */
UCHAR extPayloadData [(1)][(6)][MAX_PAYLOAD_SIZE];
UINT extPayloadSize [(1)][(6)]; /* payload sizes in bits */
UCHAR extPayloadData [(1)][(8)][MAX_PAYLOAD_SIZE];
UINT extPayloadSize [(1)][(8)]; /* payload sizes in bits */
ULONG InitFlags; /* internal status to treggier re-initialization */
@ -227,12 +230,92 @@ struct AACENCODER
UINT encoder_modis;
/* Capabity flags */
/* Capability flags */
UINT CAPF_tpEnc;
} ;
////////////////////////////////////////////////////////////////////////////////////
typedef struct
{
ULONG samplingRate; /*!< Encoder output sampling rate. */
ULONG bitrateRange; /*!< Lower bitrate range for config entry. */
UCHAR lowDelaySbr; /*!< 0: ELD sbr off,
1: ELD sbr on */
UCHAR downsampledSbr; /*!< 0: ELD with dualrate sbr,
1: ELD with downsampled sbr */
} ELD_SBR_CONFIGURATOR;
/**
* \brief This table defines ELD/SBR default configurations.
*/
static const ELD_SBR_CONFIGURATOR eldSbrAutoConfigTab[] =
{
{ 48000, 0, 1, 0 },
{ 48000, 64001, 0, 0 },
{ 44100, 0, 1, 0 },
{ 44100, 64001, 0, 0 },
{ 32000, 0, 1, 0 },
{ 32000, 28000, 1, 1 },
{ 32000, 56000, 0, 0 },
{ 24000, 0, 1, 1 },
{ 24000, 40000, 0, 0 },
{ 16000, 0, 1, 1 },
{ 16000, 28000, 0, 0 }
};
/*
* \brief Configure SBR for ELD configuration.
*
* This function finds default SBR configuration for ELD based on sampling rate and channel bitrate.
* Outputparameters are SBR on/off, and SBR ratio.
*
* \param samplingRate Audio signal sampling rate.
* \param channelMode Channel configuration to be used.
* \param totalBitrate Overall bitrate.
* \param eldSbr Pointer to eldSbr parameter, filled on return.
* \param eldSbrRatio Pointer to eldSbrRatio parameter, filled on return.
*
* \return - AACENC_OK, all fine.
* - AACENC_INVALID_CONFIG, on failure.
*/
static AACENC_ERROR eldSbrConfigurator(
const ULONG samplingRate,
const CHANNEL_MODE channelMode,
const ULONG totalBitrate,
UINT * const eldSbr,
UINT * const eldSbrRatio
)
{
AACENC_ERROR err = AACENC_OK;
int i, cfgIdx = -1;
const ULONG channelBitrate = totalBitrate / FDKaacEnc_GetChannelModeConfiguration(channelMode)->nChannelsEff;
for (i=0; i<(sizeof(eldSbrAutoConfigTab)/sizeof(ELD_SBR_CONFIGURATOR)); i++) {
if ( (samplingRate <= eldSbrAutoConfigTab[i].samplingRate)
&& (channelBitrate >= eldSbrAutoConfigTab[i].bitrateRange) )
{
cfgIdx = i;
}
}
if (cfgIdx != -1) {
*eldSbr = (eldSbrAutoConfigTab[cfgIdx].lowDelaySbr==0) ? 0 : 1;
*eldSbrRatio = (eldSbrAutoConfigTab[cfgIdx].downsampledSbr==0) ? 2 : 1;
}
else {
err = AACENC_INVALID_CONFIG; /* no default configuration for eld-sbr available. */
}
return err;
}
static inline INT isSbrActive(const HANDLE_AACENC_CONFIG hAacConfig)
{
@ -253,6 +336,70 @@ static inline INT isSbrActive(const HANDLE_AACENC_CONFIG hAacConfig)
return ( sbrUsed );
}
static inline INT isPsActive(const AUDIO_OBJECT_TYPE audioObjectType)
{
INT psUsed = 0;
if ( (audioObjectType==AOT_PS)
|| (audioObjectType==AOT_MP2_PS)
|| (audioObjectType==AOT_DABPLUS_PS)
|| (audioObjectType==AOT_DRM_MPEG_PS) )
{
psUsed = 1;
}
return ( psUsed );
}
static SBR_PS_SIGNALING getSbrSignalingMode(
const AUDIO_OBJECT_TYPE audioObjectType,
const TRANSPORT_TYPE transportType,
const UCHAR transportSignaling,
const UINT sbrRatio
)
{
SBR_PS_SIGNALING sbrSignaling;
if (transportType==TT_UNKNOWN || sbrRatio==0) {
sbrSignaling = SIG_UNKNOWN; /* Needed parameters have not been set */
return sbrSignaling;
} else {
sbrSignaling = SIG_IMPLICIT; /* default: implicit signaling */
}
if ((audioObjectType==AOT_AAC_LC) || (audioObjectType==AOT_SBR) || (audioObjectType==AOT_PS) ||
(audioObjectType==AOT_MP2_AAC_LC) || (audioObjectType==AOT_MP2_SBR) || (audioObjectType==AOT_MP2_PS) ) {
switch (transportType) {
case TT_MP4_ADIF:
case TT_MP4_ADTS:
sbrSignaling = SIG_IMPLICIT; /* For MPEG-2 transport types, only implicit signaling is possible */
break;
case TT_MP4_RAW:
case TT_MP4_LATM_MCP1:
case TT_MP4_LATM_MCP0:
case TT_MP4_LOAS:
default:
if ( transportSignaling==0xFF ) {
/* Defaults */
if ( sbrRatio==1 ) {
sbrSignaling = SIG_EXPLICIT_HIERARCHICAL; /* For downsampled SBR, explicit signaling is mandatory */
} else {
sbrSignaling = SIG_IMPLICIT; /* For dual-rate SBR, implicit signaling is default */
}
} else {
/* User set parameters */
/* Attention: Backward compatible explicit signaling does only work with AMV1 for LATM/LOAS */
sbrSignaling = (SBR_PS_SIGNALING)transportSignaling;
}
break;
}
}
return sbrSignaling;
}
/****************************************************************************
Allocate Encoder
****************************************************************************/
@ -266,8 +413,12 @@ C_ALLOC_MEM (_AacEncoder, AACENCODER, 1)
/*
* Map Encoder specific config structures to CODER_CONFIG.
*/
static
void FDKaacEnc_MapConfig(CODER_CONFIG *cc, USER_PARAM *extCfg, HANDLE_AACENC_CONFIG hAacConfig)
static void FDKaacEnc_MapConfig(
CODER_CONFIG *const cc,
const USER_PARAM *const extCfg,
const SBR_PS_SIGNALING sbrSignaling,
const HANDLE_AACENC_CONFIG hAacConfig
)
{
AUDIO_OBJECT_TYPE transport_AOT = AOT_NULL_OBJECT;
FDKmemclear(cc, sizeof(CODER_CONFIG));
@ -304,17 +455,26 @@ void FDKaacEnc_MapConfig(CODER_CONFIG *cc, USER_PARAM *extCfg, HANDLE_AACENC_CON
}
/* Configure extension aot. */
if (extCfg->userTpSignaling==0) {
if (sbrSignaling==SIG_IMPLICIT) {
cc->extAOT = AOT_NULL_OBJECT; /* implicit */
}
else {
if ( (extCfg->userTpSignaling==1) && ( (transport_AOT==AOT_SBR) || (transport_AOT==AOT_PS) ) ) {
if ( (sbrSignaling==SIG_EXPLICIT_BW_COMPATIBLE) && ( (transport_AOT==AOT_SBR) || (transport_AOT==AOT_PS) ) ) {
cc->extAOT = AOT_SBR; /* explicit backward compatible */
}
else {
cc->extAOT = transport_AOT; /* explicit hierarchical */
}
}
if ( (transport_AOT==AOT_SBR) || (transport_AOT==AOT_PS) ) {
cc->sbrPresent=1;
if (transport_AOT==AOT_PS) {
cc->psPresent=1;
}
}
cc->sbrSignaling = sbrSignaling;
cc->extSamplingRate = extCfg->userSamplerate;
cc->bitRate = hAacConfig->bitRate;
cc->noChannels = hAacConfig->nChannels;
@ -335,7 +495,7 @@ void FDKaacEnc_MapConfig(CODER_CONFIG *cc, USER_PARAM *extCfg, HANDLE_AACENC_CON
case TT_MP4_ADTS:
case TT_MP4_LOAS:
case TT_MP4_LATM_MCP1:
cc->headerPeriod = 10;
cc->headerPeriod = DEFAULT_HEADER_PERIOD_REPETITION_RATE;
break;
default:
cc->headerPeriod = 0;
@ -351,7 +511,6 @@ void FDKaacEnc_MapConfig(CODER_CONFIG *cc, USER_PARAM *extCfg, HANDLE_AACENC_CON
case AOT_MP2_SBR:
case AOT_MP2_PS:
cc->flags &= ~CC_MPEG_ID; /* Required for ADTS. */
//config->userTpSignaling=0;
cc->extAOT = AOT_NULL_OBJECT;
break;
default:
@ -411,7 +570,7 @@ AAC_ENCODER_ERROR aacEncDefaultConfig(HANDLE_AACENC_CONFIG hAacConfig,
/* make reasonable default settings */
FDKaacEnc_AacInitDefaultConfig (hAacConfig);
/* clear confure structure and copy default settings */
/* clear configuration structure and copy default settings */
FDKmemclear(config, sizeof(USER_PARAM));
/* copy encoder configuration settings */
@ -438,7 +597,7 @@ AAC_ENCODER_ERROR aacEncDefaultConfig(HANDLE_AACENC_CONFIG hAacConfig,
/* initialize transport parameters */
config->userTpType = TT_UNKNOWN;
config->userTpAmxv = 0;
config->userTpSignaling = 0; /* default, implicit signaling */
config->userTpSignaling = 0xFF; /* choose signaling automatically */
config->userTpNsubFrames = 1;
config->userTpProtection = 0; /* not crc protected*/
config->userTpHeaderPeriod = 0xFF; /* header period in auto mode */
@ -447,6 +606,14 @@ AAC_ENCODER_ERROR aacEncDefaultConfig(HANDLE_AACENC_CONFIG hAacConfig,
config->userAncDataRate = 0;
/* SBR rate is set to 0 here, which means it should be set automatically
in FDKaacEnc_AdjustEncSettings() if the user did not set a rate
expilicitely. */
config->userSbrRatio = 0;
/* SBR enable set to -1 means to inquire ELD audio configurator for reasonable configuration. */
config->userSbrEnabled = -1;
return AAC_ENC_OK;
}
@ -481,6 +648,7 @@ INT aacEncoder_LimitBitrate(
INT bitRate,
const INT nSubFrames,
const INT sbrActive,
const INT sbrDownSampleRate,
const AUDIO_OBJECT_TYPE aot
)
{
@ -490,8 +658,7 @@ INT aacEncoder_LimitBitrate(
FDKaacEnc_InitChannelMapping(channelMode, CH_ORDER_MPEG, &cm);
if (sbrActive) {
/* Assume SBR rate ratio of 2:1 */
coreSamplingRate = samplingRate / 2;
coreSamplingRate = samplingRate >> (sbrEncoder_IsSingleRatePossible(aot) ? (sbrDownSampleRate-1):1);
} else {
coreSamplingRate = samplingRate;
}
@ -506,7 +673,7 @@ INT aacEncoder_LimitBitrate(
bitRate = FDKmin(576000*nChannels, bitRate);
/*bitRate = FDKmax(0*nChannels, bitRate);*/
}
/* Limit bit rate in respect to the core coder */
bitRate = FDKaacEnc_LimitBitrate(
@ -525,56 +692,58 @@ INT aacEncoder_LimitBitrate(
/* Limit bit rate in respect to available SBR modes if active */
if (sbrActive)
{
SBR_ELEMENT_INFO sbrElInfo[6];
INT sbrBitRate = 0;
int e, tooBig=-1;
int numIterations = 0;
INT initialBitrate, adjustedBitrate;
initialBitrate = adjustedBitrate = bitRate;
FDK_ASSERT(cm.nElements <= (6));
/* Find total bitrate which provides valid configuration for each SBR element. */
do {
int e;
SBR_ELEMENT_INFO sbrElInfo[(8)];
FDK_ASSERT(cm.nElements <= (8));
/* Get bit rate for each SBR element */
aacEncDistributeSbrBits(&cm, sbrElInfo, bitRate);
initialBitrate = adjustedBitrate;
for (e=0; e<cm.nElements; e++)
{
INT sbrElementBitRateIn, sbrBitRateOut;
/* Get bit rate for each SBR element */
aacEncDistributeSbrBits(&cm, sbrElInfo, initialBitrate);
if (cm.elInfo[e].elType != ID_SCE && cm.elInfo[e].elType != ID_CPE) {
continue;
}
sbrElementBitRateIn = sbrElInfo[e].bitRate;
sbrBitRateOut = sbrEncoder_LimitBitRate(sbrElementBitRateIn , cm.elInfo[e].nChannelsInEl, coreSamplingRate, aot);
if (sbrBitRateOut == 0) {
return 0;
}
if (sbrElementBitRateIn < sbrBitRateOut) {
FDK_ASSERT(tooBig != 1);
tooBig = 0;
if (e == 0) {
sbrBitRate = 0;
}
}
if (sbrElementBitRateIn > sbrBitRateOut) {
FDK_ASSERT(tooBig != 0);
tooBig = 1;
if (e == 0) {
sbrBitRate = 5000000;
}
}
if (tooBig != -1)
for (e=0; e<cm.nElements; e++)
{
INT sbrBitRateLimit = (INT)fDivNorm((FIXP_DBL)sbrBitRateOut, cm.elInfo[e].relativeBits);
if (tooBig) {
sbrBitRate = fMin(sbrBitRate, sbrBitRateLimit-16);
FDK_ASSERT( (INT)fMultNorm(cm.elInfo[e].relativeBits, (FIXP_DBL)sbrBitRate) < sbrBitRateOut);
} else {
sbrBitRate = fMax(sbrBitRate, sbrBitRateLimit+16);
FDK_ASSERT( (INT)fMultNorm(cm.elInfo[e].relativeBits, (FIXP_DBL)sbrBitRate) >= sbrBitRateOut);
INT sbrElementBitRateIn, sbrBitRateOut;
if (cm.elInfo[e].elType != ID_SCE && cm.elInfo[e].elType != ID_CPE) {
continue;
}
}
}
if (tooBig != -1) {
bitRate = sbrBitRate;
}
sbrElementBitRateIn = sbrElInfo[e].bitRate;
sbrBitRateOut = sbrEncoder_LimitBitRate(sbrElementBitRateIn , cm.elInfo[e].nChannelsInEl, coreSamplingRate, aot);
if (sbrBitRateOut == 0) {
return 0;
}
/* If bitrates don't match, distribution and limiting needs to be determined again.
Abort element loop and restart with adapted bitrate. */
if (sbrElementBitRateIn != sbrBitRateOut) {
if (sbrElementBitRateIn < sbrBitRateOut) {
adjustedBitrate = fMax(initialBitrate, (INT)fDivNorm((FIXP_DBL)(sbrBitRateOut+8), cm.elInfo[e].relativeBits));
break;
}
if (sbrElementBitRateIn > sbrBitRateOut) {
adjustedBitrate = fMin(initialBitrate, (INT)fDivNorm((FIXP_DBL)(sbrBitRateOut-8), cm.elInfo[e].relativeBits));
break;
}
} /* sbrElementBitRateIn != sbrBitRateOut */
} /* elements */
numIterations++; /* restrict iteration to worst case of num elements */
} while ( (initialBitrate!=adjustedBitrate) && (numIterations<=cm.nElements) );
/* Unequal bitrates mean that no reasonable bitrate configuration found. */
bitRate = (initialBitrate==adjustedBitrate) ? adjustedBitrate : 0;
}
FDK_ASSERT(bitRate > 0);
@ -624,26 +793,12 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
case AOT_MP2_SBR:
case AOT_MP2_PS:
hAacConfig->usePns = 0;
if (config->userTpSignaling!=0) {
return AACENC_INVALID_CONFIG; /* only implicit signaling allowed */
}
case AOT_AAC_LC:
case AOT_SBR:
case AOT_PS:
config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_MP4_ADTS;
hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 1024;
if (hAacConfig->framelength != 1024 && hAacConfig->framelength != 960) {
return AACENC_INVALID_CONFIG;
}
break;
case AOT_ER_AAC_LC:
hAacConfig->epConfig = 0;
hAacConfig->syntaxFlags |= AC_ER;
hAacConfig->syntaxFlags |= ((config->userErTools & 0x1) ? AC_ER_VCB11 : 0);
hAacConfig->syntaxFlags |= ((config->userErTools & 0x2) ? AC_ER_HCR : 0);
config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_MP4_LOAS;
hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 1024;
if (hAacConfig->framelength != 1024 && hAacConfig->framelength != 960) {
if (hAacConfig->framelength != 1024) {
return AACENC_INVALID_CONFIG;
}
break;
@ -665,7 +820,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
hAacConfig->syntaxFlags |= ((config->userErTools & 0x1) ? AC_ER_VCB11 : 0);
hAacConfig->syntaxFlags |= ((config->userErTools & 0x2) ? AC_ER_HCR : 0);
hAacConfig->syntaxFlags |= ((config->userErTools & 0x4) ? AC_ER_RVLC : 0);
hAacConfig->syntaxFlags |= ((config->userSbrEnabled) ? AC_SBR_PRESENT : 0);
hAacConfig->syntaxFlags |= ((config->userSbrEnabled==1) ? AC_SBR_PRESENT : 0);
config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_MP4_LOAS;
hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 512;
if (hAacConfig->framelength != 512 && hAacConfig->framelength != 480) {
@ -676,19 +831,6 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
break;
}
/* We need the frame length to call aacEncoder_LimitBitrate() */
hAacConfig->bitRate = aacEncoder_LimitBitrate(
NULL,
hAacConfig->sampleRate,
hAacConfig->framelength,
hAacConfig->nChannels,
hAacConfig->channelMode,
config->userBitrate,
hAacConfig->nSubFrames,
isSbrActive(hAacConfig),
hAacConfig->audioObjectType
);
switch ( hAacConfig->audioObjectType ) {
case AOT_ER_AAC_LD:
case AOT_ER_AAC_ELD:
@ -696,7 +838,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
hAacConfig->bitrateMode = 0;
}
if (config->userBitrateMode==0) {
hAacConfig->bitreservoir = 50*config->nChannels; /* default, reduced bitreservoir */
hAacConfig->bitreservoir = 100*config->nChannels; /* default, reduced bitreservoir */
}
if (hAacConfig->bitrateMode!=0) {
return AACENC_INVALID_CONFIG;
@ -706,6 +848,110 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
break;
}
hAacConfig->bitRate = config->userBitrate;
/* get bitrate in VBR configuration */
if ( (hAacConfig->bitrateMode>=1) && (hAacConfig->bitrateMode<=5) ) {
/* In VBR mode; SBR-modul depends on bitrate, core encoder on bitrateMode. */
hAacConfig->bitRate = FDKaacEnc_GetVBRBitrate(hAacConfig->bitrateMode, hAacConfig->channelMode);
}
/* Set default bitrate if no external bitrate declared. */
if ( (hAacConfig->bitrateMode==0) && (config->userBitrate==(UINT)-1) ) {
INT bitrate = FDKaacEnc_GetChannelModeConfiguration(hAacConfig->channelMode)->nChannelsEff * hAacConfig->sampleRate;
if ( isPsActive(hAacConfig->audioObjectType) ) {
hAacConfig->bitRate = (bitrate>>1); /* 0.5 bit per sample */
}
else if ( isSbrActive(hAacConfig) )
{
if ( (config->userSbrRatio==2) || ((config->userSbrRatio==0)&&(hAacConfig->audioObjectType!=AOT_ER_AAC_ELD)) ) {
hAacConfig->bitRate = (bitrate + (bitrate>>2))>>1; /* 0.625 bits per sample */
}
if ( (config->userSbrRatio==1) || ((config->userSbrRatio==0)&&(hAacConfig->audioObjectType==AOT_ER_AAC_ELD)) ) {
hAacConfig->bitRate = (bitrate + (bitrate>>3)); /* 1.125 bits per sample */
}
} else
{
hAacConfig->bitRate = bitrate + (bitrate>>1); /* 1.5 bits per sample */
}
}
/* Initialize SBR parameters */
if ( (hAacConfig->audioObjectType==AOT_ER_AAC_ELD)
&& (config->userSbrEnabled == (UCHAR)-1) && (config->userSbrRatio==0) )
{
UINT eldSbr = 0;
UINT eldSbrRatio = 0;
if ( AACENC_OK!=(err=eldSbrConfigurator(
hAacConfig->sampleRate,
hAacConfig->channelMode,
hAacConfig->bitRate,
&eldSbr,
&eldSbrRatio)) )
{
return err;
}
hAacConfig->syntaxFlags |= ((eldSbr) ? AC_SBR_PRESENT : 0);
hAacConfig->sbrRatio = eldSbrRatio;
}
else
if ( (config->userSbrRatio==0) && (isSbrActive(hAacConfig)) ) {
/* Automatic SBR ratio configuration
* - downsampled SBR for ELD
* - otherwise always dualrate SBR
*/
hAacConfig->sbrRatio = (hAacConfig->audioObjectType==AOT_ER_AAC_ELD) ? 1 : 2;
}
else {
/* SBR ratio has been set by the user, so use it. */
hAacConfig->sbrRatio = config->userSbrRatio;
}
{
UCHAR tpSignaling=getSbrSignalingMode(hAacConfig->audioObjectType, config->userTpType, config->userTpSignaling, hAacConfig->sbrRatio);
if ( (hAacConfig->audioObjectType==AOT_AAC_LC || hAacConfig->audioObjectType==AOT_SBR || hAacConfig->audioObjectType==AOT_PS) &&
(config->userTpType==TT_MP4_LATM_MCP1 || config->userTpType==TT_MP4_LATM_MCP0 || config->userTpType==TT_MP4_LOAS) &&
(tpSignaling==1) && (config->userTpAmxv==0) ) {
/* For backward compatible explicit signaling, AMV1 has to be active */
return AACENC_INVALID_CONFIG;
}
if ( (hAacConfig->audioObjectType==AOT_AAC_LC || hAacConfig->audioObjectType==AOT_SBR || hAacConfig->audioObjectType==AOT_PS) &&
(tpSignaling==0) && (hAacConfig->sbrRatio==1)) {
/* Downsampled SBR has to be signaled explicitely (for transmission of SBR sampling fequency) */
return AACENC_INVALID_CONFIG;
}
}
/* We need the frame length to call aacEncoder_LimitBitrate() */
hAacConfig->bitRate = aacEncoder_LimitBitrate(
NULL,
hAacConfig->sampleRate,
hAacConfig->framelength,
hAacConfig->nChannels,
hAacConfig->channelMode,
hAacConfig->bitRate,
hAacConfig->nSubFrames,
isSbrActive(hAacConfig),
hAacConfig->sbrRatio,
hAacConfig->audioObjectType
);
/* Configure PNS */
if ( ((hAacConfig->bitrateMode>=1) && (hAacConfig->bitrateMode<=5)) /* VBR without PNS. */
|| (hAacConfig->useTns == 0) ) /* TNS required. */
{
hAacConfig->usePns = 0;
}
if (hAacConfig->epConfig >= 0) {
hAacConfig->syntaxFlags |= AC_ER;
if (((INT)hAacConfig->channelMode < 1) || ((INT)hAacConfig->channelMode > 7)) {
@ -725,47 +971,13 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
return AACENC_INVALID_CONFIG; /* not enough channels allocated */
}
/* get bitrate in VBR configuration */
if ( (hAacConfig->bitrateMode>=1) && (hAacConfig->bitrateMode<=5) ) {
/* In VBR mode; SBR-modul depends on bitrate, core encoder on bitrateMode. */
hAacConfig->bitRate = FDKaacEnc_GetVBRBitrate(hAacConfig->bitrateMode, hAacConfig->channelMode);
}
/* Set default bitrate if no external bitrate declared. */
if (hAacConfig->bitRate==-1) {
INT bitrate = FDKaacEnc_GetChannelModeConfiguration(hAacConfig->channelMode)->nChannelsEff * hAacConfig->sampleRate;
switch (hAacConfig->audioObjectType)
{
case AOT_AAC_LC:
hAacConfig->bitRate = bitrate + (bitrate>>1); /* 1.5 bits per sample */
break;
case AOT_SBR:
hAacConfig->bitRate = (bitrate + (bitrate>>2))>>1; /* 0.625 bits per sample */
break;
case AOT_PS:
hAacConfig->bitRate = (bitrate>>1); /* 0.5 bit per sample */
break;
default:
hAacConfig->bitRate = bitrate;
break;
}
}
/* Configure PNS */
if ( ((hAacConfig->bitrateMode>=1) && (hAacConfig->bitrateMode<=5)) /* VBR without PNS. */
|| (hAacConfig->useTns == 0) ) /* TNS required. */
{
hAacConfig->usePns = 0;
}
/* Meta data restriction. */
switch (hAacConfig->audioObjectType)
{
/* Allow metadata support */
case AOT_AAC_LC:
case AOT_SBR:
case AOT_PS:
hAacEncoder->metaDataAllowed = 1;
if (((INT)hAacConfig->channelMode < 1) || ((INT)hAacConfig->channelMode > 7)) {
config->userMetaDataMode = 0;
@ -849,10 +1061,8 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder,
((InitFlags & AACENC_INIT_CONFIG) || (InitFlags & AACENC_INIT_STATES)) )
{
INT sbrError;
SBR_ELEMENT_INFO sbrElInfo[(6)];
SBR_ELEMENT_INFO sbrElInfo[(8)];
CHANNEL_MAPPING channelMapping;
AUDIO_OBJECT_TYPE aot = hAacConfig->audioObjectType;
if ( FDKaacEnc_InitChannelMapping(hAacConfig->channelMode,
hAacConfig->channelOrder,
@ -862,7 +1072,7 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder,
}
/* Check return value and if the SBR encoder can handle enough elements */
if (channelMapping.nElements > (6)) {
if (channelMapping.nElements > (8)) {
return AACENC_INIT_ERROR;
}
@ -881,15 +1091,17 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder,
&aacBufferOffset,
&hAacConfig->nChannels,
&hAacConfig->sampleRate,
&hAacConfig->sbrRatio,
&frameLength,
&hAacConfig->audioObjectType,
hAacConfig->audioObjectType,
&hAacEncoder->nDelay,
(hAacConfig->audioObjectType == AOT_ER_AAC_ELD) ? 1 : TRANS_FAC,
(config->userTpHeaderPeriod!=0xFF) ? config->userTpHeaderPeriod : DEFAULT_HEADER_PERIOD_REPETITION_RATE,
initFlag
);
/* Suppress AOT reconfiguration and check error status. */
if ( sbrError || (hAacConfig->audioObjectType!=aot) ) {
if (sbrError) {
return AACENC_INIT_SBR_ERROR;
}
@ -915,7 +1127,11 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder,
{
UINT flags = 0;
FDKaacEnc_MapConfig(&hAacEncoder->coderConfig, config, hAacConfig);
FDKaacEnc_MapConfig(
&hAacEncoder->coderConfig,
config,
getSbrSignalingMode(hAacConfig->audioObjectType, config->userTpType, config->userTpSignaling, hAacConfig->sbrRatio),
hAacConfig);
/* create flags for transport encoder */
if (config->userTpAmxv == 1) {
@ -958,7 +1174,7 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder,
INT inputDataDelay = DELAY_AAC(hAacConfig->framelength);
if ( isSbrActive(hAacConfig) && hSbrEncoder!=NULL) {
inputDataDelay = 2*inputDataDelay + sbrEncoder_GetInputDataDelay(*hSbrEncoder);
inputDataDelay = hAacConfig->sbrRatio*inputDataDelay + sbrEncoder_GetInputDataDelay(*hSbrEncoder);
}
if ( FDK_MetadataEnc_Init(hAacEncoder->hMetadataEnc,
@ -1033,8 +1249,8 @@ AACENC_ERROR aacEncOpen(
/* Determine max channel configuration. */
if (maxChannels==0) {
hAacEncoder->nMaxAacChannels = (6);
hAacEncoder->nMaxSbrChannels = (6);
hAacEncoder->nMaxAacChannels = (8);
hAacEncoder->nMaxSbrChannels = (8);
}
else {
hAacEncoder->nMaxAacChannels = (maxChannels&0x00FF);
@ -1042,15 +1258,15 @@ AACENC_ERROR aacEncOpen(
hAacEncoder->nMaxSbrChannels = (maxChannels&0xFF00) ? (maxChannels>>8) : hAacEncoder->nMaxAacChannels;
}
if ( (hAacEncoder->nMaxAacChannels>(6)) || (hAacEncoder->nMaxSbrChannels>(6)) ) {
if ( (hAacEncoder->nMaxAacChannels>(8)) || (hAacEncoder->nMaxSbrChannels>(8)) ) {
err = AACENC_INVALID_CONFIG;
goto bail;
}
} /* maxChannels==0 */
/* Max number of elements could be tuned any more. */
hAacEncoder->nMaxAacElements = fixMin((6), hAacEncoder->nMaxAacChannels);
hAacEncoder->nMaxSbrElements = fixMin((6), hAacEncoder->nMaxSbrChannels);
hAacEncoder->nMaxAacElements = fixMin((8), hAacEncoder->nMaxAacChannels);
hAacEncoder->nMaxSbrElements = fixMin((8), hAacEncoder->nMaxSbrChannels);
hAacEncoder->nMaxSubFrames = (1);
@ -1108,7 +1324,7 @@ AACENC_ERROR aacEncOpen(
goto bail;
}
else {
C_ALLOC_SCRATCH_START(pLibInfo, LIB_INFO, FDK_MODULE_LAST);
C_ALLOC_SCRATCH_START(pLibInfo, LIB_INFO, FDK_MODULE_LAST);
FDKinitLibInfo( pLibInfo);
transportEnc_GetLibInfo( pLibInfo );
@ -1343,8 +1559,12 @@ AACENC_ERROR aacEncEncode(
for (i=0; i<(INT)nMetaDataExtensions; i++) { /* Get meta data extension payload. */
hAacEncoder->extPayload[nExtensions++] = pMetaDataExtPayload[i];
}
if (matrix_mixdown_idx!=-1) { /* Set matrix mixdown coefficient. */
UINT pceValue = (UINT)( (1<<3) | ((matrix_mixdown_idx&0x2)<<1) | 1 );
if ( (matrix_mixdown_idx!=-1)
&& ((hAacEncoder->extParam.userChannelMode==MODE_1_2_2)||(hAacEncoder->extParam.userChannelMode==MODE_1_2_2_1)) )
{
/* Set matrix mixdown coefficient. */
UINT pceValue = (UINT)( (1<<3) | ((matrix_mixdown_idx&0x3)<<1) | 1 );
if (hAacEncoder->extParam.userPceAdditions != pceValue) {
hAacEncoder->extParam.userPceAdditions = pceValue;
hAacEncoder->InitFlags |= AACENC_INIT_TRANSPORT;
@ -1375,7 +1595,7 @@ AACENC_ERROR aacEncEncode(
}
else {
/* Add SBR extension payload */
for (i = 0; i < (6); i++) {
for (i = 0; i < (8); i++) {
if (hAacEncoder->extPayloadSize[nPayload][i] > 0) {
hAacEncoder->extPayload[nExtensions].pData = hAacEncoder->extPayloadData[nPayload][i];
{
@ -1573,7 +1793,6 @@ AACENC_ERROR aacEncoder_SetParam(
}
case AOT_AAC_LC:
case AOT_MP2_AAC_LC:
case AOT_ER_AAC_LC:
case AOT_ER_AAC_LD:
case AOT_ER_AAC_ELD:
if (!(hAacEncoder->encoder_modis & (ENC_MODE_FLAG_AAC))) {
@ -1636,7 +1855,7 @@ AACENC_ERROR aacEncoder_SetParam(
}
if ( (pConfig->nElements > hAacEncoder->nMaxAacElements)
|| (pConfig->nChannelsEff > hAacEncoder->nMaxAacChannels)
|| !((value>=1) && (value<=6))
|| !(((value>=1) && (value<=7))||((value>=33) && (value<=34)))
)
{
err = AACENC_INVALID_CONFIG;
@ -1691,6 +1910,16 @@ AACENC_ERROR aacEncoder_SetParam(
}
}
break;
case AACENC_SBR_RATIO:
if (settings->userSbrRatio != value) {
if (! ((value==0) || (value==1) || (value==2)) ) {
err = AACENC_INVALID_CONFIG;
break;
}
settings->userSbrRatio = value;
hAacEncoder->InitFlags |= AACENC_INIT_CONFIG | AACENC_INIT_STATES | AACENC_INIT_TRANSPORT;
}
break;
case AACENC_SBR_MODE:
if (settings->userSbrEnabled != value) {
settings->userSbrEnabled = value;
@ -1812,7 +2041,7 @@ UINT aacEncoder_GetParam(
value = (UINT)hAacEncoder->aacConfig.bitrateMode;
break;
case AACENC_SAMPLERATE:
value = (UINT)settings->userSamplerate;
value = (UINT)hAacEncoder->coderConfig.extSamplingRate;
break;
case AACENC_CHANNELMODE:
value = (UINT)hAacEncoder->aacConfig.channelMode;
@ -1829,6 +2058,9 @@ UINT aacEncoder_GetParam(
case AACENC_GRANULE_LENGTH:
value = (UINT)hAacEncoder->aacConfig.framelength;
break;
case AACENC_SBR_RATIO:
value = isSbrActive(&hAacEncoder->aacConfig) ? hAacEncoder->aacConfig.sbrRatio : 0;
break;
case AACENC_SBR_MODE:
value = (UINT) (hAacEncoder->aacConfig.syntaxFlags & AC_SBR_PRESENT) ? 1 : 0;
break;
@ -1836,7 +2068,7 @@ UINT aacEncoder_GetParam(
value = (UINT)settings->userTpType;
break;
case AACENC_SIGNALING_MODE:
value = (UINT)settings->userTpSignaling;
value = (UINT)getSbrSignalingMode(hAacEncoder->aacConfig.audioObjectType, settings->userTpType, settings->userTpSignaling, hAacEncoder->aacConfig.sbrRatio);
break;
case AACENC_PROTECTION:
value = (UINT)settings->userTpProtection;

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -83,7 +83,7 @@ amm-info@iis.fraunhofer.de
/******************************** MPEG Audio Encoder **************************
Initial author: Alex Groeschel
Initial author: Alex Groeschel, Tobias Chalupka
contents/description: Temporal noise shaping
******************************************************************************/
@ -281,7 +281,6 @@ static INT getTnsMaxBands(
int maxBandsTabSize = 0;
switch (granuleLength) {
case 960:
case 1024:
pMaxBandsTab = tnsMaxBandsTab1024;
maxBandsTabSize = sizeof(tnsMaxBandsTab1024)/sizeof(TNS_MAX_TAB_ENTRY);
@ -404,7 +403,6 @@ AAC_ENCODER_ERROR FDKaacEnc_InitTnsConfiguration(INT bitRate,
tC->lpcStopLine = pC->sfbOffset[tC->lpcStopBand];
switch (granuleLength) {
case 960:
case 1024:
/* TNS start line: skip lower MDCT lines to prevent artifacts due to filter mismatch */
tC->lpcStartBand[LOFILT] = (blockType == SHORT_WINDOW) ? 0 : ((sampleRate < 18783) ? 4 : 8);

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -123,6 +123,117 @@ static const FIXP_DBL SnrLdMin4 = (FIXP_DBL)0x02000000; /*FL2FXCONST_DBL(FDKlog
static const FIXP_DBL SnrLdMin5 = (FIXP_DBL)0xfc000000; /*FL2FXCONST_DBL(FDKlog(0.25) /FDKlog(2.0)/LD_DATA_SCALING);*/
/*
The bits2Pe factors are choosen for the case that some times
the crash recovery strategy will be activated once.
*/
typedef struct {
INT bitrate;
LONG bits2PeFactor_mono;
LONG bits2PeFactor_mono_slope;
LONG bits2PeFactor_stereo;
LONG bits2PeFactor_stereo_slope;
LONG bits2PeFactor_mono_scfOpt;
LONG bits2PeFactor_mono_scfOpt_slope;
LONG bits2PeFactor_stereo_scfOpt;
LONG bits2PeFactor_stereo_scfOpt_slope;
} BIT_PE_SFAC;
typedef struct {
const INT sampleRate;
const BIT_PE_SFAC * pPeTab;
const INT nEntries;
} BITS2PE_CFG_TAB;
static const BIT_PE_SFAC S_Bits2PeTab16000[] = {
{ 10000, 0x228F5C29, 0x02FEF55D, 0x1D70A3D7, 0x09BC9D6D, 0x228F5C29, 0x02FEF55D, 0x1C28F5C3, 0x0CBB92CA},
{ 24000, 0x23D70A3D, 0x029F16B1, 0x2199999A, 0x07DD4413, 0x23D70A3D, 0x029F16B1, 0x2199999A, 0x07DD4413},
{ 32000, 0x247AE148, 0x11B1D92B, 0x23851EB8, 0x01F75105, 0x247AE148, 0x110A137F, 0x23851EB8, 0x01F75105},
{ 48000, 0x2D1EB852, 0x6833C600, 0x247AE148, 0x014F8B59, 0x2CCCCCCD, 0x68DB8BAC, 0x247AE148, 0x01F75105},
{ 64000, 0x60000000, 0x00000000, 0x251EB852, 0x154C985F, 0x60000000, 0x00000000, 0x2570A3D7, 0x154C985F},
{ 96000, 0x60000000, 0x00000000, 0x39EB851F, 0x088509C0, 0x60000000, 0x00000000, 0x3A3D70A4, 0x088509C0},
{128000, 0x60000000, 0x00000000, 0x423D70A4, 0x18A43BB4, 0x60000000, 0x00000000, 0x428F5C29, 0x181E03F7},
{148000, 0x60000000, 0x00000000, 0x5147AE14, 0x00000000, 0x60000000, 0x00000000, 0x5147AE14, 0x00000000}
};
static const BIT_PE_SFAC S_Bits2PeTab22050[] = {
{ 16000, 0x1a8f5c29, 0x1797cc3a, 0x128f5c29, 0x18e75793, 0x175c28f6, 0x221426fe, 0x00000000, 0x5a708ede},
{ 24000, 0x2051eb85, 0x092ccf6c, 0x18a3d70a, 0x13a92a30, 0x1fae147b, 0xbcbe61d, 0x16147ae1, 0x18e75793},
{ 32000, 0x228f5c29, 0x029f16b1, 0x1d70a3d7, 0x088509c0, 0x228f5c29, 0x29f16b1, 0x1c28f5c3, 0x0b242071},
{ 48000, 0x23d70a3d, 0x014f8b59, 0x2199999a, 0x03eea20a, 0x23d70a3d, 0x14f8b59, 0x2199999a, 0x03eea20a},
{ 64000, 0x247ae148, 0x08d8ec96, 0x23851eb8, 0x00fba882, 0x247ae148, 0x88509c0, 0x23851eb8, 0x00fba882},
{ 96000, 0x2d1eb852, 0x3419e300, 0x247ae148, 0x00a7c5ac, 0x2ccccccd, 0x346dc5d6, 0x247ae148, 0x00fba882},
{128000, 0x60000000, 0x00000000, 0x251eb852, 0x029f16b1, 0x60000000, 0x00000000, 0x2570a3d7, 0x009f16b1},
{148000, 0x60000000, 0x00000000, 0x26b851ec, 0x00000000, 0x60000000, 0x00000000, 0x270a3d71, 0x00000000}
};
static const BIT_PE_SFAC S_Bits2PeTab24000[] = {
{ 16000, 0x19eb851f, 0x13a92a30, 0x1147ae14, 0x164840e1, 0x1999999a, 0x12599ed8, 0x00000000, 0x46c764ae},
{ 24000, 0x1eb851ec, 0x0d1b7176, 0x16b851ec, 0x18e75793, 0x1e147ae1, 0x0fba8827, 0x1147ae14, 0x2c9081c3},
{ 32000, 0x21eb851f, 0x049667b6, 0x1ccccccd, 0x07357e67, 0x21eb851f, 0x03eea20a, 0x1c28f5c3, 0x07357e67},
{ 48000, 0x2428f5c3, 0x014f8b59, 0x2051eb85, 0x053e2d62, 0x23d70a3d, 0x01f75105, 0x1fae147b, 0x07357e67},
{ 64000, 0x24cccccd, 0x05e5f30e, 0x22e147ae, 0x01a36e2f, 0x24cccccd, 0x05e5f30e, 0x23333333, 0x014f8b59},
{ 96000, 0x2a8f5c29, 0x24b33db0, 0x247ae148, 0x00fba882, 0x2a8f5c29, 0x26fe718b, 0x247ae148, 0x00fba882},
{128000, 0x4e666666, 0x1cd5f99c, 0x2570a3d7, 0x010c6f7a, 0x50a3d70a, 0x192a7371, 0x2570a3d7, 0x010c6f7a},
{148000, 0x60000000, 0x00000000, 0x26147ae1, 0x00000000, 0x60000000, 0x00000000, 0x26147ae1, 0x00000000}
};
static const BIT_PE_SFAC S_Bits2PeTab32000[] = {
{ 16000, 0x1199999a, 0x20c49ba6, 0x00000000, 0x4577d955, 0x00000000, 0x60fe4799, 0x00000000, 0x00000000},
{ 24000, 0x1999999a, 0x0fba8827, 0x10f5c28f, 0x1b866e44, 0x17ae147b, 0x0fba8827, 0x00000000, 0x4d551d69},
{ 32000, 0x1d70a3d7, 0x07357e67, 0x17ae147b, 0x09d49518, 0x1b851eb8, 0x0a7c5ac4, 0x12e147ae, 0x110a137f},
{ 48000, 0x20f5c28f, 0x049667b6, 0x1c7ae148, 0x053e2d62, 0x20a3d70a, 0x053e2d62, 0x1b333333, 0x05e5f30e},
{ 64000, 0x23333333, 0x029f16b1, 0x1f0a3d71, 0x02f2f987, 0x23333333, 0x029f16b1, 0x1e147ae1, 0x03eea20a},
{ 96000, 0x25c28f5c, 0x2c3c9eed, 0x21eb851f, 0x01f75105, 0x25c28f5c, 0x0a7c5ac4, 0x21eb851f, 0x01a36e2f},
{128000, 0x50f5c28f, 0x18a43bb4, 0x23d70a3d, 0x010c6f7a, 0x30000000, 0x168b5cc0, 0x23851eb8, 0x0192a737},
{148000, 0x60000000, 0x00000000, 0x247ae148, 0x00dfb23b, 0x3dc28f5c, 0x300f4aaf, 0x247ae148, 0x01bf6476},
{160000, 0x60000000, 0xb15b5740, 0x24cccccd, 0x053e2d62, 0x4f5c28f6, 0xbefd0072, 0x251eb852, 0x04fb1184},
{200000, 0x00000000, 0x00000000, 0x2b333333, 0x0836be91, 0x00000000, 0x00000000, 0x2b333333, 0x0890390f},
{320000, 0x00000000, 0x00000000, 0x4947ae14, 0x00000000, 0x00000000, 0x00000000, 0x4a8f5c29, 0x00000000}
};
static const BIT_PE_SFAC S_Bits2PeTab44100[] = {
{ 16000, 0x10a3d70a, 0x1797cc3a, 0x00000000, 0x00000000, 0x00000000, 0x59210386, 0x00000000, 0x00000000},
{ 24000, 0x16666666, 0x1797cc3a, 0x00000000, 0x639d5e4a, 0x15c28f5c, 0x12599ed8, 0x00000000, 0x5bc01a37},
{ 32000, 0x1c28f5c3, 0x049667b6, 0x1851eb85, 0x049667b6, 0x1a3d70a4, 0x088509c0, 0x16666666, 0x053e2d62},
{ 48000, 0x1e666666, 0x05e5f30e, 0x1a8f5c29, 0x049667b6, 0x1e666666, 0x05e5f30e, 0x18f5c28f, 0x05e5f30e},
{ 64000, 0x2147ae14, 0x0346dc5d, 0x1ccccccd, 0x02f2f987, 0x2147ae14, 0x02f2f987, 0x1bd70a3d, 0x039abf34},
{ 96000, 0x247ae148, 0x068db8bb, 0x1fae147b, 0x029f16b1, 0x2428f5c3, 0x0639d5e5, 0x1f5c28f6, 0x029f16b1},
{128000, 0x2ae147ae, 0x1b435265, 0x223d70a4, 0x0192a737, 0x2a3d70a4, 0x1040bfe4, 0x21eb851f, 0x0192a737},
{148000, 0x3b851eb8, 0x2832069c, 0x23333333, 0x00dfb23b, 0x3428f5c3, 0x2054c288, 0x22e147ae, 0x00dfb23b},
{160000, 0x4a3d70a4, 0xc32ebe5a, 0x23851eb8, 0x01d5c316, 0x40000000, 0xcb923a2b, 0x23333333, 0x01d5c316},
{200000, 0x00000000, 0x00000000, 0x25c28f5c, 0x0713f078, 0x00000000, 0x00000000, 0x2570a3d7, 0x072a4f17},
{320000, 0x00000000, 0x00000000, 0x3fae147b, 0x00000000, 0x00000000, 0x00000000, 0x3fae147b, 0x00000000}
};
static const BIT_PE_SFAC S_Bits2PeTab48000[] = {
{ 16000, 0x0f5c28f6, 0x31ceaf25, 0x00000000, 0x00000000, 0x00000000, 0x74a771c9, 0x00000000, 0x00000000},
{ 24000, 0x1b851eb8, 0x029f16b1, 0x00000000, 0x663c74fb, 0x1c7ae148, 0xe47991bd, 0x00000000, 0x49667b5f},
{ 32000, 0x1c28f5c3, 0x029f16b1, 0x18f5c28f, 0x07357e67, 0x15c28f5c, 0x0f12c27a, 0x11eb851f, 0x13016484},
{ 48000, 0x1d70a3d7, 0x053e2d62, 0x1c7ae148, 0xfe08aefc, 0x1d1eb852, 0x068db8bb, 0x1b333333, 0xfeb074a8},
{ 64000, 0x20000000, 0x03eea20a, 0x1b851eb8, 0x0346dc5d, 0x2051eb85, 0x0346dc5d, 0x1a8f5c29, 0x039abf34},
{ 96000, 0x23d70a3d, 0x053e2d62, 0x1eb851ec, 0x029f16b1, 0x23851eb8, 0x04ea4a8c, 0x1e147ae1, 0x02f2f987},
{128000, 0x28f5c28f, 0x14727dcc, 0x2147ae14, 0x0218def4, 0x2851eb85, 0x0e27e0f0, 0x20f5c28f, 0x0218def4},
{148000, 0x3570a3d7, 0x1cd5f99c, 0x228f5c29, 0x01bf6476, 0x30f5c28f, 0x18777e75, 0x223d70a4, 0x01bf6476},
{160000, 0x40000000, 0xcb923a2b, 0x23333333, 0x0192a737, 0x39eb851f, 0xd08d4bae, 0x22e147ae, 0x0192a737},
{200000, 0x00000000, 0x00000000, 0x251eb852, 0x06775a1b, 0x00000000, 0x00000000, 0x24cccccd, 0x06a4175a},
{320000, 0x00000000, 0x00000000, 0x3ccccccd, 0x00000000, 0x00000000, 0x00000000, 0x3d1eb852, 0x00000000}
};
static const BITS2PE_CFG_TAB bits2PeConfigTab[] = {
{ 16000, S_Bits2PeTab16000, sizeof(S_Bits2PeTab16000)/sizeof(BIT_PE_SFAC) },
{ 22050, S_Bits2PeTab22050, sizeof(S_Bits2PeTab22050)/sizeof(BIT_PE_SFAC) },
{ 24000, S_Bits2PeTab24000, sizeof(S_Bits2PeTab24000)/sizeof(BIT_PE_SFAC) },
{ 32000, S_Bits2PeTab32000, sizeof(S_Bits2PeTab32000)/sizeof(BIT_PE_SFAC) },
{ 44100, S_Bits2PeTab44100, sizeof(S_Bits2PeTab44100)/sizeof(BIT_PE_SFAC) },
{ 48000, S_Bits2PeTab48000, sizeof(S_Bits2PeTab48000)/sizeof(BIT_PE_SFAC) }
};
/* values for avoid hole flag */
enum _avoid_hole_state {
NO_AH =0,
@ -135,6 +246,99 @@ enum _avoid_hole_state {
#define Q_BITFAC (24) /* Q scaling used in FDKaacEnc_bitresCalcBitFac() calculation */
#define Q_AVGBITS (17) /* scale bit values */
/*****************************************************************************
functionname: FDKaacEnc_InitBits2PeFactor
description: retrieve bits2PeFactor from table
*****************************************************************************/
static void FDKaacEnc_InitBits2PeFactor(
FIXP_DBL *bits2PeFactor_m,
INT *bits2PeFactor_e,
const INT bitRate,
const INT nChannels,
const INT sampleRate,
const INT advancedBitsToPe,
const INT invQuant
)
{
/* default bits2pe factor */
FIXP_DBL bit2PE_m = FL2FXCONST_DBL(1.18f/(1<<(1)));
INT bit2PE_e = 1;
/* make use of advanced bits to pe factor table */
if (advancedBitsToPe) {
int i;
const BIT_PE_SFAC *peTab = NULL;
INT size = 0;
/* Get correct table entry */
for (i=0; i<(INT)(sizeof(bits2PeConfigTab)/sizeof(BITS2PE_CFG_TAB)); i++) {
if (sampleRate >= bits2PeConfigTab[i].sampleRate) {
peTab = bits2PeConfigTab[i].pPeTab;
size = bits2PeConfigTab[i].nEntries;
}
}
if ( (peTab!=NULL) && (size!=0) ) {
INT startB = -1;
LONG startPF = 0;
LONG peSlope = 0;
/* stereo or mono mode and invQuant used or not */
for (i=0; i<size-1; i++)
{
if ((peTab[i].bitrate<=bitRate) && ((peTab[i+1].bitrate>bitRate) || ((i==size-2)) ))
{
if (nChannels==1)
{
startPF = (!invQuant) ? peTab[i].bits2PeFactor_mono : peTab[i].bits2PeFactor_mono_scfOpt;
peSlope = (!invQuant) ? peTab[i].bits2PeFactor_mono_slope : peTab[i].bits2PeFactor_mono_scfOpt_slope;
/*endPF = (!invQuant) ? peTab[i+1].bits2PeFactor_mono : peTab[i+1].bits2PeFactor_mono_scfOpt;
endB=peTab[i+1].bitrate;*/
startB=peTab[i].bitrate;
break;
}
else
{
startPF = (!invQuant) ? peTab[i].bits2PeFactor_stereo : peTab[i].bits2PeFactor_stereo_scfOpt;
peSlope = (!invQuant) ? peTab[i].bits2PeFactor_stereo_slope : peTab[i].bits2PeFactor_stereo_scfOpt_slope;
/*endPF = (!invQuant) ? peTab[i+1].bits2PeFactor_stereo : peTab[i+1].bits2PeFactor_stereo_scfOpt;
endB=peTab[i+1].bitrate;*/
startB=peTab[i].bitrate;
break;
}
}
} /* for i */
/* if a configuration is available */
if (startB!=-1) {
/* linear interpolate to actual PEfactor */
FIXP_DBL peFac = fMult((FIXP_DBL)(bitRate-startB)<<14, (FIXP_DBL)peSlope) << 2;
FIXP_DBL bit2PE = peFac + (FIXP_DBL)startPF; /* startPF_float = startPF << 2 */
/* sanity check if bits2pe value is high enough */
if ( bit2PE >= (FL2FXCONST_DBL(0.35f) >> 2) ) {
bit2PE_m = bit2PE;
bit2PE_e = 2; /* table is fixed scaled */
}
} /* br */
} /* sr */
} /* advancedBitsToPe */
/* return bits2pe factor */
*bits2PeFactor_m = bit2PE_m;
*bits2PeFactor_e = bit2PE_e;
}
/*****************************************************************************
functionname: FDKaacEnc_bits2pe2
description: convert from bits to pe
*****************************************************************************/
static INT FDKaacEnc_bits2pe2(
const INT bits,
const FIXP_DBL factor_m,
@ -450,22 +654,23 @@ void FDKaacEnc_calcWeighting(PE_DATA *peData,
FIXP_DBL nrgSum14, nrgSum12, nrgSum34, nrgTotal;
FIXP_DBL nrgFacLd_14, nrgFacLd_12, nrgFacLd_34;
INT usePatch, exePatch;
int sfb, nLinesSum = 0;
int sfb, sfbGrp, nLinesSum = 0;
nrgSum14 = nrgSum12 = nrgSum34 = nrgTotal = FL2FXCONST_DBL(0.f);
/* calculate flatness of audible spectrum, i.e. spectrum above masking threshold. */
for (sfb = 0; sfb < psyOutChan->sfbCnt; sfb++) {
FIXP_DBL nrgFac12 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfb]>>1); /* nrg^(1/2) */
FIXP_DBL nrgFac14 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfb]>>2); /* nrg^(1/4) */
for (sfbGrp = 0;sfbGrp < psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutChannel[ch]->sfbPerGroup) {
for (sfb=0; sfb<psyOutChannel[ch]->maxSfbPerGroup; sfb++) {
FIXP_DBL nrgFac12 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>1); /* nrg^(1/2) */
FIXP_DBL nrgFac14 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>2); /* nrg^(1/4) */
/* maximal number of bands is 64, results scaling factor 6 */
nLinesSum += peData->peChannelData[ch].sfbNLines[sfb]; /* relevant lines */
nrgTotal += ( psyOutChan->sfbEnergy[sfb] >> 6 ); /* sum up nrg */
nLinesSum += peData->peChannelData[ch].sfbNLines[sfbGrp+sfb]; /* relevant lines */
nrgTotal += ( psyOutChan->sfbEnergy[sfbGrp+sfb] >> 6 ); /* sum up nrg */
nrgSum12 += ( nrgFac12 >> 6 ); /* sum up nrg^(2/4) */
nrgSum14 += ( nrgFac14 >> 6 ); /* sum up nrg^(1/4) */
nrgSum34 += ( fMult(nrgFac14, nrgFac12) >> 6 ); /* sum up nrg^(3/4) */
}
}
nrgTotal = CalcLdData(nrgTotal); /* get ld64 of total nrg */
@ -479,32 +684,35 @@ void FDKaacEnc_calcWeighting(PE_DATA *peData,
usePatch = (adjThrStateElement->chaosMeasureEnFac[ch] > FL2FXCONST_DBL(0.78125f));
exePatch = ((usePatch) && (adjThrStateElement->lastEnFacPatch[ch]));
for (sfb = 0; sfb < psyOutChan->sfbCnt; sfb++) {
for (sfbGrp = 0;sfbGrp < psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutChannel[ch]->sfbPerGroup) {
for (sfb=0; sfb<psyOutChannel[ch]->maxSfbPerGroup; sfb++) {
INT sfbExePatch;
/* for MS coupled SFBs, also execute patch in side channel if done in mid channel */
if ((ch == 1) && (toolsInfo->msMask[sfb])) {
if ((ch == 1) && (toolsInfo->msMask[sfbGrp+sfb])) {
sfbExePatch = exePatchM;
}
else {
sfbExePatch = exePatch;
}
if ( (sfbExePatch) && (psyOutChan->sfbEnergy[sfb]>FL2FXCONST_DBL(0.f)) )
if ( (sfbExePatch) && (psyOutChan->sfbEnergy[sfbGrp+sfb]>FL2FXCONST_DBL(0.f)) )
{
/* execute patch based on spectral flatness calculated above */
if (adjThrStateElement->chaosMeasureEnFac[ch] > FL2FXCONST_DBL(0.8125f)) {
qcOutChannel[ch]->sfbEnFacLd[sfb] = ( (nrgFacLd_14 + (psyOutChan->sfbEnergyLdData[sfb]+(psyOutChan->sfbEnergyLdData[sfb]>>1)))>>1 ); /* sfbEnergy^(3/4) */
qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = ( (nrgFacLd_14 + (psyOutChan->sfbEnergyLdData[sfbGrp+sfb]+(psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>1)))>>1 ); /* sfbEnergy^(3/4) */
}
else if (adjThrStateElement->chaosMeasureEnFac[ch] > FL2FXCONST_DBL(0.796875f)) {
qcOutChannel[ch]->sfbEnFacLd[sfb] = ( (nrgFacLd_12 + psyOutChan->sfbEnergyLdData[sfb])>>1 ); /* sfbEnergy^(2/4) */
qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = ( (nrgFacLd_12 + psyOutChan->sfbEnergyLdData[sfbGrp+sfb])>>1 ); /* sfbEnergy^(2/4) */
}
else {
qcOutChannel[ch]->sfbEnFacLd[sfb] = ( (nrgFacLd_34 + (psyOutChan->sfbEnergyLdData[sfb]>>1))>>1 ); /* sfbEnergy^(1/4) */
qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = ( (nrgFacLd_34 + (psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>1))>>1 ); /* sfbEnergy^(1/4) */
}
qcOutChannel[ch]->sfbEnFacLd[sfb] = fixMin(qcOutChannel[ch]->sfbEnFacLd[sfb],(FIXP_DBL)0);
qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = fixMin(qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb],(FIXP_DBL)0);
}
}
} /* sfb loop */
adjThrStateElement->lastEnFacPatch[ch] = usePatch;
@ -735,7 +943,6 @@ static FIXP_DBL FDKaacEnc_calcChaosMeasure(PSY_OUT_CHANNEL *psyOutChannel,
return chaosMeasure;
}
/* apply reduction formula for VBR-mode */
static void FDKaacEnc_reduceThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)],
PSY_OUT_CHANNEL* psyOutChannel[(2)],
@ -923,7 +1130,6 @@ static void FDKaacEnc_reduceThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)],
}
}
/*****************************************************************************
functionname: FDKaacEnc_correctThresh
description: if pe difference deltaPe between desired pe and real pe is small enough,
@ -931,12 +1137,12 @@ the difference can be distributed among the scale factor bands.
New thresholds can be derived from this pe-difference
*****************************************************************************/
static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
QC_OUT_ELEMENT* qcElement[(6)],
PSY_OUT_ELEMENT* psyOutElement[(6)],
UCHAR ahFlag[(6)][(2)][MAX_GROUPED_SFB],
FIXP_DBL thrExp[(6)][(2)][MAX_GROUPED_SFB],
const FIXP_DBL redVal[(6)],
const SCHAR redValScaling[(6)],
QC_OUT_ELEMENT* qcElement[(8)],
PSY_OUT_ELEMENT* psyOutElement[(8)],
UCHAR ahFlag[(8)][(2)][MAX_GROUPED_SFB],
FIXP_DBL thrExp[(8)][(2)][MAX_GROUPED_SFB],
const FIXP_DBL redVal[(8)],
const SCHAR redValScaling[(8)],
const INT deltaPe,
const INT processElements,
const INT elementOffset)
@ -947,8 +1153,8 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
PE_CHANNEL_DATA *peChanData;
FIXP_DBL thrFactorLdData;
FIXP_DBL sfbEnLdData, sfbThrLdData, sfbThrReducedLdData;
FIXP_DBL *sfbPeFactorsLdData[(6)][(2)];
FIXP_DBL sfbNActiveLinesLdData[(2)][MAX_GROUPED_SFB];
FIXP_DBL *sfbPeFactorsLdData[(8)][(2)];
FIXP_DBL sfbNActiveLinesLdData[(8)][(2)][MAX_GROUPED_SFB];
INT normFactorInt;
FIXP_DBL normFactorLdData;
@ -979,13 +1185,13 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
for (sfb=0; sfb<psyOutChan->maxSfbPerGroup; sfb++) {
if ( peChanData->sfbNActiveLines[sfbGrp+sfb] == 0 ) {
sfbNActiveLinesLdData[ch][sfbGrp+sfb] = FL2FXCONST_DBL(-1.0f);
sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] = FL2FXCONST_DBL(-1.0f);
}
else {
/* Both CalcLdInt and CalcLdData can be used!
* No offset has to be subtracted, because sfbNActiveLinesLdData
* is shorted while thrFactor calculation */
sfbNActiveLinesLdData[ch][sfbGrp+sfb] = CalcLdInt(peChanData->sfbNActiveLines[sfbGrp+sfb]);
sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] = CalcLdInt(peChanData->sfbNActiveLines[sfbGrp+sfb]);
}
if ( ((ahFlag[elementId][ch][sfbGrp+sfb] < AH_ACTIVE) || (deltaPe > 0)) &&
peChanData->sfbNActiveLines[sfbGrp+sfb] != 0 )
@ -1002,14 +1208,14 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
- (FIXP_DBL)(minScale<<(DFRACT_BITS-1-LD_DATA_SHIFT));
if (sumLd < FL2FXCONST_DBL(0.f)) {
sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[ch][sfbGrp+sfb] - sumLd;
sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] - sumLd;
}
else {
if ( sfbNActiveLinesLdData[ch][sfbGrp+sfb] > (FL2FXCONST_DBL(-1.f) + sumLd) ) {
sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[ch][sfbGrp+sfb] - sumLd;
if ( sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] > (FL2FXCONST_DBL(-1.f) + sumLd) ) {
sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] - sumLd;
}
else {
sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[ch][sfbGrp+sfb];
sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb];
}
}
@ -1050,7 +1256,7 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
}
else {
/* new threshold */
FIXP_DBL tmp = CalcInvLdData(sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] + normFactorLdData - sfbNActiveLinesLdData[ch][sfbGrp+sfb] - FL2FXCONST_DBL((float)LD_DATA_SHIFT/LD_DATA_SCALING));
FIXP_DBL tmp = CalcInvLdData(sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] + normFactorLdData - sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] - FL2FXCONST_DBL((float)LD_DATA_SHIFT/LD_DATA_SCALING));
/* limit thrFactor to 60dB */
tmp = (deltaPe<0) ? tmp : (-tmp);
@ -1102,9 +1308,9 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
reducing minSnr
*****************************************************************************/
void FDKaacEnc_reduceMinSnr(CHANNEL_MAPPING* cm,
QC_OUT_ELEMENT* qcElement[(6)],
PSY_OUT_ELEMENT* psyOutElement[(6)],
UCHAR ahFlag[(6)][(2)][MAX_GROUPED_SFB],
QC_OUT_ELEMENT* qcElement[(8)],
PSY_OUT_ELEMENT* psyOutElement[(8)],
UCHAR ahFlag[(8)][(2)][MAX_GROUPED_SFB],
const INT desiredPe,
INT* redPeGlobal,
const INT processElements,
@ -1204,10 +1410,10 @@ bail:
bands have to be quantized to zero
*****************************************************************************/
static void FDKaacEnc_allowMoreHoles(CHANNEL_MAPPING* cm,
QC_OUT_ELEMENT* qcElement[(6)],
PSY_OUT_ELEMENT* psyOutElement[(6)],
ATS_ELEMENT* AdjThrStateElement[(6)],
UCHAR ahFlag[(6)][(2)][MAX_GROUPED_SFB],
QC_OUT_ELEMENT* qcElement[(8)],
PSY_OUT_ELEMENT* psyOutElement[(8)],
ATS_ELEMENT* AdjThrStateElement[(8)],
UCHAR ahFlag[(8)][(2)][MAX_GROUPED_SFB],
const INT desiredPe,
const INT currentPe,
const int processElements,
@ -1439,17 +1645,17 @@ functionname: FDKaacEnc_adaptThresholdsToPe
description: two guesses for the reduction value and one final correction of the thresholds
*****************************************************************************/
static void FDKaacEnc_adaptThresholdsToPe(CHANNEL_MAPPING* cm,
ATS_ELEMENT* AdjThrStateElement[(6)],
QC_OUT_ELEMENT* qcElement[(6)],
PSY_OUT_ELEMENT* psyOutElement[(6)],
ATS_ELEMENT* AdjThrStateElement[(8)],
QC_OUT_ELEMENT* qcElement[(8)],
PSY_OUT_ELEMENT* psyOutElement[(8)],
const INT desiredPe,
const INT processElements,
const INT elementOffset)
{
FIXP_DBL redValue[(6)];
SCHAR redValScaling[(6)];
UCHAR pAhFlag[(6)][(2)][MAX_GROUPED_SFB];
FIXP_DBL pThrExp[(6)][(2)][MAX_GROUPED_SFB];
FIXP_DBL redValue[(8)];
SCHAR redValScaling[(8)];
UCHAR pAhFlag[(8)][(2)][MAX_GROUPED_SFB];
FIXP_DBL pThrExp[(8)][(2)][MAX_GROUPED_SFB];
int iter;
INT constPartGlobal, noRedPeGlobal, nActiveLinesGlobal, redPeGlobal;
@ -1683,7 +1889,6 @@ static void FDKaacEnc_adaptThresholdsToPe(CHANNEL_MAPPING* cm,
}
/* similar to FDKaacEnc_adaptThresholdsToPe(), for VBR-mode */
void FDKaacEnc_AdaptThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)],
PSY_OUT_CHANNEL* psyOutChannel[(2)],
@ -1692,8 +1897,14 @@ void FDKaacEnc_AdaptThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)],
PE_DATA *peData,
const INT nChannels)
{
UCHAR pAhFlag[(2)][MAX_GROUPED_SFB];
FIXP_DBL pThrExp[(2)][MAX_GROUPED_SFB];
UCHAR (*pAhFlag)[MAX_GROUPED_SFB];
FIXP_DBL (*pThrExp)[MAX_GROUPED_SFB];
/* allocate scratch memory */
C_ALLOC_SCRATCH_START(_pAhFlag, UCHAR, (2)*MAX_GROUPED_SFB)
C_ALLOC_SCRATCH_START(_pThrExp, FIXP_DBL, (2)*MAX_GROUPED_SFB)
pAhFlag = (UCHAR(*)[MAX_GROUPED_SFB])_pAhFlag;
pThrExp = (FIXP_DBL(*)[MAX_GROUPED_SFB])_pThrExp;
/* thresholds to the power of redExp */
FDKaacEnc_calcThreshExp(pThrExp, qcOutChannel, psyOutChannel, nChannels);
@ -1711,6 +1922,9 @@ void FDKaacEnc_AdaptThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)],
AdjThrStateElement->vbrQualFactor,
&AdjThrStateElement->chaosMeasureOld);
/* free scratch memory */
C_ALLOC_SCRATCH_END(_pThrExp, FIXP_DBL, (2)*MAX_GROUPED_SFB)
C_ALLOC_SCRATCH_END(_pAhFlag, UCHAR, (2)*MAX_GROUPED_SFB)
}
@ -2002,95 +2216,112 @@ bail:
functionname: FDKaacEnc_AdjThrInit
description: initialize ADJ_THR_STATE
*****************************************************************************/
void FDKaacEnc_AdjThrInit(ADJ_THR_STATE *hAdjThr,
const INT meanPe,
ELEMENT_BITS *elBits[(6)],
INT nElements,
FIXP_DBL vbrQualFactor)
void FDKaacEnc_AdjThrInit(
ADJ_THR_STATE *hAdjThr,
const INT meanPe,
ELEMENT_BITS *elBits[(8)],
INT invQuant,
INT nElements,
INT nChannelsEff,
INT sampleRate,
INT advancedBitsToPe,
FIXP_DBL vbrQualFactor
)
{
INT i;
INT i;
FIXP_DBL POINT8 = FL2FXCONST_DBL(0.8f);
FIXP_DBL POINT6 = FL2FXCONST_DBL(0.6f);
FIXP_DBL POINT8 = FL2FXCONST_DBL(0.8f);
FIXP_DBL POINT6 = FL2FXCONST_DBL(0.6f);
/* common for all elements: */
/* parameters for bitres control */
hAdjThr->bresParamLong.clipSaveLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */
hAdjThr->bresParamLong.clipSaveHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */
hAdjThr->bresParamLong.minBitSave = (FIXP_DBL)0xf999999a; /* FL2FXCONST_DBL(-0.05f); */
hAdjThr->bresParamLong.maxBitSave = (FIXP_DBL)0x26666666; /* FL2FXCONST_DBL(0.3f); */
hAdjThr->bresParamLong.clipSpendLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */
hAdjThr->bresParamLong.clipSpendHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */
hAdjThr->bresParamLong.minBitSpend = (FIXP_DBL)0xf3333333; /* FL2FXCONST_DBL(-0.10f); */
hAdjThr->bresParamLong.maxBitSpend = (FIXP_DBL)0x33333333; /* FL2FXCONST_DBL(0.4f); */
hAdjThr->bresParamShort.clipSaveLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
hAdjThr->bresParamShort.clipSaveHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */
hAdjThr->bresParamShort.minBitSave = (FIXP_DBL)0x00000000; /* FL2FXCONST_DBL(0.0f); */
hAdjThr->bresParamShort.maxBitSave = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
hAdjThr->bresParamShort.clipSpendLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
hAdjThr->bresParamShort.clipSpendHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */
hAdjThr->bresParamShort.minBitSpend = (FIXP_DBL)0xf9999998; /* FL2FXCONST_DBL(-0.05f); */
hAdjThr->bresParamShort.maxBitSpend = (FIXP_DBL)0x40000000; /* FL2FXCONST_DBL(0.5f); */
/* specific for each element: */
for (i=0; i<nElements; i++) {
ATS_ELEMENT* atsElem = hAdjThr->adjThrStateElem[i];
MINSNR_ADAPT_PARAM *msaParam = &atsElem->minSnrAdaptParam;
INT chBitrate = elBits[i]->chBitrateEl;
/* common for all elements: */
/* parameters for bitres control */
hAdjThr->bresParamLong.clipSaveLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */
hAdjThr->bresParamLong.clipSaveHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */
hAdjThr->bresParamLong.minBitSave = (FIXP_DBL)0xf999999a; /* FL2FXCONST_DBL(-0.05f); */
hAdjThr->bresParamLong.maxBitSave = (FIXP_DBL)0x26666666; /* FL2FXCONST_DBL(0.3f); */
hAdjThr->bresParamLong.clipSpendLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */
hAdjThr->bresParamLong.clipSpendHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */
hAdjThr->bresParamLong.minBitSpend = (FIXP_DBL)0xf3333333; /* FL2FXCONST_DBL(-0.10f); */
hAdjThr->bresParamLong.maxBitSpend = (FIXP_DBL)0x33333333; /* FL2FXCONST_DBL(0.4f); */
atsElem->peMin = fMultI(POINT8, meanPe) >> 1;
atsElem->peMax = fMultI(POINT6, meanPe);
hAdjThr->bresParamShort.clipSaveLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
hAdjThr->bresParamShort.clipSaveHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */
hAdjThr->bresParamShort.minBitSave = (FIXP_DBL)0x00000000; /* FL2FXCONST_DBL(0.0f); */
hAdjThr->bresParamShort.maxBitSave = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
hAdjThr->bresParamShort.clipSpendLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
hAdjThr->bresParamShort.clipSpendHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */
hAdjThr->bresParamShort.minBitSpend = (FIXP_DBL)0xf9999998; /* FL2FXCONST_DBL(-0.05f); */
hAdjThr->bresParamShort.maxBitSpend = (FIXP_DBL)0x40000000; /* FL2FXCONST_DBL(0.5f); */
/* for use in FDKaacEnc_reduceThresholdsVBR */
atsElem->chaosMeasureOld = FL2FXCONST_DBL(0.3f);
/* specific for each element: */
for (i=0; i<nElements; i++) {
ATS_ELEMENT* atsElem = hAdjThr->adjThrStateElem[i];
MINSNR_ADAPT_PARAM *msaParam = &atsElem->minSnrAdaptParam;
INT chBitrate = elBits[i]->chBitrateEl;
/* additional pe offset to correct pe2bits for low bitrates */
atsElem->peOffset = 0;
/* parameters for bitres control */
atsElem->peMin = fMultI(POINT8, meanPe) >> 1;
atsElem->peMax = fMultI(POINT6, meanPe);
/* for use in FDKaacEnc_reduceThresholdsVBR */
atsElem->chaosMeasureOld = FL2FXCONST_DBL(0.3f);
/* additional pe offset to correct pe2bits for low bitrates */
atsElem->peOffset = 0;
/* vbr initialisation */
atsElem->vbrQualFactor = vbrQualFactor;
if (chBitrate < 32000)
{
atsElem->peOffset = fixMax(50, 100-fMultI((FIXP_DBL)0x666667, chBitrate));
}
/* avoid hole parameters */
if (chBitrate > 20000) {
atsElem->ahParam.modifyMinSnr = TRUE;
atsElem->ahParam.startSfbL = 15;
atsElem->ahParam.startSfbS = 3;
}
else {
atsElem->ahParam.modifyMinSnr = FALSE;
atsElem->ahParam.startSfbL = 0;
atsElem->ahParam.startSfbS = 0;
}
/* minSnr adaptation */
msaParam->maxRed = FL2FXCONST_DBL(0.00390625f); /* 0.25f/64.0f */
/* start adaptation of minSnr for avgEn/sfbEn > startRatio */
msaParam->startRatio = FL2FXCONST_DBL(0.05190512648f); /* ld64(10.0f) */
/* maximum minSnr reduction to minSnr^maxRed is reached for
avgEn/sfbEn >= maxRatio */
/* msaParam->maxRatio = 1000.0f; */
/*msaParam->redRatioFac = ((float)1.0f - msaParam->maxRed) / ((float)10.0f*log10(msaParam->startRatio/msaParam->maxRatio)/log10(2.0f)*(float)0.3010299956f);*/
msaParam->redRatioFac = FL2FXCONST_DBL(-0.375f); /* -0.0375f * 10.0f */
/*msaParam->redOffs = (float)1.0f - msaParam->redRatioFac * (float)10.0f * log10(msaParam->startRatio)/log10(2.0f) * (float)0.3010299956f;*/
msaParam->redOffs = FL2FXCONST_DBL(0.021484375); /* 1.375f/64.0f */
/* init pe correction */
atsElem->peCorrectionFactor_m = FL2FXCONST_DBL(0.5f); /* 1.0 */
atsElem->peCorrectionFactor_e = 1;
atsElem->dynBitsLast = -1;
atsElem->peLast = 0;
/* init bits to pe factor */
atsElem->bits2PeFactor_m = FL2FXCONST_DBL(1.18f/(1<<(1)));
atsElem->bits2PeFactor_e = 1;
/* vbr initialisation */
atsElem->vbrQualFactor = vbrQualFactor;
if (chBitrate < 32000)
{
atsElem->peOffset = fixMax(50, 100-fMultI((FIXP_DBL)0x666667, chBitrate));
}
/* avoid hole parameters */
if (chBitrate > 20000) {
atsElem->ahParam.modifyMinSnr = TRUE;
atsElem->ahParam.startSfbL = 15;
atsElem->ahParam.startSfbS = 3;
}
else {
atsElem->ahParam.modifyMinSnr = FALSE;
atsElem->ahParam.startSfbL = 0;
atsElem->ahParam.startSfbS = 0;
}
/* minSnr adaptation */
msaParam->maxRed = FL2FXCONST_DBL(0.00390625f); /* 0.25f/64.0f */
/* start adaptation of minSnr for avgEn/sfbEn > startRatio */
msaParam->startRatio = FL2FXCONST_DBL(0.05190512648f); /* ld64(10.0f) */
/* maximum minSnr reduction to minSnr^maxRed is reached for
avgEn/sfbEn >= maxRatio */
/* msaParam->maxRatio = 1000.0f; */
/*msaParam->redRatioFac = ((float)1.0f - msaParam->maxRed) / ((float)10.0f*log10(msaParam->startRatio/msaParam->maxRatio)/log10(2.0f)*(float)0.3010299956f);*/
msaParam->redRatioFac = FL2FXCONST_DBL(-0.375f); /* -0.0375f * 10.0f */
/*msaParam->redOffs = (float)1.0f - msaParam->redRatioFac * (float)10.0f * log10(msaParam->startRatio)/log10(2.0f) * (float)0.3010299956f;*/
msaParam->redOffs = FL2FXCONST_DBL(0.021484375); /* 1.375f/64.0f */
/* init pe correction */
atsElem->peCorrectionFactor_m = FL2FXCONST_DBL(0.5f); /* 1.0 */
atsElem->peCorrectionFactor_e = 1;
atsElem->dynBitsLast = -1;
atsElem->peLast = 0;
/* init bits to pe factor */
/* init bits2PeFactor */
FDKaacEnc_InitBits2PeFactor(
&atsElem->bits2PeFactor_m,
&atsElem->bits2PeFactor_e,
chBitrate, /* bitrate/channel*/
nChannelsEff, /* number of channels */
sampleRate,
advancedBitsToPe,
invQuant
);
} /* for nElements */
}
@ -2154,6 +2385,67 @@ static void FDKaacEnc_FDKaacEnc_calcPeCorrection(
}
static void FDKaacEnc_calcPeCorrectionLowBitRes(
FIXP_DBL *const correctionFac_m,
INT *const correctionFac_e,
const INT peLast,
const INT bitsLast,
const INT bitresLevel,
const INT nChannels,
const FIXP_DBL bits2PeFactor_m,
const INT bits2PeFactor_e
)
{
/* tuning params */
const FIXP_DBL amp = FL2FXCONST_DBL(0.005);
const FIXP_DBL maxDiff = FL2FXCONST_DBL(0.25f);
if (bitsLast > 0) {
/* Estimate deviation of granted and used dynamic bits in previous frame, in PE units */
const int bitsBalLast = peLast - FDKaacEnc_bits2pe2(
bitsLast,
bits2PeFactor_m,
bits2PeFactor_e);
/* reserve n bits per channel */
int headroom = (bitresLevel>=50*nChannels) ? 0 : (100*nChannels);
/* in PE units */
headroom = FDKaacEnc_bits2pe2(
headroom,
bits2PeFactor_m,
bits2PeFactor_e);
/*
* diff = amp * ((bitsBalLast - headroom) / (bitresLevel + headroom)
* diff = max ( min ( diff, maxDiff, -maxDiff)) / 2
*/
FIXP_DBL denominator = (FIXP_DBL)FDKaacEnc_bits2pe2(bitresLevel, bits2PeFactor_m, bits2PeFactor_e) + (FIXP_DBL)headroom;
int scaling = 0;
FIXP_DBL diff = (bitsBalLast>=headroom)
? fMult(amp, fDivNorm( (FIXP_DBL)(bitsBalLast - headroom), denominator, &scaling))
: -fMult(amp, fDivNorm(-(FIXP_DBL)(bitsBalLast - headroom), denominator, &scaling)) ;
scaling -= 1; /* divide by 2 */
diff = (scaling<=0) ? FDKmax( FDKmin (diff>>(-scaling), maxDiff>>1), -maxDiff>>1)
: FDKmax( FDKmin (diff, maxDiff>>(1+scaling)), -maxDiff>>(1+scaling)) << scaling;
/*
* corrFac += diff
* corrFac = max ( min ( corrFac/2.f, 1.f/2.f, 0.75f/2.f ) )
*/
*correctionFac_m = FDKmax(FDKmin((*correctionFac_m)+diff, FL2FXCONST_DBL(1.0f/2.f)), FL2FXCONST_DBL(0.75f/2.f)) ;
*correctionFac_e = 1;
}
else {
*correctionFac_m = FL2FXCONST_DBL(0.75/2.f);
*correctionFac_e = 1;
}
}
void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
ATS_ELEMENT *AdjThrStateElement,
PSY_OUT_CHANNEL *psyOutChannel[(2)],
@ -2166,7 +2458,7 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
const INT bitresBits,
const INT maxBitresBits,
const FIXP_DBL maxBitFac,
const INT bitDistributenMode)
const INT bitDistributionMode)
{
FIXP_DBL bitFactor;
INT noRedPe = peData->pe;
@ -2184,7 +2476,7 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
}
if (grantedDynBits >= 1) {
if (bitDistributenMode!=0) {
if (bitDistributionMode!=0) {
*grantedPe = FDKaacEnc_bits2pe2(grantedDynBits, AdjThrStateElement->bits2PeFactor_m, AdjThrStateElement->bits2PeFactor_e);
}
else
@ -2208,16 +2500,32 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
}
/* correction of pe value */
{
FDKaacEnc_FDKaacEnc_calcPeCorrection(
&AdjThrStateElement->peCorrectionFactor_m,
&AdjThrStateElement->peCorrectionFactor_e,
fixMin(*grantedPe, noRedPe),
AdjThrStateElement->peLast,
AdjThrStateElement->dynBitsLast,
AdjThrStateElement->bits2PeFactor_m,
AdjThrStateElement->bits2PeFactor_e
switch (bitDistributionMode) {
case 2:
case 1:
FDKaacEnc_calcPeCorrectionLowBitRes(
&AdjThrStateElement->peCorrectionFactor_m,
&AdjThrStateElement->peCorrectionFactor_e,
AdjThrStateElement->peLast,
AdjThrStateElement->dynBitsLast,
bitresBits,
nChannels,
AdjThrStateElement->bits2PeFactor_m,
AdjThrStateElement->bits2PeFactor_e
);
break;
case 0:
default:
FDKaacEnc_FDKaacEnc_calcPeCorrection(
&AdjThrStateElement->peCorrectionFactor_m,
&AdjThrStateElement->peCorrectionFactor_e,
fixMin(*grantedPe, noRedPe),
AdjThrStateElement->peLast,
AdjThrStateElement->dynBitsLast,
AdjThrStateElement->bits2PeFactor_m,
AdjThrStateElement->bits2PeFactor_e
);
break;
}
*grantedPeCorr = (INT)(fMult((FIXP_DBL)(*grantedPe<<Q_AVGBITS), AdjThrStateElement->peCorrectionFactor_m) >> (Q_AVGBITS-AdjThrStateElement->peCorrectionFactor_e));
@ -2232,10 +2540,10 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
functionname: FDKaacEnc_AdjustThresholds
description: adjust thresholds
*****************************************************************************/
void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(6)],
QC_OUT_ELEMENT* qcElement[(6)],
void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(8)],
QC_OUT_ELEMENT* qcElement[(8)],
QC_OUT* qcOut,
PSY_OUT_ELEMENT* psyOutElement[(6)],
PSY_OUT_ELEMENT* psyOutElement[(8)],
INT CBRbitrateMode,
CHANNEL_MAPPING* cm)
{
@ -2291,20 +2599,19 @@ void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(6)],
} /* -end- element loop */
}
for (i=0; i<cm->nElements; i++) {
int ch,sfb,sfbGrp;
/* no weighting of threholds and energies for mlout */
/* weight energies and thresholds */
for (ch=0; ch<cm->elInfo[i].nChannelsInEl; ch++) {
QC_OUT_CHANNEL* pQcOutCh = qcElement[i]->qcOutChannel[ch];
for (sfbGrp = 0;sfbGrp < psyOutElement[i]->psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutElement[i]->psyOutChannel[ch]->sfbPerGroup) {
for (sfb=0; sfb<psyOutElement[i]->psyOutChannel[ch]->maxSfbPerGroup; sfb++) {
pQcOutCh->sfbThresholdLdData[sfb+sfbGrp] += pQcOutCh->sfbEnFacLd[sfb+sfbGrp];
}
for (i=0; i<cm->nElements; i++) {
int ch,sfb,sfbGrp;
/* no weighting of threholds and energies for mlout */
/* weight energies and thresholds */
for (ch=0; ch<cm->elInfo[i].nChannelsInEl; ch++) {
QC_OUT_CHANNEL* pQcOutCh = qcElement[i]->qcOutChannel[ch];
for (sfbGrp = 0;sfbGrp < psyOutElement[i]->psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutElement[i]->psyOutChannel[ch]->sfbPerGroup) {
for (sfb=0; sfb<psyOutElement[i]->psyOutChannel[ch]->maxSfbPerGroup; sfb++) {
pQcOutCh->sfbThresholdLdData[sfb+sfbGrp] += pQcOutCh->sfbEnFacLd[sfb+sfbGrp];
}
}
}
}
}
void FDKaacEnc_AdjThrClose(ADJ_THR_STATE** phAdjThr)
@ -2313,7 +2620,7 @@ void FDKaacEnc_AdjThrClose(ADJ_THR_STATE** phAdjThr)
ADJ_THR_STATE* hAdjThr = *phAdjThr;
if (hAdjThr!=NULL) {
for (i=0; i<(6); i++) {
for (i=0; i<(8); i++) {
if (hAdjThr->adjThrStateElem[i]!=NULL) {
FreeRam_aacEnc_AdjThrStateElement(&hAdjThr->adjThrStateElem[i]);
}

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -98,23 +98,28 @@ amm-info@iis.fraunhofer.de
#include "interface.h"
void FDKaacEnc_peCalculation(PE_DATA *peData,
PSY_OUT_CHANNEL* psyOutChannel[(2)],
QC_OUT_CHANNEL* qcOutChannel[(2)],
struct TOOLSINFO *toolsInfo,
ATS_ELEMENT* adjThrStateElement,
const INT nChannels);
void FDKaacEnc_peCalculation(
PE_DATA *peData,
PSY_OUT_CHANNEL* psyOutChannel[(2)],
QC_OUT_CHANNEL* qcOutChannel[(2)],
struct TOOLSINFO *toolsInfo,
ATS_ELEMENT* adjThrStateElement,
const INT nChannels
);
INT FDKaacEnc_AdjThrNew(ADJ_THR_STATE** phAdjThr,
INT nElements);
void FDKaacEnc_AdjThrInit(ADJ_THR_STATE *hAdjThr,
const INT peMean,
ELEMENT_BITS* elBits[(6)],
ELEMENT_BITS* elBits[(8)],
INT invQuant,
INT nElements,
INT nChannelsEff,
INT sampleRate,
INT advancedBitsToPe,
FIXP_DBL vbrQualFactor);
void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
ATS_ELEMENT *AdjThrStateElement,
@ -128,12 +133,12 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
const INT bitresBits,
const INT maxBitresBits,
const FIXP_DBL maxBitFac,
const INT bitDistributenMode);
const INT bitDistributionMode);
void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(6)],
QC_OUT_ELEMENT* qcElement[(6)],
void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(8)],
QC_OUT_ELEMENT* qcElement[(8)],
QC_OUT* qcOut,
PSY_OUT_ELEMENT* psyOutElement[(6)],
PSY_OUT_ELEMENT* psyOutElement[(8)],
INT CBRbitrateMode,
CHANNEL_MAPPING* cm);

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -144,7 +144,7 @@ typedef struct {
typedef struct {
BRES_PARAM bresParamLong, bresParamShort;
ATS_ELEMENT* adjThrStateElem[(6)];
ATS_ELEMENT* adjThrStateElem[(8)];
} ADJ_THR_STATE;
#endif

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -204,7 +204,6 @@ static INT GetBandwidthEntry(
INT bwTabSize = 0;
switch (frameLength) {
case 960:
case 1024:
pBwTab = bandWidthTable;
bwTabSize = sizeof(bandWidthTable)/sizeof(BANDWIDTH_TAB);
@ -253,7 +252,6 @@ static INT GetBandwidthEntry(
chanBitRate < pBwTab[i+1].chanBitRate)
{
switch (frameLength) {
case 960:
case 1024:
bandwidth = (entryNo==0)
? pBwTab[i].bandWidthMono
@ -318,6 +316,8 @@ AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth,
case MODE_1_2_2:
case MODE_1_2_2_1:
case MODE_1_2_2_2_1:
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
*bandWidth = bandWidthTableVBR[bitrateMode].bandWidth2AndMoreChan;
break;
default:
@ -348,6 +348,8 @@ AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth,
case MODE_1_2_2: /* sce + cpe + cpe */
case MODE_1_2_2_1: /* (5.1) sce + cpe + cpe + lfe */
case MODE_1_2_2_2_1: /* (7.1) sce + cpe + cpe + cpe + lfe */
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
entryNo = 1; /* use stereo bandwith settings */
break;

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -1360,7 +1360,7 @@ AAC_ENCODER_ERROR FDKaacEnc_WriteBitstream(HANDLE_TRANSPORTENC hTpEnc,
if ( (syntaxFlags & AC_ER) && !(syntaxFlags & AC_DRM) )
{
UCHAR channelElementExtensionWritten[(6)][(1)]; /* 0: extension not touched, 1: extension already written */
UCHAR channelElementExtensionWritten[(8)][(1)]; /* 0: extension not touched, 1: extension already written */
FDKmemclear(channelElementExtensionWritten, sizeof(channelElementExtensionWritten));

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -83,7 +83,7 @@ amm-info@iis.fraunhofer.de
/***************************** MPEG-4 AAC Encoder **************************
Author(s): M. Werner
Author(s): M. Werner, Tobias Chalupka
Description: Block switching
******************************************************************************/
@ -100,9 +100,11 @@ amm-info@iis.fraunhofer.de
static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT blSwWndIdx);
static void FDKaacEnc_CalcWindowEnergy( BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl,
INT windowLen);
static void FDKaacEnc_CalcWindowEnergy(
BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl,
INT windowLen,
const INT_PCM *pTimeSignal
);
/****************** Constants *****************************/
/* LONG START SHORT STOP LOWOV */
@ -145,20 +147,9 @@ static const FIXP_DBL minAttackNrg = (FL2FXCONST_DBL(1e+6f*NORM_PCM_ENERGY)>>BLO
/**************** internal function prototypes ***********/
static INT FDKaacEnc_GetWindowIndex(INT blockSwWindowIndex);
static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT shortWndIdx);
static void FDKaacEnc_CalcWindowEnergy( BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl,
INT windowLen);
/****************** Routines ****************************/
void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay)
{
/* note: the pointer to timeSignal can be zeroed here, because it is initialized for every call
to FDKaacEnc_BlockSwitching anew */
FDKmemclear (blockSwitchingControl, sizeof(BLOCK_SWITCHING_CONTROL));
if (isLowDelay)
@ -214,7 +205,7 @@ static const INT chgWndSqLkAhd[2][2][N_BLOCKTYPES] =
/*attack */ {START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, START_WINDOW, WRONG_WINDOW, WRONG_WINDOW} } /* attack */
};
int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE)
int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE, const INT_PCM *pTimeSignal)
{
UINT i;
FIXP_DBL enM1, enMax;
@ -263,7 +254,7 @@ int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, con
/* Calculate unfiltered and filtered energies in subwindows and combine to segments */
FDKaacEnc_CalcWindowEnergy(blockSwitchingControl, granuleLength>>(nBlockSwitchWindows==4? 2:3 ));
FDKaacEnc_CalcWindowEnergy(blockSwitchingControl, granuleLength>>(nBlockSwitchWindows==4? 2:3 ), pTimeSignal);
/* now calculate if there is an attack */
@ -335,8 +326,7 @@ static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT blSwWnd
}
static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen)
static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen, const INT_PCM *pTimeSignal)
{
INT i;
UINT w;
@ -344,8 +334,6 @@ static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSw
FIXP_SGL hiPassCoeff0 = hiPassCoeff[0];
FIXP_SGL hiPassCoeff1 = hiPassCoeff[1];
INT_PCM *timeSignal = blockSwitchingControl->timeSignal;
/* sum up scalarproduct of timesignal as windowed Energies */
for (w=0; w < blockSwitchingControl->nBlockSwitchWindows; w++) {
@ -361,9 +349,9 @@ static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSw
FIXP_DBL tempUnfiltered, tempFiltred, t1, t2;
/* tempUnfiltered is scaled with 1 to prevent overflows during calculation of tempFiltred */
#if SAMPLE_BITS == DFRACT_BITS
tempUnfiltered = (FIXP_DBL) *timeSignal++ >> 1;
tempUnfiltered = (FIXP_DBL) *pTimeSignal++ >> 1;
#else
tempUnfiltered = (FIXP_DBL) *timeSignal++ << (DFRACT_BITS-SAMPLE_BITS-1);
tempUnfiltered = (FIXP_DBL) *pTimeSignal++ << (DFRACT_BITS-SAMPLE_BITS-1);
#endif
t1 = fMultDiv2(hiPassCoeff1, tempUnfiltered-temp_iirState0);
t2 = fMultDiv2(hiPassCoeff0, temp_iirState1);

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -107,7 +107,6 @@ amm-info@iis.fraunhofer.de
/****************** Structures ***************************/
typedef struct{
INT_PCM *timeSignal;
INT lastWindowSequence;
INT windowShape;
INT lastWindowShape;
@ -136,7 +135,7 @@ typedef struct{
void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay);
int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE);
int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE, const INT_PCM *pTimeSignal);
int FDKaacEnc_SyncBlockSwitching(
BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft,

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -124,7 +124,7 @@ amm-info@iis.fraunhofer.de
typedef struct {
CHANNEL_MODE encoderMode;
INT channel_assignment[/*(6)*/12];
INT channel_assignment[/*(8)*/12];
} CHANNEL_ASSIGNMENT_INFO_TAB;
@ -139,6 +139,8 @@ static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabMpeg[] =
{ MODE_1_2_2, { 0, 1, 2, 3, 4,-1,-1,-1,-1,-1,-1,-1} }, /* 5ch */
{ MODE_1_2_2_1, { 0, 1, 2, 3, 4, 5,-1,-1,-1,-1,-1,-1} }, /* 5.1ch */
{ MODE_1_2_2_2_1, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_REAR_SURROUND, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_FRONT_CENTER, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} } /* 7.1ch */
};
static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabWav[] =
@ -150,7 +152,9 @@ static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabWav[] =
{ MODE_1_2_1, { 2, 0, 1, 3,-1,-1,-1,-1,-1,-1,-1,-1} }, /* 4ch */
{ MODE_1_2_2, { 2, 0, 1, 3, 4,-1,-1,-1,-1,-1,-1,-1} }, /* 5ch */
{ MODE_1_2_2_1, { 2, 0, 1, 4, 5, 3,-1,-1,-1,-1,-1,-1} }, /* 5.1ch */
{ MODE_1_2_2_2_1, { 2, 0, 1, 6, 7, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_1_2_2_2_1, { 2, 6, 7, 0, 1, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_REAR_SURROUND, { 2, 0, 1, 6, 7, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_FRONT_CENTER, { 2, 6, 7, 0, 1, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
};
static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabWg4[] =
@ -177,6 +181,8 @@ static const CHANNEL_MODE_CONFIG_TAB channelModeConfig[] =
{ MODE_1_2_2, 5, 5, 3 }, /* SCE,CPE,CPE */
{ MODE_1_2_2_1, 6, 5, 4 }, /* SCE,CPE,CPE,LFE */
{ MODE_1_2_2_2_1, 8, 7, 5 }, /* SCE,CPE,CPE,CPE,LFE */
{ MODE_7_1_REAR_SURROUND, 8, 7, 5 },
{ MODE_7_1_FRONT_CENTER, 8, 7, 5 },
};
#define MAX_MODES (sizeof(assignmentInfoTabWav)/sizeof(CHANNEL_ASSIGNMENT_INFO_TAB))
@ -329,6 +335,8 @@ AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode, CHANNEL_ORDER
break;
case MODE_1_2_2_2_1:
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
/* (7.1) sce + cpe + cpe + cpe + lfe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.18f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f));
@ -336,14 +344,13 @@ AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode, CHANNEL_ORDER
FDKaacEnc_initElement(&cm->elInfo[3], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[4], ID_LFE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.04f));
break;
default:
//*chMap=0;
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
};
FDK_ASSERT(cm->nElements<=(6));
FDK_ASSERT(cm->nElements<=(8));
return AAC_ENC_OK;
@ -456,19 +463,18 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
break;
}
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
case MODE_1_2_2_2_1: {
int cpe3Idx = 3;
int lfeIdx = 4;
case MODE_1_2_2_2_1:{
/* (7.1) sce + cpe + cpe + cpe + lfe */
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits;
hQC->elementBits[3]->relativeBitsEl = cm->elInfo[3].relativeBits;
hQC->elementBits[4]->relativeBitsEl = cm->elInfo[4].relativeBits;
FIXP_DBL sceRate = cm->elInfo[0].relativeBits;
FIXP_DBL cpe1Rate = cm->elInfo[1].relativeBits;
FIXP_DBL cpe2Rate = cm->elInfo[2].relativeBits;
FIXP_DBL cpe3Rate = cm->elInfo[3].relativeBits;
FIXP_DBL lfeRate = cm->elInfo[4].relativeBits;
/* (7.1) sce + cpe + cpe + cpe + lfe */
FIXP_DBL sceRate = hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
FIXP_DBL cpe1Rate = hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
FIXP_DBL cpe2Rate = hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits;
FIXP_DBL cpe3Rate = hQC->elementBits[cpe3Idx]->relativeBitsEl = cm->elInfo[cpe3Idx].relativeBits;
FIXP_DBL lfeRate = hQC->elementBits[lfeIdx]->relativeBitsEl = cm->elInfo[lfeIdx].relativeBits;
int maxBitsTot = maxChannelBits * 7; /* LFE does not add to bit reservoir */
int sc = CountLeadingBits(fixMax(maxChannelBits,averageBitsTot));
@ -480,17 +486,16 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
hQC->elementBits[0]->chBitrateEl = fMult(sceRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[1]->chBitrateEl = fMult(cpe1Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[2]->chBitrateEl = fMult(cpe2Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[3]->chBitrateEl = fMult(cpe3Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[4]->chBitrateEl = fMult(lfeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[cpe3Idx]->chBitrateEl = fMult(cpe3Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[lfeIdx]->chBitrateEl = fMult(lfeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[2]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[3]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[4]->maxBitsEl = maxLfeBits;
hQC->elementBits[cpe3Idx]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[lfeIdx]->maxBitsEl = maxLfeBits;
break;
}
default:
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
}
@ -532,6 +537,8 @@ ELEMENT_MODE FDKaacEnc_GetMonoStereoMode(const CHANNEL_MODE mode){
case MODE_1_2_2:
case MODE_1_2_2_1:
case MODE_1_2_2_2_1:
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
monoStereoSetting = EL_MODE_STEREO;
break;
default: /* error */

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -450,23 +450,24 @@ FDKaacEnc_finalizeIntensityDecision(const FIXP_DBL *hrrErr,
const INT maxSfbPerGroup)
{
INT sfb,sfboffs, j;
INT startIsSfb = 0;
INT inIsBlock;
INT currentIsSfbCount;
FIXP_DBL overallHrrError;
FIXP_DBL isScaleLast = FL2FXCONST_DBL(0.0f);
FIXP_DBL isRegionLoudness;
INT isStartValueFound = 0;
for (sfboffs = 0; sfboffs < sfbCnt; sfboffs += sfbPerGroup) {
inIsBlock = 0;
currentIsSfbCount = 0;
overallHrrError = FL2FXCONST_DBL(0.0f);
isRegionLoudness = FL2FXCONST_DBL(0.0f);
INT startIsSfb = 0;
INT inIsBlock = 0;
INT currentIsSfbCount = 0;
FIXP_DBL overallHrrError = FL2FXCONST_DBL(0.0f);
FIXP_DBL isRegionLoudness = FL2FXCONST_DBL(0.0f);
for (sfb = 0; sfb < maxSfbPerGroup; sfb++) {
if (isMask[sfboffs + sfb] == 1) {
if (currentIsSfbCount == 0) {
startIsSfb = sfboffs + sfb;
}
if (isStartValueFound==0) {
isScaleLast = realIsScale[sfboffs + sfb];
isStartValueFound = 1;
}
inIsBlock = 1;
currentIsSfbCount++;
@ -510,6 +511,14 @@ FDKaacEnc_finalizeIntensityDecision(const FIXP_DBL *hrrErr,
for(j = startIsSfb; j <= sfboffs + sfb; j++) {
isMask[j] = 0;
}
isScaleLast = FL2FXCONST_DBL(0.0f);
isStartValueFound = 0;
for (j=0; j < startIsSfb; j++) {
if (isMask[j]!=0) {
isScaleLast = realIsScale[j];
isStartValueFound = 1;
}
}
}
currentIsSfbCount = 0;
overallHrrError = FL2FXCONST_DBL(0.0f);

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -92,6 +92,7 @@ amm-info@iis.fraunhofer.de
#define _INTERFACE_H
#include "common_fix.h"
#include "FDK_audio.h"
#include "psy_data.h"
#include "aacenc_tns.h"
@ -155,9 +156,14 @@ typedef struct {
typedef struct {
PSY_OUT_ELEMENT* psyOutElement[(6)];
PSY_OUT_CHANNEL* pPsyOutChannels[(6)];
PSY_OUT_ELEMENT* psyOutElement[(8)];
PSY_OUT_CHANNEL* pPsyOutChannels[(8)];
}PSY_OUT;
inline int isLowDelay( AUDIO_OBJECT_TYPE aot )
{
return (aot==AOT_ER_AAC_LD || aot==AOT_ER_AAC_ELD);
}
#endif /* _INTERFACE_H */

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@ -421,7 +421,7 @@ static FIXP_DBL tc2Coeff(
result = f2Pow(-exponent, DFRACT_BITS-1-METADATA_FRACT_BITS, &e_res);
/* result = 1.0 - exp(-1.0/((t) * (f))) */
result = FL2FXCONST_DBL(1.0f) - scaleValue(result, e_res);
result = (FIXP_DBL)MAXVAL_DBL - scaleValue(result, e_res);
return result;
}
@ -539,14 +539,25 @@ INT FDK_DRC_Generator_Initialize(
drcComp->channelIdx[RS] = channelMapping.elInfo[2].ChannelIndex[1];
break;
case MODE_1_2_2_2_1: /* 7.1 ch */
drcComp->channelIdx[L] = channelMapping.elInfo[1].ChannelIndex[0];
drcComp->channelIdx[R] = channelMapping.elInfo[1].ChannelIndex[1];
drcComp->channelIdx[C] = channelMapping.elInfo[0].ChannelIndex[0];
drcComp->channelIdx[LFE] = channelMapping.elInfo[4].ChannelIndex[0];
drcComp->channelIdx[LS] = channelMapping.elInfo[2].ChannelIndex[0];
drcComp->channelIdx[RS] = channelMapping.elInfo[2].ChannelIndex[1];
drcComp->channelIdx[LS2] = channelMapping.elInfo[3].ChannelIndex[0];
drcComp->channelIdx[RS2] = channelMapping.elInfo[3].ChannelIndex[1];
case MODE_7_1_FRONT_CENTER:
drcComp->channelIdx[L] = channelMapping.elInfo[2].ChannelIndex[0]; /* l */
drcComp->channelIdx[R] = channelMapping.elInfo[2].ChannelIndex[1]; /* r */
drcComp->channelIdx[C] = channelMapping.elInfo[0].ChannelIndex[0]; /* c */
drcComp->channelIdx[LFE] = channelMapping.elInfo[4].ChannelIndex[0]; /* lfe */
drcComp->channelIdx[LS] = channelMapping.elInfo[3].ChannelIndex[0]; /* ls */
drcComp->channelIdx[RS] = channelMapping.elInfo[3].ChannelIndex[1]; /* rs */
drcComp->channelIdx[LS2] = channelMapping.elInfo[1].ChannelIndex[0]; /* lc */
drcComp->channelIdx[RS2] = channelMapping.elInfo[1].ChannelIndex[1]; /* rc */
break;
case MODE_7_1_REAR_SURROUND:
drcComp->channelIdx[L] = channelMapping.elInfo[1].ChannelIndex[0]; /* l */
drcComp->channelIdx[R] = channelMapping.elInfo[1].ChannelIndex[1]; /* r */
drcComp->channelIdx[C] = channelMapping.elInfo[0].ChannelIndex[0]; /* c */
drcComp->channelIdx[LFE] = channelMapping.elInfo[4].ChannelIndex[0]; /* lfe */
drcComp->channelIdx[LS] = channelMapping.elInfo[3].ChannelIndex[0]; /* lrear */
drcComp->channelIdx[RS] = channelMapping.elInfo[3].ChannelIndex[1]; /* rrear */
drcComp->channelIdx[LS2] = channelMapping.elInfo[2].ChannelIndex[0]; /* ls */
drcComp->channelIdx[RS2] = channelMapping.elInfo[2].ChannelIndex[1]; /* rs */
break;
case MODE_1_1:
case MODE_1_1_1_1:
@ -832,12 +843,12 @@ INT FDK_DRC_Generator_Calc(
FIXP_DBL accu;
/* drcComp->smoothLevel[i] = (1-alpha) * drcComp->smoothLevel[i] + alpha * level; */
accu = fMult((FL2FXCONST_DBL(1.f)-alpha), drcComp->smoothLevel[i]);
accu = fMult(((FIXP_DBL)MAXVAL_DBL-alpha), drcComp->smoothLevel[i]);
accu += fMult(alpha,level);
drcComp->smoothLevel[i] = accu;
/* drcComp->smoothGain[i] = (1-alpha) * drcComp->smoothGain[i] + alpha * gain; */
accu = fMult((FL2FXCONST_DBL(1.f)-alpha), drcComp->smoothGain[i]);
accu = fMult(((FIXP_DBL)MAXVAL_DBL-alpha), drcComp->smoothGain[i]);
accu += fMult(alpha,gain);
drcComp->smoothGain[i] = accu;
}
@ -941,7 +952,7 @@ INT FDK_DRC_Generator_Calc(
if ((drcComp->channelIdx[LS] >= 0) && (drcComp->channelIdx[LS2] >= 0)) tmp = fMult(FL2FXCONST_DBL(0.707f), tmp); /* 7.1ch */
/*if ((drcComp->channelIdx[RS] >= 0) && (drcComp->channelIdx[RS2] >= 0)) tmp *=0.707f;*/ /* 7.1ch */
if (drcComp->channelIdx[S] >= 0) tmp += fMultDiv2(slev, fMult(FL2FXCONST_DBL(0.7f), (FIXP_PCM)pSamples[drcComp->channelIdx[S]]))>>(DOWNMIX_SHIFT-1); /* S */
if (drcComp->channelIdx[C] >= 0) tmp += fMultDiv2(clev, (FIXP_PCM)pSamples[drcComp->channelIdx[C]])>>(DOWNMIX_SHIFT-1); /* C */
if (drcComp->channelIdx[C] >= 0) tmp += fMult(clev, (FIXP_PCM)pSamples[drcComp->channelIdx[C]])>>(DOWNMIX_SHIFT-1); /* C (2*clev) */
tmp += (FX_PCM2FX_DBL((FIXP_PCM)pSamples[drcComp->channelIdx[L]])>>DOWNMIX_SHIFT); /* L */
tmp += (FX_PCM2FX_DBL((FIXP_PCM)pSamples[drcComp->channelIdx[R]])>>DOWNMIX_SHIFT); /* R */
@ -973,7 +984,7 @@ INT FDK_DRC_Generator_Calc(
* + 0.2f*2^(-METADATA_FRACT_BITS) + drcComp->smoothGain[i]
*/
peak[i] = fMult((FIXP_DBL)(10<<(METADATA_FRACT_BITS+LD_DATA_SHIFT)), fMult( FL2FX_DBL(2*0.30102999566398119521373889472449f), ld_peak));
peak[i] += (FL2FX_DBL(0.2f)>>METADATA_INT_BITS); /* add a little bit headroom */
peak[i] += (FL2FX_DBL(0.5f)>>METADATA_INT_BITS); /* add a little bit headroom */
peak[i] += drcComp->smoothGain[i];
}

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION

Some files were not shown because too many files have changed in this diff Show More