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

📄 vadg729.c

📁 G.729 and G.723.1 codecs x86 (and x86_64) Linux and FreeBSD source code for Asterisk open source PBX
💻 C
📖 第 1 页 / 共 2 页
字号:
/*/////////////////////////////////////////////////////////////////////////////////                  INTEL CORPORATION PROPRIETARY INFORMATION//     This software is supplied under the terms of a license agreement or//     nondisclosure agreement with Intel Corporation and may not be copied//     or disclosed except in accordance with the terms of that agreement.//          Copyright(c) 2005-2007 Intel Corporation. All Rights Reserved.////     Intel(R) Integrated Performance Primitives//     USC - Unified Speech Codec interface library//// By downloading and installing USC codec, you hereby agree that the// accompanying Materials are being provided to you under the terms and// conditions of the End User License Agreement for the Intel(R) Integrated// Performance Primitives product previously accepted by you. Please refer// to the file ippEULA.rtf or ippEULA.txt located in the root directory of your Intel(R) IPP// product installation for more information.//// A speech coding standards promoted by ITU, ETSI, 3GPP and other// organizations. Implementations of these standards, or the standard enabled// platforms may require licenses from various entities, including// Intel Corporation.////// Purpose: G.729/A/B/D/E vad: VAD functions.//*/#include "vadg729.h"#include "aux_fnxs.h"#define     ZEROcrossBegin  120#define     VADinitFrame    32#define     ZEROcrossEnd    200static __ALIGN32 CONST Ipp16s lbfCorr[VAD_LPC_DIM +1] = { 7869, 7011, 4838, 2299, 321,    -660, -782, -484, -164, 3, 39, 21, 4};static __ALIGN32 CONST Ipp16s ifactor[33] = {  IPP_MAX_16S, 16913, 17476, 18079,    18725, 19418, 20165, 20972, 21845, 22795, 23831, 24966,    26214, 27594,    29127, 30840, IPP_MAX_16S, 17476, 18725, 20165, 21845, 23831, 26214, 29127,    IPP_MAX_16S, 18725, 21845, 26214, IPP_MAX_16S, 21845, IPP_MAX_16S, IPP_MAX_16S, 0};static __ALIGN32 CONST Ipp16s ishift[33] = { 15, (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1),    (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), 13, 13, 13, 13, 13, 13, 13, 13, 12, 12,    12, 12, 11, 11, 10, 15};#if defined(__ICL ) && defined(_IPP_A6)static Ipp32s ownSignChangeRate_A6(Ipp16s *pSrc /* [ZEROcrossEnd-ZEROcrossBegin+1] */) {    Ipp32s i,ll;    Ipp32s sum=0;    __m64 m1,m2,m3,m4,mmSum,left_3_zer0;    mmSum = _mm_setzero_si64();    left_3_zer0 = _mm_set_pi16(0,0,0,0xffff);    i = 0;    m1    = *(__m64*)&pSrc[i];       /* m1 = first 4 */    for(i+=16; i<=ZEROcrossEnd-ZEROcrossBegin; i+=16) {        m3    = *(__m64*)&pSrc[i-12];/* m3 = second 4 */        m2    = _mm_srli_si64(m1,16);        m4    = _mm_slli_si64(m3,48);        m4    = _mm_or_si64(m4,m2);        m1    = _mm_mulhi_pi16(m1,m4);        m1    = _mm_srli_pi16(m1,15);/* get the sign bit to lowest position*/        mmSum = _mm_add_pi16(mmSum,m1);        m1    = *(__m64*)&pSrc[i-8]; /* m1 = third 4 */        m2    = _mm_srli_si64(m3,16);        m4    = _mm_slli_si64(m1,48);        m4    = _mm_or_si64(m4,m2);        m3    = _mm_mulhi_pi16(m3,m4);        m3    = _mm_srli_pi16(m3,15);/* get the sign bit to lowest position*/        mmSum = _mm_add_pi16(mmSum,m3);        m3    = *(__m64*)&pSrc[i-4]; /* m3 = fourth 4 */        m2    = _mm_srli_si64(m1,16);        m4    = _mm_slli_si64(m3,48);        m4    = _mm_or_si64(m4,m2);        m1    = _mm_mulhi_pi16(m1,m4);        m1    = _mm_srli_pi16(m1,15);/* get the sign bit to lowest position*/        mmSum = _mm_add_pi16(mmSum,m1);        m1    = *(__m64*)&pSrc[i];   /* m1 = fifth 4 */        m2    = _mm_srli_si64(m3,16);        m4    = _mm_slli_si64(m1,48);        m4    = _mm_or_si64(m4,m2);        m3  = _mm_mulhi_pi16(m3,m4);        m3    = _mm_srli_pi16(m3,15);/* get the sign bit to lowest position*/        mmSum = _mm_add_pi16(mmSum,m3);    }    /* sum the lower 4 counts to 1*/    m1    = mmSum;    m1    = _mm_srli_si64(m1,32);    mmSum = _mm_add_pi16(mmSum,m1);    m1    = mmSum;    m1    = _mm_srli_si64(m1,16);    mmSum = _mm_add_pi16(mmSum,m1);    mmSum = _mm_and_si64(mmSum,left_3_zer0);    ll    = _mm_cvtsi64_si32(mmSum);    sum  += ll;    _mm_empty();    return sum;}#elsestatic Ipp32s ownSignChangeRate(Ipp16s *pSrc /* [ZEROcrossEnd-ZEROcrossBegin+1] */) {    Ipp32s i;    Ipp32s sum=0;    for(i=1; i<=ZEROcrossEnd-ZEROcrossBegin; i++)        sum += (pSrc[i-1] * pSrc[i] < 0);    return sum;}#endif/* /////////////////////////////////////////////////////////////////////////////////////////  Name:    ownMakeDecision//  Purpose://  Parameters://  lowBandE       - energy//  highBandE      - fullenergy//  spectrDist     - distortion//  crossZeroRate  - zero crossing*/static Ipp16s ownMakeDecision(Ipp16s lowBandE,Ipp16s highBandE, Ipp16s spectrDist,Ipp16s crossZeroRate) {    Ipp32s L_tmp;    /* spectrDist vs crossZeroRate */    L_tmp = crossZeroRate * (-14680);    L_tmp += BWF_HARMONIC_E * (-28521);    L_tmp = L_tmp >> 7;    if(L_tmp > -spectrDist<<16 )        return 1;    L_tmp = crossZeroRate * 19065;    L_tmp += BWF_HARMONIC_E * (-19446);    L_tmp = L_tmp>>6;    if(L_tmp > -spectrDist<<16)        return 1;    /* highBandE vs crossZeroRate */    L_tmp = crossZeroRate * 20480;    L_tmp += BWF_HARMONIC_E * BWF_HARMONIC;    L_tmp = L_tmp>>1;    if(L_tmp < -highBandE<<16)        return 1;    L_tmp = crossZeroRate * (-BWF_HARMONIC);    L_tmp += BWF_HARMONIC_E * 19660;    L_tmp = L_tmp>>1;    if(L_tmp < -highBandE<<16)        return 1;    L_tmp = highBandE * IPP_MAX_16S;    if(L_tmp < -1024 * 30802)        return 1;    /* highBandE vs spectrDist */    L_tmp = spectrDist * (-28160);    L_tmp += 64 * 19988;    if(L_tmp < -highBandE<<9)        return 1;    L_tmp = spectrDist * IPP_MAX_16S;    if(L_tmp > 32 * 30199)        return 1;    /* lowBandE vs crossZeroRate */    L_tmp = crossZeroRate * (-20480);    L_tmp += BWF_HARMONIC_E * BWF2;    L_tmp = L_tmp >> 1;    if(L_tmp < -highBandE<<16)        return 1;    L_tmp = crossZeroRate * 23831;    L_tmp += (1<<12) * 31576;    L_tmp = L_tmp>>1;    if(L_tmp < -highBandE<<16)        return 1;    L_tmp = highBandE * IPP_MAX_16S;    if(L_tmp < -(1<<11) * 17367        ) return 1;    /* lowBandE vs spectrDist */    L_tmp = spectrDist * (-22400);    L_tmp += (1<<5) * 25395;    if(L_tmp < -lowBandE<<8)        return 1;    /* lowBandE vs highBandE */    L_tmp = highBandE * (-30427);    L_tmp += (1<<8) * (-29959);    if(L_tmp > -lowBandE<<15)        return 1;    L_tmp = highBandE * (-23406);    L_tmp += (1<<9) * 28087;    if(L_tmp < -lowBandE<<15)        return 1;    L_tmp = highBandE * 24576;    L_tmp += (1<<10) * COEFF1;    if(L_tmp < -lowBandE<<14)        return 1;    return 0;}void VoiceActivityDetectInit_G729(Ipp8s* pVADmem) {    VADmemory_Obj* vadMem =  (VADmemory_Obj*)pVADmem;    ippsZero_16s(vadMem->LSFMean, LPF_DIM);    ippsZero_16s(vadMem->minBuf, 16);    vadMem->SEMean = 0;    vadMem->SLEMean = 0;    vadMem->EMean = 0;    vadMem->SZCMean = 0;    vadMem->SILcounter = 0;    vadMem->updateCounter = 0;    vadMem->extCounter = 0;    vadMem->lessCounter = 0;    vadMem->frameCounter = 0;    vadMem->VADflag = 1;    vadMem->minVAD = IPP_MAX_16S;    vadMem->VADPrev  = 1;    vadMem->VADPPrev = 1;    vadMem->minPrev = IPP_MAX_16S;    vadMem->minNext = IPP_MAX_16S;    vadMem->VADPrevEnergy = IPP_MAX_16S;    vadMem->VADflag2 = 0;    ippsZero_16s(vadMem->musicRC, 10);    vadMem->musicCounter=0;    vadMem->musicMCounter=0;    vadMem->conscCounter=0;    vadMem->MeanPgain =BWF_HARMONIC_E;    vadMem->count_pflag=0;    vadMem->Mcount_pflag=0;    vadMem->conscCounterFlagP=0;    vadMem->conscCounterFlagR=0;    vadMem->musicSEMean =0;}void VoiceActivityDetectSize_G729(Ipp32s* pVADsize) {    //pVADsize[0] = (sizeof(VADmemory)+7)&(~7);pVADsize[0] = (sizeof(VADmemory_Obj)+32);}static __ALIGN32 CONST Ipp16s vadTable[6][6]={    {24576, BWF_HARMONIC_E,26214, 6554,19661,PITCH_SHARP_MAX},    {31130, 1638,30147, 2621,21299,11469},    {31785,  983,30802, 1966,BWF2, 9830},    {32440,  328,31457, 1311,24576, BWF_HARMONIC_E},

⌨️ 快捷键说明

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