📄 decodesid.dsp
字号:
/***********************************************************************
* Description: Comfort noise generation *
* $$01/10/2000 checked Dec_sid module data 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 Decodesid;
/***********************************************************************/
#include "ld8a.inc"
#include "vad.inc"
#include "dtx.inc"
#include "tab_dtx.inc"
#include "tab_ld8a.inc"
/************************************************************************/
/* $$01/10/2000 static memory and pointer */
/************************************************************************/
.VAR/DM/RAM/SEG=App_DMmem lspSid[M];
.VAR/DM/RAM/SEG=App_DMmem Dec_sidgain;
.VAR/DM/RAM/SEG=App_DMmem Dec_curgain;
/************************************************************************/
.EXTERNAL DecodeParm,Az_dec,Dec_seed,Dec_excit;
.EXTERNAL Dec_sidsav,Dec_sh_sidsav,past_ftyp;
.EXTERNAL Lsf_lsp2;
.EXTERNAL Int_qlpc;
.EXTERNAL Qua_Sidgain;
.EXTERNAL Calc_exc_rand;
.EXTERNAL Lsp_stability;
.EXTERNAL Lsp_prev_compose;
.EXTERNAL Lsp_prev_update;
/************************************************************************
* Description: Initialize dec_cng static variables *
* $$01/10/2000 used both in decoder *
* $$01/11/2000 move dm data table to pm data table *
* Calling Parameters *
* Return Values *
* Altered Registers: AR,I1,I5,M4 *
* Computation Time : 18 cycles *
*************************************************************************/
.ENTRY Init_Dec_cng;
//Init_Dec_cng: CNTR=M;
Init_Dec_cng: I1=^lspSid;
I5=^freq_prev_reset;
CNTR=M;
DO copy_cng UNTIL CE;
AR=PM(I5,M4);
copy_cng: DM(I1,M1)=AR;
I5=^tab_Sidgain;
AR=PM(I5,M4);
DM(Dec_sidgain)=AR;
RTS;
/************************************************************************
* Initialization of variables for the lsf quantization in the SID *
* initialize the noise_fg *
* $$01/10/2000 used both in encoder *
* Calling Parameters *
* Return Values *
* Altered Registers: MR,AR,MX0,MY0,MY1,I4,I5,I6,M1 *
* Computation Time : 18 cycles *
*************************************************************************/
.ENTRY Init_lsfq_noise;
Init_lsfq_noise:
I4=^fg;
// CNTR=4*M;
I5=^noise_fg;
CNTR=4*M;
DO copy_lsfq UNTIL CE;
AR=PM(I4,M4);
copy_lsfq: PM(I5,M4)=AR;
I4=^fg;
MY0=H#4CCC;
MY1=H#3333;
// CNTR=4*M;
I5=^fg+4*M;
I6=^noise_fg+4*M;
MX0=PM(I4,M4);
CNTR=4*M;
DO copy_noise UNTIL CE;
MR=MX0 * MY0 (SS),MX0=PM(I5,M4);
MR=MR+MX0*MY1(SS),MX0=PM(I4,M4);
copy_noise: PM(I6,M4)=MR1;
RTS;
/************************************************************************
* procedure to Receives frame type *
* 0 : for untransmitted frames *
* 2 : for SID frames *
* Decodes SID frames *
* Computes current frame excitation *
* Computes current frame LSPs *
* $$01/10/2000 used only in decoder *
* Calling Parameters *
* past_ftyp, : past frame type *
* Dec_sidsav, : energy to recover SID gain *
* Dec_sh_sidsav, : corresponding scaling factor *
* DecodeParm : coded SID parameters *
* *exc, : excitation array *
* I0 : previous lsp *
* *Az_dec, : set of interpolated LPC coefficients *
* *seed, : random generator seed *
* I0 : memory of predictor *
* Return Values *
* Altered Registers: MR,AR,MX0,MY0,MY1,I1,I2,I3,M1 *
* Computation Time : 18 cycles *
*************************************************************************/
.ENTRY Dec_cng;
.VAR/DM/RAM/SEG=App_DMtmp lsfq_mem,lsp_old;
Dec_cng: DM(lsp_old)=I0;
DM(lsfq_mem)=I1;
AR=DM(DecodeParm+1);
{---------SID Frame--------------}
NONE=PASS AR;
IF EQ JUMP nonSID_frame;
I5=^tab_Sidgain;
M5=DM(DecodeParm+5);
MODIFY(I5,M5);
AR=PM(I5,M4);
DM(Dec_sidgain)=AR;
{---------Inverse quantization of the LSP---------}
CALL sid_lsfq_decode;
JUMP excit_compute;
nonSID_frame: AY0=DM(past_ftyp);
{---------Case of 1st SID frame erased : quantize-decode-----}
{---------energy estimate stored in Dec_sidgain------}
AR=AY0-1;
IF NE JUMP excit_compute;
AY0=0;
I1=^Dec_sidsav;
I2=^Dec_sh_sidsav;
CALL Qua_Sidgain;
M5=AX0;
I5=^tab_Sidgain;
MODIFY(I5,M5);
AR=PM(I5,M5);
DM(Dec_sidgain)=AR;
excit_compute: AY0=DM(past_ftyp);
AR=DM(Dec_sidgain);
NONE=AY0-1;
IF EQ JUMP calc_excit;
MX0=A_GAIN1;
MY0=DM(Dec_sidgain);
MR=MX0*MY0 (RND);
MX0=A_GAIN0;
MY0=DM(Dec_curgain);
MR=MX0*MY0 (RND),AY0=MR1;
AR=MR1+AY0;
calc_excit: DM(Dec_curgain)=AR;
I1=DM(Dec_excit);
MX0=DM(Dec_seed);
AX0=DM(Dec_curgain);
CALL Calc_exc_rand;
DM(Dec_seed)=MX0;
{---------Interpolate the Lsp vectors-----------}
I0=^Az_dec;
I2=^lspSid;
I1=DM(lsp_old);
CALL Int_qlpc;
// CNTR=M;
I1=^lspSid;
I2=DM(lsp_old);
CNTR=M;
DO copy_lspframe UNTIL CE;
AR=DM(I1,M1);
copy_lspframe: DM(I2,M1)=AR;
RTS;
/************************************************************************
* sid_lsfq_decode---decode lsfq sid information *
* $$01/10/2000 used only in decoder *
* $$01/11/2000 move table from dm area to pm area *
* Calling Parameters *
* DecodeParm: quantized indices *
* lsfq_mem : memory of predictor *
* Return Values *
* lspSid : quantized lsp vector *
* Altered Registers: AR,I1,I2,M1 *
* Computation Time : 18 cycles *
*************************************************************************/
.ENTRY sid_lsfq_decode;
.VAR/DM/RAM/SEG=App_DMbuf lsfq[M], tmpbuf[M];
sid_lsfq_decode:
/*-------get the lsf error vector--------*/
// CNTR=M;
I5=^PtrTab_1;
M5=DM(DecodeParm+3);
MODIFY(I5,M5);
AR=PM(I5,M5);
MY0=M_2;
MR=AR * MY0(SS);
I5=^lspcb1;
M5=MR0;
MODIFY(I5,M5);
I1=^tmpbuf;
CNTR=M;
DO copy_lspcb1 UNTIL CE;
AR=PM(I5,M4);
copy_lspcb1: DM(I1,M1)=AR;
// CNTR=M_2;
M5=DM(DecodeParm+4);
I5=^PtrTab_2;
MODIFY(I5,M5);
AR=PM(I5,M5);
MR=AR * MY0(SS);
I5=^lspcb2;
M6=MR0;
MODIFY(I5,M6);
I1=^tmpbuf;
CNTR=M_2;
DO lsfq_loop1 UNTIL CE;
AX0=DM(I1,M0),AY0=PM(I5,M4);
AR=AX0+AY0;
lsfq_loop1: DM(I1,M1)=AR;
I5=^PtrTab_2+16;
// CNTR=M_2;
MODIFY(I5,M5);
AR=PM(I5,M5);
MR=AR * MY0(SS);
I5=^lspcb2+M_2;
M6=MR0;
MODIFY(I5,M6);
CNTR=M_2;
DO lsfq_loop2 UNTIL CE;
AX0=DM(I1,M0),AY0=PM(I5,M4);
AR=AX0+AY0;
lsfq_loop2: DM(I1,M1)=AR;
/*-- guarantee minimum distance of 0.0012 (~10 in Q13)---*/
/*-- between tmpbuf[j] and tmpbuf[j+1]-------------------*/
MX0=10;
// CNTR=M-1;
MY0=H#4000;
MY1=H#C000;
I1=^tmpbuf;
CNTR=M-1;
DO lsfq_loop3 UNTIL CE;
SR0=DM(I1,M1);
MR=SR0 * MY0 (SS),AR=DM(I1,M0);
MR=MR+AR*MY1 (SS),AY0=SR0;
MR=MR+MX0*MY0 (SS),AY1=AR;
NONE=PASS MR1;
IF LE JUMP lsfq_loop3;
AR=AY0-MR1,AY0=DM(I1,M2);
AR=MR1+AY1,DM(I1,M1)=AR;
lsfq_loop3: DM(I1,M0)=AR;
/*------- compute the quantized lsf vector ----------*/
I0=^lsfq;
I1=^tmpbuf;
MY0=MA_NP*M_2;
SR0=DM(DecodeParm+2);
MR=SR0 * MY0(SS);
M5=MR0;
I5=^noise_fg;
MODIFY(I5,M5);
MY0=M_2;
MR=SR0 * MY0(SS);
M5=MR0;
I4=^noise_fg_sum;
MODIFY(I4,M5);
AR=DM(lsfq_mem);
CALL Lsp_prev_compose;
/*------- update the prediction memory -*/
I1=^tmpbuf;
I0=DM(lsfq_mem);
CALL Lsp_prev_update;
/*------- lsf stability check ----------*/
I0=^lsfq;
CALL Lsp_stability;
/*--------convert lsf to lsp ----------*/
CNTR=M;
I1=^lsfq;
I0=^lspSid;
CALL Lsf_lsp2;
RTS;
/************************************************************************/
.ENDMOD;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -