📄 omxacaac_noiselessdecode.c
字号:
/** * * File Name: omxACAAC_NoiselessDecode.c * OpenMAX DL: v1.0.2 * Revision: 10586 * Date: Wednesday, March 5, 2008 * * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. * * * * Description: * This file contains module for Noiseless decoding for an AAC decoder * */ #include "omxtypes.h"#include "armOMX.h"#include "omxAC.h"#include "armCOMM.h"#include "armCOMM_Bitstream.h"#include "armAC.h"#include "armACAAC.h"#include "armACAAC_Tables.h"/*Local Function Declarations - Not used outside this file*/static OMXVoid armACAAC_DecodeSectionData( const OMX_U8 **ppBitStream, OMX_INT *pOffset, OMX_U8 *pDstSfbCb, OMXAACChanInfo *pChanInfo ); static OMXResult armACAAC_DecodeScaleFactorData( const OMX_U8 **ppBitStream, OMX_INT *pOffset, OMX_U8 *pDstSfbCb, OMX_S16 *pDstScalefactor, OMX_INT globGain, OMXAACIcsInfo *pIcsInfo ); static OMXResult armACAAC_DecodeSpectralData( const OMX_U8 **ppBitStream, OMX_INT *pOffset, OMX_S32 *pDstQuantizedSpectralCoef, OMXAACChanInfo *pChanInfo );static OMXResult armACAAC_DecodePulseData( const OMX_U8 **ppBitStream, OMX_INT *pOffset, const OMX_U16 *pOffsetTable, OMX_INT *numPulse, OMX_INT *pulseStart, OMX_INT *pulseOff, OMX_INT *pulseAmp, OMX_U16 numSwb ); static OMXVoid armACAAC_DecodeTNSData( const OMX_U8 **ppBitStream, OMX_INT *pOffset, OMX_INT audioObjectType, OMX_S8 *pDstTnsFiltCoef, OMXAACChanInfo *pChanInfo );/** * Function: omxACAAC_NoiselessDecode (3.2.3.8.1) * * Description: * Noiseless decoder for a single channel of AAC LC and LTP audio objects. * Extracts side information, scalefactor information, quantized spectral * coefficients, TNS parameters, and LTP parameters from the input stream for * one channel and places the contents into the arrays referenced by the * parameters pChanInfo, pDstScalefactor, pDstQuantizedSpectralCoef, * pDstTnsFiltCoef, and pLtpInfo, respectively. Individual output structure * member update dependencies on elementary stream properties are specified * below under Output Arguments for each parameter. * * Reference: [ISO14496-3], sub-clause 4.6.3 * * Input Arguments: * * ppBitStream - double pointer to current byte in the input bitstream * pOffset - pointer to the offset indicating the next available bit in the * current byte of the input bitstream; valid in the rage [0,7]. * pChanInfo - pointer to the channel information structure; the structure * member samplingRateIndex must contain valid information prior to * calling this function. The remaining structure members are * updated upon return as described under Output Arguments. * commonWin - commonWin==1 indicates that the channel pair uses the same * individual channel stream information (ICS); commonWin==0 * indicates that ICS is not shared across a channel pair. * audioObjectType - audio object type indicator: 2=LC, 4=LTP * * Output Arguments: * * ppBitStream - double pointer to the updated stream pointer; references * the current byte in the input bitstream after Huffman decoding * has been completed * pOffset - pointer to the updated bit index indicating the next available * bit in the input stream following after Huffman decoding has * been completed * pChanInfo - pointer to the updated channel information structure. * NoiselessDecode updates all members of this structure, with the * following exceptions: i) the following members are never * updated by this function: tag, id, predSfbMax, preWinShape, and * pChanPairElt; ii) if commonWin==1 then the contents of ICS * structure *(pChanInfo->pIcsInfo) are not modified (for the * common window case, refer to function * omxACAAC_DecodeChanPairElt); iii) if commonWin==0 then all * members of the ICS structure *(pChanInfo->pIcsInfo) are modified * unconditionally except as shown in Table 3-11, and only the * first pIcsInfo->numWinGrp elements in pIcsInfo-> pWinGrpLen are * updated; iv) only elements 0, 1, 2,...pIcsInfo->maxSfb-1 of * arrays pSectCb[.] and pSectEnd[.] are updated; v) only elements * 0, 1, 2,..., pIcsInfo >numWinGrp of arrays pMaxSect[.], * pTnsNumFilt[.], and pTnsFiltCoefRes[.] are updated; vi) only * elements 0, 1, 2,..., sum(pTnsNumFilt[i]) for i = 0, 1, , * (pIcsInfo >numWinGrp)-1 are updated for arrays pTnsRegionLen[.], * pTnsFilterOrder[.], and pTnsDirection[.]. The updated TNS * parameters returned in the TNS parameter arrays pTnsNumFilt, * pTnsFiltCoefRes, pTnsRegionLen, pTnsFiltOrder, and pTnsDirection * are organized as described in the corresponding input parameter * descriptions given in section 3.2.7.2.3 (EncodeTNS_S32_I). * pDstScalefactor - pointer to the updated scalefactor table; the buffer * must have sufficient space to contain up to 120 scalefactor * elements. * pDstQuantizedSpectralCoef - pointer to the 1024-element array containing * the decoded, quantized spectral coefficients, all of which are * integer values represented using Q0, i.e., no scaling. * pDstSfbCb - pointer to the updated table of scalefactor band codebook * indices; the buffer must have sufficient space to contain up to * 120 SFB codebook indices. * pDstTnsFiltCoef - pointer to the updated table containing the complete * set of TNS filter coefficients for all windows and regions on * the current channel. Filter coefficients are stored * contiguously in filter-major order, i.e., the table is organized * such that the filter coefficients for the k-th filter of the * w-th window are indexed using pTnsFiltCoef[w][k][i], where 0 <= * i <= pTnsFiltOrder[j]-1, 0 <= k <= pTnsNumFilt[w]-1, 0 <= w <= * numWin-1, and the filter order index, j, is computed as * described in section 3.2.7.2.3 (EncodeTNS_S32_I) under the * pTnsFiltOrder input parameter description. * pLtpInfo - pointer to the LTP information structure associated with the * current channel; updated only if (pChanPairElt->CommonWin == 0) * && (audioObjectType==4) and the elementary stream bit field * predictor_data_present==1. Otherwise, if * (pChanPairElt >CommonWin == 1) || (audioObjectType!=4) || * predictor_data_present==0 then the function * omxACAAC_NoiselessDecode will not update the contents of the * structure *pLtpInfo. The LTP information structure will be * updated by the function omxACAAC_DecodeChanPairElt if * (pChanPairElt->CommonWin == 1) && (audioObjectType==4). * Reference: [ISO14496-3], sub-clause 4.4.2.1 and Tables 4.5 4.6. * * Return Value: * * OMX_Sts_NoErr - no error * OMX_Sts_BadArgErr - bad arguments * - at least one of the pointers: ppBitStream, pOffset, *ppBitStream, * pDstScaleFactor, pDstTnsFiltCoef, pDstQuantizedSpectralCoef, * pChanInfo or pDstSfbCb is NULL. * - *pOffset exceeds [0,7] * - commonWin exceeds [0,1] * - audioObjectType is not equal to either 2 or 4 * - commonWin==1 and pChanInfo->pIcsInfo->winSequence exceeds [0,3] * OMX_Sts_InvalidBitstreamValErr - invalid bitstream parameter value * detected * - commonWin==0 and the decoded value of pChanInfo->pIcsInfo->maxSfb * is out of range, i.e., exceeds [0,51] * OMX_StsACAAC_PlsDataErr - pulse data error; returned if one or more of * the following conditions is true: * i) pulse data is present during a short window sequence, i.e., * pChanInfo >pIcsInfo->winSequence==EIGHT_SHORT_SEQUENCE && * pChanInfo->pulsePres==1; * ii) the start scalefactor band for pulse data (pulse_start_sfb) * is out of range, i.e., * (pulse_start_sfb>= pChanInfo->numSwb) || (pulse_start_sfb >= 51); * iii) pulse data position offset (pulse_offset[i]), is out * of range, i.e., pulse_offset[i]>= pChanInfo->winLen. * Reference: [ISO14496-3], sub-clause 4.6.3. * OMX_StsACAAC_GainCtrErr - pChanInfo->gainContrDataPres==1. * */OMXResult omxACAAC_NoiselessDecode( const OMX_U8 **ppBitStream, OMX_INT *pOffset, OMX_S16 *pDstScalefactor, OMX_S32 *pDstQuantizedSpectralCoef, OMX_U8 *pDstSfbCb, OMX_S8 *pDstTnsFiltCoef, OMXAACChanInfo *pChanInfo, OMX_INT commonWin, OMX_INT audioObjectType, OMXAACLtpInfo *pLtpInfo ){ OMXAACIcsInfo *pIcsInfo; OMXResult errorCode; const OMX_U16 *pOffsetTable; OMX_U16 numSwb; OMX_INT numPulse = 0,pulseStart = 0; OMX_INT pulseOff[4],pulseAmp[4]; OMX_INT j,k; /* Argument Check */ armRetArgErrIf( pDstQuantizedSpectralCoef == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pDstScalefactor == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pDstTnsFiltCoef == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pDstSfbCb == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( ppBitStream == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( *ppBitStream == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pOffset == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pChanInfo == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( (commonWin > 1) || (commonWin < 0) , OMX_Sts_BadArgErr); armRetArgErrIf( (*pOffset > 7) || (*pOffset < 0) , OMX_Sts_BadArgErr); armRetArgErrIf( (audioObjectType != 2 ) && (audioObjectType != 4 ) , OMX_Sts_BadArgErr); /* Processing */ pIcsInfo = pChanInfo->pIcsInfo; pOffsetTable = armACAAC_swbOffsetLongWindow[pChanInfo->samplingRateIndex]; pChanInfo->globGain = (OMX_INT)armGetBits(ppBitStream,pOffset,8); if(!commonWin) { errorCode = armACAAC_DecodeIcsInfoData(ppBitStream,pOffset,commonWin, audioObjectType,pChanInfo->predSfbMax,pChanInfo,pChanInfo->pIcsInfo,&pLtpInfo); armRetDataErrIf(errorCode != OMX_Sts_NoErr , errorCode); } else { armRetArgErrIf( pIcsInfo->winSequence > 3 , OMX_Sts_BadArgErr); armRetArgErrIf( pIcsInfo->winSequence < 0 , OMX_Sts_BadArgErr); } /*Section Data*/ armACAAC_DecodeSectionData(ppBitStream,pOffset,pDstSfbCb,pChanInfo); /*ScaleFactor data*/ errorCode = armACAAC_DecodeScaleFactorData(ppBitStream,pOffset,pDstSfbCb, pDstScalefactor,pChanInfo->globGain,pIcsInfo); armRetDataErrIf(errorCode != OMX_Sts_NoErr , errorCode); /*Pulse Data*/ pChanInfo->pulseDataPres = (OMX_INT)armGetBits(ppBitStream,pOffset,1); if(pChanInfo->pulseDataPres == 1) { armRetDataErrIf(pIcsInfo->winSequence == ARM_AAC_EIGHT_SHORT_SEQUENCE , OMX_StsACAAC_PlsDataErr); numSwb = armACAAC_numSwbLong[pChanInfo->samplingRateIndex]; errorCode = armACAAC_DecodePulseData(ppBitStream,pOffset,pOffsetTable, &numPulse,&pulseStart,pulseOff,pulseAmp,numSwb); armRetDataErrIf(errorCode != OMX_Sts_NoErr , errorCode); } /*TNS Data*/ pChanInfo->tnsDataPres = (OMX_INT)armGetBits(ppBitStream,pOffset,1); if(pChanInfo->tnsDataPres == 1) { armACAAC_DecodeTNSData(ppBitStream,pOffset,audioObjectType, pDstTnsFiltCoef,pChanInfo); } /*Gain Control Data*/ pChanInfo->gainContrDataPres = (OMX_INT)armGetBits(ppBitStream,pOffset,1); armRetDataErrIf(pChanInfo->gainContrDataPres == 1 , OMX_StsACAAC_GainCtrErr); /*Spectral Data*/ errorCode = armACAAC_DecodeSpectralData(ppBitStream,pOffset,pDstQuantizedSpectralCoef, pChanInfo); armRetDataErrIf(errorCode != OMX_Sts_NoErr , errorCode); /* Applying Pulse data */ if (pChanInfo->pulseDataPres == 1) { k = pOffsetTable[pulseStart]; for (j = 0; j< (numPulse + 1); j++) { k += pulseOff[j]; if ( pDstQuantizedSpectralCoef[k] > 0 ) { pDstQuantizedSpectralCoef[k] += pulseAmp[j]; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -