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

📄 omxacaac_decodemspns_s32_i.c

📁 The OpenMAX DL (Development Layer) APIs contain a comprehensive set of audio, video, signal processi
💻 C
字号:
/** *  * File Name:  omxACAAC_DecodeMsPNS_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 Perceptual Noise Substitution for an AAC decoder * */#include<math.h>#include "omxtypes.h"#include "armOMX.h"#include "omxAC.h"#include "armCOMM.h"#include "armAC.h"#include "armACAAC_Tables.h"#define NUMBER_OF_BANDS_SHORT     15/** * Function:  omxACAAC_DecodeMsPNS_S32_I   (3.2.3.6.1) * * Description: * Performs perceptual noise substitution for one channel across all window  * groups and scalefactor bands.  PNS is activated for SFBs labeled in the  * pSfbCb vector to be of type NOISE_HCB. For PNS scalefactor bands, spectral  * coefficients are derived from random vectors rather than from decoded  * Huffman symbols.  * * Reference: [ISO14496-3], sub-clause 4.6.13  * * Input Arguments: *    *   pSrcDstSpec - pointer to the spectral coefficient vector to which PNS  *            should be applied  *   pSrcDstLtpFlag - pointer to LTP used flag  *   pSfbCb - pointer to scalefactor codebook; PNS is applied to SFBs tagged  *            with NOISE_HCB  *   pScaleFactor - pointer to the scalefactor value  *   maxSfb - number of scale factor bands used  *   numWinGrp - number of window group  *   pWinGrpLen - pointer to the length of every window group  *   samplingFreqIndex - sampling frequency index  *   winLen - window length, 1024 for long, 128 for short  *   pRandomSeed - random seed for PNS  *   channel - index of current channel, 0:left, 1:right  *   pMsUsed - pointer to MS used buffer from the CPE structure  *   pNoiseState - pointer to random noise generator seed history buffer, of  *            dimension [OMX_AAC_GROUP_NUM_MAX][OMX_AAC_SF_MAX].  If channel==0,  *            this buffer is used only as an output and the contents upon  *            input are ignored.  If  channel==1 the entries in this buffer  *            are used to seed the PNS random number generator for each  *            scalefactor band in which pMsUsed==1 in order to guarantee L-R  *            correlation in those particular SFBs. Correlation is guaranteed  *            as long as the seed entries were previously stored into this  *            buffer during a prior call to the function with the input  *            parameter channel==0.  * * Output Arguments: *    *   pSrcDstSpec - pointer to updated spectral coefficient vector after  *            completion of PNS  *   pSrcDstLtpFlag - pointer to the LTP used flag  *   pRandomSeed - updated PNS random seed  *   pNoiseState - random seed buffer, of dimension [OMX_AAC_GROUP_NUM_MAX]  *            [OMX_AAC_SF_MAX].  Two possible return conditions are possible:   *            If channel==0, this buffer returns the complete set of left  *            channel random seeds used at the start of PNS synthesis for  *            every scalefactor band in every group for which pSfbCb ==  *            NOISE_HCB.  If channel==1 the buffer is used as an input only  *            and the contents are unchanged from input to output.  * * 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:  *          - pSrcDstSpec,  *          - pSfbCb,  *          - pScaleFactor,  *          - pWinGrpLenor  *          - pSrcDstLtpFlag  *    -    numWinGrp exceeds [1, 8]  *    -    samplingFreqIndex exceeds [0,12]  *    -    winLen is neither 128 nor 1024  *    -    maxSfb not in [0,51]  * */ static OMX_INT armACAAC_GenerateRandomVector(    OMX_S32 *pDstSpec,    OMX_INT seed,    OMX_INT width,    OMX_S16 scale);OMXResult omxACAAC_DecodeMsPNS_S32_I(     OMX_S32 *pSrcDstSpec,     OMX_INT *pSrcDstLtpFlag,     OMX_U8 *pSfbCb,     OMX_S16 *pScaleFactor,     OMX_INT maxSfb,     OMX_INT numWinGrp,     OMX_INT *pWinGrpLen,     OMX_INT samplingFreqIndex,     OMX_INT winLen,     OMX_INT *pRandomSeed,     OMX_INT channel,     OMX_U8 *pMsUsed,     OMX_INT *pNoiseState ){    OMX_INT groupNum,sfbNum,seed = 0;    OMX_INT width,cbNum,msUsed;    OMX_S16 scale;    OMX_U16 numSwb;        const OMX_U16 *pOffsetTable;        /* Argument Check */            armRetArgErrIf( pSrcDstSpec    == NULL, OMX_Sts_BadArgErr);    armRetArgErrIf( pScaleFactor   == NULL, OMX_Sts_BadArgErr);    armRetArgErrIf( pSrcDstLtpFlag == NULL, OMX_Sts_BadArgErr);    armRetArgErrIf( pWinGrpLen     == NULL, OMX_Sts_BadArgErr);    armRetArgErrIf( pSfbCb         == NULL, OMX_Sts_BadArgErr);    armRetArgErrIf( pRandomSeed    == NULL, OMX_Sts_BadArgErr);    armRetArgErrIf( pMsUsed        == NULL, OMX_Sts_BadArgErr);    armRetArgErrIf( pNoiseState    == NULL, OMX_Sts_BadArgErr);    armRetArgErrIf( (maxSfb > 51)  || (maxSfb < 0),   OMX_Sts_BadArgErr);    armRetArgErrIf( (channel != 1) && (channel != 0), OMX_Sts_BadArgErr);    armRetArgErrIf( samplingFreqIndex > 12, OMX_Sts_BadArgErr);     armRetArgErrIf( samplingFreqIndex < 0 , OMX_Sts_BadArgErr);    armRetArgErrIf( (numWinGrp > 8) || (numWinGrp < 1),  OMX_Sts_BadArgErr );    armRetArgErrIf( ( winLen != ARM_AAC_WIN_SHORT ) &&                     ( winLen != ARM_AAC_WIN_LONG  ) ,                    OMX_Sts_BadArgErr );    /* Processing */        if(winLen == ARM_AAC_WIN_SHORT)    {        pOffsetTable = armACAAC_swbOffsetShortWindow[samplingFreqIndex];        numSwb       = armACAAC_numSwbShort[samplingFreqIndex];            }    else    {        pOffsetTable = armACAAC_swbOffsetLongWindow[samplingFreqIndex];        numSwb       = armACAAC_numSwbLong[samplingFreqIndex];    }        armRetArgErrIf( maxSfb > numSwb, OMX_StsACAAC_MaxSfbErr);        seed = *pRandomSeed;                                for( groupNum = 0; groupNum < numWinGrp; groupNum++ )    {        for( sfbNum = 0; sfbNum < maxSfb; sfbNum ++ )        {            cbNum  = *pSfbCb++;            scale  = *pScaleFactor++;            msUsed = pMsUsed[sfbNum];                        width  = pOffsetTable[sfbNum + 1] - pOffsetTable[sfbNum];            width  = width * pWinGrpLen[groupNum];                        if( cbNum == ARM_AAC_NOISE_HCB )            {                if(winLen == ARM_AAC_WIN_LONG)                {                    pSrcDstLtpFlag[sfbNum] = 0;                }                if(msUsed == 1)                {                    /*Two channels are correlated*/                    if (channel == 0)                    {                        /* Left Channel */                        /* Stores the seed used, for the right channel */                        pNoiseState[groupNum * NUMBER_OF_BANDS_SHORT + sfbNum] = seed;                    }                    else                    {                        /* Right Channel */                        /* Uses the stored seed */                        seed = pNoiseState[groupNum * NUMBER_OF_BANDS_SHORT + sfbNum];                    }                }                else if(channel == 1)                {                    seed = *pRandomSeed;                                        }                seed = armACAAC_GenerateRandomVector(pSrcDstSpec,seed,width,scale);                                if( ( (msUsed == 0) && (channel == 1)) || (channel == 0) )                {                    *pRandomSeed = seed;                }            }            pSrcDstSpec += width;        }        pNoiseState += OMX_AAC_SF_MAX;        pMsUsed     += OMX_AAC_SF_MAX;    }    return OMX_Sts_NoErr;}/** *  * Function: armACAAC_GenerateRandomVector * * Description: * Generates random vector to be used in PNS tool * * * Parameters: * [in]  pDstSpec     pointer to spectrum coefficients to be PNS *                      represented in Q13.18 format. * [in]  seed       random seed for PNS * [in]  width      size of the vector to be generated * [in]  scale      Scaling value to applied on generated vector * * [out] pDstSpec   pointer to the output spectrum substituted by *                        perceptual noise;represented in Q13.18 format.  * * Return Value: * seed: the modified random seed. * */ static OMX_INT armACAAC_GenerateRandomVector(    OMX_S32 *pDstSpec,    OMX_INT seed,    OMX_INT width,    OMX_S16 scale){    OMX_INT coeffNum;    OMX_F64 temp,power = 0;    OMX_F64 coeff,scaleValue;        for(coeffNum = 0 ; coeffNum < width ; coeffNum++)    {        seed   = seed*(ARM_AAC_RAND_MULT) + (ARM_AAC_RAND_ADD);         temp   = (OMX_F64)seed/8.0;        power += (temp*temp);                pDstSpec[coeffNum] = seed;    }        /* Scaling the Noise energy */        scaleValue  = pow( 2.0, 0.25 * scale);    scaleValue *= ( 1/sqrt(power) );    for(coeffNum = 0; coeffNum < width ; coeffNum++ )    {        coeff  = (OMX_F64)pDstSpec[coeffNum];        coeff *= scaleValue;        coeff *= (1/8.0);        pDstSpec[coeffNum] = armSatRoundFloatToS32(coeff * (1 << ARM_AAC_Q_FACTOR)) ;    }    return seed;}/*End Of file*/

⌨️ 快捷键说明

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