mirror of https://github.com/mstorsjo/fdk-aac.git
Snap for 4801384 from a4d1f0ad52
to pi-release
Change-Id: Iab0959417db83cdeb3af7ce59ef4d8584a96b8be
This commit is contained in:
commit
c85b838a65
|
@ -1589,9 +1589,6 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
|
||||||
case 14:
|
case 14:
|
||||||
ascChannels = 8;
|
ascChannels = 8;
|
||||||
break;
|
break;
|
||||||
case 13: /* 22.2 setup */
|
|
||||||
ascChannels = 24;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return AAC_DEC_UNSUPPORTED_CHANNELCONFIG;
|
return AAC_DEC_UNSUPPORTED_CHANNELCONFIG;
|
||||||
}
|
}
|
||||||
|
@ -2837,7 +2834,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
|
||||||
/* usacExtElementStop = 1; */
|
/* usacExtElementStop = 1; */
|
||||||
}
|
}
|
||||||
|
|
||||||
usacExtBitPos = FDKgetValidBits(bs);
|
usacExtBitPos = (INT)FDKgetValidBits(bs);
|
||||||
|
|
||||||
USAC_EXT_ELEMENT_TYPE usacExtElementType =
|
USAC_EXT_ELEMENT_TYPE usacExtElementType =
|
||||||
self->pUsacConfig[streamIndex]
|
self->pUsacConfig[streamIndex]
|
||||||
|
@ -2862,7 +2859,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
|
||||||
|
|
||||||
/* Skip any remaining bits of extension payload */
|
/* Skip any remaining bits of extension payload */
|
||||||
usacExtBitPos = (usacExtElementPayloadLength * 8) -
|
usacExtBitPos = (usacExtElementPayloadLength * 8) -
|
||||||
(usacExtBitPos - FDKgetValidBits(bs));
|
(usacExtBitPos - (INT)FDKgetValidBits(bs));
|
||||||
if (usacExtBitPos < 0) {
|
if (usacExtBitPos < 0) {
|
||||||
self->frameOK = 0;
|
self->frameOK = 0;
|
||||||
ErrorStatus = AAC_DEC_PARSE_ERROR;
|
ErrorStatus = AAC_DEC_PARSE_ERROR;
|
||||||
|
|
|
@ -1082,15 +1082,15 @@ static void aacDecoder_UpdateBitStreamCounters(CStreamInfo *pSi,
|
||||||
|
|
||||||
/* bit/byte counters */
|
/* bit/byte counters */
|
||||||
{
|
{
|
||||||
int nBytes;
|
INT nBytes;
|
||||||
|
|
||||||
nBytes = nBits >> 3;
|
nBytes = nBits >> 3;
|
||||||
pSi->numTotalBytes += nBytes;
|
pSi->numTotalBytes = (UINT)((INT)pSi->numTotalBytes + nBytes);
|
||||||
if (IS_OUTPUT_VALID(ErrorStatus)) {
|
if (IS_OUTPUT_VALID(ErrorStatus)) {
|
||||||
pSi->numTotalAccessUnits++;
|
pSi->numTotalAccessUnits++;
|
||||||
}
|
}
|
||||||
if (IS_DECODE_ERROR(ErrorStatus)) {
|
if (IS_DECODE_ERROR(ErrorStatus)) {
|
||||||
pSi->numBadBytes += nBytes;
|
pSi->numBadBytes = (UINT)((INT)pSi->numBadBytes + nBytes);
|
||||||
pSi->numBadAccessUnits++;
|
pSi->numBadAccessUnits++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,8 +158,8 @@ amm-info@iis.fraunhofer.de
|
||||||
#define CONCEAL_NOT_DEFINED ((UCHAR)-1)
|
#define CONCEAL_NOT_DEFINED ((UCHAR)-1)
|
||||||
|
|
||||||
/* default settings */
|
/* default settings */
|
||||||
#define CONCEAL_DFLT_FADEOUT_FRAMES (0)
|
#define CONCEAL_DFLT_FADEOUT_FRAMES (6)
|
||||||
#define CONCEAL_DFLT_FADEIN_FRAMES (0)
|
#define CONCEAL_DFLT_FADEIN_FRAMES (5)
|
||||||
#define CONCEAL_DFLT_MUTE_RELEASE_FRAMES (0)
|
#define CONCEAL_DFLT_MUTE_RELEASE_FRAMES (0)
|
||||||
|
|
||||||
#define CONCEAL_DFLT_FADE_FACTOR (0.707106781186548f) /* 1/sqrt(2) */
|
#define CONCEAL_DFLT_FADE_FACTOR (0.707106781186548f) /* 1/sqrt(2) */
|
||||||
|
|
|
@ -1116,7 +1116,8 @@ void CLpd_AcelpPrepareInternalMem(const FIXP_DBL *synth, UCHAR last_lpd_mode,
|
||||||
const FIXP_LPC *A_new, const INT A_new_exp,
|
const FIXP_LPC *A_new, const INT A_new_exp,
|
||||||
const FIXP_LPC *A_old, const INT A_old_exp,
|
const FIXP_LPC *A_old, const INT A_old_exp,
|
||||||
CAcelpStaticMem *acelp_mem,
|
CAcelpStaticMem *acelp_mem,
|
||||||
INT coreCoderFrameLength, UCHAR lpd_mode) {
|
INT coreCoderFrameLength, INT clearOldExc,
|
||||||
|
UCHAR lpd_mode) {
|
||||||
int l_div =
|
int l_div =
|
||||||
coreCoderFrameLength / NB_DIV; /* length of one ACELP/TCX20 frame */
|
coreCoderFrameLength / NB_DIV; /* length of one ACELP/TCX20 frame */
|
||||||
int l_div_partial;
|
int l_div_partial;
|
||||||
|
@ -1154,6 +1155,13 @@ void CLpd_AcelpPrepareInternalMem(const FIXP_DBL *synth, UCHAR last_lpd_mode,
|
||||||
&syn[PIT_MAX_MAX + L_INTERPOL - M_LP_FILTER_ORDER],
|
&syn[PIT_MAX_MAX + L_INTERPOL - M_LP_FILTER_ORDER],
|
||||||
M_LP_FILTER_ORDER * sizeof(FIXP_DBL));
|
M_LP_FILTER_ORDER * sizeof(FIXP_DBL));
|
||||||
|
|
||||||
|
if (clearOldExc) {
|
||||||
|
FDKmemclear(old_exc_mem, (PIT_MAX_MAX + L_INTERPOL) * sizeof(FIXP_DBL));
|
||||||
|
C_ALLOC_SCRATCH_END(synth_buf, FIXP_DBL,
|
||||||
|
PIT_MAX_MAX + L_INTERPOL + M_LP_FILTER_ORDER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* update past [PIT_MAX_MAX+L_INTERPOL] samples of exc memory */
|
/* update past [PIT_MAX_MAX+L_INTERPOL] samples of exc memory */
|
||||||
if (last_lpd_mode == 1) { /* last frame was TCX20 */
|
if (last_lpd_mode == 1) { /* last frame was TCX20 */
|
||||||
if (last_last_lpd_mode == 0) { /* ACELP -> TCX20 -> ACELP transition */
|
if (last_last_lpd_mode == 0) { /* ACELP -> TCX20 -> ACELP transition */
|
||||||
|
@ -1170,7 +1178,6 @@ void CLpd_AcelpPrepareInternalMem(const FIXP_DBL *synth, UCHAR last_lpd_mode,
|
||||||
int exc_A_new_length = (coreCoderFrameLength / 2 > PIT_MAX_MAX + L_INTERPOL)
|
int exc_A_new_length = (coreCoderFrameLength / 2 > PIT_MAX_MAX + L_INTERPOL)
|
||||||
? PIT_MAX_MAX + L_INTERPOL
|
? PIT_MAX_MAX + L_INTERPOL
|
||||||
: coreCoderFrameLength / 2;
|
: coreCoderFrameLength / 2;
|
||||||
|
|
||||||
int exc_A_old_length = PIT_MAX_MAX + L_INTERPOL - exc_A_new_length;
|
int exc_A_old_length = PIT_MAX_MAX + L_INTERPOL - exc_A_new_length;
|
||||||
E_UTIL_residu(A_old, A_old_exp, syn, old_exc_mem, exc_A_old_length);
|
E_UTIL_residu(A_old, A_old_exp, syn, old_exc_mem, exc_A_old_length);
|
||||||
E_UTIL_residu(A_new, A_new_exp, &syn[exc_A_old_length],
|
E_UTIL_residu(A_new, A_new_exp, &syn[exc_A_old_length],
|
||||||
|
|
|
@ -238,7 +238,8 @@ void CLpd_AcelpPrepareInternalMem(const FIXP_DBL *synth, UCHAR last_lpd_mode,
|
||||||
const FIXP_LPC *A_new, const INT A_new_exp,
|
const FIXP_LPC *A_new, const INT A_new_exp,
|
||||||
const FIXP_LPC *A_old, const INT A_old_exp,
|
const FIXP_LPC *A_old, const INT A_old_exp,
|
||||||
CAcelpStaticMem *acelp_mem,
|
CAcelpStaticMem *acelp_mem,
|
||||||
INT coreCoderFrameLength, UCHAR lpd_mode);
|
INT coreCoderFrameLength, INT clearOldExc,
|
||||||
|
UCHAR lpd_mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Calculate zero input response (zir) of the acelp synthesis filter
|
* \brief Calculate zero input response (zir) of the acelp synthesis filter
|
||||||
|
|
|
@ -1776,7 +1776,7 @@ AAC_DECODER_ERROR CLpd_RenderTimeSignal(
|
||||||
pAacDecoderChannelInfo->data.usac.lp_coeff[k],
|
pAacDecoderChannelInfo->data.usac.lp_coeff[k],
|
||||||
pAacDecoderChannelInfo->data.usac.lp_coeff_exp[k], lp_prev,
|
pAacDecoderChannelInfo->data.usac.lp_coeff_exp[k], lp_prev,
|
||||||
lp_prev_exp, &pAacDecoderStaticChannelInfo->acelp, lFrame,
|
lp_prev_exp, &pAacDecoderStaticChannelInfo->acelp, lFrame,
|
||||||
mod[k]);
|
(last_frame_lost && k < 2), mod[k]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (k == 0 && pAacDecoderStaticChannelInfo->IMdct.ov_offset !=
|
if (k == 0 && pAacDecoderStaticChannelInfo->IMdct.ov_offset !=
|
||||||
|
|
|
@ -258,26 +258,6 @@ inline void cplxMult(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
|
||||||
const FIXP_DBL a_Im, const FIXP_DPK w) {
|
const FIXP_DBL a_Im, const FIXP_DPK w) {
|
||||||
cplxMult(c_Re, c_Im, a_Re, a_Im, w.v.re, w.v.im);
|
cplxMult(c_Re, c_Im, a_Re, a_Im, w.v.re, w.v.im);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(FUNCTION_cplxMult_nIm)
|
|
||||||
#define FUNCTION_cplxMult_nIm
|
|
||||||
|
|
||||||
/* Same as cplxMult, but
|
|
||||||
a_Im must be negated, when used
|
|
||||||
c_re must be negated, when output
|
|
||||||
*/
|
|
||||||
inline void cplxMult_nIm(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
|
|
||||||
const FIXP_DBL a_Im, const FIXP_SPK w) {
|
|
||||||
*c_Re = -(fMult(a_Re, w.v.re) + fMult(a_Im, w.v.im));
|
|
||||||
*c_Im = fMult(a_Re, w.v.im) - fMult(a_Im, w.v.re);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void cplxMult_nIm(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
|
|
||||||
const FIXP_DBL a_Im, const FIXP_DPK w) {
|
|
||||||
*c_Re = -(fMult(a_Re, w.v.re) + fMult(a_Im, w.v.im));
|
|
||||||
*c_Im = fMult(a_Re, w.v.im) - fMult(a_Im, w.v.re);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* #############################################################################
|
/* #############################################################################
|
||||||
|
|
|
@ -119,6 +119,7 @@ amm-info@iis.fraunhofer.de
|
||||||
#define IMDCT_SCALE(x) SATURATE_LEFT_SHIFT(x, -MDCT_OUTPUT_SCALE, PCM_OUT_BITS)
|
#define IMDCT_SCALE(x) SATURATE_LEFT_SHIFT(x, -MDCT_OUTPUT_SCALE, PCM_OUT_BITS)
|
||||||
#endif
|
#endif
|
||||||
#define IMDCT_SCALE_DBL(x) (FIXP_DBL)(x)
|
#define IMDCT_SCALE_DBL(x) (FIXP_DBL)(x)
|
||||||
|
#define IMDCT_SCALE_DBL_LSH1(x) SATURATE_LEFT_SHIFT_ALT((x), 1, DFRACT_BITS)
|
||||||
|
|
||||||
#define MLT_FLAG_CURR_ALIAS_SYMMETRY 1
|
#define MLT_FLAG_CURR_ALIAS_SYMMETRY 1
|
||||||
|
|
||||||
|
|
|
@ -184,12 +184,19 @@ void CLpc_SynthesisLattice(FIXP_DBL *signal, const int signal_size,
|
||||||
for (i = signal_size; i != 0; i--) {
|
for (i = signal_size; i != 0; i--) {
|
||||||
FIXP_DBL *pState = state + order - 1;
|
FIXP_DBL *pState = state + order - 1;
|
||||||
const FIXP_DBL *pCoeff = coeff + order - 1;
|
const FIXP_DBL *pCoeff = coeff + order - 1;
|
||||||
FIXP_DBL tmp;
|
FIXP_DBL tmp, accu;
|
||||||
|
|
||||||
|
accu =
|
||||||
|
fMultSubDiv2(scaleValue(*pSignal, signal_e - 1), *pCoeff--, *pState--);
|
||||||
|
tmp = SATURATE_LEFT_SHIFT_ALT(accu, 1, DFRACT_BITS);
|
||||||
|
|
||||||
tmp = scaleValue(*pSignal, signal_e) - fMult(*pCoeff--, *pState--);
|
|
||||||
for (j = order - 1; j != 0; j--) {
|
for (j = order - 1; j != 0; j--) {
|
||||||
tmp = tmp - fMult(pCoeff[0], pState[0]);
|
accu = fMultSubDiv2(tmp >> 1, pCoeff[0], pState[0]);
|
||||||
pState[1] = pState[0] + fMult(*pCoeff--, tmp);
|
tmp = SATURATE_LEFT_SHIFT_ALT(accu, 1, DFRACT_BITS);
|
||||||
|
|
||||||
|
accu = fMultAddDiv2(pState[0] >> 1, *pCoeff--, tmp);
|
||||||
|
pState[1] = SATURATE_LEFT_SHIFT_ALT(accu, 1, DFRACT_BITS);
|
||||||
|
|
||||||
pState--;
|
pState--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,18 +274,29 @@ static int FDK_QmfDomain_AllocatePersistentMemory(HANDLE_FDK_QMF_DOMAIN qd) {
|
||||||
size = gc->nBandsAnalysis * 10;
|
size = gc->nBandsAnalysis * 10;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
if (gc->nBandsAnalysis == QMF_DOMAIN_ANALYSIS_QMF_BANDS_16) {
|
if (gc->nBandsAnalysis == QMF_DOMAIN_ANALYSIS_QMF_BANDS_16) {
|
||||||
if (NULL == (qd->QmfDomainIn[ch].pAnaQmfStates = GetAnaQmfStates16(ch)))
|
if (qd->QmfDomainIn[ch].pAnaQmfStates == NULL) {
|
||||||
|
if (NULL ==
|
||||||
|
(qd->QmfDomainIn[ch].pAnaQmfStates = GetAnaQmfStates16(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
}
|
||||||
} else if (gc->nBandsAnalysis == QMF_DOMAIN_ANALYSIS_QMF_BANDS_24) {
|
} else if (gc->nBandsAnalysis == QMF_DOMAIN_ANALYSIS_QMF_BANDS_24) {
|
||||||
if (NULL == (qd->QmfDomainIn[ch].pAnaQmfStates = GetAnaQmfStates24(ch)))
|
if (qd->QmfDomainIn[ch].pAnaQmfStates == NULL) {
|
||||||
|
if (NULL ==
|
||||||
|
(qd->QmfDomainIn[ch].pAnaQmfStates = GetAnaQmfStates24(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
}
|
||||||
} else if (gc->nBandsAnalysis == QMF_DOMAIN_ANALYSIS_QMF_BANDS_32) {
|
} else if (gc->nBandsAnalysis == QMF_DOMAIN_ANALYSIS_QMF_BANDS_32) {
|
||||||
if (NULL == (qd->QmfDomainIn[ch].pAnaQmfStates = GetAnaQmfStates32(ch)))
|
if (qd->QmfDomainIn[ch].pAnaQmfStates == NULL) {
|
||||||
|
if (NULL ==
|
||||||
|
(qd->QmfDomainIn[ch].pAnaQmfStates = GetAnaQmfStates32(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (qd->QmfDomainIn[ch].pAnaQmfStates == NULL) {
|
||||||
if (NULL == (qd->QmfDomainIn[ch].pAnaQmfStates = GetAnaQmfStates(ch)))
|
if (NULL == (qd->QmfDomainIn[ch].pAnaQmfStates = GetAnaQmfStates(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qd->QmfDomainIn[ch].pAnaQmfStates = NULL;
|
qd->QmfDomainIn[ch].pAnaQmfStates = NULL;
|
||||||
}
|
}
|
||||||
|
@ -293,21 +304,37 @@ static int FDK_QmfDomain_AllocatePersistentMemory(HANDLE_FDK_QMF_DOMAIN qd) {
|
||||||
size = gc->nQmfOvTimeSlots + gc->nQmfTimeSlots;
|
size = gc->nQmfOvTimeSlots + gc->nQmfTimeSlots;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
if (gc->nQmfTimeSlots == QMF_DOMAIN_TIMESLOTS_16) {
|
if (gc->nQmfTimeSlots == QMF_DOMAIN_TIMESLOTS_16) {
|
||||||
if (NULL == (qd->QmfDomainIn[ch].hQmfSlotsReal = GetQmfSlotsReal16(ch)))
|
if (qd->QmfDomainIn[ch].hQmfSlotsReal == NULL) {
|
||||||
|
if (NULL ==
|
||||||
|
(qd->QmfDomainIn[ch].hQmfSlotsReal = GetQmfSlotsReal16(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
if (NULL == (qd->QmfDomainIn[ch].hQmfSlotsImag = GetQmfSlotsImag16(ch)))
|
}
|
||||||
|
if (qd->QmfDomainIn[ch].hQmfSlotsImag == NULL) {
|
||||||
|
if (NULL ==
|
||||||
|
(qd->QmfDomainIn[ch].hQmfSlotsImag = GetQmfSlotsImag16(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
}
|
||||||
} else if (gc->nQmfTimeSlots == QMF_DOMAIN_TIMESLOTS_32) {
|
} else if (gc->nQmfTimeSlots == QMF_DOMAIN_TIMESLOTS_32) {
|
||||||
if (NULL == (qd->QmfDomainIn[ch].hQmfSlotsReal = GetQmfSlotsReal32(ch)))
|
if (qd->QmfDomainIn[ch].hQmfSlotsReal == NULL) {
|
||||||
|
if (NULL ==
|
||||||
|
(qd->QmfDomainIn[ch].hQmfSlotsReal = GetQmfSlotsReal32(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
if (NULL == (qd->QmfDomainIn[ch].hQmfSlotsImag = GetQmfSlotsImag32(ch)))
|
}
|
||||||
|
if (qd->QmfDomainIn[ch].hQmfSlotsImag == NULL) {
|
||||||
|
if (NULL ==
|
||||||
|
(qd->QmfDomainIn[ch].hQmfSlotsImag = GetQmfSlotsImag32(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (qd->QmfDomainIn[ch].hQmfSlotsReal == NULL) {
|
||||||
if (NULL == (qd->QmfDomainIn[ch].hQmfSlotsReal = GetQmfSlotsReal(ch)))
|
if (NULL == (qd->QmfDomainIn[ch].hQmfSlotsReal = GetQmfSlotsReal(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
}
|
||||||
|
if (qd->QmfDomainIn[ch].hQmfSlotsImag == NULL) {
|
||||||
if (NULL == (qd->QmfDomainIn[ch].hQmfSlotsImag = GetQmfSlotsImag(ch)))
|
if (NULL == (qd->QmfDomainIn[ch].hQmfSlotsImag = GetQmfSlotsImag(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qd->QmfDomainIn[ch].hQmfSlotsReal = NULL;
|
qd->QmfDomainIn[ch].hQmfSlotsReal = NULL;
|
||||||
qd->QmfDomainIn[ch].hQmfSlotsImag = NULL;
|
qd->QmfDomainIn[ch].hQmfSlotsImag = NULL;
|
||||||
|
@ -316,18 +343,24 @@ static int FDK_QmfDomain_AllocatePersistentMemory(HANDLE_FDK_QMF_DOMAIN qd) {
|
||||||
size = gc->nQmfOvTimeSlots * gc->nQmfProcBands * CMPLX_MOD;
|
size = gc->nQmfOvTimeSlots * gc->nQmfProcBands * CMPLX_MOD;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
if (gc->nQmfOvTimeSlots == QMF_DOMAIN_OV_TIMESLOTS_16) {
|
if (gc->nQmfOvTimeSlots == QMF_DOMAIN_OV_TIMESLOTS_16) {
|
||||||
|
if (qd->QmfDomainIn[ch].pOverlapBuffer == NULL) {
|
||||||
if (NULL ==
|
if (NULL ==
|
||||||
(qd->QmfDomainIn[ch].pOverlapBuffer = GetQmfOverlapBuffer16(ch)))
|
(qd->QmfDomainIn[ch].pOverlapBuffer = GetQmfOverlapBuffer16(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
}
|
||||||
} else if (gc->nQmfOvTimeSlots == QMF_DOMAIN_OV_TIMESLOTS_32) {
|
} else if (gc->nQmfOvTimeSlots == QMF_DOMAIN_OV_TIMESLOTS_32) {
|
||||||
|
if (qd->QmfDomainIn[ch].pOverlapBuffer == NULL) {
|
||||||
if (NULL ==
|
if (NULL ==
|
||||||
(qd->QmfDomainIn[ch].pOverlapBuffer = GetQmfOverlapBuffer32(ch)))
|
(qd->QmfDomainIn[ch].pOverlapBuffer = GetQmfOverlapBuffer32(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (qd->QmfDomainIn[ch].pOverlapBuffer == NULL) {
|
||||||
if (NULL ==
|
if (NULL ==
|
||||||
(qd->QmfDomainIn[ch].pOverlapBuffer = GetQmfOverlapBuffer(ch)))
|
(qd->QmfDomainIn[ch].pOverlapBuffer = GetQmfOverlapBuffer(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qd->QmfDomainIn[ch].pOverlapBuffer = NULL;
|
qd->QmfDomainIn[ch].pOverlapBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
@ -336,8 +369,10 @@ static int FDK_QmfDomain_AllocatePersistentMemory(HANDLE_FDK_QMF_DOMAIN qd) {
|
||||||
for (ch = 0; ch < gc->nOutputChannels; ch++) {
|
for (ch = 0; ch < gc->nOutputChannels; ch++) {
|
||||||
int size = gc->nBandsSynthesis * 9;
|
int size = gc->nBandsSynthesis * 9;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
|
if (qd->QmfDomainOut[ch].pSynQmfStates == NULL) {
|
||||||
if (NULL == (qd->QmfDomainOut[ch].pSynQmfStates = GetSynQmfStates(ch)))
|
if (NULL == (qd->QmfDomainOut[ch].pSynQmfStates = GetSynQmfStates(ch)))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qd->QmfDomainOut[ch].pSynQmfStates = NULL;
|
qd->QmfDomainOut[ch].pSynQmfStates = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -541,11 +541,16 @@ INT imlt_block(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *spectrum,
|
||||||
*/
|
*/
|
||||||
/* and de-scale current spectrum signal (time domain, no yet windowed) */
|
/* and de-scale current spectrum signal (time domain, no yet windowed) */
|
||||||
if (gain != (FIXP_DBL)0) {
|
if (gain != (FIXP_DBL)0) {
|
||||||
scaleValuesWithFactor(pSpec, gain, tl, scalefactor[w] + specShiftScale);
|
for (i = 0; i < tl; i++) {
|
||||||
} else {
|
pSpec[i] = fMult(pSpec[i], gain);
|
||||||
int loc_scale = scalefactor[w] + specShiftScale;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int loc_scale =
|
||||||
|
fixmin_I(scalefactor[w] + specShiftScale, (INT)DFRACT_BITS - 1);
|
||||||
DWORD_ALIGNED(pSpec);
|
DWORD_ALIGNED(pSpec);
|
||||||
scaleValues(pSpec, tl, loc_scale);
|
scaleValuesSaturate(pSpec, tl, loc_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noOutSamples <= nrSamples) {
|
if (noOutSamples <= nrSamples) {
|
||||||
|
@ -614,59 +619,34 @@ INT imlt_block(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *spectrum,
|
||||||
if (!hMdct->pAsymOvlp) {
|
if (!hMdct->pAsymOvlp) {
|
||||||
for (i = 0; i < fl / 2; i++) {
|
for (i = 0; i < fl / 2; i++) {
|
||||||
FIXP_DBL x0, x1;
|
FIXP_DBL x0, x1;
|
||||||
#ifdef FUNCTION_cplxMult_nIm
|
cplxMultDiv2(&x1, &x0, *pCurr++, -*pOvl--, pWindow[i]);
|
||||||
/* This macro negates 4th parameter (*pOvl--) */
|
*pOut0 = IMDCT_SCALE_DBL_LSH1(x0);
|
||||||
/* and inverts the sign of result x1 */
|
*pOut1 = IMDCT_SCALE_DBL_LSH1(-x1);
|
||||||
|
|
||||||
/* This subroutine calculates the two output segments (C,D) from the
|
|
||||||
two availabe DCT IV data blocks, namely, (-D-Cr,A-Br) and
|
|
||||||
(-F-Er,C-Dr). "pOvl" is the pointer to the overlap block and points
|
|
||||||
to the end of the (-D-Cr) part of the overlap buffer (-D-Cr,A-Br).
|
|
||||||
It points to the end of the (-D-Cr) because it will read this part
|
|
||||||
in a flipped order. "pCurr" is the pointer to the current block
|
|
||||||
(-F-Er,C-Dr) and points to the beginning of the (C-Dr) block,
|
|
||||||
because this block will be read consequitively. "pWindow" is a
|
|
||||||
pointer to the used window coefficients. In pointer "x1" we get the
|
|
||||||
already computed from the function "Dr" segment. In pointer "x0" we
|
|
||||||
get the "C" segment. Since we have to output them sequentially the
|
|
||||||
"x0" pointer points to the beginnig of the output buffer (X,X), and
|
|
||||||
pointer "x1" points to the end of the output buffer (X,X). When we
|
|
||||||
get the output of the cplxMult_nIm function we write it sequentially
|
|
||||||
in the output buffer from the left to right ("x0"=>C) and right to
|
|
||||||
left ("x1"=>Dr) implementing flipping. At the end we get an output
|
|
||||||
in the form (C,D). */
|
|
||||||
cplxMult_nIm(&x1, &x0, *pCurr++, *pOvl--, pWindow[i]);
|
|
||||||
*pOut0++ = IMDCT_SCALE_DBL(x0);
|
|
||||||
*pOut1-- = IMDCT_SCALE_DBL(x1);
|
|
||||||
#else
|
|
||||||
cplxMult(&x1, &x0, *pCurr++, -*pOvl--, pWindow[i]);
|
|
||||||
*pOut0 = IMDCT_SCALE_DBL(x0);
|
|
||||||
*pOut1 = IMDCT_SCALE_DBL(-x1);
|
|
||||||
pOut0++;
|
pOut0++;
|
||||||
pOut1--;
|
pOut1--;
|
||||||
#endif /* #ifdef FUNCTION_cplxMult_nIm */
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FIXP_DBL *pAsymOvl = hMdct->pAsymOvlp + fl / 2 - 1;
|
FIXP_DBL *pAsymOvl = hMdct->pAsymOvlp + fl / 2 - 1;
|
||||||
for (i = 0; i < fl / 2; i++) {
|
for (i = 0; i < fl / 2; i++) {
|
||||||
FIXP_DBL x0, x1;
|
FIXP_DBL x0, x1;
|
||||||
x1 = -fMult(*pCurr, pWindow[i].v.re) +
|
x1 = -fMultDiv2(*pCurr, pWindow[i].v.re) +
|
||||||
fMult(*pAsymOvl, pWindow[i].v.im);
|
fMultDiv2(*pAsymOvl, pWindow[i].v.im);
|
||||||
x0 = fMult(*pCurr, pWindow[i].v.im) - fMult(*pOvl, pWindow[i].v.re);
|
x0 = fMultDiv2(*pCurr, pWindow[i].v.im) -
|
||||||
|
fMultDiv2(*pOvl, pWindow[i].v.re);
|
||||||
pCurr++;
|
pCurr++;
|
||||||
pOvl--;
|
pOvl--;
|
||||||
pAsymOvl--;
|
pAsymOvl--;
|
||||||
*pOut0++ = IMDCT_SCALE_DBL(x0);
|
*pOut0++ = IMDCT_SCALE_DBL_LSH1(x0);
|
||||||
*pOut1-- = IMDCT_SCALE_DBL(x1);
|
*pOut1-- = IMDCT_SCALE_DBL_LSH1(x1);
|
||||||
}
|
}
|
||||||
hMdct->pAsymOvlp = NULL;
|
hMdct->pAsymOvlp = NULL;
|
||||||
}
|
}
|
||||||
} else { /* prevAliasingSymmetry == 1 */
|
} else { /* prevAliasingSymmetry == 1 */
|
||||||
for (i = 0; i < fl / 2; i++) {
|
for (i = 0; i < fl / 2; i++) {
|
||||||
FIXP_DBL x0, x1;
|
FIXP_DBL x0, x1;
|
||||||
cplxMult(&x1, &x0, *pCurr++, -*pOvl--, pWindow[i]);
|
cplxMultDiv2(&x1, &x0, *pCurr++, -*pOvl--, pWindow[i]);
|
||||||
*pOut0 = IMDCT_SCALE_DBL(x0);
|
*pOut0 = IMDCT_SCALE_DBL_LSH1(x0);
|
||||||
*pOut1 = IMDCT_SCALE_DBL(x1);
|
*pOut1 = IMDCT_SCALE_DBL_LSH1(x1);
|
||||||
pOut0++;
|
pOut0++;
|
||||||
pOut1--;
|
pOut1--;
|
||||||
}
|
}
|
||||||
|
@ -675,18 +655,18 @@ INT imlt_block(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *spectrum,
|
||||||
if (hMdct->prevAliasSymmetry == 0) {
|
if (hMdct->prevAliasSymmetry == 0) {
|
||||||
for (i = 0; i < fl / 2; i++) {
|
for (i = 0; i < fl / 2; i++) {
|
||||||
FIXP_DBL x0, x1;
|
FIXP_DBL x0, x1;
|
||||||
cplxMult(&x1, &x0, *pCurr++, *pOvl--, pWindow[i]);
|
cplxMultDiv2(&x1, &x0, *pCurr++, *pOvl--, pWindow[i]);
|
||||||
*pOut0 = IMDCT_SCALE_DBL(x0);
|
*pOut0 = IMDCT_SCALE_DBL_LSH1(x0);
|
||||||
*pOut1 = IMDCT_SCALE_DBL(-x1);
|
*pOut1 = IMDCT_SCALE_DBL_LSH1(-x1);
|
||||||
pOut0++;
|
pOut0++;
|
||||||
pOut1--;
|
pOut1--;
|
||||||
}
|
}
|
||||||
} else { /* prevAliasingSymmetry == 1 */
|
} else { /* prevAliasingSymmetry == 1 */
|
||||||
for (i = 0; i < fl / 2; i++) {
|
for (i = 0; i < fl / 2; i++) {
|
||||||
FIXP_DBL x0, x1;
|
FIXP_DBL x0, x1;
|
||||||
cplxMult(&x1, &x0, *pCurr++, *pOvl--, pWindow[i]);
|
cplxMultDiv2(&x1, &x0, *pCurr++, *pOvl--, pWindow[i]);
|
||||||
*pOut0 = IMDCT_SCALE_DBL(x0);
|
*pOut0 = IMDCT_SCALE_DBL_LSH1(x0);
|
||||||
*pOut1 = IMDCT_SCALE_DBL(x1);
|
*pOut1 = IMDCT_SCALE_DBL_LSH1(x1);
|
||||||
pOut0++;
|
pOut0++;
|
||||||
pOut1--;
|
pOut1--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1618,7 +1618,7 @@ static TRANSPORTDEC_ERROR configExtension(CSUsacConfig *usc,
|
||||||
usacConfigExtLength = (int)escapedValue(hBs, 4, 8, 16);
|
usacConfigExtLength = (int)escapedValue(hBs, 4, 8, 16);
|
||||||
|
|
||||||
/* Start bit position of config extension */
|
/* Start bit position of config extension */
|
||||||
nbits = FDKgetValidBits(hBs);
|
nbits = (INT)FDKgetValidBits(hBs);
|
||||||
|
|
||||||
/* Return an error in case the bitbuffer fill level is too low. */
|
/* Return an error in case the bitbuffer fill level is too low. */
|
||||||
if (nbits < usacConfigExtLength * 8) {
|
if (nbits < usacConfigExtLength * 8) {
|
||||||
|
@ -1650,7 +1650,7 @@ static TRANSPORTDEC_ERROR configExtension(CSUsacConfig *usc,
|
||||||
|
|
||||||
/* Skip remaining bits. If too many bits were parsed, assume error. */
|
/* Skip remaining bits. If too many bits were parsed, assume error. */
|
||||||
usacConfigExtLength =
|
usacConfigExtLength =
|
||||||
8 * usacConfigExtLength - (nbits - FDKgetValidBits(hBs));
|
8 * usacConfigExtLength - (nbits - (INT)FDKgetValidBits(hBs));
|
||||||
if (usacConfigExtLength < 0) {
|
if (usacConfigExtLength < 0) {
|
||||||
return TRANSPORTDEC_PARSE_ERROR;
|
return TRANSPORTDEC_PARSE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1337,9 +1337,9 @@ static TRANSPORTDEC_ERROR transportDec_readStream(HANDLE_TRANSPORTDEC hTp,
|
||||||
INT bitDistance, bfDelta;
|
INT bitDistance, bfDelta;
|
||||||
|
|
||||||
/* Obtain distance to next synch word */
|
/* Obtain distance to next synch word */
|
||||||
bitDistance = FDKgetValidBits(hBs);
|
bitDistance = (INT)FDKgetValidBits(hBs);
|
||||||
error = synchronization(hTp, &headerBits);
|
error = synchronization(hTp, &headerBits);
|
||||||
bitDistance -= FDKgetValidBits(hBs);
|
bitDistance -= (INT)FDKgetValidBits(hBs);
|
||||||
|
|
||||||
FDK_ASSERT(bitDistance >= 0);
|
FDK_ASSERT(bitDistance >= 0);
|
||||||
|
|
||||||
|
@ -1380,7 +1380,7 @@ static TRANSPORTDEC_ERROR transportDec_readStream(HANDLE_TRANSPORTDEC hTp,
|
||||||
int num, denom;
|
int num, denom;
|
||||||
|
|
||||||
/* Obtain estimate of number of lost frames */
|
/* Obtain estimate of number of lost frames */
|
||||||
num = hTp->asc[0].m_samplingFrequency * (bfDelta + bitDistance) +
|
num = (INT)hTp->asc[0].m_samplingFrequency * (bfDelta + bitDistance) +
|
||||||
hTp->remainder;
|
hTp->remainder;
|
||||||
denom = hTp->avgBitRate * hTp->asc[0].m_samplesPerFrame;
|
denom = hTp->avgBitRate * hTp->asc[0].m_samplesPerFrame;
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
|
|
|
@ -311,6 +311,7 @@ int DecodePs(struct PS_DEC *h_ps_d, /*!< PS handle */
|
||||||
pBsData->noEnv = 1;
|
pBsData->noEnv = 1;
|
||||||
|
|
||||||
if (pBsData->bEnableIid) {
|
if (pBsData->bEnableIid) {
|
||||||
|
pBsData->bFineIidQ = h_ps_d->specificTo.mpeg.bPrevFrameFineIidQ;
|
||||||
for (gr = 0; gr < NO_HI_RES_IID_BINS; gr++) {
|
for (gr = 0; gr < NO_HI_RES_IID_BINS; gr++) {
|
||||||
pBsData->aaIidIndex[pBsData->noEnv - 1][gr] =
|
pBsData->aaIidIndex[pBsData->noEnv - 1][gr] =
|
||||||
h_ps_d->specificTo.mpeg.aIidPrevFrameIndex[gr];
|
h_ps_d->specificTo.mpeg.aIidPrevFrameIndex[gr];
|
||||||
|
@ -333,6 +334,9 @@ int DecodePs(struct PS_DEC *h_ps_d, /*!< PS handle */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update previous frame Iid quantization */
|
||||||
|
h_ps_d->specificTo.mpeg.bPrevFrameFineIidQ = pBsData->bFineIidQ;
|
||||||
|
|
||||||
/* Update previous frame index buffers */
|
/* Update previous frame index buffers */
|
||||||
for (gr = 0; gr < NO_HI_RES_IID_BINS; gr++) {
|
for (gr = 0; gr < NO_HI_RES_IID_BINS; gr++) {
|
||||||
h_ps_d->specificTo.mpeg.aIidPrevFrameIndex[gr] =
|
h_ps_d->specificTo.mpeg.aIidPrevFrameIndex[gr] =
|
||||||
|
|
|
@ -274,6 +274,8 @@ struct PS_DEC {
|
||||||
previous frame */
|
previous frame */
|
||||||
SCHAR aIccPrevFrameIndex[NO_HI_RES_ICC_BINS]; /*!< The ICC index for
|
SCHAR aIccPrevFrameIndex[NO_HI_RES_ICC_BINS]; /*!< The ICC index for
|
||||||
previous frame */
|
previous frame */
|
||||||
|
UCHAR
|
||||||
|
bPrevFrameFineIidQ; /*!< The IID quantization of the previous frame */
|
||||||
UCHAR lastUsb; /*!< uppermost WMF delay band of last frame */
|
UCHAR lastUsb; /*!< uppermost WMF delay band of last frame */
|
||||||
|
|
||||||
FIXP_DBL pHybridAnaStatesLFdmx
|
FIXP_DBL pHybridAnaStatesLFdmx
|
||||||
|
|
|
@ -269,23 +269,33 @@ static FIXP_DBL addLowbandEnergies(FIXP_DBL **Energies, int *scaleEnergies,
|
||||||
FIXP_DBL accu1 = FL2FXCONST_DBL(0.0f);
|
FIXP_DBL accu1 = FL2FXCONST_DBL(0.0f);
|
||||||
FIXP_DBL accu2 = FL2FXCONST_DBL(0.0f);
|
FIXP_DBL accu2 = FL2FXCONST_DBL(0.0f);
|
||||||
int tran_offdiv2 = tran_off >> nrgSzShift;
|
int tran_offdiv2 = tran_off >> nrgSzShift;
|
||||||
|
const int sc1 =
|
||||||
|
DFRACT_BITS -
|
||||||
|
fNormz((FIXP_DBL)fMax(
|
||||||
|
1, (freqBandTable[0] * (YBufferWriteOffset - tran_offdiv2) - 1)));
|
||||||
|
const int sc2 =
|
||||||
|
DFRACT_BITS -
|
||||||
|
fNormz((FIXP_DBL)fMax(
|
||||||
|
1, (freqBandTable[0] *
|
||||||
|
(tran_offdiv2 + (slots >> nrgSzShift) - YBufferWriteOffset) -
|
||||||
|
1)));
|
||||||
int ts, k;
|
int ts, k;
|
||||||
|
|
||||||
/* Sum up lowband energy from one frame at offset tran_off */
|
/* Sum up lowband energy from one frame at offset tran_off */
|
||||||
/* freqBandTable[LORES] has MAX_FREQ_COEFFS/2 +1 coeefs max. */
|
/* freqBandTable[LORES] has MAX_FREQ_COEFFS/2 +1 coeefs max. */
|
||||||
for (ts = tran_offdiv2; ts < YBufferWriteOffset; ts++) {
|
for (ts = tran_offdiv2; ts < YBufferWriteOffset; ts++) {
|
||||||
for (k = 0; k < freqBandTable[0]; k++) {
|
for (k = 0; k < freqBandTable[0]; k++) {
|
||||||
accu1 += Energies[ts][k] >> 6;
|
accu1 += Energies[ts][k] >> sc1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (; ts < tran_offdiv2 + (slots >> nrgSzShift); ts++) {
|
for (; ts < tran_offdiv2 + (slots >> nrgSzShift); ts++) {
|
||||||
for (k = 0; k < freqBandTable[0]; k++) {
|
for (k = 0; k < freqBandTable[0]; k++) {
|
||||||
accu2 += Energies[ts][k] >> 9;
|
accu2 += Energies[ts][k] >> sc2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nrgTotal_m = fAddNorm(accu1, 1 - scaleEnergies[0], accu2,
|
nrgTotal_m = fAddNorm(accu1, (sc1 - 5) - scaleEnergies[0], accu2,
|
||||||
4 - scaleEnergies[1], &nrgTotal_e);
|
(sc2 - 5) - scaleEnergies[1], &nrgTotal_e);
|
||||||
nrgTotal_m = scaleValueSaturate(nrgTotal_m, nrgTotal_e);
|
nrgTotal_m = scaleValueSaturate(nrgTotal_m, nrgTotal_e);
|
||||||
|
|
||||||
return (nrgTotal_m);
|
return (nrgTotal_m);
|
||||||
|
|
Loading…
Reference in New Issue