亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? decoder.cpp

?? G711語音壓縮源碼
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
//#include "stdafx.h"
#include <math.h>
#include <memory.h>
#include <float.h>

#include "LanAudio.h"
#include "Global.h"

unsigned char linear2alaw(_int16	pcm_val);
_int16 alaw2linear(unsigned char  a_val);
unsigned char linear2ulaw(_int16	pcm_val);
_int16 ulaw2linear(unsigned char	u_val);
unsigned char alaw2ulaw(unsigned char	aval);
unsigned char ulaw2alaw(unsigned char	uval);

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CLanAudioDecoder::CLanAudioDecoder(BOOL bPostFilter,EAudioCodec nCodec)
{
	UsePf = bPostFilter;
    Init_Decod();
    Init_Dec_Cng();
//	OutputDebugString("Audio Decoder Inited\n");
	m_nCodec = nCodec;
	m_bMute = FALSE;
}

CLanAudioDecoder::~CLanAudioDecoder()
{
}
int CLanAudioDecoder::DecodeG711(unsigned char * input,short* decode)
{
	unsigned char * org_input = input;
	short* org_decode = decode;

	if(m_bMute)
		for(int i = 0; i < G711_Frame; i++){
			*decode = 0;
			decode ++;
		}
	else{ 
		if(m_nCodec==G711_A)
			for(int i = 0; i < G711_Frame; i++){
				*decode = alaw2linear(*input);
				input ++;
				decode ++;
			}
		else
			for(int i = 0; i < G711_Frame; i++){
				*decode = ulaw2linear(*input);
				input ++;
				decode ++;
			}
	}

	input = org_input;
	decode = org_decode;
	return(G711_Frame);
}

int CLanAudioDecoder::DecodeG723(short * iFrame, char * cCode)
{
	int i, iInfo, iSize;

    short Crc = (short) 0;
    Decod(DataBuff, cCode, Crc);

    for (i = 0; i < Frame; i ++)
    {
        if (DataBuff[i] < (float)-32767.5)
            iFrame[i] = -32768L;
        else if (DataBuff[i] > (float)32766.5)
            iFrame[i] = 32767;
        else
        {
            if (DataBuff[i] < 0)
                iFrame[i] = (short) (DataBuff[i]-(float)0.5);
            else
                iFrame[i] = (short) (DataBuff[i]+(float)0.5);
        }
    }

    iInfo = cCode[0] & 0x0003;

    /* Check frame type and rate information */
    switch (iInfo) 
	{
        case 0x0002 : {  /* SID frame */
            iSize = 4;
            break;
        }

        case 0x0003 : {  /* untransmitted silence frame */
            iSize = 1;
            break;
        }

        case 0x0001 : {  /* active frame, low rate */
            iSize = 20;
            break;
        }

        default : {      /* active frame, high rate */
            iSize = 24;
        }
    }
	return iSize;
}

int CLanAudioDecoder::Decode(short * iFrame, char * cCode)
{
	switch (m_nCodec){
	case G711_A:
	case G711_U:
		return(DecodeG711((unsigned char *)cCode,iFrame));
		break;
	case G723:
		return(DecodeG723(iFrame,cCode));
		break;
	default:
		return(0);
		break;
	}
}

/*
**
** Function:        Init_Decod()
**
** Description:     Initializes non-zero state variables
**          for the decoder.
**
** Links to text:   Section 3.11
**
** Arguments:       None
**
** Outputs:     None
**
** Return value:    None
**
*/
void  CLanAudioDecoder::Init_Decod(void)
{
    int i;

    /* Initialize decoder data structure with zeros */
    ::memset(&DecStat,0,sizeof(DECSTATDEF));

    /* Initialize the previously decoded LSP vector to the DC vector */
    for (i = 0; i < LpcOrder; i++)
        DecStat.PrevLsp[i] = LspDcTable[i];

    DecStat.Gain = (float)1.0;
}

/*
**
** Function:        Init_Dec_Cng()
**
** Description:     Initialize Dec_Cng static variables
**
** Links to text:
**
** Arguments:       None
**
** Outputs:         None
**
** Return value:    None
**
*/
void CLanAudioDecoder::Init_Dec_Cng(void)
{
    int i;

    DecCng.PastFtyp = 1;
    DecCng.SidGain = (float)0.0;
    for (i=0; i<LpcOrder; i++)
        DecCng.LspSid[i] = LspDcTable[i];
    DecCng.RandSeed = 12345;
    return;
}

/*
**
** Function:        Decod()
**
** Description:     Implements G.723.1 dual-rate decoder for  a frame
**          of speech
**
** Links to text:   Section 3
**
** Arguments:
**
**  float  *DataBuff    Empty buffer
**  short Vinp[]       Encoded frame (22/26 bytes)
**

** Outputs:
**
**  float  DataBuff[]   Decoded frame (480 bytes)
**
** Return value:
**
**  BOOL            Always TRUE
**
*/

BOOL  CLanAudioDecoder::Decod(float *DataBuff, char *Vinp, short Crc)
{
    int      i, j, g;

    float    Senr;
    float    QntLpc[SubFrames*LpcOrder];
    float    AcbkCont[SubFrLen];

    float    LspVect[LpcOrder];
    float    Temp[PitchMax+Frame];
    float   *Dpnt;

    LINEDEF  Line;
    PFDEF    Pf[SubFrames];

    short   Ftyp;

    /*
     * Decode the packed bitstream for the frame.  (Text: Section 4;
     * pars of sectio,d 2.17, 2.18)
     */
    Line = Line_Unpk(Vinp, &Ftyp, Crc);

    if (Line.Crc != (short) 0) {
        if(DecCng.PastFtyp == 1)
            Ftyp = 1;  /* active */
        else
            Ftyp = 0;  /* untransmitted */
    }

    if (Ftyp != 1) {

        /* Silence frame : do noise generation */
        Dec_Cng(Ftyp, &Line, DataBuff, QntLpc);
    }
    else {

        /*
         * Update the frame erasure count (Text: Section 3.10)
         */
        if (Line.Crc != 0)
            DecStat.Ecount++;
        else
            DecStat.Ecount = 0;

        if (DecStat.Ecount >  ErrMaxNum)
            DecStat.Ecount = ErrMaxNum;

        /*
         * Decode the LSP vector for subframe 3.  (Text: Section 3.2)
         */
        Lsp_Inq(LspVect, DecStat.PrevLsp, Line.LspId, Line.Crc);

        /*
         * Interpolate the LSP vectors for subframes 0--2.  Convert the
         * LSP vectors to LPC coefficients.  (Text: Section 3.3)
         */
        Lsp_Int(QntLpc, LspVect, DecStat.PrevLsp);

        /* Copy the LSP vector for the next frame */
        for ( i = 0 ; i < LpcOrder ; i ++ )
            DecStat.PrevLsp[i] = LspVect[i];

        /*
         * In case of no erasure, update the interpolation gain memory.
         * Otherwise compute the interpolation gain (Text: Section 3.10)
         */
        if (DecStat.Ecount == 0) {
            g = (Line.Sfs[SubFrames-2].Mamp + Line.Sfs[SubFrames-1].Mamp) >> 1;
            DecStat.InterGain = FcbkGainTable[g];
        }
        else
            DecStat.InterGain = DecStat.InterGain*(float)0.75;

        /*
         * Generate the excitation for the frame
         */
        for (i = 0; i < PitchMax; i++)
            Temp[i] = DecStat.PrevExc[i];

        Dpnt = &Temp[PitchMax];

        if (DecStat.Ecount == 0) {

            for (i = 0; i < SubFrames; i++) {

                /* Generate the fixed codebook excitation for a
                   subframe. (Text: Section 3.5) */
                Fcbk_Unpk(Dpnt, Line.Sfs[i], Line.Olp[i>>1], i);

                /* Generate the adaptive codebook excitation for a
                   subframe. (Text: Section 3.4) */
                Decod_Acbk(AcbkCont, &Temp[SubFrLen*i], Line.Olp[i>>1],
                           Line.Sfs[i].AcLg, Line.Sfs[i].AcGn);

                /* Add the adaptive and fixed codebook contributions to
                   generate the total excitation. */

                for (j = 0; j < SubFrLen; j++)
                    Dpnt[j] = Dpnt[j] + AcbkCont[j];

                Dpnt += SubFrLen;
            }

            /* Save the excitation */
            for (j = 0; j < Frame; j++)
                DataBuff[j] = Temp[PitchMax+j];

            /* Compute interpolation index. (Text: Section 3.10) */
            /* Use DecCng.SidGain to store                       */
            /* excitation energy estimation                      */
            DecStat.InterIndx = Comp_Info(Temp, Line.Olp[SubFrames/2-1],
                                          &DecCng.SidGain);

            /* Compute pitch post filter coefficients.  (Text: Section 3.6) */
            if (UsePf)
                for (i = 0; i < SubFrames; i++)
                    Pf[i] = Comp_Lpf(Temp, Line.Olp[i>>1], i);

            /* Reload the original excitation */
            for (j = 0; j < PitchMax; j++)
                Temp[j] = DecStat.PrevExc[j];
            for (j = 0; j < Frame; j++)
                Temp[PitchMax+j] = DataBuff[j];

            /* Clip newly generated samples in Temp array */
            for (j = 0; j < Frame; j++) {
                if (Temp[PitchMax+j] < (float)-32767.5)
                    Temp[PitchMax+j] = (float)-32768.0;
                else if (Temp[PitchMax+j] > (float)32766.5)
                    Temp[PitchMax+j] = (float)32767.0;
            }

            /* Perform pitch post filtering for the frame.  (Text: Section
               3.6) */
            if (UsePf)
                for (i = 0; i < SubFrames; i++)
                    Filt_Lpf(DataBuff, Temp, Pf[i], i);

            /* Save Lsps --> LspSid */
            for (i=0; i < LpcOrder; i++)
                DecCng.LspSid[i] = DecStat.PrevLsp[i];
        }
        else {
            /* If a frame erasure has occurred, regenerate the
               signal for the frame. (Text: Section 3.10) */
            Regen(DataBuff, Temp, DecStat.InterIndx, DecStat.InterGain,
                  DecStat.Ecount, &DecStat.Rseed);
        }

        /* Update the previous excitation for the next frame */
        for (j = 0; j < PitchMax; j++)
            DecStat.PrevExc[j] = Temp[Frame+j];

        /* Resets random generator for CNG */
        DecCng.RandSeed = 12345;
    }

    /* Save Ftyp information for next frame */
    DecCng.PastFtyp = Ftyp;

    /*
     * Synthesize the speech for the frame
     */
    Dpnt = DataBuff;
    for (i = 0; i < SubFrames; i++) {

        /* Compute the synthesized speech signal for a subframe.
         * (Text: Section 3.7)
         */
        Synt(Dpnt, &QntLpc[i*LpcOrder]);

        if (UsePf) {

            /* Do the formant post filter. (Text: Section 3.8) */
            Senr = Spf( Dpnt, &QntLpc[i*LpcOrder] ) ;

            /* Do the gain scaling unit.  (Text: Section 3.9) */
            Scale(Dpnt, Senr);
        }

        Dpnt += SubFrLen;
    }

    return TRUE;
}

