diff options
Diffstat (limited to 'libSBRdec')
-rw-r--r-- | libSBRdec/include/sbrdecoder.h | 15 | ||||
-rw-r--r-- | libSBRdec/src/HFgen_preFlat.cpp | 4 | ||||
-rw-r--r-- | libSBRdec/src/hbe.cpp | 2 | ||||
-rw-r--r-- | libSBRdec/src/hbe.h | 10 | ||||
-rw-r--r-- | libSBRdec/src/sbr_dec.cpp | 26 | ||||
-rw-r--r-- | libSBRdec/src/sbr_dec.h | 11 | ||||
-rw-r--r-- | libSBRdec/src/sbr_ram.h | 5 | ||||
-rw-r--r-- | libSBRdec/src/sbrdecoder.cpp | 32 |
8 files changed, 62 insertions, 43 deletions
diff --git a/libSBRdec/include/sbrdecoder.h b/libSBRdec/include/sbrdecoder.h index cc55572..c09c985 100644 --- a/libSBRdec/include/sbrdecoder.h +++ b/libSBRdec/include/sbrdecoder.h @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten +© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -361,15 +361,20 @@ SBR_ERROR sbrDecoder_Parse(HANDLE_SBRDECODER self, HANDLE_FDK_BITSTREAM hBs, * error (0: core decoder found errors, 1: no errors). * \param psDecoded Pointer to a buffer holding a flag. Input: PS is * possible, Output: PS has been rendered. + * \param inDataHeadroom Headroom of the SBR input time signal to prevent + * clipping. + * \param outDataHeadroom Pointer to headroom of the SBR output time signal to + * prevent clipping. * * \return Error code. */ -SBR_ERROR sbrDecoder_Apply(HANDLE_SBRDECODER self, INT_PCM *input, - INT_PCM *timeData, const int timeDataSize, - int *numChannels, int *sampleRate, +SBR_ERROR sbrDecoder_Apply(HANDLE_SBRDECODER self, LONG *input, LONG *timeData, + const int timeDataSize, int *numChannels, + int *sampleRate, const FDK_channelMapDescr *const mapDescr, const int mapIdx, const int coreDecodedOk, - UCHAR *psDecoded); + UCHAR *psDecoded, const INT inDataHeadroom, + INT *outDataHeadroom); /** * \brief Close SBR decoder instance and free memory. diff --git a/libSBRdec/src/HFgen_preFlat.cpp b/libSBRdec/src/HFgen_preFlat.cpp index 268011e..ad4caba 100644 --- a/libSBRdec/src/HFgen_preFlat.cpp +++ b/libSBRdec/src/HFgen_preFlat.cpp @@ -897,10 +897,10 @@ void sbrDecoder_calculateGainVec(FIXP_DBL **sourceBufferReal, for (i = startSample; i < stopSample; i++) { maxVal |= (FIXP_DBL)((LONG)(sourceBufferReal[i][loBand]) ^ - ((LONG)sourceBufferReal[i][loBand] >> (SAMPLE_BITS - 1))); + ((LONG)sourceBufferReal[i][loBand] >> (DFRACT_BITS - 1))); maxVal |= (FIXP_DBL)((LONG)(sourceBufferImag[i][loBand]) ^ - ((LONG)sourceBufferImag[i][loBand] >> (SAMPLE_BITS - 1))); + ((LONG)sourceBufferImag[i][loBand] >> (DFRACT_BITS - 1))); } if (maxVal != FL2FX_DBL(0.0f)) { diff --git a/libSBRdec/src/hbe.cpp b/libSBRdec/src/hbe.cpp index 2284c42..d210bb6 100644 --- a/libSBRdec/src/hbe.cpp +++ b/libSBRdec/src/hbe.cpp @@ -957,7 +957,7 @@ QmfTransposerCreate(HANDLE_HBE_TRANSPOSER* hQmfTransposer, const int frameSize, hQmfTran->qmfOutBufSize = 2 * (hQmfTran->noCols / 2 + QMF_WIN_LEN - 1); hQmfTran->inBuf_F = - (INT_PCM*)FDKcalloc(QMF_SYNTH_CHANNELS + 20 + 1, sizeof(INT_PCM)); + (LONG*)FDKcalloc(QMF_SYNTH_CHANNELS + 20 + 1, sizeof(LONG)); /* buffered time signal needs to be delayed by synthesis_size; max * synthesis_size = 20; */ if (hQmfTran->inBuf_F == NULL) { diff --git a/libSBRdec/src/hbe.h b/libSBRdec/src/hbe.h index fdffe1e..3556783 100644 --- a/libSBRdec/src/hbe.h +++ b/libSBRdec/src/hbe.h @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten +© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -132,6 +132,9 @@ typedef enum { } KEEP_STATES_SYNCED_MODE; struct hbeTransposer { + FIXP_DBL anaQmfStates[HBE_QMF_FILTER_STATE_ANA_SIZE]; + FIXP_QSS synQmfStates[HBE_QMF_FILTER_STATE_SYN_SIZE]; + int xOverQmf[MAX_NUM_PATCHES_HBE]; int maxStretch; @@ -144,7 +147,7 @@ struct hbeTransposer { int stopBand; int bSbr41; - INT_PCM *inBuf_F; + LONG *inBuf_F; FIXP_DBL **qmfInBufReal_F; FIXP_DBL **qmfInBufImag_F; @@ -156,9 +159,6 @@ struct hbeTransposer { FIXP_DBL const *synthesisQmfPreModCos_F; FIXP_DBL const *synthesisQmfPreModSin_F; - FIXP_QAS anaQmfStates[HBE_QMF_FILTER_STATE_ANA_SIZE]; - FIXP_QSS synQmfStates[HBE_QMF_FILTER_STATE_SYN_SIZE]; - FIXP_DBL **qmfHBEBufReal_F; FIXP_DBL **qmfHBEBufImag_F; diff --git a/libSBRdec/src/sbr_dec.cpp b/libSBRdec/src/sbr_dec.cpp index 30611e7..b1fb0da 100644 --- a/libSBRdec/src/sbr_dec.cpp +++ b/libSBRdec/src/sbr_dec.cpp @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten +© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -259,17 +259,18 @@ static void copyHarmonicSpectrum(int *xOverQmf, FIXP_DBL **qmfReal, void sbr_dec( HANDLE_SBR_DEC hSbrDec, /*!< handle to Decoder channel */ - INT_PCM *timeIn, /*!< pointer to input time signal */ - INT_PCM *timeOut, /*!< pointer to output time signal */ + LONG *timeIn, /*!< pointer to input time signal */ + LONG *timeOut, /*!< pointer to output time signal */ HANDLE_SBR_DEC hSbrDecRight, /*!< handle to Decoder channel right */ - INT_PCM *timeOutRight, /*!< pointer to output time signal */ + LONG *timeOutRight, /*!< pointer to output time signal */ const int strideOut, /*!< Time data traversal strideOut */ HANDLE_SBR_HEADER_DATA hHeaderData, /*!< Static control data */ HANDLE_SBR_FRAME_DATA hFrameData, /*!< Control data of current frame */ HANDLE_SBR_PREV_FRAME_DATA hPrevFrameData, /*!< Some control data of last frame */ const int applyProcessing, /*!< Flag for SBR operation */ - HANDLE_PS_DEC h_ps_d, const UINT flags, const int codecFrameSize) { + HANDLE_PS_DEC h_ps_d, const UINT flags, const int codecFrameSize, + const INT sbrInDataHeadroom) { int i, slot, reserve; int saveLbScale; int lastSlotOffs; @@ -278,7 +279,7 @@ void sbr_dec( /* temporary pointer / variable for QMF; required as we want to use temporary buffer creating one frame delay for HBE in LP mode */ - INT_PCM *pTimeInQmf = timeIn; + LONG *pTimeInQmf = timeIn; /* Number of QMF timeslots in the overlap buffer: */ int ov_len = hSbrDec->LppTrans.pSettings->overlap; @@ -341,8 +342,8 @@ void sbr_dec( } else { C_AALLOC_SCRATCH_START(qmfTemp, FIXP_DBL, 2 * (64)); qmfAnalysisFiltering(&hSbrDec->qmfDomainInCh->fb, pReal, pImag, - &hSbrDec->qmfDomainInCh->scaling, pTimeInQmf, 0, 1, - qmfTemp); + &hSbrDec->qmfDomainInCh->scaling, pTimeInQmf, + 0 + sbrInDataHeadroom, 1, qmfTemp); C_AALLOC_SCRATCH_END(qmfTemp, FIXP_DBL, 2 * (64)); } @@ -658,7 +659,7 @@ void sbr_dec( if (!(flags & SBRDEC_PS_DECODED)) { if (!(flags & SBRDEC_SKIP_QMF_SYN)) { - int outScalefactor = 0; + int outScalefactor = -(8); if (h_ps_d != NULL) { h_ps_d->procFrameBased = 1; /* we here do frame based processing */ @@ -743,6 +744,7 @@ void sbr_dec( */ FDK_ASSERT(hSbrDec->qmfDomainInCh->pGlobalConf->nBandsSynthesis <= QMF_MAX_SYNTHESIS_BANDS); + qmfChangeOutScalefactor(synQmfRight, -(8)); FDKmemcpy(synQmfRight->FilterStates, synQmf->FilterStates, 9 * hSbrDec->qmfDomainInCh->pGlobalConf->nBandsSynthesis * sizeof(FIXP_QSS)); @@ -814,7 +816,8 @@ void sbr_dec( : scaleFactorLowBand_no_ov, scaleFactorHighBand, synQmf->lsb, synQmf->usb); - outScalefactorL = outScalefactorR = 1; /* psDiffScale! (MPEG-PS) */ + outScalefactorL = outScalefactorR = + 1 + sbrInDataHeadroom; /* psDiffScale! (MPEG-PS) */ } sbrDecoder_drcApplySlot(/* right channel */ @@ -831,6 +834,9 @@ void sbr_dec( outScalefactorL += maxShift; if (!(flags & SBRDEC_SKIP_QMF_SYN)) { + qmfChangeOutScalefactor(synQmf, -(8)); + qmfChangeOutScalefactor(synQmfRight, -(8)); + qmfSynthesisFilteringSlot( synQmfRight, rQmfReal, /* QMF real buffer */ rQmfImag, /* QMF imag buffer */ diff --git a/libSBRdec/src/sbr_dec.h b/libSBRdec/src/sbr_dec.h index 156da03..eb9c394 100644 --- a/libSBRdec/src/sbr_dec.h +++ b/libSBRdec/src/sbr_dec.h @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten +© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -176,17 +176,18 @@ typedef SBR_CHANNEL *HANDLE_SBR_CHANNEL; void sbr_dec( HANDLE_SBR_DEC hSbrDec, /*!< handle to Decoder channel */ - INT_PCM *timeIn, /*!< pointer to input time signal */ - INT_PCM *timeOut, /*!< pointer to output time signal */ + LONG *timeIn, /*!< pointer to input time signal */ + LONG *timeOut, /*!< pointer to output time signal */ HANDLE_SBR_DEC hSbrDecRight, /*!< handle to Decoder channel right */ - INT_PCM *timeOutRight, /*!< pointer to output time signal */ + LONG *timeOutRight, /*!< pointer to output time signal */ INT strideOut, /*!< Time data traversal strideOut */ HANDLE_SBR_HEADER_DATA hHeaderData, /*!< Static control data */ HANDLE_SBR_FRAME_DATA hFrameData, /*!< Control data of current frame */ HANDLE_SBR_PREV_FRAME_DATA hPrevFrameData, /*!< Some control data of last frame */ const int applyProcessing, /*!< Flag for SBR operation */ - HANDLE_PS_DEC h_ps_d, const UINT flags, const int codecFrameSize); + HANDLE_PS_DEC h_ps_d, const UINT flags, const int codecFrameSize, + const INT sbrInDataHeadroom); SBR_ERROR createSbrDec(SBR_CHANNEL *hSbrChannel, HANDLE_SBR_HEADER_DATA hHeaderData, diff --git a/libSBRdec/src/sbr_ram.h b/libSBRdec/src/sbr_ram.h index e00f8b5..452f835 100644 --- a/libSBRdec/src/sbr_ram.h +++ b/libSBRdec/src/sbr_ram.h @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten +© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -170,6 +170,9 @@ struct SBR_DECODER_INSTANCE { flushed consecutively. */ UINT flags; + + INT sbrInDataHeadroom; /* Headroom of the SBR input time signal to prevent + clipping */ }; H_ALLOC_MEM(Ram_SbrDecElement, SBR_DECODER_ELEMENT) diff --git a/libSBRdec/src/sbrdecoder.cpp b/libSBRdec/src/sbrdecoder.cpp index 52403f6..6e4aad4 100644 --- a/libSBRdec/src/sbrdecoder.cpp +++ b/libSBRdec/src/sbrdecoder.cpp @@ -155,7 +155,7 @@ amm-info@iis.fraunhofer.de /* Decoder library info */ #define SBRDECODER_LIB_VL0 3 -#define SBRDECODER_LIB_VL1 0 +#define SBRDECODER_LIB_VL1 1 #define SBRDECODER_LIB_VL2 0 #define SBRDECODER_LIB_TITLE "SBR Decoder" #ifdef __ANDROID__ @@ -1570,10 +1570,10 @@ bail: * \return SBRDEC_OK if successfull, else error code */ static SBR_ERROR sbrDecoder_DecodeElement( - HANDLE_SBRDECODER self, QDOM_PCM *input, INT_PCM *timeData, - const int timeDataSize, const FDK_channelMapDescr *const mapDescr, - const int mapIdx, int channelIndex, const int elementIndex, - const int numInChannels, int *numOutChannels, const int psPossible) { + HANDLE_SBRDECODER self, LONG *input, LONG *timeData, const int timeDataSize, + const FDK_channelMapDescr *const mapDescr, const int mapIdx, + int channelIndex, const int elementIndex, const int numInChannels, + int *numOutChannels, const int psPossible) { SBR_DECODER_ELEMENT *hSbrElement = self->pSbrElement[elementIndex]; HANDLE_SBR_CHANNEL *pSbrChannel = self->pSbrElement[elementIndex]->pSbrChannel; @@ -1743,7 +1743,7 @@ static SBR_ERROR sbrDecoder_DecodeElement( timeData + offset1, strideOut, hSbrHeader, hFrameDataLeft, &pSbrChannel[0]->prevFrameData, (hSbrHeader->syncState == SBR_ACTIVE), h_ps_d, self->flags, - codecFrameSize); + codecFrameSize, self->sbrInDataHeadroom); if (stereo) { /* Process right channel */ @@ -1751,7 +1751,7 @@ static SBR_ERROR sbrDecoder_DecodeElement( timeData + offset1, NULL, NULL, strideOut, hSbrHeader, hFrameDataRight, &pSbrChannel[1]->prevFrameData, (hSbrHeader->syncState == SBR_ACTIVE), NULL, self->flags, - codecFrameSize); + codecFrameSize, self->sbrInDataHeadroom); } C_ALLOC_SCRATCH_END(pPsScratch, struct PS_DEC_COEFFICIENTS, 1) @@ -1771,14 +1771,14 @@ static SBR_ERROR sbrDecoder_DecodeElement( int copyFrameSize = codecFrameSize * self->pQmfDomain->QmfDomainOut->fb.no_channels; copyFrameSize /= self->pQmfDomain->QmfDomainIn->fb.no_channels; - INT_PCM *ptr; + LONG *ptr; INT i; FDK_ASSERT(strideOut == 2); ptr = timeData; for (i = copyFrameSize >> 1; i--;) { - INT_PCM tmp; /* This temporal variable is required because some - compilers can't do *ptr++ = *ptr++ correctly. */ + LONG tmp; /* This temporal variable is required because some compilers + can't do *ptr++ = *ptr++ correctly. */ tmp = *ptr++; *ptr++ = tmp; tmp = *ptr++; @@ -1791,12 +1791,13 @@ static SBR_ERROR sbrDecoder_DecodeElement( return errorStatus; } -SBR_ERROR sbrDecoder_Apply(HANDLE_SBRDECODER self, INT_PCM *input, - INT_PCM *timeData, const int timeDataSize, - int *numChannels, int *sampleRate, +SBR_ERROR sbrDecoder_Apply(HANDLE_SBRDECODER self, LONG *input, LONG *timeData, + const int timeDataSize, int *numChannels, + int *sampleRate, const FDK_channelMapDescr *const mapDescr, const int mapIdx, const int coreDecodedOk, - UCHAR *psDecoded) { + UCHAR *psDecoded, const INT inDataHeadroom, + INT *outDataHeadroom) { SBR_ERROR errorStatus = SBRDEC_OK; int psPossible; @@ -1833,6 +1834,9 @@ SBR_ERROR sbrDecoder_Apply(HANDLE_SBRDECODER self, INT_PCM *input, psPossible = 0; } + self->sbrInDataHeadroom = inDataHeadroom; + *outDataHeadroom = (INT)(8); + /* Make sure that even if no SBR data was found/parsed *psDecoded is returned * 1 if psPossible was 0. */ if (psPossible == 0) { |