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

📄 gaecnlps.c

📁 TI公司DSP/tms320c55x/tms320c54x系列的声学回声消除代码
💻 C
字号:
/*-------------------------------------------------------------------------*
 *                                                                         *
 *   THIS IS AN UNPUBLISHED WORK CONTAINING CONFIDENTIAL AND PROPRIETARY   *
 *   INFORMATION.  IF PUBLICATION OCCURS, THE FOLLOWING NOTICE APPLIES:    *
 *      "COPYRIGHT 2002 MIKET DSP SOLUTIONS, ALL RIGHTS RESERVED"          *
 *                                                                         *
 *-------------------------------------------------------------------------*/

#include "gaeci.h"

/*--------------------- local defs ----------------------------------------*/


#define _TCL_MIN                (GAEC_DB(10))

#define _MULT                   (31821)
#define _INC                    (13849)

/*--------------------- public vars ---------------------------------------*/
/*--------------------- local vars ----------------------------------------*/
/*--------------------- local functions -----------------------------------*/
/*-------------------------------------------------------------------------*/

////////////////////////////    NLP    //////////////////////////////////////
/* ------------------------------------------------------------------------ */
#if !defined(_dsp)
void                        gaec_nlp_add_noise
#else
void                        gaec_nlp_add_noiseC
#endif
/* ------------------------------------------------------------------------ */
(
S16 *psSeed,
S16 *psTo,
S16 sLevel
)
{
    int k;
    S16 t = _MULT;
    S16 b = _INC;
    S32 ac0;

    for (k = 0; k < GAEC_ERR_SZ; k++)
    {
        ac0 = *psSeed * (S32) t;
        ac0 += b;
        *psSeed = (S16)ac0;
        ac0 = *psSeed * (S32) sLevel;
//        *psTo++ += _srnd(ac0, 3);
        // the sLevel is 8 times higher than it should be,
        // so we shift the last accumulator accordingly...
#if 0        
        *psTo++ += _Srnd(ac0, 0);
#else
		ac0 += ((S32)*psTo) << 15;
		*psTo++ = _Srnd(ac0, 0);
#endif        
    }
}

/*-------------------------------------------------------------------------*/
#if !defined(_dsp)
void                        gaec_nlp_mix_noise
#else
void                        gaec_nlp_mix_noiseC
#endif
/*-------------------------------------------------------------------------*/
(
GAEC_tDb *pDb,
GAEC_tSc *pSc,
U16 uUseDtCrit
)
{
// asTmp use: GAEC_BANDS*2
    int band;
//    int idx;
//    S32 ac0;
//    S16 coef;
//    S16 sLevel;

#if 1   
    S16 sCorr = GAEC_DB(13.0);

    // correct for expected nse reduction...
    // what would be better is to avarage NR gain and apply it here
    if (!(pDb->uControl & IGAEC_CMD_NSE_RED_OFF))
    {
        sCorr = GAEC_DB(6.0);
    }

    for (band = 0; band < GAEC_BANDS+1; band++)
    {
        pSc->u.asTmp[band] = pDb->asVadErrNse[band] + sCorr;
    }

    for (band = 0; band < GAEC_BANDS+1; band++)
    {
    	pSc->u.asTmp[band] = 
#if defined(_dsp)    
    		gaec_utl_expC
#else    		
    		gaec_utl_exp
#endif    		
    			(pSc->u.asTmp[band]);
    }
    if (uUseDtCrit)
    {
	    for (band = 0; band < GAEC_BANDS+1; band++)
    	{
    		S32 ac0 = 4096- pSc->asAttErr[band];
            ac0 *= pSc->u.asTmp[band];
            pSc->u.asTmp[band] = _Srnd(ac0, 3);
    	}
    }
    for (band = 1; band < GAEC_BANDS; band++)
    {
    	pSc->u.asTmp[band+GAEC_BANDS] = pSc->u.asTmp[band];
    }
    for (band = 0; band < 2*GAEC_BANDS; band++)
    {
#if defined(_dsp)    
        gaec_nlp_add_noiseC(
#else
        gaec_nlp_add_noise(
#endif        
        	&pDb->sNseSav, 
        	&pSc->aasErr0[band][0], 
        	pSc->u.asTmp[band]);
	}
    
#if 0    
#endif	   

#else
    for (band = 0; band < GAEC_BANDS*2; band ++)
    {

        idx = band;
        if (band > GAEC_BANDS)
            idx -= GAEC_BANDS;
//        sLevel = pDb->asNse[idx]-GAEC_DB(15.0);
        // the level is 18 db (8 times, 3 shifts left) higher
        // than needed, to prevent going below 1 - fixed point case
        // that increase is accounted for in the gaec_add_noise();
        sLevel = pDb->asVadErrNse[idx]+GAEC_DB(13.0);
        coef = gaec_utl_expC(sLevel);
        
        if (uUseDtCrit)
        {
            ac0 = 4096 - pSc->asNlpCoef[idx];
            ac0 *= coef;
            coef = _Srnd(ac0, 3);
        }
		pSc->u.asTmp[band] = coef;
        gaec_nlp_add_noiseC(&pDb->sNseSav, &pSc->aasErr0[band][0], coef);
    }
#endif    
}
/*-------------------------------------------------------------------------*/
#if !defined(_dsp)
void                        gaec_nlp_att_rx
#else
void                        gaec_nlp_att_rxC
#endif
/*-------------------------------------------------------------------------*/
(
GAEC_tDb *pDb,
GAEC_tSc *pSc
)
{
// asTmp use: GAEC_BANDS*2
    int band;
    S16 coef;
    int k;
    S32 ac0;

    for (band = 0; band < GAEC_BANDS*2; band++)
    {
        S16 idx = band;
        if (band > GAEC_BANDS)
            idx -= GAEC_BANDS;
        coef = pSc->asAttErr[idx];
        
        // dbg
        pSc->u.asTmp[band] = coef;

        for (k = 0; k < GAEC_ERR_SZ; k++)
        {
            ac0 = pDb->aasErrSav[band][k]*(S32)coef;
            pSc->aasErr0[band][k] = _Srnd(ac0,3);
        }
    }
}


/*--------------------- public  functions ---------------------------------*/

⌨️ 快捷键说明

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