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

📄 omxacaac_quantinv_s32_i.c

📁 The OpenMAX DL (Development Layer) APIs contain a comprehensive set of audio, video, signal processi
💻 C
字号:
/** *  * File Name:  omxACAAC_QuantInv_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 Inverse Quantization of input data for an AAC decoder * */#include <math.h> #include "omxtypes.h"#include "armOMX.h"#include "omxAC.h"#include "armCOMM.h"#include "armCOMM_Bitstream.h"#include "armAC.h"#include "armACAAC_Tables.h"static OMX_S32 armACAAC_Rescale(        OMX_S32 Value,        OMX_INT signBit,         OMX_S16 scalefactor        );/** * Function:  omxACAAC_QuantInv_S32_I   (3.2.3.2.1) * * Description: * Inverse quantize the Huffman symbols for current channel. The equation is  * shown below: * *  pSrcDst[i] = sign( pSrcDst[i]) * (pSrcDst[i])^(4/3) * 2^( pScalefactor[sfb] - 100)) * * Reference: [ISO14496-3], sub-clause 4.6.1  * * Input Arguments: *    *   pSrcDstSpectralCoef - pointer to the quantized coefficients extracted  *            from the input stream by the Huffman decoder.  The quantized  *            coefficients are integer values represented using Q0, i.e., no  *            scaling.  For short blocks the coefficients are interleaved by  *            scalefactor window bands in each group. Buffer must have  *            sufficient space to contain 1024 elements.  *   pScalefactor - pointer to the scalefactor buffer, of length 120  *   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  *   pSfbCb - pointer to the scalefactor band codebook, of length 120. Only  *            maxSfb elements for each group are meaningful. There are no  *            spaces between the sequence groups.  *   samplingRateIndex - sampling rate index. Valid in [0, 11]  *   winLen - the data number in one window  * * Output Arguments: *    *   pSrcDstSpectralCoef - pointer to the inverse quantized coefficient  *            array, in Q28.3 format and of length 1024. For short blocks, the  *            coefficients are interleaved by scalefactor window bands in each  *            group.  * * Return Value: *     *    OMX_Sts_NoErr - no error  *    OMX_Sts_BadArgErr - bad arguments: *    -    At least one of the following pointers is NULL:  *         - pSrcDstSpectralCoef,  *         - pScalefactor,  *         - pWinGrpLenor  *         - pSfbCb  *    -    If short block, and numWinGrp exceeds [1, 8]  *    -    If long block, and numWinGrp!= 1  *    -    maxSfb exceeds [0, 51]  *    -    samplingRateIndex exceeds [0, 11]  *    -    winLen is neither 1024 nor 128  *    OMX_StsACAAC_CoefValErr - an input coefficient value contained in the  *              array referenced by pSrcDstSpectralCoef exceeds the  *              range [-8191, 8191]. *    OMX_StsACAAC_MaxSfbErr - invalid maxSfb value in relation to numSwb  * */ OMXResult omxACAAC_QuantInv_S32_I(     OMX_S32 *pSrcDstSpectralCoef,     const OMX_S16 *pScalefactor,     OMX_INT numWinGrp,     const OMX_INT *pWinGrpLen,     OMX_INT maxSfb,     const OMX_U8 *pSfbCb,     OMX_INT samplingRateIndex,     OMX_INT winLen ){    const OMX_U16 *pOffsetTable;    OMX_U16 width,numSwb;    OMX_INT groupNum,sfbNum,signBit;    OMX_INT winNum,coeffNum,cbNum;    OMX_S32 Value;    OMX_S16 scale;        /* Argument Check */            armRetArgErrIf(pSrcDstSpectralCoef == NULL , OMX_Sts_BadArgErr);    armRetArgErrIf(pScalefactor        == NULL , OMX_Sts_BadArgErr);    armRetArgErrIf(pWinGrpLen          == NULL , OMX_Sts_BadArgErr);    armRetArgErrIf(pSfbCb              == 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( ( 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 ++ )        {            cbNum = *pSfbCb++;            scale = *pScalefactor++;                        width = pOffsetTable[sfbNum + 1] - pOffsetTable[sfbNum];                        if(                cbNum != ARM_AAC_ZERO_HCB       &&                cbNum != ARM_AAC_NOISE_HCB      &&                cbNum != ARM_AAC_INTENSITY_HCB2 &&                cbNum != ARM_AAC_INTENSITY_HCB                 )            {                for(winNum = 0 ; winNum < pWinGrpLen[groupNum] ; winNum++ )                {                    for(coeffNum = 0; coeffNum < width ; coeffNum++ )                    {                        Value = *pSrcDstSpectralCoef;                                                signBit  = 1;                                                if(Value < 0)                        {                            Value   = -Value;                            signBit = -1;                        }                                                armRetDataErrIf(Value > 8191, OMX_StsACAAC_CoefValErr)                        Value = armACAAC_Rescale( Value, signBit, scale );                                            *pSrcDstSpectralCoef++ = Value;                    }                }            }            else            {                pSrcDstSpectralCoef += pWinGrpLen[groupNum]*width;            }        }    }    return OMX_Sts_NoErr;}/** * Function: armACAAC_Rescale * * Description: * Scales input with 2^( (scalefactor - 100)/ 4) * * Parameters: * [in]  Value	     the input to be scaled * [in]  scalefactor scaling coefficient * * Return Value: * The scaled value of the input * */static OMX_S32 armACAAC_Rescale(OMX_S32 Value, OMX_INT signBit, OMX_S16 scalefactor){    OMX_F64 ValueFl;    ValueFl = pow((OMX_F64)Value, 4.0/3);    ValueFl = ValueFl * pow( 2 , (scalefactor - 100)/4.0 );    ValueFl *= (1 << ARM_AAC_Q_FACTOR );    ValueFl *= signBit;        Value = armSatRoundFloatToS32(ValueFl);        return Value;}/* End of File */

⌨️ 快捷键说明

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