📄 omxacaac_decodeisstereo_s32.c
字号:
/** * * File Name: omxACAAC_DecodeIsStereo_S32.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 Intensity Stereo decoding for an AAC decoder * */#include <math.h> #include "omxtypes.h"#include "armOMX.h"#include "omxAC.h"#include "armCOMM_Bitstream.h" #include "armCOMM.h"#include "armACAAC_Tables.h"/** * Function: omxACAAC_DecodeIsStereo_S32 (3.2.3.3.2) * * Description: * Decodes jointly-coded scalefactor bands into discrete L/R stereo pairs for * scalefactor bands in which the intensity stereo indicator flag stored in * pSfbCb[sfb] is asserted. As described in [ISO14496-3], the discrete L/R * signals pSrcL[i], pDstR[i] are recovered from the intensity-coded * representation (single channel spectral coefficients + scalefactor) using * the scaling operation expressed below. The parameter invert_intensity(g, * sfb) is not used in the formula, since it decoded and stored in pSfbCb[sfb] * by the MS stereo decoder. * * pDstR[i] = pSrcL[i]*is_intensity(g, sfb) * 2^(-0.25*pScalefactor[sfb]) * * Reference: [ISO14496-3], sub-clause 4.6.8.2 * * Input Arguments: * * pSrcL - pointer to left channel data in Q28.3 format. For short block, * the coefficients are interleaved by scalefactor window bands in * each group. Buffer length is 1024. pSrcL must be 8-byte aligned. * pScalefactor - pointer to the scalefactor buffer, of length 120 * pSfbCb - pointer to the scalefactor band codebook, of length 120. Store * maxSfb elements for each group. There are no spaces 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 [0, 11] * winLen - the data number in one window * * Output Arguments: * * pDstR - pointer to right channel data in Q28.3 format. For short block, * the coefficients are interleaved by scalefactor window bands in * each group. Buffer length is 1024. pDstR must be 8-byte aligned. * * Return Value: * * OMX_Sts_NoErr - no error * OMX_Sts_BadArgErr - bad arguments At least one of the following * pointers: pSrcL, pDstR, pWinGrpLen, pScalefactor, pSfbCbis * NULL. * If pSrcL, pDstR is not 8-byte aligned. * If short block, numWinGrpexceeds [1, 8] If long block, numWinGrp!= 1 * maxSfbexceeds [0, 51] samplingRateIndexexceeds [0, 11] * winLenis neither 1024 nor 128 * OMX_StsACAAC_MaxSfbErr - invalid maxSfb value in relation to numSwb * */ static OMX_S32 armACAAC_ScaleIsStereo( OMX_S32 input, OMX_INT cbNum, OMX_S16 isPos );OMXResult omxACAAC_DecodeIsStereo_S32( const OMX_S32 *pSrcL, OMX_S32 *pDstR, const OMX_S16 *pScalefactor, const OMX_U8 *pSfbCb, OMX_INT numWinGrp, const OMX_INT *pWinGrpLen, OMX_INT maxSfb, OMX_INT samplingRateIndex, OMX_INT winLen ){ OMX_INT groupNum,sfbNum,cbNum,winNum = 0; OMX_INT coeff; const OMX_U16 *pOffsetTable; OMX_U16 width,numSwb; OMX_S16 isPos; /* Argument Check */ armRetArgErrIf( pSrcL == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pDstR == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pScalefactor == 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( samplingRateIndex > 11, OMX_Sts_BadArgErr); armRetArgErrIf( samplingRateIndex < 0 , OMX_Sts_BadArgErr); armRetArgErrIf( armNot8ByteAligned(pSrcL), OMX_Sts_BadArgErr); armRetArgErrIf( armNot8ByteAligned(pDstR), 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 */ 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++) { isPos = *pScalefactor++; cbNum = *pSfbCb++; width = pOffsetTable[sfbNum + 1] - pOffsetTable[sfbNum]; if ( cbNum == ARM_AAC_INTENSITY_HCB || cbNum == ARM_AAC_INTENSITY_HCB2 ) { for (winNum = 0; winNum < pWinGrpLen[groupNum]; winNum++) { for (coeff = 0; coeff < width; coeff++) { *pDstR = armACAAC_ScaleIsStereo(*pSrcL,cbNum,isPos); pSrcL++; pDstR++; } } } else { pSrcL += (pWinGrpLen[groupNum] * width); pDstR += (pWinGrpLen[groupNum] * width); } } } return OMX_Sts_NoErr;}/** * Function: armACAAC_ScaleIsStereo * * Description: * Computes 2^(-isPos/4) and scales the input with this value * * * Parameters: * [in] input the input to be scaled * [in] cbNum the code book index used * [in] isPos scaling coefficient * * Return Value: * The scaled value of the input * */static OMX_S32 armACAAC_ScaleIsStereo(OMX_S32 input,OMX_INT cbNum,OMX_S16 isPos){ OMX_F64 coeff; OMX_S32 output; coeff = input /(OMX_F64)(1 << ARM_AAC_Q_FACTOR); coeff = coeff * pow(2.0 , -isPos/4.0); if (cbNum == ARM_AAC_INTENSITY_HCB2) { coeff = -coeff; } output = armSatRoundFloatToS32(coeff * (1 << ARM_AAC_Q_FACTOR )); return output;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -