⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 omxacaac_decodetns_s32_i.c

📁 The OpenMAX DL (Development Layer) APIs contain a comprehensive set of audio, video, signal processi
💻 C
字号:
/** *  * File Name:  omxACAAC_DecodeTNS_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 TNS decoding for an AAC decoder * */#include "omxtypes.h"#include "armOMX.h"#include "omxAC.h"#include "armCOMM.h"#include "armAC.h"#include "armACAAC.h"#include "armACAAC_Tables.h"/** * Function:  omxACAAC_DecodeTNS_S32_I   (3.2.3.4.1) * * Description: * This function applies all-pole Temporal Noise Shaping (TNS) decoding  * filters to selected spectral coefficient regions. The output sequence is  * ready for the IMDCT synthesis bank.  * * Reference [ISO14496-3], sub-clause 4.6.9  * * Input Arguments: *    *   pSrcDstSpectralCoefs - spectral coefficient input vector, of length  *            1024, represented using Q28.3 format  *   pTnsNumFilt - pointer to a table containing the number of TNS filters  *            that are applied on each window of the current frame. 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; 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] pTnsNumFilt[ 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; 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] pTnsNumFilt[ 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.  *            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. 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] pTnsNumFilt[ j] + k  * *               where 0 <= w <= numWin-1, and 0 <= k <= pTnsNumFilt[w]-1.  * *   maxSfb - number of scalefactor bands transmitted per window group on the  *            current frame  *   profile -profile index, 0=main, 1=LC, 2=SSR as shown in [ISO14496-3],  *            Table 4.6.9  *   samplingRateIndex - sample rate index for the current frame  *   winLen - window length  * * Output Arguments: *   pSrcDstSpectralCoefs - pointer to the output spectral coefficients after  *            TNS filtering represented using Q28.3 format.  * * Return Value: *     *    OMX_Sts_NoErr - no error  *    OMX_Sts_BadArgErr - bad arguments  *    -    At least one of the following pointers is NULL:  *            - pSrcDstSpectralCoefs,  *            - pTnsNumFilt,  *            - pTnsRegionLen,  *            - pTnsFiltOrder,  *            - pTnsFiltCoefRes,  *            - pTnsFiltCoef, *            - pTnsDirection.  *    -    profile!=1  *    -    samplingRateIndex exceeds [0, 11]  *    -    winLen!=128 and winLen!=1024  *    -    maxSfb exceeds [0,51]  *    OMX_StsACAAC_TnsNumFiltErr - for a short window sequence,  *              pTnsNumFilt[w] exceeds [0, 1]; For long window sequence,  *              pTnsNumFilt[w] exceeds [0, 3], w=0 to numWin-1.  *    OMX_StsACAAC_TnsLenErr - *pTnsRegionLen exceeds [0, numSwb]  *    OMX_StsACAAC_TnsOrderErr - for short window sequence, *pTnsFiltOrder  *              exceeds [0, 7]; For long window sequence, *pTnsFiltOrder  *              exceeds [0, 12]  *    OMX_StsACAAC_TnsCoefResErr - pTnsFiltCoefRes[w] exceeds [3, 4], w=0 to  *              numWin-1  *    OMX_StsACAAC_TnsCoefErr - *pTnsFiltCoef exceeds [-8, 7]  *    OMX_StsACAAC_TnsDirectErr - *pTnsDirection exceeds [0, 1]  *    OMX_StsACAAC_MaxSfbErr - invalid maxSfb value in relation to numSwb  * */OMXResult omxACAAC_DecodeTNS_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,     OMX_INT winLen ){    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( samplingRateIndex > 11, OMX_Sts_BadArgErr);    armRetArgErrIf( samplingRateIndex < 0 , OMX_Sts_BadArgErr);    armRetArgErrIf( profile != 1          , OMX_Sts_BadArgErr);    armRetArgErrIf( ( winLen != 128 ) &&                     ( winLen != 1024  ),                    OMX_Sts_BadArgErr );      /* Processing */    if(winLen == ARM_AAC_WIN_SHORT)    {        /*Short Window*/                swbCount     = armACAAC_numSwbShort[samplingRateIndex];        pOffsetTable = armACAAC_swbOffsetShortWindow[samplingRateIndex];        tnsMaxBand   = armACAAC_TnsMaxBands[samplingRateIndex][1];        winCount     = OMX_AAC_WIN_MAX;    }    else    {        swbCount     = armACAAC_numSwbLong[samplingRateIndex];        pOffsetTable = armACAAC_swbOffsetLongWindow[samplingRateIndex];        tnsMaxBand   = armACAAC_TnsMaxBands[samplingRateIndex][0];        winCount     = 1;    }    armRetArgErrIf( (maxSfb > swbCount) || (maxSfb < 0), OMX_StsACAAC_MaxSfbErr);       for(winNum = 0; winNum < winCount ; winNum++)    {        filtCount = pTnsNumFilt[winNum];        coeffRes  = pTnsFiltCoefRes[winNum];        /* Argument Check */        if(winLen == ARM_AAC_WIN_SHORT)        {            armRetDataErrIf( (filtCount < 0)|| (filtCount > 1),                                    OMX_StsACAAC_TnsNumFiltErr );        }        else        {            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];                                    armRetDataErrIf( (regionLen < 0) || (regionLen > swbCount),                                    OMX_StsACAAC_TnsLenErr );            armRetDataErrIf( (tnsOrder < 0) || (winLen == 1024 && tnsOrder > 12) ||                 (winLen == 128 && tnsOrder > 7), OMX_StsACAAC_TnsOrderErr );            armRetDataErrIf( (direction < 0) || (direction > 1),                                    OMX_StsACAAC_TnsDirectErr );            top    = bottom;            bottom = top - regionLen;                        if(bottom < 0)            {                bottom = 0;            }            if (tnsOrder == 0)            {                continue;            }            /*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,0);        }                pSrcDstSpectralCoefs += ARM_AAC_WIN_SHORT;    }    return OMX_Sts_NoErr;}/* End of File */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -