omxacaac_encodetns_s32_i.c
来自「The OpenMAX DL (Development Layer) APIs 」· C语言 代码 · 共 254 行
C
254 行
/** * * File Name: omxACAAC_EncodeTNS_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 reversing TNS decoding process in an LTP loop * for an AAC decoder * */#include "omxtypes.h" #include "armOMX.h"#include "omxAC.h"#include "armAC.h"#include "armACAAC.h"#include "armCOMM.h"#include "armACAAC_Tables.h"/** * Function: omxACAAC_EncodeTNS_S32_I (3.2.3.7.3) * * Description: * This function applies a TNS analysis (encoding) filter to spectral * coefficients in the LTP feedback loop for one channel. * * Reference: [ISO14496-3], sub-clause 4.6.9 * * Input Arguments: * * pSrcDstSpectralCoefs - pointer to the unprocessed spectral coefficient * vector for one channel; coefficients are represented using Q28.3 * pTnsNumFilt - pointer to a table containing the number of TNS filters * that are applied on each window of the current frame for the * current channel. The table elements are indexed as follows: * pTnsNumFilt[w] * w=0 to numWin-1; depending upon the current window sequence, * this vector may contain up to 8 elements * pTnsRegionLen - pointer to a table containing TNS region lengths (in * scalefactor band units) for all regions and windows on the * current frame for the current channel; the table entry * pTnsRegionLen[i] specifies the region length for k-th filter on * the w-th window. The table index, i, is computed as follows: * * i = SUM[j=0; w-1] (pnsNumFilt[j] + k) * * where 0 <= w <= numWin-1, and 0 <= k <= pTnsNumFilt[w]-1. * * pTnsFiltOrder - pointer to a table containing TNS filter orders for all * regions and windows on the current frame for the current * channel; the table entry pTnsFiltOrder[i] specifies the TNS * filter order for the k-th filter on the w-th window. The table * index, i, is computed as follows: * * i = SUM[j=0; w-1] (pnsNumFilt[j] + k) * * where 0 <= w <= numWin-1, and 0 <= k <= pTnsNumFilt[w]-1. * * pTnsFiltCoefRes - pointer to a table of TNS filter coefficient * resolution indicators for each window on the current frame for * the current channel. Resolutions for filters on the w-th window * are specified in table entry pTnsFiltCoefRes[w], and w=0 to * numWin-1. * pTnsFiltCoef - pointer to a table containing the complete set of TNS * filter coefficients for all windows and regions on the current * frame for 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 shown above. * * pTnsDirection - pointer to a table of tokens that indicate the direction * of TNS filtering for all regions and windows on the current * frame, with 0 indicating upward and 1 indicating downward; in * particular the table entry pTnsDirection[i] specifies direction * for k-th filter on the w-th window, and the table index, i, is * computed as follows: * * i = SUM[j=0; w-1] (pnsNumFilt[j] + k) * * where 0 <= w <= numWin-1, and 0 <= k <= pTnsNumFilt[w]-1. * * maxSfb - number of scalefactor bands * profile - audio profile * samplingRateIndex - sampling rate index * * Output Arguments: * * pSrcDstSpectralCoefs - pointer to the TNS-encoded spectral coefficient * vector; coefficients are represented using Q28.3 * * Return Value: * * OMX_Sts_NoErr - no error * OMX_StsACAAC_MaxSfbErr - invalid maxSfb value in relation to numSwb * OMX_Sts_BadArgErr - bad arguments * - at least one of the pointers is NULL: * - pSrcDstSpectralCoefs, * - pTnsNumFilt, * - pTnsRegionLen, * - pTnsFiltOrder, * - pTnsFiltCoefRes, * - pTnsFiltCoefor * - pTnsDirection * - samplingRateIndex exceeds [0,12] * - maxSfb not in [0,51] * */OMXResult omxACAAC_EncodeTNS_S32_I( OMX_S32 *pSrcDstSpectralCoefs, const OMX_INT *pTnsNumFilt, const OMX_INT *pTnsRegionLen, const OMX_INT *pTnsFiltOrder, const OMX_INT *pTnsFiltCoefRes, const OMX_S8 *pTnsFiltCoef, const OMX_INT *pTnsDirection, OMX_INT maxSfb, OMX_INT profile, OMX_INT samplingRateIndex ){ const OMX_U16 *pOffsetTable; OMX_U16 swbCount,top,offset; OMX_INT winCount,filtCount,winNum,filtNum,regionLen,bottom; OMX_INT tnsOrder,direction,increment,coeffRes,size,start,end; OMX_U8 tnsMaxBand; OMX_F64 lpCoeff[20]; OMXResult errorCode; /* Argument Check */ armRetArgErrIf( pSrcDstSpectralCoefs == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pTnsNumFilt == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pTnsRegionLen == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pTnsFiltOrder == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pTnsFiltCoefRes == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pTnsFiltCoef == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( pTnsDirection == NULL, OMX_Sts_BadArgErr); armRetArgErrIf( (maxSfb > 51) || (maxSfb < 0), OMX_Sts_BadArgErr); armRetArgErrIf( samplingRateIndex > 12, OMX_Sts_BadArgErr); armRetArgErrIf( samplingRateIndex < 0 , OMX_Sts_BadArgErr); /* Processing */ swbCount = armACAAC_numSwbLong[samplingRateIndex]; pOffsetTable = armACAAC_swbOffsetLongWindow[samplingRateIndex]; tnsMaxBand = armACAAC_TnsMaxBands[samplingRateIndex][0]; winCount = 1; armRetArgErrIf(maxSfb > swbCount, OMX_StsACAAC_MaxSfbErr); for(winNum = 0; winNum < winCount ; winNum++) { filtCount = pTnsNumFilt[winNum]; coeffRes = pTnsFiltCoefRes[winNum]; /* Argument Check */ armRetDataErrIf( (filtCount < 0)|| (filtCount > 3), OMX_StsACAAC_TnsNumFiltErr ); armRetDataErrIf( (filtCount!= 0) && ( (coeffRes < 3) || (coeffRes > 4) ), OMX_StsACAAC_TnsCoefResErr ); bottom = swbCount; for(filtNum = 0; filtNum < filtCount ; filtNum++) { regionLen = pTnsRegionLen[winNum + filtNum]; tnsOrder = pTnsFiltOrder[winNum + filtNum]; direction = pTnsDirection[winNum + filtNum]; if (tnsOrder == 0) { continue; } armRetDataErrIf( (regionLen < 0) || (regionLen > swbCount), OMX_StsACAAC_TnsLenErr ); armRetDataErrIf( (tnsOrder < 0) || (tnsOrder > 12), OMX_StsACAAC_TnsOrderErr ); armRetDataErrIf( (direction < 0) || (direction > 1), OMX_StsACAAC_TnsDirectErr ); top = bottom; bottom = top - regionLen; if(bottom < 0) { bottom = 0; } /*Decoding Filter Coefficients*/ errorCode = armACAAC_TnsDecodeCoef(pTnsFiltCoef,lpCoeff,coeffRes,tnsOrder); armRetDataErrIf( errorCode != OMX_Sts_NoErr, errorCode ); pTnsFiltCoef += tnsOrder; offset = armMin(tnsMaxBand,maxSfb); start = pOffsetTable[armMin(bottom,offset)]; end = pOffsetTable[armMin(top,offset)]; size = end - start; if ( size <= 0 ) { continue; } if (direction == 1) { increment = -1; start = end - 1; } else { increment = 1; } /*Filtering*/ armACAAC_TnsFilter(&pSrcDstSpectralCoefs[start],lpCoeff,size,increment,tnsOrder,1); } pSrcDstSpectralCoefs += ARM_AAC_WIN_SHORT; } return OMX_Sts_NoErr;}/* End of File */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?