📄 omxacaac_decodemsstereo_s32_i.c
字号:
/** * * File Name: omxACAAC_DecodeMsStereo_S32_I.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 M/S Stereo decoding for an AAC decoder * */#include "omxtypes.h"#include "armOMX.h"#include "omxAC.h"#include "armCOMM_Bitstream.h"#include "armAC.h"#include "armCOMM.h"#include "armACAAC_Tables.h"/** * Function: omxACAAC_DecodeMsStereo_S32_I (3.2.3.3.1) * * Description: * Performs M-S stereo decoding; converts the MS stereo jointly-coded * scalefactor bands of a channel pair from the M-S representation to the L-R * representation; also performs the invert_intensity(group,sfb) function and * stores the values in the pSfbCb buffer. If invert_intensity(group, sfb) = * 1, and if *pSfbCb = INTERITY_HCB, let *pSfbCb = INTERITY_HCB2; else if * *pSfbCb = INTERITY_HCB2, let *pSfbCb = INTERITY_HCB. For scalefactor bands * in which the MS stereo flag is asserted, the individual left and right * channel spectral samples pSrcDstL[i] and pSrcDstR[i] are computed as * follows: * pSrcDstL'[i] = pSrcDstL[i] + pSrcDstR[i], * pSrcDstR'[i] = pSrcDstL[i] - pSrcDstR[i]. * * Reference: [ISO14496-3], sub-clause 4.6.8.1 * * Input Arguments: * * pSrcDstL - pointer to left channel data in Q28.3 format. For short * blocks, the coefficients are interleaved by scalefactor window * bands in each group, of length 1024. pSrcDstL must be 8-byte * aligned. * pSrcDstR - pointer to right channel data in Q28.3 format. For short * block, the coefficients are interleaved by scalefactor window * bands in each group, of length 1024. pSrcDstR must be 8-byte * aligned. * pChanPairElt - pointer to a Channel Pair Element structure that has been * previously populated. At minimum, the contents of msMaskPres and * pMsUsed fields are used to control MS decoding process and must * be valid. These provide, respectively, the MS stereo mask for a * scalefactor band (0: MS Off, 1: MS On, 2: all bands on), and the * MS stereo flag buffer, of length 120. * pSfbCb -pointer to the scalefactor band codebook, of length 120. Stores * maxSfb elements for each group. There is no space between the * sequence groups * numWinGrp - group number * pWinGrpLen - pointer to the number of windows in each group, of length 8 * maxSfb - max scalefactor bands number for the current block * samplingRateIndex - sampling rate index; valid in the range [0, 11] * winLen - the data number in one window * * Output Arguments: * * pSrcDstL - pointer to left channel data in Q28.3 format. For short * blocks, the coefficients are interleaved by scalefactor window * bands in each group, of length 1024. pSrcDstL must be 8-byte * aligned. * pSrcDstR - pointer to right channel data in Q28.3 format. For short * blocks, the coefficients are interleaved by scalefactor window * bands in each group, of length 1024. pSrcDstR must be 8-byte * aligned. * pSfbCb- pointer to the scalefactor band codebook. If invert_intensity * group, sfb) = -1, and if *pSfbCb = INTERITY_HCB, let *pSfbCb = * INTERITY_HCB2; else if *pSfbCb = INTERITY_HCB2, let *pSfbCb = * INTERITY_HCB. Buffer length is 120. Store maxSfb elements for * each group. There is no space between the sequence groups. * * Return Value: * * OMX_Sts_NoErr - no error * OMX_Sts_BadArgErr - bad arguments: * - At least one of the following pointers is NULL: * - pSrcDstL, * - pSrcDstR, * - pMsUsed, * - pWinGrpLen, * - pSfbCb * - pSrcDstL or pSrcDstR is not 8-byte aligned * - For short blocks, numWinGrpexceeds [1, 8] * - For long blocks, numWinGrp != 1 * - maxSfb exceeds [0, 51] * - msMaskPres exceeds [1, 2] * - samplingRateIndex exceeds [0, 11] * - winLen is neither 1024 nor 128 * OMX_StsACAAC_MaxSfbErr - invalid maxSfb value in relation to numSwb * */OMXResult omxACAAC_DecodeMsStereo_S32_I( OMX_S32 *pSrcDstL, OMX_S32 *pSrcDstR, OMXAACChanPairElt *pChanPairElt, OMX_U8 *pSfbCb, OMX_INT numWinGrp, const OMX_INT *pWinGrpLen, OMX_INT maxSfb, OMX_INT samplingRateIndex, OMX_INT winLen){ OMX_INT groupNum,winNum,sfbNum,cbNum; OMX_INT msMask,coeff; OMX_S32 diff; const OMX_U16 *pOffsetTable; OMX_U16 width,numSwb; OMX_INT msMaskPres; /* Argument Check */ armRetArgErrIf( pChanPairElt == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pSrcDstL == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pSrcDstR == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pSfbCb == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pWinGrpLen == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( (maxSfb > 51) || (maxSfb < 0) , OMX_Sts_BadArgErr); armRetArgErrIf( pChanPairElt->msMaskPres > 2, OMX_Sts_BadArgErr); armRetArgErrIf( pChanPairElt->msMaskPres < 1, OMX_Sts_BadArgErr); armRetArgErrIf( samplingRateIndex > 11, OMX_Sts_BadArgErr); armRetArgErrIf( samplingRateIndex < 0 , OMX_Sts_BadArgErr); armRetArgErrIf( armNot8ByteAligned(pSrcDstL), OMX_Sts_BadArgErr) armRetArgErrIf( armNot8ByteAligned(pSrcDstR), OMX_Sts_BadArgErr) armRetArgErrIf( ( winLen != ARM_AAC_WIN_SHORT ) && ( winLen != ARM_AAC_WIN_LONG ), OMX_Sts_BadArgErr ); armRetArgErrIf( ( winLen == ARM_AAC_WIN_SHORT ) && ( (numWinGrp > 8) || (numWinGrp < 1) ), OMX_Sts_BadArgErr ); armRetArgErrIf( ( winLen == ARM_AAC_WIN_LONG ) && ( numWinGrp != 1), OMX_Sts_BadArgErr ); /* Processing */ msMaskPres = pChanPairElt->msMaskPres; if(winLen == ARM_AAC_WIN_SHORT) { pOffsetTable = armACAAC_swbOffsetShortWindow[samplingRateIndex]; numSwb = armACAAC_numSwbShort[samplingRateIndex]; } else { pOffsetTable = armACAAC_swbOffsetLongWindow[samplingRateIndex]; numSwb = armACAAC_numSwbLong[samplingRateIndex]; } armRetArgErrIf( maxSfb > numSwb, OMX_StsACAAC_MaxSfbErr); for (groupNum = 0; groupNum < numWinGrp; groupNum++) { for(sfbNum = 0; sfbNum < maxSfb; sfbNum++) { msMask = pChanPairElt->ppMsMask[groupNum][sfbNum]; cbNum = *pSfbCb; /*inverting the intensity*/ if(msMask == 1 && cbNum == ARM_AAC_INTENSITY_HCB) { cbNum = ARM_AAC_INTENSITY_HCB2; *pSfbCb = ARM_AAC_INTENSITY_HCB2; } else if(msMask == 1 && cbNum == ARM_AAC_INTENSITY_HCB2) { cbNum = ARM_AAC_INTENSITY_HCB; *pSfbCb = ARM_AAC_INTENSITY_HCB; } width = pOffsetTable[sfbNum + 1] - pOffsetTable[sfbNum]; pSfbCb++; if ( ( msMask == 1 || msMaskPres == 2 ) && cbNum != ARM_AAC_INTENSITY_HCB && cbNum != ARM_AAC_INTENSITY_HCB2 && cbNum != ARM_AAC_NOISE_HCB ) { for (winNum = 0; winNum < pWinGrpLen[groupNum]; winNum++) { for (coeff = 0; coeff < width; coeff++) { diff = armSatSub_S32(*pSrcDstL,*pSrcDstR); *pSrcDstL = armSatAdd_S32(*pSrcDstL,*pSrcDstR); *pSrcDstR = diff; pSrcDstL++; pSrcDstR++; } } } else { pSrcDstL += pWinGrpLen[groupNum] * width; pSrcDstR += pWinGrpLen[groupNum] * width; } } } return OMX_Sts_NoErr;}/* End of File */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -