Merge remote-tracking branch 'aosp/jb-mr1-release' into master

Conflicts:
	libAACenc/src/band_nrg.cpp
	libAACenc/src/grp_data.cpp
	libSBRenc/src/env_est.cpp
This commit is contained in:
Martin Storsjo 2012-11-01 11:08:03 +02:00
commit 54dfe1ec69
41 changed files with 4672 additions and 4744 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1729,20 +1729,36 @@ const UCHAR tns_max_bands_tbl[13][2] =
{ 39, 14 }, /* 7350 */
};
/* TNS_MAX_BANDS for low delay. The array index is sampleRateIndex-3 */
const UCHAR tns_max_bands_tbl_480[5] = {
/* TNS_MAX_BANDS for low delay. The array index is the sampleRateIndex */
const UCHAR tns_max_bands_tbl_480[13] = {
31, /* 96000 */
31, /* 88200 */
31, /* 64000 */
31, /* 48000 */
32, /* 44100 */
37, /* 32000 */
30, /* 24000 */
30 /* 22050 */
30, /* 22050 */
30, /* 16000 */
30, /* 12000 */
30, /* 11025 */
30, /* 8000 */
30 /* 7350 */
};
const UCHAR tns_max_bands_tbl_512[5] = {
const UCHAR tns_max_bands_tbl_512[13] = {
31, /* 96000 */
31, /* 88200 */
31, /* 64000 */
31, /* 48000 */
32, /* 44100 */
37, /* 32000 */
31, /* 24000 */
31 /* 22050 */
31, /* 22050 */
31, /* 16000 */
31, /* 12000 */
31, /* 11025 */
31, /* 8000 */
31 /* 7350 */
};
#define TCC(x) (FIXP_DBL(x))

View File

@ -164,8 +164,8 @@ extern const UINT aHuffTreeRvlCodewds[];
extern const UCHAR tns_max_bands_tbl[13][2];
extern const UCHAR tns_max_bands_tbl_480[5];
extern const UCHAR tns_max_bands_tbl_512[5];
extern const UCHAR tns_max_bands_tbl_480[13];
extern const UCHAR tns_max_bands_tbl_512[13];
#define FIXP_TCC FIXP_DBL

View File

@ -220,8 +220,9 @@ AAC_DECODER_ERROR aacDecoder_drcSetParam (
else {
/* ref_level must be between 0 and MAX_REFERENCE_LEVEL, inclusive */
self->digitalNorm = 1;
self->progRefLevel = AACDEC_DRC_DEFAULT_REF_LEVEL;
self->params.targetRefLevel = value;
self->progRefLevel = (SCHAR)value; /* Set the program reference level equal to the target
level according to 4.5.2.7.3 of ISO/IEC 14496-3. */
}
break;
case APPLY_HEAVY_COMPRESSION:
@ -783,6 +784,7 @@ void aacDecoder_drcApply (
{
int band, top, bin, numBands;
int bottom = 0;
int modifyBins = 0;
FIXP_DBL max_mantissa;
INT max_exponent;
@ -937,6 +939,12 @@ void aacDecoder_drcApply (
if (fact_exponent[band] < max_exponent) {
fact_mantissa[band] >>= max_exponent - fact_exponent[band];
}
if (fact_mantissa[band] != FL2FXCONST_DBL(0.5f)) {
modifyBins = 1;
}
}
if (max_exponent != 1) {
modifyBins = 1;
}
}
@ -948,6 +956,12 @@ void aacDecoder_drcApply (
{
bottom = 0;
if (!modifyBins) {
/* We don't have to modify the spectral bins because the fractional part of all factors is 0.5.
In order to keep accurancy we don't apply the factor but decrease the exponent instead. */
max_exponent -= 1;
} else
{
for (band = 0; band < numBands; band++)
{
top = fixMin((int)( (pDrcChData->bandTop[band]+1)<<2 ), aacFrameSize); /* ... * DRC_BAND_MULT; */
@ -958,13 +972,12 @@ void aacDecoder_drcApply (
bottom = top;
}
}
/* above topmost DRC band gain factor is 1 */
if (max_exponent > 0) {
FIXP_DBL fact = FL2FXCONST_DBL(0.5f) >> (max_exponent - 1);
for (bin = top; bin < aacFrameSize; bin++) {
pSpectralCoefficient[bin] = fMult(pSpectralCoefficient[bin], fact);
for (bin = bottom; bin < aacFrameSize; bin+=1) {
pSpectralCoefficient[bin] >>= max_exponent;
}
}
@ -980,12 +993,13 @@ void aacDecoder_drcApply (
}
else {
HANDLE_SBRDECODER hSbrDecoder = (HANDLE_SBRDECODER)pSbrDec;
UINT numBands = pDrcChData->numBands;
/* feed factors into SBR decoder for application in QMF domain. */
sbrDecoder_drcFeedChannel (
hSbrDecoder,
ch,
pDrcChData->numBands,
numBands,
fact_mantissa,
max_exponent,
pDrcChData->drcInterpolationScheme,

View File

@ -99,10 +99,7 @@ amm-info@iis.fraunhofer.de
#include "FDK_bitstream.h"
#define AACDEC_DRC_DEFAULT_REF_LEVEL ( 108 ) /* -27 dB below full scale (typical for movies) */
#define AACDEC_DRC_DFLT_EXPIRY_FRAMES ( 40 ) /* Default DRC data expiry time in AAC frames */
#define MAX_SBR_SYN_CHAN ( 64 )
#define MAX_SBR_COLS ( 32 )
#define AACDEC_DRC_DFLT_EXPIRY_FRAMES ( 50 ) /* Default DRC data expiry time in AAC frames */
/**
* \brief DRC module setting parameters

View File

@ -374,10 +374,10 @@ void CTns_Apply (
switch (granuleLength) {
case 480:
tns_max_bands = tns_max_bands_tbl_480[pSamplingRateInfo->samplingRateIndex-3];
tns_max_bands = tns_max_bands_tbl_480[pSamplingRateInfo->samplingRateIndex];
break;
case 512:
tns_max_bands = tns_max_bands_tbl_512[pSamplingRateInfo->samplingRateIndex-3];
tns_max_bands = tns_max_bands_tbl_512[pSamplingRateInfo->samplingRateIndex];
break;
default:
tns_max_bands = GetMaximumTnsBands(pIcsInfo, pSamplingRateInfo->samplingRateIndex);

View File

@ -865,6 +865,17 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self, const CS
self->chMapping[ch] = 255;
}
}
#ifdef TP_PCE_ENABLE
else {
if (CProgramConfig_IsValid(&asc->m_progrConfigElement)) {
/* Set matrix mixdown infos if available from PCE. */
pcmDmx_SetMatrixMixdownFromPce ( self->hPcmUtils,
asc->m_progrConfigElement.MatrixMixdownIndexPresent,
asc->m_progrConfigElement.MatrixMixdownIndex,
asc->m_progrConfigElement.PseudoSurroundEnable );
}
}
#endif
self->streamInfo.channelConfig = asc->m_channelConfiguration;
@ -1565,7 +1576,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
self->streamInfo.numChannels = aacChannels;
#ifdef TP_PCE_ENABLE
if (pceRead == 1 || CProgramConfig_IsValid(pce)) {
if (pceRead == 1 && CProgramConfig_IsValid(pce)) {
/* Set matrix mixdown infos if available from PCE. */
pcmDmx_SetMatrixMixdownFromPce ( self->hPcmUtils,
pce->MatrixMixdownIndexPresent,
@ -1646,10 +1657,6 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
self->sbrEnabled
);
if ( flags&AACDEC_FLUSH ) {
FDKmemclear(pAacDecoderChannelInfo->pSpectralCoefficient, sizeof(FIXP_DBL)*self->streamInfo.aacSamplesPerFrame);
}
switch (pAacDecoderChannelInfo->renderMode)
{
case AACDEC_RENDER_IMDCT:
@ -1677,6 +1684,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
break;
}
if ( flags&AACDEC_FLUSH ) {
FDKmemclear(pAacDecoderChannelInfo->pSpectralCoefficient, sizeof(FIXP_DBL)*self->streamInfo.aacSamplesPerFrame);
FDKmemclear(self->pAacDecoderStaticChannelInfo[c]->pOverlapBuffer, OverlapBufferSize*sizeof(FIXP_DBL));
}
}

View File

@ -110,7 +110,7 @@ amm-info@iis.fraunhofer.de
/* Decoder library info */
#define AACDECODER_LIB_VL0 2
#define AACDECODER_LIB_VL1 4
#define AACDECODER_LIB_VL2 4
#define AACDECODER_LIB_VL2 7
#define AACDECODER_LIB_TITLE "AAC Decoder Lib"
#define AACDECODER_LIB_BUILD_DATE __DATE__
#define AACDECODER_LIB_BUILD_TIME __TIME__

View File

@ -424,102 +424,11 @@ For HE-AAC and HE-AAC v2 the lowest possible audio input sampling frequency is 1
AAC-LC core encoder operates in dual rate mode at its lowest possible sampling frequency, which is 8 kHz.
HE-AAC v2 requires stereo input audio data.
The following table lists the supported bitrates for AAC-LC, HE-AAC and HE-AAC v2 encoding depending
on input sampling frequency ("Hz") and number of input channels ("chan"). The minimum and maximum
allowed bitrate ("BR Min", "BR Max") is given in bits per second.
In case the desired combination of bitrate and sampling frequency is not available ("NA") for HE-AAC or
HE-AAC v2 then the encoder will automatically switch to AAC-LC and give a command line warning.
Please note that in HE-AAC or HE-AAC v2 mode the encoder supports much higher bitrates than are
appropriate for HE-AAC or HE-AAC v2. For example, at a bitrate of more than 64 kbit/s for a stereo
audio signal at 44.1 kHz it usually makes sense to use AAC-LC, which will produce better audio
quality at that bitrate than HE-AAC or HE-AAC v2.
\verbatim
Config AAC-LC HE-AAC (SBR) HE-AACv2 (SBR+PS)
Hz chan BR Min BR Max BR Min BR Max BR Min BR Max
8000 1 758 48000 NA NA NA NA
11025 1 1045 66150 NA NA NA NA
12000 1 1137 72000 NA NA NA NA
16000 1 1516 96000 8000 48000 NA NA
22050 1 2089 132300 8000 64000 NA NA
24000 1 2274 144000 8000 64000 NA NA
32000 1 3032 192000 8000 64000 NA NA
44100 1 4178 264576 8000 64000 NA NA
48000 1 4547 288000 12000 64000 NA NA
64000 1 6063 384000 24000 160000 NA NA
88200 1 8355 529200 24000 160000 NA NA
96000 1 9094 576000 24000 160000 NA NA
-----------------------------------------------------------------------------------
8000 2 1071 96000 NA NA NA NA
11025 2 1476 132300 NA NA NA NA
12000 2 1606 144000 NA NA NA NA
16000 2 2141 192000 16000 96000 8000 48000
22050 2 2951 264600 16000 128000 8000 64000
24000 2 3211 288000 16000 128000 8000 64000
32000 2 4282 384000 16000 128000 8000 64000
44100 2 5900 529152 16000 128000 8000 64000
48000 2 6422 576000 16000 128000 12000 64000
64000 2 8563 768000 32000 256000 24000 160000
88200 2 11801 1058400 32000 256000 24000 160000
96000 2 12844 1152000 32000 256000 24000 160000
-----------------------------------------------------------------------------------
8000 3 1383 144000 NA NA NA NA
11025 3 1906 198450 NA NA NA NA
12000 3 2075 216000 NA NA NA NA
16000 3 2766 288000 26667 120000 NA NA
22050 3 3812 396900 26667 160000 NA NA
24000 3 4149 432000 26667 160000 NA NA
32000 3 5532 576000 26667 160000 NA NA
44100 3 7623 793728 26667 160000 NA NA
48000 3 8297 864000 29996 160000 NA NA
64000 3 11063 1152000 59996 400000 NA NA
88200 3 15246 1587600 59996 400000 NA NA
96000 3 16594 1728000 59996 400000 NA NA
-----------------------------------------------------------------------------------
8000 4 1696 192000 NA NA NA NA
11025 4 2337 264600 NA NA NA NA
12000 4 2543 288000 NA NA NA NA
16000 4 3391 384000 40000 160000 NA NA
22050 4 4673 529200 40000 213330 NA NA
24000 4 5086 576000 40000 213330 NA NA
32000 4 6782 768000 40000 213330 NA NA
44100 4 9345 1058304 40000 213330 NA NA
48000 4 10172 1152000 40000 213330 NA NA
64000 4 13563 1536000 80000 533330 NA NA
88200 4 18691 2116800 80000 533330 NA NA
96000 4 20344 2304000 80000 533330 NA NA
-----------------------------------------------------------------------------------
8000 5 2008 240000 NA NA NA NA
11025 5 2768 330750 NA NA NA NA
12000 5 3012 360000 NA NA NA NA
16000 5 4016 480000 43244 184612 NA NA
22050 5 5535 661500 43244 246152 NA NA
24000 5 6024 720000 43244 246152 NA NA
32000 5 8032 960000 43244 246152 NA NA
44100 5 11068 1322880 43244 246152 NA NA
48000 5 12047 1440000 46140 246152 NA NA
64000 5 16063 1920000 92296 615384 NA NA
88200 5 22137 2646000 92296 615384 NA NA
96000 5 24094 2880000 92296 615384 NA NA
-----------------------------------------------------------------------------------
8000 5.1 2321 240000 NA NA NA NA
11025 5.1 3198 330750 NA NA NA NA
12000 5.1 3481 360000 NA NA NA NA
16000 5.1 4641 480000 45715 199990 NA NA
22050 5.1 6396 661500 45715 266658 NA NA
24000 5.1 6961 720000 45715 266658 NA NA
32000 5.1 9282 960000 45715 266658 NA NA
44100 5.1 12790 1322880 45715 266658 NA NA
48000 5.1 13922 1440000 49982 266658 NA NA
64000 5.1 18563 1920000 99982 666658 NA NA
88200 5.1 25582 2646000 99982 666658 NA NA
96000 5.1 27844 2880000 99982 666658 NA NA
\endverbatim \n
\section reommendedConfig Recommended Sampling Rate and Bitrate Combinations
The following table provides an overview of recommended encoder configuration parameters
@ -956,8 +865,8 @@ typedef enum
AACENC_GRANULE_LENGTH = 0x0105, /*!< Core encoder (AAC) audio frame length in samples:
- 1024: Default configuration.
- 512: Optional length in LD/ELD configuration.
- 480: Default LD/ELD configuration. */
- 512: Default LD/ELD configuration.
- 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. */

View File

@ -149,7 +149,7 @@ INT FDKaacEnc_LimitBitrate(
transportBits = 208;
}
bitRate = FDKmax(bitRate, ((((40 * nChannels) + transportBits + frameLength) * (coreSamplingRate)) / frameLength) );
bitRate = FDKmax(bitRate, ((((40 * nChannels) + transportBits) * (coreSamplingRate)) / frameLength) );
FDK_ASSERT(bitRate >= 0);
bitRate = FDKmin(bitRate, ((nChannelsEff * MIN_BUFSIZE_PER_EFF_CHAN)*(coreSamplingRate>>shift)) / (frameLength>>shift)) ;
@ -280,7 +280,7 @@ void FDKaacEnc_AacInitDefaultConfig(AACENC_CONFIG *config)
config->useTns = TNS_ENABLE_MASK; /* tns enabled completly */
config->usePns = 1; /* depending on channelBitrate this might be set to 0 later */
config->useIS = 1; /* Intensity Stereo Configuration */
config->framelength = DEFAULT_FRAMELENGTH; /* used frame size */
config->framelength = -1; /* Framesize not configured */
config->syntaxFlags = 0; /* default syntax with no specialities */
config->epConfig = -1; /* no ER syntax -> no additional error protection */
config->nSubFrames = 1; /* default, no sub frames */
@ -451,11 +451,8 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc,
switch (config->framelength)
{
case 1024:
if ( config->audioObjectType != AOT_AAC_LC
&& config->audioObjectType != AOT_SBR
&& config->audioObjectType != AOT_PS
&& config->audioObjectType != AOT_ER_AAC_LC
&& config->audioObjectType != AOT_AAC_SCAL )
if ( config->audioObjectType == AOT_ER_AAC_LD
|| config->audioObjectType == AOT_ER_AAC_ELD )
{
return AAC_ENC_INVALID_FRAME_LENGTH;
}

View File

@ -153,7 +153,6 @@ typedef enum {
/*-------------------------- defines --------------------------------------*/
#define ANC_DATA_BUFFERSIZE 1024 /* ancBuffer size */
#define DEFAULT_FRAMELENGTH 1024 /* size of AAC core frame in (new) PCM samples */
#define MAX_TOTAL_EXT_PAYLOADS (((6) * (1)) + (2+2))

View File

@ -98,7 +98,7 @@ amm-info@iis.fraunhofer.de
/* Encoder library info */
#define AACENCODER_LIB_VL0 3
#define AACENCODER_LIB_VL1 3
#define AACENCODER_LIB_VL2 1
#define AACENCODER_LIB_VL2 3
#define AACENCODER_LIB_TITLE "AAC Encoder"
#define AACENCODER_LIB_BUILD_DATE __DATE__
#define AACENCODER_LIB_BUILD_TIME __TIME__

View File

@ -1067,11 +1067,11 @@ static void FDKaacEnc_CalcGaussWindow(
const INT timeResolution_e
)
{
#define PI_SCALE (2)
#define PI_FIX FL2FXCONST_DBL(3.1416f/(float)(1<<PI_SCALE))
#define PI_E (2)
#define PI_M FL2FXCONST_DBL(3.1416f/(float)(1<<PI_E))
#define EULER_SCALE (2)
#define EULER_FIX FL2FXCONST_DBL(2.7183/(float)(1<<EULER_SCALE))
#define EULER_E (2)
#define EULER_M FL2FXCONST_DBL(2.7183/(float)(1<<EULER_E))
#define COEFF_LOOP_SCALE (4)
@ -1083,9 +1083,9 @@ static void FDKaacEnc_CalcGaussWindow(
* gaussExp = PI * samplingRate * 0.001f * timeResolution / transformResolution;
* gaussExp = -0.5f * gaussExp * gaussExp;
*/
gaussExp_m = fMultNorm(timeResolution, fMult(PI_FIX, fDivNorm( (FIXP_DBL)(samplingRate), (FIXP_DBL)(LONG)(transformResolution*1000.f), &e1)), &e2);
gaussExp_m = fMultNorm(timeResolution, fMult(PI_M, fDivNorm( (FIXP_DBL)(samplingRate), (FIXP_DBL)(LONG)(transformResolution*1000.f), &e1)), &e2);
gaussExp_m = -fPow2Div2(gaussExp_m);
gaussExp_e = 2*(e1+e2+timeResolution_e+PI_SCALE);
gaussExp_e = 2*(e1+e2+timeResolution_e+PI_E);
FDK_ASSERT( winSize < (1<<COEFF_LOOP_SCALE) );
@ -1095,13 +1095,13 @@ static void FDKaacEnc_CalcGaussWindow(
for( i=0; i<winSize; i++) {
win[i] = fPow(
EULER_FIX,
EULER_SCALE,
EULER_M,
EULER_E,
fMult(gaussExp_m, fPow2((i*FL2FXCONST_DBL(1.f/(float)(1<<COEFF_LOOP_SCALE)) + FL2FXCONST_DBL(.5f/(float)(1<<COEFF_LOOP_SCALE))))),
gaussExp_e + 2*COEFF_LOOP_SCALE,
&e1);
win[i] = scaleValue(win[i], e1);
win[i] = scaleValueSaturate(win[i], e1);
}
}
@ -1157,7 +1157,10 @@ static INT FDKaacEnc_AutoToParcor(
workBuffer++;
}
tmp = fMult((FIXP_DBL)((LONG)TNS_PREDGAIN_SCALE<<21), fDivNorm(autoCorr_0, input[0], &scale));
tmp = fMult((FIXP_DBL)((LONG)TNS_PREDGAIN_SCALE<<21), fDivNorm(fAbs(autoCorr_0), fAbs(input[0]), &scale));
if ( fMultDiv2(autoCorr_0, input[0])<FL2FXCONST_DBL(0.0f) ) {
tmp = -tmp;
}
predictionGain = (LONG)scaleValue(tmp,scale-21);
return (predictionGain);

View File

@ -260,21 +260,21 @@ FDKaacEnc_CalcBandEnergyOptimShort(const FIXP_DBL *RESTRICT mdctSpectrum,
for(i=0; i<numBands; i++)
{
int leadingBits = fixMax(0,sfbMaxScaleSpec[i]-4); /* max sfbWidth = 96 ; 2^7=128 => 7/2 = 4 (spc*spc) */
int leadingBits = sfbMaxScaleSpec[i]-3; /* max sfbWidth = 36 ; 2^6=64 => 6/2 = 3 (spc*spc) */
FIXP_DBL tmp = FL2FXCONST_DBL(0.0);
for (j=bandOffset[i];j<bandOffset[i+1];j++)
{
FIXP_DBL spec = mdctSpectrum[j]<<leadingBits;
FIXP_DBL spec = scaleValue(mdctSpectrum[j],leadingBits);
tmp = fPow2AddDiv2(tmp, spec);
}
bandEnergy[i] = scaleValueSaturate(tmp, 1);
bandEnergy[i] = tmp;
}
for(i=0; i<numBands; i++)
{
INT scale = 2*fixMax(0,sfbMaxScaleSpec[i]-4); /* max sfbWidth = 96 ; 2^7=128 => 7/2 = 4 (spc*spc) */
scale = fixMin(scale,(DFRACT_BITS-1));
bandEnergy[i] >>= scale;
INT scale = (2*(sfbMaxScaleSpec[i]-3))-1; /* max sfbWidth = 36 ; 2^6=64 => 6/2 = 3 (spc*spc) */
scale = fixMax(fixMin(scale,(DFRACT_BITS-1)),-(DFRACT_BITS-1));
bandEnergy[i] = scaleValueSaturate(bandEnergy[i], -scale);
}
}

View File

@ -94,6 +94,10 @@ amm-info@iis.fraunhofer.de
* this routine does not work in-place
*/
static inline FIXP_DBL nrgAddSaturate(const FIXP_DBL a, const FIXP_DBL b) {
return ( (a>=(FIXP_DBL)MAXVAL_DBL-b) ? (FIXP_DBL)MAXVAL_DBL : (a + b) );
}
void
FDKaacEnc_groupShortData(FIXP_DBL *mdctSpectrum, /* in-out */
SFB_THRESHOLD *sfbThreshold, /* in-out */
@ -177,7 +181,7 @@ FDKaacEnc_groupShortData(FIXP_DBL *mdctSpectrum, /* in-out
FIXP_DBL thresh = sfbThreshold->Short[wnd][sfb];
for (j=1; j<groupLen[grp]; j++)
{
thresh = fAddSaturate(thresh, sfbThreshold->Short[wnd+j][sfb]);
thresh = nrgAddSaturate(thresh, sfbThreshold->Short[wnd+j][sfb]);
}
sfbThreshold->Long[i++] = thresh;
}
@ -195,7 +199,7 @@ FDKaacEnc_groupShortData(FIXP_DBL *mdctSpectrum, /* in-out
FIXP_DBL energy = sfbEnergy->Short[wnd][sfb];
for (j=1; j<groupLen[grp]; j++)
{
energy = fAddSaturate(energy, sfbEnergy->Short[wnd+j][sfb]);
energy = nrgAddSaturate(energy, sfbEnergy->Short[wnd+j][sfb]);
}
sfbEnergy->Long[i++] = energy;
}
@ -213,7 +217,7 @@ FDKaacEnc_groupShortData(FIXP_DBL *mdctSpectrum, /* in-out
FIXP_DBL energy = sfbEnergyMS->Short[wnd][sfb];
for (j=1; j<groupLen[grp]; j++)
{
energy = fAddSaturate(energy, sfbEnergyMS->Short[wnd+j][sfb]);
energy = nrgAddSaturate(energy, sfbEnergyMS->Short[wnd+j][sfb]);
}
sfbEnergyMS->Long[i++] = energy;
}
@ -231,7 +235,7 @@ FDKaacEnc_groupShortData(FIXP_DBL *mdctSpectrum, /* in-out
FIXP_DBL energy = sfbSpreadEnergy->Short[wnd][sfb];
for (j=1; j<groupLen[grp]; j++)
{
energy = fAddSaturate(energy, sfbSpreadEnergy->Short[wnd+j][sfb]);
energy = nrgAddSaturate(energy, sfbSpreadEnergy->Short[wnd+j][sfb]);
}
sfbSpreadEnergy->Long[i++] = energy;
}

View File

@ -122,6 +122,8 @@ void FDKaacEnc_prepareSfbPe(PE_CHANNEL_DATA *peChanData,
avgFormFactorLdData = ((-sfbEnergyLdData[sfbGrp+sfb]>>1) + (CalcLdInt(sfbWidth)>>1))>>1;
peChanData->sfbNLines[sfbGrp+sfb] =
(INT)CalcInvLdData( (sfbFormFactorLdData[sfbGrp+sfb] + formFacScaling) + avgFormFactorLdData);
/* Make sure sfbNLines is never greater than sfbWidth due to unaccuracies (e.g. sfbEnergyLdData[sfbGrp+sfb] = 0x80000000) */
peChanData->sfbNLines[sfbGrp+sfb] = fMin(sfbWidth, peChanData->sfbNLines[sfbGrp+sfb]);
}
else {
peChanData->sfbNLines[sfbGrp+sfb] = 0;

View File

@ -797,7 +797,7 @@ AAC_ENCODER_ERROR FDKaacEnc_QCMain(QC_STATE* RESTRICT hQC,
{
int i, c;
AAC_ENCODER_ERROR ErrorStatus = AAC_ENC_OK;
INT avgTotalDynBits = 0; /* maximal allowd dynamic bits for all frames */
INT avgTotalDynBits = 0; /* maximal allowed dynamic bits for all frames */
INT totalAvailableBits = 0;
INT nSubFrames = 1;
@ -1092,7 +1092,7 @@ AAC_ENCODER_ERROR FDKaacEnc_QCMain(QC_STATE* RESTRICT hQC,
int sumBitsConsumedTotal = FDKaacEnc_getTotalConsumedBits(qcOut, qcElement, cm, hQC->globHdrBits, nSubFrames);
/* in all frames are valid dynamic bits */
if (sumBitsConsumedTotal < totalAvailableBits && (decreaseBitConsumption==1) && checkMinFrameBitsDemand(qcOut,hQC->minBitsPerFrame,nSubFrames)
if ( ((sumBitsConsumedTotal < totalAvailableBits) || qcOut[c]->usedDynBits==0) && (decreaseBitConsumption==1) && checkMinFrameBitsDemand(qcOut,hQC->minBitsPerFrame,nSubFrames)
/*()*/ )
{
quantizationDone = 1; /* exit bit adjustment */
@ -1365,43 +1365,55 @@ AAC_ENCODER_ERROR FDKaacEnc_FinalizeBitConsumption(CHANNEL_MAPPING *cm,
QC_OUT_EXTENSION fillExtPayload;
INT totFillBits, alignBits;
{
int exactTpBits;
int max_iter = 3;
/* Get total consumed bits in AU */
qcOut->totalBits = qcOut->staticBits + qcOut->usedDynBits + qcOut->totFillBits +
qcOut->elementExtBits + qcOut->globalExtBits;
if (qcKernel->bitrateMode==QCDATA_BR_MODE_CBR) {
/* Now we can get the exact transport bit amount, and hopefully it is equal to the estimated value */
exactTpBits = transportEnc_GetStaticBits(hTpEnc, qcOut->totalBits);
INT exactTpBits = transportEnc_GetStaticBits(hTpEnc, qcOut->totalBits);
if (exactTpBits != qcKernel->globHdrBits) {
INT diffFillBits = 0;
/* How many bits can be taken by bitreservoir */
const INT bitresSpace = qcKernel->bitResTotMax - (qcKernel->bitResTot + (qcOut->grantedDynBits - (qcOut->usedDynBits + qcOut->totFillBits) ) );
/* Number of bits which can be moved to bitreservoir. */
INT bitsToBitres = qcKernel->globHdrBits - exactTpBits;
const INT bitsToBitres = qcKernel->globHdrBits - exactTpBits;
FDK_ASSERT(bitsToBitres>=0); /* is always positive */
if (bitsToBitres>0) {
/* if bitreservoir can not take all bits, move ramaining bits to fillbits */
diffFillBits = FDKmax(0, bitsToBitres - (qcKernel->bitResTotMax-qcKernel->bitResTot));
}
else if (bitsToBitres<0) {
/* if bits mus be taken from bitreservoir, reduce fillbits first. */
diffFillBits = (FDKmax(FDKmax(bitsToBitres, -qcKernel->bitResTot), -qcOut->totFillBits));
}
/* If bitreservoir can not take all bits, move ramaining bits to fillbits */
diffFillBits = FDKmax(0, bitsToBitres - bitresSpace);
diffFillBits = (diffFillBits+7)&~7; /* assure previous alignment */
/* Assure previous alignment */
diffFillBits = (diffFillBits+7)&~7;
/* Move as many bits as possible to bitreservoir */
qcKernel->bitResTot += (bitsToBitres-diffFillBits);
/* Write remaing bits as fill bits */
qcOut->totFillBits += diffFillBits;
qcOut->totalBits += diffFillBits;
qcOut->grantedDynBits += diffFillBits;
/* new header bits */
/* Get new header bits */
qcKernel->globHdrBits = transportEnc_GetStaticBits(hTpEnc, qcOut->totalBits);
if (qcKernel->globHdrBits != exactTpBits) {
/* In previous step, fill bits and corresponding total bits were changed when bitreservoir was completely filled.
Now we can take the too much taken bits caused by header overhead from bitreservoir.
*/
qcKernel->bitResTot -= (qcKernel->globHdrBits - exactTpBits);
}
}
} /* MODE_CBR */
/* Update exact number of consumed header bits. */
qcKernel->globHdrBits = transportEnc_GetStaticBits(hTpEnc, qcOut->totalBits);
/* Save total fill bits and distribut to alignment and fill bits */
totFillBits = qcOut->totFillBits;

View File

@ -127,10 +127,7 @@ static void FDKaacEnc_quantizeLines(INT gain,
accu = fMultDiv2(FDKaacEnc_mTab_3_4[tabIndex],FDKaacEnc_quantTableE[totalShift&3]);
totalShift = (16-4)-(3*(totalShift>>2));
FDK_ASSERT(totalShift >=0); /* MAX_QUANT_VIOLATION */
if (totalShift < 32)
accu>>=totalShift;
else
accu = 0;
quaSpectrum[line] = (SHORT)(-((LONG)(k + accu) >> (DFRACT_BITS-1-16)));
}
else if(accu > FL2FXCONST_DBL(0.0f))
@ -143,10 +140,7 @@ static void FDKaacEnc_quantizeLines(INT gain,
accu = fMultDiv2(FDKaacEnc_mTab_3_4[tabIndex],FDKaacEnc_quantTableE[totalShift&3]);
totalShift = (16-4)-(3*(totalShift>>2));
FDK_ASSERT(totalShift >=0); /* MAX_QUANT_VIOLATION */
if (totalShift < 32)
accu>>=totalShift;
else
accu = 0;
quaSpectrum[line] = (SHORT)((LONG)(k + accu) >> (DFRACT_BITS-1-16));
}
else
@ -319,6 +313,9 @@ FIXP_DBL FDKaacEnc_calcSfbDist(FIXP_DBL *mdctSpectrum,
&mdctSpectrum[i],
&quantSpectrum[i]);
if (fAbs(quantSpectrum[i])>MAX_QUANT) {
return FL2FXCONST_DBL(0.0f);
}
/* inverse quantization */
FDKaacEnc_invQuantizeLines(gain,1,&quantSpectrum[i],&invQuantSpec);
@ -361,15 +358,22 @@ void FDKaacEnc_calcSfbQuantEnergyAndDist(FIXP_DBL *mdctSpectrum,
FIXP_DBL invQuantSpec;
FIXP_DBL diff;
*en = FL2FXCONST_DBL(0.0f);
*dist = FL2FXCONST_DBL(0.0f);
FIXP_DBL energy = FL2FXCONST_DBL(0.0f);
FIXP_DBL distortion = FL2FXCONST_DBL(0.0f);
for (i=0; i<noOfLines; i++) {
if (fAbs(quantSpectrum[i])>MAX_QUANT) {
*en = FL2FXCONST_DBL(0.0f);
*dist = FL2FXCONST_DBL(0.0f);
return;
}
/* inverse quantization */
FDKaacEnc_invQuantizeLines(gain,1,&quantSpectrum[i],&invQuantSpec);
/* energy */
*en += fPow2(invQuantSpec);
energy += fPow2(invQuantSpec);
/* dist */
diff = fixp_abs(fixp_abs(invQuantSpec) - fixp_abs(mdctSpectrum[i]>>1));
@ -382,10 +386,10 @@ void FDKaacEnc_calcSfbQuantEnergyAndDist(FIXP_DBL *mdctSpectrum,
diff = scaleValue(diff, -scale);
*dist += diff;
distortion += diff;
}
*en = CalcLdData(*en)+FL2FXCONST_DBL(0.03125f);
*dist = CalcLdData(*dist);
*en = CalcLdData(energy)+FL2FXCONST_DBL(0.03125f);
*dist = CalcLdData(distortion);
}

View File

@ -1,93 +0,0 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
Initial author: M.Werner
contents/description: TNS parameters
******************************************************************************/
#include "tns_param.h"

View File

@ -155,7 +155,6 @@ amm-info@iis.fraunhofer.de
#endif
/* Define preferred Multiplication type */
#if defined(FDK_HIGH_PERFORMANCE) && !defined(FDK_HIGH_QUALITY) /* FDK_HIGH_PERFORMANCE */

View File

@ -100,6 +100,9 @@ amm-info@iis.fraunhofer.de
#elif defined(__mips__) /* cppp replaced: elif */
#include "mips/clz_mips.h"
#elif defined(__x86__) /* cppp replaced: elif */
#include "x86/clz_x86.h"
#endif /* all cores */

View File

@ -225,7 +225,6 @@ FDK_INLINE FIXP_DBL fAbs(FIXP_DBL x)
FDK_INLINE FIXP_SGL fAbs(FIXP_SGL x)
{ return fixabs_S(x); }
/* workaround for TI C6x compiler but not for TI ARM9E compiler */
#if (!defined(__TI_COMPILER_VERSION__) || defined(__TI_TMS470_V5__)) && !defined(__x86_64__)
FDK_INLINE INT fAbs(INT x)
@ -336,7 +335,6 @@ FDK_INLINE FIXP_SGL fMin(FIXP_SGL a, FIXP_SGL b)
FDK_INLINE FIXP_SGL fMax(FIXP_SGL a, FIXP_SGL b)
{ return fixmax_S(a,b); }
/* workaround for TI C6x compiler but not for TI ARM9E */
#if ((!defined(__TI_COMPILER_VERSION__) || defined(__TI_TMS470_V5__)) && !defined(__x86_64__)) || (FIX_FRACT == 1)
FDK_INLINE INT fMax(INT a, INT b)

View File

@ -108,9 +108,22 @@ inline void cplxMultDiv2( FIXP_DBL *c_Re,
FIXP_DBL b_Im)
{
INT result;
result = (((long long)a_Re * b_Re) - ((long long) a_Im * b_Im)) >> 32;
__asm__ ("mult %[a_Re], %[b_Re];\n"
"msub %[a_Im], %[b_Im];\n"
"mfhi %[result];\n"
: [result]"=r"(result)
: [a_Re]"d"(a_Re), [b_Re]"d"(b_Re), [a_Im]"d"(a_Im), [b_Im]"d"(b_Im)
: "lo");
*c_Re = result;
result = (((long long)a_Re * b_Im) - ((long long) a_Im * b_Re)) >> 32;
__asm__ ("mult %[a_Re], %[b_Im];\n"
"madd %[a_Im], %[b_Re];\n"
"mfhi %[result];\n"
: [result]"=r"(result)
: [a_Re]"r"(a_Re), [b_Im]"r"(b_Im), [a_Im]"r"(a_Im), [b_Re]"r"(b_Re)
: "lo");
*c_Im = result;
}
#endif
@ -124,9 +137,23 @@ inline void cplxMult( FIXP_DBL *c_Re,
FIXP_DBL b_Im)
{
INT result;
result = (((long long)a_Re * b_Re) - ((long long) a_Im * b_Im)) >> 32;
__asm__ ("mult %[a_Re], %[b_Re];\n"
"msub %[a_Im], %[b_Im];\n"
"mfhi %[result];\n"
//"extr_w %[result], 31;\n"
: [result]"=r"(result)
: [a_Re]"r"(a_Re), [b_Re]"r"(b_Re), [a_Im]"r"(a_Im), [b_Im]"r"(b_Im)
: "lo");
*c_Re = result<<1;
result = (((long long)a_Re * b_Im) - ((long long) a_Im * b_Re)) >> 32;
__asm__ ("mult %[a_Re], %[b_Im];\n"
"madd %[a_Im], %[b_Re];\n"
"mfhi %[result];\n"
//"extr_w %[result], 31;\n"
: [result]"=r"(result)
: [a_Re]"r"(a_Re), [b_Im]"r"(b_Im), [a_Im]"r"(a_Im), [b_Re]"r"(b_Re)
: "lo");
*c_Im = result<<1;
}
#endif

View File

@ -100,11 +100,14 @@ amm-info@iis.fraunhofer.de
inline INT fixmuldiv2_DD (const INT a, const INT b)
{
return ((long long) a * b) >> 32;
INT result ;
result = ((long long)a * b)>>32;
return result ;
}
#endif /* (__GNUC__) && defined(__mips__) */
#endif /* __mips__ */
#define FUNCTION_fixmulBitExact_DD
#define fixmulBitExact_DD fixmul_DD

View File

@ -148,13 +148,21 @@ FIXP_DBL scaleValueSaturate(
{
if(scalefactor > 0) {
if (fNorm(value) < scalefactor && value != (FIXP_DBL)0) {
if (value > (FIXP_DBL)0) {
return (FIXP_DBL)MAXVAL_DBL;
} else {
return (FIXP_DBL)MINVAL_DBL;
}
} else {
return (value<<scalefactor);
}
} else {
if (-(DFRACT_BITS-1) > scalefactor) {
return (FIXP_DBL)0;
} else {
return (value>>(-scalefactor));
}
}
}
#endif

View File

@ -81,16 +81,74 @@ www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/*************************** Fraunhofer IIS FDK Tools **********************
Initial author: Alex Goeschel
contents/description: Temporal noise shaping
Author(s):
Description: fixed point intrinsics
******************************************************************************/
#ifndef _TNS_PARAM_H
#define _TNS_PARAM_H
#if defined(__GNUC__) && (defined(__x86__) || defined(__x86_64__))
#define FUNCTION_fixnormz_D
#define FUNCTION_fixnorm_D
inline INT fixnormz_D(LONG value)
{
INT result;
if (value != 0) {
result = __builtin_clz(value);
} else {
result = 32;
}
return result;
}
inline INT fixnorm_D(LONG value)
{
INT result;
if (value == 0) {
return 0;
}
if (value < 0) {
value = ~value;
}
result = fixnormz_D(value);
return result - 1;
}
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
#endif /* _TNS_PARAM_H */
#include <intrin.h>
#define FUNCTION_fixnormz_D
#define FUNCTION_fixnorm_D
inline INT fixnormz_D(LONG value)
{
unsigned long result = 0;
unsigned char err;
err = _BitScanReverse(&result, value);
if (err) {
return 31 - result;
} else {
return 32;
}
}
inline INT fixnorm_D(LONG value)
{
INT result;
if (value == 0) {
return 0;
}
if (value < 0) {
value = ~value;
}
result = fixnormz_D(value);
return result - 1;
}
#endif /* toolchain */

View File

@ -93,7 +93,7 @@ amm-info@iis.fraunhofer.de
/* FDK tools library info */
#define FDK_TOOLS_LIB_VL0 2
#define FDK_TOOLS_LIB_VL1 2
#define FDK_TOOLS_LIB_VL2 6
#define FDK_TOOLS_LIB_VL2 8
#define FDK_TOOLS_LIB_TITLE "FDK Tools"
#define FDK_TOOLS_LIB_BUILD_DATE __DATE__
#define FDK_TOOLS_LIB_BUILD_TIME __TIME__

View File

@ -1040,7 +1040,8 @@ qmfInitFilterBank (HANDLE_QMF_FILTER_BANK h_Qmf, /*!< Handle to return */
h_Qmf->outScalefactor = ALGORITHMIC_SCALING_IN_ANALYSIS_FILTERBANK + ALGORITHMIC_SCALING_IN_SYNTHESIS_FILTERBANK + h_Qmf->filterScale;
if (h_Qmf->p_stride == 2) {
if ( (h_Qmf->p_stride == 2)
|| ((flags & QMF_FLAG_CLDFB) && (no_channels == 32)) ) {
h_Qmf->outScalefactor -= 1;
}
h_Qmf->outGain = (FIXP_DBL)0x80000000; /* default init value will be not applied */
@ -1147,7 +1148,8 @@ qmfChangeOutScalefactor (HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf S
/* Add internal filterbank scale */
outScalefactor += ALGORITHMIC_SCALING_IN_ANALYSIS_FILTERBANK + ALGORITHMIC_SCALING_IN_SYNTHESIS_FILTERBANK + synQmf->filterScale;
if (synQmf->p_stride == 2) {
if ( (synQmf->p_stride == 2)
|| ((synQmf->flags & QMF_FLAG_CLDFB) && (synQmf->no_channels == 32)) ) {
outScalefactor -= 1;
}

View File

@ -96,7 +96,7 @@ amm-info@iis.fraunhofer.de
/* Decoder library info */
#define PCMDMX_LIB_VL0 2
#define PCMDMX_LIB_VL1 2
#define PCMDMX_LIB_VL1 3
#define PCMDMX_LIB_VL2 1
#define PCMDMX_LIB_TITLE "PCM Downmix Lib"
#define PCMDMX_LIB_BUILD_DATE __DATE__
@ -107,7 +107,7 @@ amm-info@iis.fraunhofer.de
#define PCM_DMX_MAX_CHANNELS ( 8 )
#define PCM_DMX_MAX_CHANNEL_GROUPS ( 4 )
#define PCM_DMX_MAX_CHANNELS_PER_GROUP ( 3 ) /* The maximum over all groups */
#define PCMDMX_DFLT_EXPIRY_FRAME ( 40 ) /* At least 400ms (FL 960 @ 96kHz) */
#define PCMDMX_DFLT_EXPIRY_FRAME ( 50 ) /* At least 500ms (FL 960 @ 96kHz) */
/* Fixed and unique channel group indices.
* The last group index has to be smaller than PCM_DMX_MAX_CHANNEL_GROUPS. */
@ -264,7 +264,6 @@ C_ALLOC_MEM_STATIC(PcmDmxInstance, struct PCM_DMX_INSTANCE, 1)
* @param [in] The total number of channels of the given configuration.
* @param [in] Array holding the corresponding channel types for each channel.
* @param [in] Array holding the corresponding channel type indices for each channel.
* @param [in] Array containing the channel mapping to be used (From MPEG PCE ordering to whatever is required).
* @param [out] Array where the buffer offsets for each channel are stored into.
* @returns Returns the packed channel mode.
**/
@ -273,7 +272,6 @@ PCM_DMX_CHANNEL_MODE getChannelMode (
const INT numChannels, /* in */
const AUDIO_CHANNEL_TYPE channelType[], /* in */
const UCHAR channelIndices[], /* in */
const UCHAR channelMapping[PCM_DMX_MAX_CHANNELS], /* in */
UCHAR offsetTable[PCM_DMX_MAX_CHANNELS] /* out */
)
{
@ -284,12 +282,12 @@ PCM_DMX_CHANNEL_MODE getChannelMode (
FDK_ASSERT(channelType != NULL);
FDK_ASSERT(channelIndices != NULL);
FDK_ASSERT(channelMapping != NULL);
FDK_ASSERT(offsetTable != NULL);
/* For details see ISO/IEC 13818-7:2005(E), 8.5.3 Channel configuration */
FDKmemclear(numChInGrp, PCM_DMX_MAX_CHANNEL_GROUPS*sizeof(UCHAR));
FDKmemset(offsetTable, 255, PCM_DMX_MAX_CHANNELS*sizeof(UCHAR));
FDKmemset(chIdx, 255, PCM_DMX_MAX_CHANNEL_GROUPS*PCM_DMX_MAX_CHANNELS_PER_GROUP*sizeof(UCHAR));
/* Categorize channels */
for (ch = 0; ch < numChannels; ch += 1) {
@ -335,7 +333,7 @@ PCM_DMX_CHANNEL_MODE getChannelMode (
if (numChInGrp[CH_GROUP_FRONT] & 0x1) {
/* Odd number of front channels -> we have a center channel.
In MPEG-4 the center has the index 0. */
offsetTable[CENTER_FRONT_CHANNEL] = channelMapping[chIdx[CH_GROUP_FRONT][0]];
offsetTable[CENTER_FRONT_CHANNEL] = chIdx[CH_GROUP_FRONT][0];
}
for (grpIdx = 0; grpIdx < PCM_DMX_MAX_CHANNEL_GROUPS; grpIdx += 1) {
@ -367,7 +365,7 @@ PCM_DMX_CHANNEL_MODE getChannelMode (
for ( ; ch < numChInGrp[grpIdx]; ch += 1) {
if (ch < maxChannels) {
offsetTable[chMapPos] = channelMapping[chIdx[grpIdx][ch]];
offsetTable[chMapPos] = chIdx[grpIdx][ch];
chMapPos += 1;
} else {
err = -1;
@ -814,7 +812,6 @@ PCMDMX_ERROR pcmDmx_ApplyFrame (
numInChannels,
channelType,
channelIndices,
channelMapping[numInChannels],
inOffsetTable
);
if (inChMode == CH_MODE_UNDEFINED) {

View File

@ -581,10 +581,11 @@ sbr_dec ( HANDLE_SBR_DEC hSbrDec, /*!< handle to Decoder channel */
outScalefactor += (SCAL_HEADROOM+1); /* psDiffScale! */
{
C_ALLOC_SCRATCH_START(pWorkBuffer, FIXP_DBL, 2*(64));
C_AALLOC_SCRATCH_START(pWorkBuffer, FIXP_DBL, 2*(64));
int maxShift = 0;
if (hSbrDec->sbrDrcChannel.enable != 0) {
if (hSbrDec->sbrDrcChannel.prevFact_exp > maxShift) {
maxShift = hSbrDec->sbrDrcChannel.prevFact_exp;
}
@ -594,6 +595,7 @@ sbr_dec ( HANDLE_SBR_DEC hSbrDec, /*!< handle to Decoder channel */
if (hSbrDec->sbrDrcChannel.nextFact_exp > maxShift) {
maxShift = hSbrDec->sbrDrcChannel.nextFact_exp;
}
}
/* copy DRC data to right channel (with PS both channels use the same DRC gains) */
FDKmemcpy(&hSbrDecRight->sbrDrcChannel, &hSbrDec->sbrDrcChannel, sizeof(SBRDEC_DRC_CHANNEL));
@ -682,7 +684,7 @@ sbr_dec ( HANDLE_SBR_DEC hSbrDec, /*!< handle to Decoder channel */
synQmf->lsb,
synQmf->no_col );
C_ALLOC_SCRATCH_END(pWorkBuffer, FIXP_DBL, 2*(64));
C_AALLOC_SCRATCH_END(pWorkBuffer, FIXP_DBL, 2*(64));
}
}

View File

@ -115,17 +115,17 @@ void sbrDecoder_drcInitChannel (
}
for (band = 0; band < (64); band++) {
hDrcData->prevFact_mag[band] = (FIXP_DBL)MAXVAL_DBL /*FL2FXCONST_DBL(1.0f)*/;
hDrcData->prevFact_mag[band] = FL2FXCONST_DBL(0.5f);
}
for (band = 0; band < SBRDEC_MAX_DRC_BANDS; band++) {
hDrcData->currFact_mag[band] = (FIXP_DBL)MAXVAL_DBL /*FL2FXCONST_DBL(1.0f)*/;
hDrcData->nextFact_mag[band] = (FIXP_DBL)MAXVAL_DBL /*FL2FXCONST_DBL(1.0f)*/;
hDrcData->currFact_mag[band] = FL2FXCONST_DBL(0.5f);
hDrcData->nextFact_mag[band] = FL2FXCONST_DBL(0.5f);
}
hDrcData->prevFact_exp = 0;
hDrcData->currFact_exp = 0;
hDrcData->nextFact_exp = 0;
hDrcData->prevFact_exp = 1;
hDrcData->currFact_exp = 1;
hDrcData->nextFact_exp = 1;
hDrcData->numBandsCurr = 0;
hDrcData->numBandsNext = 0;
@ -238,7 +238,7 @@ void sbrDecoder_drcApplySlot (
}
else {
if (j >= offset[hDrcData->drcInterpolationSchemeCurr - 1]) {
alphaValue = FL2FXCONST_DBL(1.0f);
alphaValue = (FIXP_DBL)MAXVAL_DBL;
}
}
}
@ -262,7 +262,7 @@ void sbrDecoder_drcApplySlot (
}
else {
if (j >= offset[hDrcData->drcInterpolationSchemeNext - 1]) {
alphaValue = FL2FXCONST_DBL(1.0f);
alphaValue = (FIXP_DBL)MAXVAL_DBL;
}
}
@ -301,7 +301,7 @@ void sbrDecoder_drcApplySlot (
}
else {
if (j >= offset[hDrcData->drcInterpolationSchemeNext - 1]) {
alphaValue = FL2FXCONST_DBL(1.0f);
alphaValue = (FIXP_DBL)MAXVAL_DBL;
}
}
}
@ -322,7 +322,7 @@ void sbrDecoder_drcApplySlot (
for (band = 0; band < (int)numBands; band++) {
int bottomQmf, topQmf;
FIXP_DBL drcFact_mag = FL2FXCONST_DBL(1.0f);
FIXP_DBL drcFact_mag = (FIXP_DBL)MAXVAL_DBL;
topMdct = (bandTop[band]+1) << 2;
@ -361,7 +361,13 @@ void sbrDecoder_drcApplySlot (
}
/* interpolate */
drcFact_mag = fMult(alphaValue, drcFact2_mag) + fMult((FL2FXCONST_DBL(1.0f) - alphaValue), drcFact1_mag);
if (alphaValue == (FIXP_DBL)0) {
drcFact_mag = drcFact1_mag;
} else if (alphaValue == (FIXP_DBL)MAXVAL_DBL) {
drcFact_mag = drcFact2_mag;
} else {
drcFact_mag = fMult(alphaValue, drcFact2_mag) + fMult(((FIXP_DBL)MAXVAL_DBL - alphaValue), drcFact1_mag);
}
/* apply scaling */
qmfRealSlot[bin] = fMult(qmfRealSlot[bin], drcFact_mag);
@ -481,6 +487,15 @@ void sbrDecoder_drcApply (
int col;
int maxShift = 0;
if (hDrcData == NULL) {
return;
}
if ( (hDrcData->enable == 0)
|| ((hDrcData->numBandsCurr == 0) && (hDrcData->numBandsNext == 0))
) {
return; /* Avoid changing the scaleFactor even though the processing is disabled. */
}
/* get max scale factor */
if (hDrcData->prevFact_exp > maxShift) {
maxShift = hDrcData->prevFact_exp;

View File

@ -94,6 +94,7 @@ amm-info@iis.fraunhofer.de
#include "sbrdecoder.h"
#define SBRDEC_MAX_DRC_CHANNELS (6)
#define SBRDEC_MAX_DRC_BANDS ( 16 )

View File

@ -137,7 +137,7 @@ amm-info@iis.fraunhofer.de
/* Decoder library info */
#define SBRDECODER_LIB_VL0 2
#define SBRDECODER_LIB_VL1 1
#define SBRDECODER_LIB_VL2 2
#define SBRDECODER_LIB_VL2 3
#define SBRDECODER_LIB_TITLE "SBR Decoder"
#define SBRDECODER_LIB_BUILD_DATE __DATE__
#define SBRDECODER_LIB_BUILD_TIME __TIME__
@ -818,6 +818,7 @@ SBR_ERROR sbrDecoder_drcFeedChannel ( HANDLE_SBRDECODER self,
USHORT *pBandTop )
{
SBRDEC_DRC_CHANNEL *pSbrDrcChannelData = NULL;
int band, isValidData = 0;
if (self == NULL) {
return SBRDEC_NOT_INITIALIZED;
@ -826,10 +827,21 @@ SBR_ERROR sbrDecoder_drcFeedChannel ( HANDLE_SBRDECODER self,
return SBRDEC_SET_PARAM_FAIL;
}
/* Search for gain values different to 1.0f */
for (band = 0; band < numBands; band += 1) {
if ( !((pNextFact_mag[band] == FL2FXCONST_DBL(0.5)) && (nextFact_exp == 1))
&& !((pNextFact_mag[band] == (FIXP_DBL)MAXVAL_DBL) && (nextFact_exp == 0)) ) {
isValidData = 1;
break;
}
}
/* Find the right SBR channel */
pSbrDrcChannelData = sbrDecoder_drcGetChannel( self, ch );
if ( pSbrDrcChannelData != NULL ) {
if ( pSbrDrcChannelData->enable || isValidData )
{ /* Activate processing only with real and valid data */
int i;
pSbrDrcChannelData->enable = 1;
@ -844,6 +856,7 @@ SBR_ERROR sbrDecoder_drcFeedChannel ( HANDLE_SBRDECODER self,
pSbrDrcChannelData->nextFact_mag[i] = pNextFact_mag[i];
}
}
}
return SBRDEC_OK;
}

View File

@ -536,13 +536,18 @@ mhLoweringEnergy(FIXP_DBL nrg, INT M)
\return void
****************************************************************************/
static FIXP_DBL
nmhLoweringEnergy(FIXP_DBL nrg, FIXP_DBL nrgSum, INT M)
static FIXP_DBL nmhLoweringEnergy(
FIXP_DBL nrg,
const FIXP_DBL nrgSum,
const INT nrgSum_scale,
const INT M
)
{
if (nrg>FL2FXCONST_DBL(0)) {
int sc=0;
/* gain = nrgSum / (nrg*(M+1)) */
FIXP_DBL gain = fMult(fDivNorm(nrgSum, nrg, &sc), GetInvInt(M+1));
sc += nrgSum_scale;
/* reduce nrg if gain smaller 1.f */
if ( !((sc>=0) && ( gain > ((FIXP_DBL)MAXVAL_DBL>>sc) )) ) {
@ -616,6 +621,7 @@ calculateSbrEnvelope (FIXP_DBL **RESTRICT YBufferLeft, /*! energy buffer left *
FIXP_DBL pNrgLeft[QMF_MAX_TIME_SLOTS];
FIXP_DBL pNrgRight[QMF_MAX_TIME_SLOTS];
int envNrg_scale;
FIXP_DBL envNrgLeft = FL2FXCONST_DBL(0.0f);
FIXP_DBL envNrgRight = FL2FXCONST_DBL(0.0f);
int missingHarmonic[QMF_MAX_TIME_SLOTS];
@ -625,6 +631,7 @@ calculateSbrEnvelope (FIXP_DBL **RESTRICT YBufferLeft, /*! energy buffer left *
stop_pos = timeStep * frame_info->borders[i + 1];
freq_res = frame_info->freqRes[i];
no_of_bands = h_con->nSfb[freq_res];
envNrg_scale = DFRACT_BITS-fNormz((FIXP_DBL)no_of_bands);
if (i == short_env) {
stop_pos -= fixMax(2, timeStep); /* consider at least 2 QMF slots less for short envelopes (envelopes just before transients) */
@ -762,9 +769,8 @@ calculateSbrEnvelope (FIXP_DBL **RESTRICT YBufferLeft, /*! energy buffer left *
/* save energies */
pNrgLeft[j] = nrgLeft;
pNrgRight[j] = nrgRight;
envNrgLeft = fAddSaturate(envNrgLeft, nrgLeft);
envNrgRight = fAddSaturate(envNrgRight, nrgRight);
envNrgLeft += (nrgLeft>>envNrg_scale);
envNrgRight += (nrgRight>>envNrg_scale);
} /* j */
for (j = 0; j < no_of_bands; j++) {
@ -777,9 +783,9 @@ calculateSbrEnvelope (FIXP_DBL **RESTRICT YBufferLeft, /*! energy buffer left *
if(!missingHarmonic[j] && h_sbr->fLevelProtect) {
/* in case of missing energy in base band,
reduce reference energy to prevent overflows in decoder output */
nrgLeft = nmhLoweringEnergy(nrgLeft, envNrgLeft, no_of_bands);
nrgLeft = nmhLoweringEnergy(nrgLeft, envNrgLeft, envNrg_scale, no_of_bands);
if (stereoMode == SBR_COUPLING) {
nrgRight = nmhLoweringEnergy(nrgRight, envNrgRight, no_of_bands);
nrgRight = nmhLoweringEnergy(nrgRight, envNrgRight, envNrg_scale, no_of_bands);
}
}

View File

@ -103,7 +103,7 @@ amm-info@iis.fraunhofer.de
#define SBRENCODER_LIB_VL0 3
#define SBRENCODER_LIB_VL1 2
#define SBRENCODER_LIB_VL2 1
#define SBRENCODER_LIB_VL2 2

View File

@ -119,8 +119,8 @@ extern const INT bookSbrNoiseBalanceC11T[25];
extern const UCHAR bookSbrNoiseBalanceL11T[25];
#define SBRENC_AACLC_TUNING_SIZE 124
#define SBRENC_AACELD_TUNING_SIZE 35
#define SBRENC_AACELD2_TUNING_SIZE 31
#define SBRENC_AACELD_TUNING_SIZE (26)
#define SBRENC_AACELD2_TUNING_SIZE (26)
#define SBRENC_TUNING_SIZE (SBRENC_AACLC_TUNING_SIZE + SBRENC_AACELD_TUNING_SIZE)

View File

@ -588,7 +588,7 @@ const sbrTuningTable_t sbrTuningTable[SBRENC_TUNING_SIZE] =
{ 100000,160001, 44100, 1, 13,13,11,11, 2, 0, 3, SBR_MONO, 1 }, /* backwards compatible */
/* 48/96 kHz dual rate */ /* not yet finally tuned */
{ 24000, 36000, 48000, 1, 4, 4, 9, 9, 2, 0, 3, SBR_MONO, 3 }, /* lowest range (multichannel rear) */
{ 32000, 36000, 48000, 1, 4, 4, 9, 9, 2, 0, 3, SBR_MONO, 3 }, /* lowest range (multichannel rear) */
{ 36000, 60000, 48000, 1, 7, 7,10,10, 2, 0, 3, SBR_MONO, 2 }, /* nominal: 40 */
{ 60000, 72000, 48000, 1, 9, 9,10,10, 2, 0, 3, SBR_MONO, 1 }, /* nominal: 64 */
{ 72000,100000, 48000, 1, 11,11,11,11, 2, 0, 3, SBR_MONO, 1 }, /* nominal: 80 */
@ -671,7 +671,7 @@ const sbrTuningTable_t sbrTuningTable[SBRENC_TUNING_SIZE] =
{ 144000,256001, 44100, 2, 13,13,11,11, 3, 0, -3, SBR_LEFT_RIGHT, 1 }, /* backwards compatible */
/* 48/96 kHz dual rate */ /* not yet finally tuned */
{ 32000, 60000, 48000, 2, 4, 4, 9, 9, 2, 0, -3, SBR_SWITCH_LRC, 3 }, /* lowest range (multichannel rear) */
{ 36000, 60000, 48000, 2, 4, 4, 9, 9, 2, 0, -3, SBR_SWITCH_LRC, 3 }, /* lowest range (multichannel rear) */
{ 60000, 80000, 48000, 2, 7, 7, 9, 9, 3, 0, -3, SBR_SWITCH_LRC, 2 }, /* nominal: 64 */
{ 80000,112000, 48000, 2, 9, 9,10,10, 3, 0, -3, SBR_LEFT_RIGHT, 1 }, /* nominal: 96 */
{ 112000,144000, 48000, 2, 11,11,11,11, 3, 0, -3, SBR_LEFT_RIGHT, 1 }, /* nominal: 128 */
@ -680,9 +680,6 @@ const sbrTuningTable_t sbrTuningTable[SBRENC_TUNING_SIZE] =
/** AAC LOW DELAY SECTION **/
/* 22.05/44.1 kHz dual rate */
{ 8000, 11369, 22050, 1, 1, 1, 1, 1, 1, 0, 6, SBR_MONO, 3 }, /* nominal: 8 kbit/s */ /**changed (not changed !!)*/
{ 11369, 16000, 22050, 1, 1, 0, 3, 3, 1, 0, 6, SBR_MONO, 3 }, /* nominal: 12 kbit/s */
{ 16000, 18000, 22050, 1, 2, 4, 4, 3, 1, 0, 6, SBR_MONO, 3 }, /* nominal: 16 kbit/s */
{ 18000, 22000, 22050, 1, 4, 4, 5, 5, 2, 0, 6, SBR_MONO, 2 }, /* nominal: 20 kbit/s */
{ 22000, 28000, 22050, 1, 4, 4, 6, 5, 2, 0, 6, SBR_MONO, 2 }, /* nominal: 24 kbit/s */
{ 28000, 36000, 22050, 1, 7, 8, 8, 8, 2, 0, 3, SBR_MONO, 2 }, /* nominal: 32 kbit/s */
@ -691,10 +688,7 @@ const sbrTuningTable_t sbrTuningTable[SBRENC_TUNING_SIZE] =
{ 52000, 64001, 22050, 1, 12,11,11,11, 2, 0, 3, SBR_MONO, 1 }, /* nominal: 56 kbit/s */
/* 24/48 kHz dual rate */
{ 8000, 12000, 24000, 1, 1, 1, 1, 1, 1, 0, 6, SBR_MONO, 3 }, /* nominal: 8 kbit/s */ /**changed (not changed !!)*/
{ 12000, 16000, 24000, 1, 1, 0, 3, 3, 1, 0, 6, SBR_MONO, 3 }, /* nominal: 12 kbit/s */
{ 16000, 18000, 24000, 1, 2, 4, 4, 3, 1, 0, 6, SBR_MONO, 3 }, /* nominal: 16 kbit/s */
{ 18000, 22000, 24000, 1, 4, 4, 5, 5, 2, 0, 6, SBR_MONO, 2 }, /* nominal: 20 kbit/s */
{ 20000, 22000, 24000, 1, 4, 4, 5, 5, 2, 0, 6, SBR_MONO, 2 }, /* nominal: 20 kbit/s */
{ 22000, 28000, 24000, 1, 4, 4, 6, 5, 2, 0, 6, SBR_MONO, 2 }, /* nominal: 24 kbit/s */
{ 28000, 36000, 24000, 1, 6, 8, 8, 8, 2, 0, 3, SBR_MONO, 2 }, /* nominal: 32 kbit/s */
{ 36000, 44000, 24000, 1, 8, 9, 9, 9, 2, 0, 3, SBR_MONO, 1 }, /* nominal: 40 kbit/s */
@ -702,8 +696,6 @@ const sbrTuningTable_t sbrTuningTable[SBRENC_TUNING_SIZE] =
{ 52000, 64001, 24000, 1, 13,11,11,10, 2, 0, 3, SBR_MONO, 1 }, /* nominal: 48 kbit/s */
/* 22.05/44.1 kHz dual rate */
{ 24000, 28000, 22050, 2, 3, 2, 5, 4, 1, 0, -3, SBR_SWITCH_LRC, 3 }, /* nominal: 24 kbit/s */
{ 28000, 32000, 22050, 2, 3, 2, 7, 6, 2, 0, -3, SBR_SWITCH_LRC, 2 }, /* nominal: 28 kbit/s */
{ 32000, 36000, 22050, 2, 5, 4, 7, 6, 2, 0, -3, SBR_SWITCH_LRC, 2 }, /* nominal: 32 kbit/s */
{ 36000, 44000, 22050, 2, 5, 8, 8, 8, 2, 0, -3, SBR_SWITCH_LRC, 2 }, /* nominal: 40 kbit/s */
{ 44000, 52000, 22050, 2, 7,10, 8, 8, 3, 0, -3, SBR_SWITCH_LRC, 2 }, /* nominal: 48 kbit/s */
@ -713,8 +705,7 @@ const sbrTuningTable_t sbrTuningTable[SBRENC_TUNING_SIZE] =
{ 82000,128001, 22050, 2, 13,12,11,11, 3, 0, -3, SBR_LEFT_RIGHT, 1 }, /* nominal: 80 kbit/s */
/* 24/48 kHz dual rate */
{ 24000, 28000, 24000, 2, 3, 3, 5, 5, 1, 0, -3, SBR_SWITCH_LRC, 3 }, /* nominal: 24 kbit/s */
{ 28000, 36000, 24000, 2, 5, 4, 7, 6, 2, 0, -3, SBR_SWITCH_LRC, 2 }, /* nominal: 32 kbit/s */
{ 32000, 36000, 24000, 2, 5, 4, 7, 6, 2, 0, -3, SBR_SWITCH_LRC, 2 }, /* nominal: 32 kbit/s */
{ 36000, 44000, 24000, 2, 4, 8, 8, 8, 2, 0, -3, SBR_SWITCH_LRC, 2 }, /* nominal: 40 kbit/s */
{ 44000, 52000, 24000, 2, 6,10, 8, 8, 3, 0, -3, SBR_SWITCH_LRC, 2 }, /* nominal: 48 kbit/s */
{ 52000, 60000, 24000, 2, 9,11, 9, 9, 3, 0, -3, SBR_SWITCH_LRC, 1 }, /* nominal: 56 kbit/s */

View File

@ -96,6 +96,8 @@ amm-info@iis.fraunhofer.de
#include "machine_type.h"
/* Work around for broken android toolchain: sys/types.h:137: error: 'uint64_t' does not name a type */
#define _SYS_TYPES_H_
/* Always increase verbosity of memory allocation in case of a debug built. DEBUG is defined globally in that case. */

View File

@ -173,7 +173,7 @@ amm-info@iis.fraunhofer.de
/* Define 64 bit base integer type. */
#ifdef _MSC_VER
#ifdef _WIN32
typedef __int64 INT64;
typedef unsigned __int64 UINT64;
#else

View File

@ -92,6 +92,9 @@ amm-info@iis.fraunhofer.de
#define _CRT_SECURE_NO_WARNINGS
/* Work around for broken android toolchain: sys/types.h:137: error: 'uint64_t' does not name a type */
#define _SYS_TYPES_H_
#include <stdarg.h>
#include <stdio.h>
#include <string.h>