/*
**
** Function:           Dec_Cng()
**
** Description:        Receives Ftyp
**                     0  :  for untransmitted frames
**                     2  :  for SID frames
**                     Decodes SID frames
**                     Computes current frame excitation
**                     Computes current frame LSPs
**
** Links to text:
**
** Arguments:
**
**  short  Ftyp       Type of silence frame
**  LINEDEF *Line      Coded parameters
**  float   *DataExc   Current frame excitation
**  float   *QntLpc    Interpolated frame LPC coefficients
**
** Outputs:
**
**  float   *DataExc
**  float   *QntLpc
**
** Return value:       None
**
*/
void CLanAudioDecoder::Dec_Cng(short Ftyp, LINEDEF *Line, float *DataExc, float *QntLpc)
{
    short temp;
    int i;

    if (Ftyp == 2) {
        /*
         * SID Frame decoding
         */

        DecCng.SidGain = Dec_SidGain((short) Line->Sfs[0].Mamp);

        /* Inverse quantization of the LSP */
        Lsp_Inq(DecCng.LspSid, DecStat.PrevLsp, Line->LspId, 0);
    }
    else {

        /*
         * non SID Frame
         */
        if (DecCng.PastFtyp == 1) {
            /*
             * Case of 1st SID frame erased : quantize-decode
             * energy estimate stored in DecCng.SidGain
             * scaling factor in DecCng.CurGain
             */
            temp = Qua_SidGain(&DecCng.SidGain, 0);
            DecCng.SidGain = Dec_SidGain(temp);
        }
    }

    if (DecCng.PastFtyp == 1) {
        DecCng.CurGain = DecCng.SidGain;
    }
    else {
        DecCng.CurGain =   (float) 0.875 * DecCng.CurGain
                         + (float) 0.125 * DecCng.SidGain;
    }
    Calc_Exc_Rand(DecCng.CurGain, DecStat.PrevExc, DataExc,
                    &DecCng.RandSeed, Line);

    /* Interpolate the Lsp vectors */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产一区二区在线观看| 国产日产欧产精品推荐色| 狠狠色狠狠色合久久伊人| 国产精品美女久久久久av爽李琼| 欧美日韩亚洲综合在线| 国产精品香蕉一区二区三区| 婷婷开心激情综合| 国产精品理伦片| 精品精品国产高清一毛片一天堂| 91亚洲精品久久久蜜桃| 国产乱码字幕精品高清av | 亚洲综合色婷婷| 久久亚洲精品小早川怜子| 欧美日韩精品一区视频| av日韩在线网站| 国产一区二区三区精品视频| 性做久久久久久免费观看| 亚洲男人的天堂一区二区| 久久影院午夜片一区| 555www色欧美视频| 色av综合在线| 91麻豆国产福利精品| 99视频在线精品| 高清久久久久久| 国产乱子伦视频一区二区三区| 免费观看久久久4p| 日韩精品成人一区二区在线| 亚洲一区二区偷拍精品| 亚洲欧洲一区二区在线播放| 国产目拍亚洲精品99久久精品| 2023国产精华国产精品| 欧美一卡2卡三卡4卡5免费| 欧美色精品在线视频| 91免费看视频| 色呦呦日韩精品| 91一区二区在线| 一本到不卡免费一区二区| av网站免费线看精品| 99re6这里只有精品视频在线观看| 国产成人精品免费一区二区| 高清国产一区二区三区| 丰满岳乱妇一区二区三区| 成人激情小说网站| jlzzjlzz亚洲女人18| 色综合久久中文字幕综合网| 99精品在线免费| 91福利小视频| 91麻豆精品国产91| 欧美一区二区在线免费观看| 日韩视频国产视频| 久久久久国产精品人| 国产精品五月天| 亚洲天堂a在线| 亚洲观看高清完整版在线观看| 午夜精品久久久久久久99樱桃| 天天亚洲美女在线视频| 蜜桃精品在线观看| 国产麻豆9l精品三级站| 成人av资源网站| 欧美日韩一区二区三区高清| 欧美高清性hdvideosex| 欧美精品一区男女天堂| 国产精品久久久久一区二区三区共| 亚洲欧美综合在线精品| 午夜伊人狠狠久久| 精品一区二区三区在线视频| 国产成人一区在线| 色综合网色综合| 日韩一卡二卡三卡四卡| 国产欧美日韩在线视频| 亚洲欧美另类综合偷拍| 丝袜美腿亚洲一区| 国内精品嫩模私拍在线| www.日本不卡| 7777精品伊人久久久大香线蕉| 久久久久久久久久久久久久久99| 国产精品国产精品国产专区不片| 亚洲一区二区精品久久av| 欧美日韩午夜在线视频| 日韩三级免费观看| 中文字幕五月欧美| 免费在线观看视频一区| av成人免费在线| 日韩美女视频一区二区在线观看| 国产精品美女久久久久aⅴ| 日韩专区欧美专区| 成人免费视频网站在线观看| 欧美日韩国产大片| 欧美国产日本韩| 日韩高清不卡在线| 91影视在线播放| 亚洲精品在线电影| 亚洲制服丝袜一区| 国产精品羞羞答答xxdd| 91精品视频网| 亚洲人午夜精品天堂一二香蕉| 日本欧美一区二区在线观看| 成人黄色软件下载| 日韩欧美一级二级三级| 亚洲精品日产精品乱码不卡| 国产在线不卡一卡二卡三卡四卡| 欧美中文字幕久久| 国产日韩影视精品| 石原莉奈一区二区三区在线观看 | 欧美体内she精高潮| 欧美国产综合一区二区| 亚洲午夜视频在线观看| 99视频在线精品| 久久久不卡网国产精品一区| 视频一区二区三区在线| 日本电影欧美片| 亚洲欧美综合在线精品| 成人午夜电影久久影院| 欧美成人video| 蜜桃在线一区二区三区| 欧美区视频在线观看| 亚洲精品欧美专区| 99re这里都是精品| 国产精品夫妻自拍| 国产不卡视频在线观看| 欧美大胆一级视频| 日韩一区精品视频| 欧美亚洲国产一区二区三区va | 福利电影一区二区三区| 精品成人在线观看| 秋霞影院一区二区| 91精品国产综合久久蜜臀| 亚洲一区二区三区四区在线免费观看| 成人免费视频免费观看| 国产欧美1区2区3区| 国产成a人亚洲精| 中文字幕av一区二区三区免费看| 国产精品亚洲一区二区三区妖精 | 五月婷婷激情综合网| 欧美在线视频全部完| 亚洲九九爱视频| 91国产成人在线| 亚洲亚洲精品在线观看| 欧美色大人视频| 日韩激情在线观看| 欧美猛男男办公室激情| 日韩精品午夜视频| 日韩亚洲电影在线| 国产一区美女在线| 欧美韩日一区二区三区| 成人一区二区三区视频在线观看 | 欧美精品在线观看一区二区| 日韩国产高清在线| 精品国产三级a在线观看| 国内精品免费**视频| 久久久久久久免费视频了| 成人三级伦理片| 一区二区三区在线免费观看| 欧美日韩一区三区| 久久精品国产精品青草| 久久久影院官网| 91亚洲资源网| 日本视频免费一区| 久久精品视频在线免费观看| voyeur盗摄精品| 亚洲国产精品自拍| 日韩精品在线一区| 成人在线综合网站| 亚洲精品国产一区二区三区四区在线| 欧美视频一区二区在线观看| 老色鬼精品视频在线观看播放| 国产日韩高清在线| 色www精品视频在线观看| 日韩1区2区3区| 国产日韩在线不卡| 欧美日韩一区二区欧美激情| 免费观看日韩av| 亚洲视频精选在线| 日韩女同互慰一区二区| 不卡免费追剧大全电视剧网站| 亚洲永久精品大片| 欧美精品一区男女天堂| 色综合久久久久久久久| 日本亚洲视频在线| 国产精品丝袜在线| 91精品国产综合久久久久久久久久 | 天堂午夜影视日韩欧美一区二区| 欧美v日韩v国产v| www.久久精品| 久久精品国产一区二区| 国产精品久久久久三级| 日韩三级在线观看| 在线免费av一区| 国产成人精品影视| 偷拍一区二区三区四区| 中文字幕欧美国产| 91麻豆精品91久久久久同性| youjizz国产精品| 国产资源精品在线观看| 亚洲综合精品自拍| 中文字幕的久久| 日韩西西人体444www| 欧美亚洲图片小说| 91一区一区三区| 高清日韩电视剧大全免费|