📄 decodeld.dsp
字号:
/***********************************************************************
* Functions Init_Decod_ld8a and Decod_ld8a *
* $$01/10/2000 checked Dec_ld8a module data variables and function *
* $$01/16/2001 modified and printed,Author: Jason.wang (zhigang wang) *
* $$01/16/2001 Email: wzg119@yeah.net, BP: 86+02195950-161452 *
* $$01/16/2001 This modlue is not optimized! should be test on Emulator*
************************************************************************/
.MODULE/SEG=App_PM Decodeld;
/************************************************************************/
#include "ld8a.inc"
#include "dtx.inc"
#include "Tab_ld8a.inc"
/************************************************************************/
/* $$01/10/2000 static memory and pointer */
/************************************************************************/
/****Excitation vector*************/
.VAR/DM/RAM/SEG=App_DMmem Dec_oldexc[L_FRAME+PIT_MAX+L_INTERPOL],Dec_excit;
.VAR/DM/RAM/SEG=App_DMmem Dec_lspold[M]; /*Lsp (Line spectral pairs) */
.VAR/DM/RAM/SEG=App_DMmem Dec_memsyn[M]; /*Filter's memory */
.VAR/DM/RAM/SEG=App_DMmem Dec_sharp; /* pitch sharpening of previous frame */
.VAR/DM/RAM/SEG=App_DMmem Dec_oldT0; /* integer delay of previous frame */
.VAR/DM/RAM/SEG=App_DMmem Dec_gaincode; /* Code gain */
.VAR/DM/RAM/SEG=App_DMmem Dec_gainpitch; /* Pitch gain */
.VAR/DM/RAM/SEG=App_DMmem seed_fer; /* for G.729B */
.VAR/DM/RAM/SEG=App_DMmem Dec_seed,past_ftyp;
.VAR/DM/RAM/SEG=App_DMmem Dec_sidsav,Dec_sh_sidsav; /* CNG variables */
.GLOBAL Dec_oldexc,Dec_sidsav,Dec_sh_sidsav;
.GLOBAL Dec_oldT0,Dec_memsyn,past_ftyp,Dec_lspold;
.GLOBAL Dec_sharp,Dec_seed,Dec_code,Dec_excit;
/************************************************************************/
.EXTERNAL VadDecode,bad_lsf,SynthDecode;
.EXTERNAL Dec_T2,Az_dec,DecodeParm;
.EXTERNAL D_lsp;
.EXTERNAL Random;
.EXTERNAL Dec_cng;
.EXTERNAL Dec_gain;
.EXTERNAL Syn_filt;
.EXTERNAL Dec_lag3;
.EXTERNAL Int_qlpc;
.EXTERNAL Pred_lt_3;
.EXTERNAL Decode_ACELP;
.EXTERNAL Lsp_decw_reset;
.EXTERNAL Get_decfreq_prev;
.EXTERNAL Init_lsfq_noise;
.EXTERNAL Update_decfreq_prev;
/************************************************************************
* Function Init_Decod_ld8a *
* ->Initialization of variables for the decoder section. *
* $$01/10/2000 used only in decoder *
* Calling Parameters *
* Return Values *
* Altered Registers: MR,SR,AR,I0,I1,I2,I3,AX0,MY0 *
* Computation Time : 18 cycles *
*************************************************************************/
.ENTRY Init_Decod_ld8a;
Init_Decod_ld8a:
I1=^Dec_oldexc;
CNTR=PIT_MAX+L_INTERPOL;
DO zero_old_exc UNTIL CE;
zero_old_exc: DM(I1,M1)=0;
nop;
AR=PASS 0;
// CNTR=M;
I2=^Dec_memsyn;
DM(Dec_excit)=I1;
DM(Dec_gaincode)=AR;
DM(Dec_gainpitch)=AR;
CNTR=M;
DO zero_mem_syn UNTIL CE;
zero_mem_syn: DM(I2,M1)=0;
SI=SHARPMIN;
DM(Dec_sharp)=SI;
SI=60;
DM(Dec_oldT0)=SI;
CALL Lsp_decw_reset;
SI=1;
DM(past_ftyp)=SI;
DM(Dec_sh_sidsav)=SI;
SI=21845;
DM(seed_fer)=SI;
SI=INIT_SEED;
DM(Dec_seed)=SI;
DM(Dec_sidsav)=AR;
CALL Init_lsfq_noise;
I1=^Dec_lspold;
DM(I1,M1)=30000;
DM(I1,M1)=26000;
DM(I1,M1)=21000;
DM(I1,M1)=15000;
DM(I1,M1)=8000;
DM(I1,M1)=0;
DM(I1,M1)=-8000;
DM(I1,M1)=-15000;
DM(I1,M1)=-21000;
DM(I1,M1)=-26000;
RTS;
/************************************************************************
* Function Decod_ld8a ->Main decoder routine. *
* $$01/10/2000 used only in decoder *
* Calling Parameters *
* DecodeParm[] : vector of synthesis parameters *
* : DecodeParm[0] = bad frame indicator (bfi) *
* SynthDecode : synthesis speech *
* Az_dec[], : decoded LP filter in 2 subframes *
* *Dec_T2 : decoded pitch lag in 2 subframes *
* Return Values *
* *VadDecode : frame type *
* Altered Registers: MR,SR,AR,I0,I1,I2,I3,AX0,MY0 *
* Computation Time : 18 cycles *
*************************************************************************/
.ENTRY Decod_ld8a;
.VAR/DM/RAM/SEG=App_DMbuf Dec_lspnew[M]; /* LSPs */
.VAR/DM/RAM/SEG=App_DMbuf Dec_code[L_SUBFR]; /* Fixed codebook excitation*/
.VAR/DM/RAM/SEG=App_DMbuf Dec_lsfqmem[MA_NP*M];
.VAR/DM/RAM/SEG=App_DMbuf bad_pitch,Az,bfi,ftyp;
.VAR/DM/RAM/SEG=App_DMbuf T2_save,Az_save,prm_save;
.VAR/DM/RAM/SEG=App_DMbuf Dec_T0,Dec_T0frac,Dec_subfr;
Decod_ld8a:
/*-------Test bad frame indicator (bfi)------------------*/
AY0=DM(DecodeParm);
DM(bfi)=AY0;
/*-------for G.729B---------------------------------------*/
AR=DM(DecodeParm+1);
DM(ftyp)=AR;
AF=AY0-1;
IF NE JUMP process_frame;
AR=DM(past_ftyp);
AF=AR-1;
IF NE AR=PASS 0;
DM(ftyp)=AR;
DM(DecodeParm+1)=AR;
process_frame: DM(VadDecode)=AR;
/*-------Processing non active frames (SID & not transmitted)----*/
AF=AR-1;
IF EQ JUMP process_active;
I1=^Dec_lsfqmem;
CALL Get_decfreq_prev;
I0=^Dec_lspold;
I1=^Dec_lsfqmem;
CALL Dec_cng;
I1=^Dec_lsfqmem;
CALL Update_decfreq_prev;
I0=^Dec_T2;
I1=^Az_dec;
AR=PASS 0;
Synfilt_loop: DM(T2_save)=I0;
DM(Az_save)=I1;
DM(Dec_subfr)=AR;
M3=AR;
AY0=0;
I2=DM(Dec_excit);
I0=DM(SynthDecode);
SI=L_SUBFR;
I3=^Dec_memsyn;
MODIFY(I0,M3);
MODIFY(I2,M3);
CALL Syn_filt;
AR=PASS AR;
IF EQ JUMP Synfilt_Scale;
/*------In case of overflow in the synthesis-----------------*/
/*------Scale down vector Dec_excit[] and redo synthesis-----------*/
I2=^Dec_oldexc;
CNTR=PIT_MAX+L_INTERPOL+L_FRAME;
DO back_old_exc UNTIL CE;
AR=DM(I2,M0);
SR=ASHIFT AR BY -2(LO);
back_old_exc: DM(I2,M1)=SR0;
AY0=1;
SI=L_SUBFR;
I2=DM(Dec_excit);
I0=DM(SynthDecode);
I3=^Dec_memsyn;
I1=DM(Az_save);
M3=DM(Dec_subfr);
MODIFY(I0,M3);
MODIFY(I2,M3);
CALL Syn_filt;
JUMP Synfilt_next;
//Synfilt_Scale: CNTR=M;
Synfilt_Scale: M3=L_SUBFR-M;
I3=DM(SynthDecode);
MODIFY(I3,M3);
M3=DM(Dec_subfr);
MODIFY(I3,M3);
I2=^Dec_memsyn;
CNTR=M;
DO copy_decode UNTIL CE;
AR=DM(I3,M1);
copy_decode: DM(I2,M1)=AR;
Synfilt_next: M3=MP1;
AR=DM(Dec_oldT0);
I0=DM(T2_save);
DM(I0,M1)=AR;
I1=DM(Az_save);
MODIFY(I1,M3);
AY0=L_SUBFR;
AX0=DM(Dec_subfr);
AR=AX0+AY0;
AY0=L_FRAME;
NONE=AR-AY0;
IF LT JUMP Synfilt_loop;
AR=SHARPMIN;
DM(Dec_sharp)=AR;
JUMP decode_comm;
process_active:
AR=INIT_SEED;
DM(Dec_seed)=AR;
/*-------Decode the LSPs-------------------------------*/
AX0=DM(bad_lsf);
AR=AX0+AY0;
SI=^Dec_lspnew;
I1=^DecodeParm+2;
CALL D_lsp;
/*-----------------------------------------------------*/
/*-------Note: "bad_lsf" is introduce in case the standard--*/
/*-------is used with channel protection.-------------------*/
/*-------Interpolation of LPC for the 2 subframes-----------*/
I0=^Az_dec;
I1=^Dec_lspold;
I2=^Dec_lspnew;
CALL Int_qlpc;
/*-------update the LSFs for the next frame-----------------*/
// CNTR=M;
I2=^Dec_lspold;
I3=^Dec_lspnew;
CNTR=M;
DO update_lsf UNTIL CE;
AR=DM(I3,M1);
update_lsf: DM(I2,M1)=AR;
/*------------------------------------------------------------------*
* Loop for every subframe in the analysis frame *
* - decode the pitch delay *
* - decode algebraic Dec_code *
* - decode pitch and codebook gains *
* - find the excitation and compute synthesis speech *
*------------------------------------------------------------------*/
AR=PASS 0;
I0=^Dec_T2;
I1=^Az_dec;
I2=^DecodeParm+4;
DM(prm_save)=I2;
Analfilt_loop: DM(T2_save)=I0;
DM(Az_save)=I1;
DM(Dec_subfr)=AR;
AX0=DM(I2,M1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -