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

📄 lecaa.s55

📁 The line echo canceller (LEC) is designed to provide the maximum attainable transparent voice qualit
💻 S55
📖 第 1 页 / 共 2 页
字号:
	brc0 = #(LEC_SECTION_SZ-1);
	mar(*(ar2 + t0)), mar(*(ar3 + t0)), mar(coef(*cdp))
	|| localrepeat {
		ac0 = t1 * *ar2+;
		*ar3+ = HI(saturate(rnd(ac0<<#12)));
	}
	xar2 = dbl(*ar0(#(LEC_tDb.psTxF)));
	mar(ar2 + #LEC_FLT2_SZ);
	xar3 = mar(*ar2(#(-1)));
	xar4 = dbl(*ar0(#(LEC_tDb.psFlt2)))
	xcdp = mar(*ar1(#(LEC_tSc.asNormErr)))
	mar(*(ar2 + t0)), mar(*(ar3 + t0)), mar(coef(*(cdp + t0)))
	
    .arms_off
	bit(ST2, #ST2_ARMS) = #0;
	bit(ST1, #ST1_FRCT) = #1;
	
	t0 = #(1-LEC_SECTION_SZ);
	t1 = #(-1-LEC_SECTION_SZ);
	brc0 = #(LEC_FLT2_SZ/2-1);
	localrepeat {
		pair(HI(ac0)) = *ar4;
		ac2 = *ar2+ * coef(*cdp+),
		ac3 = *ar3+ * coef(*cdp+);
		|| repeat (#(LEC_SECTION_SZ-3))
			ac2 = ac2 + (*ar2+ * coef(*cdp+)),
			ac3 = ac3 + (*ar3+ * coef(*cdp+));
		ac2 = ac2 + (*(ar2+t1) * coef(*(cdp+t0))),
		ac3 = ac3 + (*(ar3+t1) * coef(*(cdp+t0)));
		
		ac0 = ac0 + (ac2 << #-2);
		ac1 = ac1 + (ac3 << #-2);
		*ar4+ = HI(rnd(ac0));
		*ar4+ = HI(rnd(ac1));		
		
	}
	bit(ST1, #ST1_FRCT) = #0;
	.arms_on
	bit(ST2, #ST2_ARMS) = #1;
	return;	(none)
	
;-------------------------------------------------------------------------
	.global               		_lec_adapt_slow_low
	.sym _lec_adapt_slow_low, _lec_adapt_slow_low, 32, 2, 0
_lec_adapt_slow_low
;-------------------------------------------------------------------------
;	LEC_tDb *pDb	= xar0
;	LEC_tSc *pSc	= xar1
;	S16 sBase		= t0
;	S16 Step		= t1
;
	xar2 = mar(*ar1(#(LEC_tSc.asErr2)))
	xar3 = mar(*ar1(#(LEC_tSc.asNormErr)))
	brc0 = #(LEC_SECTION_SZ-1);
	mar(*(ar2 + t0)), mar(*(ar3 + t0)), mar(coef(*cdp))
	|| localrepeat {
		ac0 = t1 * *ar2+;
		*ar3+ = HI(saturate(ac0 << #16));
	}
    .arms_off
	bit(ST2, #ST2_ARMS) = #0;
	bit(ST1, #ST1_FRCT) = #1;
	xar2 = dbl(*ar0(#(LEC_tDb.psTxF)));
	mar(ar2 + #LEC_FLT2_SZ);
	xar3 = mar(*ar2(#(-1)))
	xar4 = dbl(*ar0(#(LEC_tDb.psFlt2)))
	xcdp = mar(*ar1(#(LEC_tSc.asNormErr)))
	mar(*(ar2+t0)), mar(*(ar3+t0)), mar(coef(*(cdp+t0)))
	brc0 = #(LEC_FLT2_SZ/2-1);
	t0 = #(1-LEC_SECTION_SZ);
	t1 = #(-1-LEC_SECTION_SZ);
	|| localrepeat {
		pair(HI(ac0)) = *ar4;
		ac2 = *ar2+ * coef(*cdp+),
		ac3 = *ar3+ * coef(*cdp+);
		|| repeat (#(LEC_SECTION_SZ-3))
			ac2 = ac2 + (*ar2+ * coef(*cdp+)),
			ac3 = ac3 + (*ar3+ * coef(*cdp+));
		ac2 = ac2 + (*(ar2+t1) * coef(*(cdp+t0))),
		ac3 = ac3 + (*(ar3+t1) * coef(*(cdp+t0)));
		
		ac0 = ac0 + (ac2 << #4);
		ac1 = ac1 + (ac3 << #4);
		*ar4+ = HI(rnd(ac0));
		*ar4+ = HI(rnd(ac1));		
		
	}
	bit(ST1, #ST1_FRCT) = #0;
	.arms_on
	bit(ST2, #ST2_ARMS) = #1;
	return;	(none)
;-------------------------------------------------------------------------
	.global               		_lec_shift_err2
	.sym _lec_shift_err2, _lec_shift_err2, 32, 2, 0
_lec_shift_err2
;-------------------------------------------------------------------------
;	LEC_tDb *pDb	= xar0
;	LEC_tSc *pSc	= xar1
	xar2 = mar(*ar1(#(LEC_tSc.asErr2)))
	t0 = *ar0(#(LEC_tDb.Adf2.sNegShift))
	brc0 = #(ILEC_FR_SZ-1);
	localrepeat {
		ac0 = *ar2 << #16;
		*ar2+ = HI(rnd(ac0 << t0))		
	}
	return
	
;-------------------------------------------------------------------------
	.global               		_lec_step_size_corr_slow
	.sym _lec_step_size_corr_slow, _lec_step_size_corr_slow, 32, 2, 0
_lec_step_size_corr_slow
;-------------------------------------------------------------------------
;	LEC_tDb *pDb 	= xar0
;	LEC_tSc *pSc	= xar1
; 	S16 sBase		= t0
;
; setting pointers	
	xar3 = mar(*ar1(#(LEC_tSc.asErr2)));
	mar	(ar3 + t0);
	ac0 = *ar0(#(LEC_tDb.Adf2.sNegShift)) << #1;
	t1 = ac0;
; calculating and shifting energy
	ac0 = #0;
	|| repeat (#(LEC_SECTION_SZ-1));
		ac0 = ac0 + (*ar3+ * *ar3+)
	ac0 = ac0 << #-2;
	ac0 = ac0 << t1;
	macro_en2log ac0, t0, (512*(5-2)+125-1024);
	ac1 = ac0 - *ar0(#(LEC_tDb.sErrAvrEn));
	ac1 = ac1 << #15;
	if (ac1 <= #0) execute (D_unit)
		|| ac1 = ac1 << #-2
	ac1 = rnd(ac1);
	ac1 = ac1 + (*ar0(#(LEC_tDb.sErrAvrEn)) << #16);
	*ar0(#(LEC_tDb.sErrAvrEn)) = HI(ac1);
	
	ac0 = ac1 - (*ar1(#(LEC_tSc.sExpectedErrorEn)) << #16)
	ac0 =  ac0 << #-16;
; ac0 = sErleLoss = pDb->sErrAvrEn - pSc->sExpectedErrorEn;
	
	ac2 = *ar1(#(LEC_tSc.sExpectedErrorEn))
	ac2 =  ac2 - *ar0(#(LEC_tDb.VadErr.sEnNoise))
; ac2 = pSc->sExpectedErrorEn - pDb->VadErr.sEnNoise;
	if (ac2 >= #0) goto L93
		ac3 = ac2 + #(6*ILEC_1DB);
		if (ac3 > #0) execute (D_unit)
		|| ac0 =  ac0 + ac2; 
		if (ac3 <= #0) execute (D_unit)
		|| ac0 =  ac0 - #(6*ILEC_1DB);
L93
	ac1 = #0;
	ac0 = max(ac1, ac0)
;    if (sErleLoss < 0) sErleLoss = 0;
	t0 = -ac0;
	.global	_lec_exp
	goto _lec_exp
	
	.if 0
;-------------------------------------------------------------------------
	.global               		_lec_step_size_corr_fast
	.sym _lec_step_size_corr_fast, _lec_step_size_corr_fast, 32, 2, 0
_lec_step_size_corr_fast
;-------------------------------------------------------------------------
;	LEC_tDb *pDb 	= xar0
;	LEC_tSc *pSc	= xar1
; 	S16 sBase		= t0
;
; setting pointers	
	xar3 = mar(*ar1(#(LEC_tSc.asErr2)))
	ac0 = *ar0(#(LEC_tDb.Adf2.sNegShift)) << #1
	mar (ar3 + t0)
	|| t1 = ac0;
; calculating and shifting energy
	ac0 = *ar3 * *ar3;
	ac0 = ac0 << t1;
	macro_en2log ac0, t0, 512*(5-2)+125-1024;	
	ac0 = ac0 - *ar0(#(LEC_tDb.sErrAvrEn))
	ac0 = ac0 << #13;
	if (ac0 <= #0) execute(D_unit)
		|| ac0 = ac0 << #-2;
	ac0 = rnd(ac0);
	ac0 = ac0 + (*ar0(#(LEC_tDb.sErrAvrEn)) << #16);
	*ar0(#(LEC_tDb.sErrAvrEn)) = HI(ac0);
	ac0 = ac0 - (*ar1(#(LEC_tSc.sExpectedErrorEn)) << #16);
	ac0 = ac0 << #-16;
;    if (sErleLoss < 0) sErleLoss = 0;
	|| ac1 = #0;
	ac0 = max(ac1, ac0);
	t0 = -ac0;
	.global	_lec_exp
	goto	_lec_exp
	.endif
;-------------------------------------------------------------------------
blk_adapt_fh2	.macro sSz, sShift
	ac3 = *ar5 << #(16+(sShift));
	brc0 = #(sSz/2-1);
	*sp = HI(rnd(ac3));
	|| localrepeat {
		pair(HI(ac0)) = *ar4;
		ac0 = rnd(ac0 + (*(ar3-t0) * coef(*cdp))),
		ac1 = rnd(ac1 + (*(ar6-t0) * coef(*cdp)));
		*ar4+ = pair(HI(ac0));
	}
	.endm
;-------------------------------------------------------------------------
blk_adapt_fl2	.macro sSz, sShift
	brc0 = #((sSz)/2-1);
	*sp = #(1<<(15-sShift))
	|| localrepeat {
		ac0 = *ar4 * coef(*cdp+),
		ac1 = *ar7 * coef(*cdp+);				0.5
		ac0 = ac0 + (*(ar3+t0) * coef(*cdp-)),
		ac1 = ac1 + (*(ar6+t0) * coef(*cdp-));	0.5
		*(ar4-t0) = HI(rnd(ac0 << #sShift));
		*(ar7-t0) = HI(rnd(ac1 << #sShift));	1.0
	}
	.endm
;-------------------------------------------------------------------------
get_xz2	.macro sShift
	ac1 = *ar2- * *ar3-
	|| repeat	(#(ILEC_FR_SZ/2-2))
		ac1 = ac1 + (*ar2- * *ar3-);
	ac0 = ac0 + (ac1 << sShift);
	.endm
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
	.global				_lec_adapt_fast
	.sym _lec_adapt_fast, _lec_adapt_fast, 32, 2, 0
;-------------------------------------------------------------------------
;	LEC_tDb *pDb 	= xar0
;	LEC_tSc *pSc	= xar1
;
; t3 = base
; *sp = tmp
; xar2 = psHst
; xar3 = psTxF
; xar4 = psFlt
; xar5 = psErr / psNormErr
; xar6 = else...
; xar7 = else...
;
_lec_adapt_fast	
    .arms_off
	bit(ST2, #ST2_ARMS) = #0;
	pshboth(xar7);
	pshboth(xar6);
	pshboth(xar5);
	push(t3)
	sp = sp + #-2	
	mar (t1 = #(LEC_FLT2_SZ-1));
;	
; pSc->slEn = get_xz(...);
;
	xar2 = dbl(*ar0(#(LEC_tDb.psHst)))
	xar3 = dbl(*ar0(#(LEC_tDb.psTxF)));
	mar(ar2 + #LEC_FLT2_SZ);
	mar(ar3 + #LEC_FLT2_SZ);
	|| ac0 = #0
	get_xz2	-4
	get_xz2	-4
	get_xz2	-2
	get_xz2	-3
	get_xz2	-4
	get_xz2	-5
	get_xz2	-6
	get_xz2	-6
	get_xz2	-6
	get_xz2	-6
	mar (ar2 + #LEC_FLT2_SZ);
	mar (ar3 + #LEC_FLT2_SZ);

	dbl(*ar1(#(LEC_tSc.slEn))) = ac0;

	xar4 = dbl(*ar0(#(LEC_tDb.psFlt2)));
	xar5 = mar(*ar1(#(LEC_tSc.asErr2)));
	xcdp = xsp;
;	
; for (base = 0; base < ILEC_FR_SZ; base++)
; {
	mar (t3 = #0)
L301									; loop start
;
;    pSc->asErr2[base] = lec_cancel(...)
;
	xar6 = dbl(*ar1(#(LEC_tSc.psRx)));
	mar (ar6 + t3);
	ac0 = *ar6 << #15;
	|| repeat (#(LEC_FLT2_SZ-2))
		ac0 = ac0 - (*ar2- * *ar4+);
	ac0 = ac0 - (*(ar2+t1) * *(ar4-t1));
	*ar5 = HI(rnd(ac0 << #1));
;
; if (base != 0)  pSc->slEn = lec_update_xz(....)
;
	if (t3 == #0) goto L302
		mar (t0 = #(-ILEC_FR_SZ/2))
		ac0 = dbl(*ar1(#(LEC_tSc.slEn)));
		
		ac1 = *(ar2+t0) * *(ar3+t0); 0.5
		ac0 = ac0 + (ac1 << -4);
	
		ac1 = *(ar2+t0) * *(ar3+t0); 1.
		ac1 = *(ar2+t0) * *(ar3+t0); 1.5
		ac0 = ac0 - (ac1 << -4);
		ac0 = ac0 + (ac1 << -2);
	
		ac1 = *(ar2+t0) * *(ar3+t0); 2.0
		ac0 = ac0 - (ac1 << -2);
		ac0 = ac0 + (ac1 << -3);
	
		ac1 = *(ar2+t0) * *(ar3+t0); 2.5
		ac0 = ac0 - (ac1 << -3);
		ac0 = ac0 + (ac1 << -4);
	
		ac1 = *(ar2+t0) * *(ar3+t0); 3.0
		mar(t0 = #(-ILEC_FR_SZ*2))
		ac0 = ac0 - (ac1 << -4);
		ac0 = ac0 + (ac1 << -5);
	
		ac1 = *(ar2+t0) * *(ar3+t0); 5.0
		ac0 = ac0 - (ac1 << -5);
		ac0 = ac0 + (ac1 << -6);
	
		ac1 = *ar2 * *ar3; 			; 5.0
		ac0 = ac0 - (ac1 << -6);
		|| mar(ar3 + #LEC_FLT2_SZ);
		mar(ar2 + #(LEC_FLT2_SZ));
			
		dbl(*ar1(#(LEC_tSc.slEn))) = ac0;
L302
;
; pSc->sStepCorr = lec_step_size_corr_fast(pDb, pSc, base);
;
; calculating & averaging energy
	ac0 = *ar5 * *ar5;
	macro_en2log ac0, t0, 512*(5-2)+125-1024;	
	ac0 = ac0 - *ar0(#(LEC_tDb.sErrAvrEn))
	ac0 = ac0 << #13;
	if (ac0 <= #0) execute(D_unit)
		|| ac0 = ac0 << #-2;
	ac0 = rnd(ac0);
	ac0 = ac0 + (*ar0(#(LEC_tDb.sErrAvrEn)) << #16);
; get corr in dB	
	*ar0(#(LEC_tDb.sErrAvrEn)) = HI(ac0);
	ac0 = ac0 - (*ar1(#(LEC_tSc.sExpectedErrorEn)) << #16);
	ac0 = ac0 << #-16;
;    if (sErleLoss < 0) sErleLoss = 0;
	|| ac1 = #0;
	ac0 = max(ac1, ac0);
	ac0 = -ac0;
;	
; exp2()	
;
	ac1 = ac0 << #-10;
	t0 = ac1;
	|| ac0 = ac0 << #2;
	ac0 = ac0 & #4095;
	ac0 = ac0 + #4096;
	*ar1(#(LEC_tSc.sStepCorr)) = LO(ac0 << t0);
;
; uEn = lec_step_size(slEn, &pSc->sStepSize);
;
	ac0 = dbl(*ar1(#(LEC_tSc.slEn)));
	ac0 = ac0 + dbl(*ar0(#(LEC_tDb.Adf2.slAcc)));
	
	ac1 = ac0 - (#0x10 << #15)
	if (ac1 > #0) goto L303
	ac1 = ac0 - #(1<<9)
	if (ac1 > #0) goto L304
; energy is too low	---------- 
	*ar1(#(LEC_tSc.sStepSize)) = #0;
;
; ptr reset
; 	
	mar(ar3 + #(1));
; --	mar(ar4 - #(LEC_FLT2_SZ));
	mar(ar5 + #(1))
	*ar1(#(LEC_tSc.uAdaptMode)) = *ar1(#(LEC_tSc.uAdaptMode)) | #(4<<2);
	
	goto L305
;	
L303	; energy is high ---------- 
;
; get step size
	ac1 = ac0 << #-17
	ac1 = ac1 + #1
	*sp = ac1;
	ac1 = #1 << #15;
	|| repeat	(#(16-1))
		subc	(*sp, ac1, ac1);
	*ar1(#(LEC_tSc.sStepSize)) = ac1;
	*ar1(#(LEC_tSc.sStepSize)) = *ar1(#(LEC_tSc.sStepSize)) + #-1;
	*ar1(#(LEC_tSc.uAdaptMode)) = *ar1(#(LEC_tSc.uAdaptMode)) | #(1<<2);
;
; correct step size
	ac0 = *ar1(#(LEC_tSc.sStepSize)) << #16;
	ac0 = *ar1(#(LEC_tSc.sStepCorr)) * ac0;
	*sp = HI(rnd(ac0 << #4)) ; *sp = step size
;
; adapt fast high
;  normalize & save error
	ac2 = *ar5 * coef(*cdp);
	|| mar (ar5 + #(LEC_tSc.asNormErr-LEC_tSc.asErr2))
	*ar5 = HI(saturate(rnd(ac2<<#12)));
;	
; set-up pData & pFlt
	xar6 = mar(*ar3(#-1));
	mar (t0 = #2)
	|| bit(ST1, #ST1_FRCT) = #1;
; blocks 0, 1
	blk_adapt_fh2	(ILEC_FR_SZ), -2
; blocks 2
	blk_adapt_fh2	(ILEC_FR_SZ/2), 0
; blocks 3
	blk_adapt_fh2	(ILEC_FR_SZ/2), -1
; blocks 4
	blk_adapt_fh2	(ILEC_FR_SZ/2), -2
; blocks 5
	blk_adapt_fh2	(ILEC_FR_SZ/2), -3
; blocks 6+
	blk_adapt_fh2	(ILEC_FR_SZ*2), -4
	
	mar(ar3 + #(LEC_FLT2_SZ+1));
	mar(ar4 - #(LEC_FLT2_SZ));
	mar(ar5 - #(LEC_tSc.asNormErr-LEC_tSc.asErr2-1))
	
	goto L305
;
L304	; energy is low	---------- 
;
	ac1 = ac0 << #-7;
	ac1 = ac1 + #1
	*sp = ac1;
	ac1 = #1 << #15;
	|| repeat	(#(16-1))
		subc	(*sp, ac1, ac1);
	*ar1(#(LEC_tSc.sStepSize)) = ac1;
	*ar1(#(LEC_tSc.sStepSize)) = *ar1(#(LEC_tSc.sStepSize)) + #-1;
	*ar1(#(LEC_tSc.uAdaptMode)) = *ar1(#(LEC_tSc.uAdaptMode)) | #(2<<2);
;
; correct step size
	ac0 = *ar1(#(LEC_tSc.sStepSize)) << #16;
	ac0 = *ar1(#(LEC_tSc.sStepCorr)) * ac0;
	*sp = HI(rnd(ac0 << #4)) ; *sp = step size
;	
; normalize & save error	
	ac2 = *ar5 * coef(*cdp);
	|| mar (ar5 + #(LEC_tSc.asNormErr-LEC_tSc.asErr2))
	*ar5 = HI(saturate(ac2<<#16))
	*sp(#1)  = HI(saturate(ac2<<#16))
	
; set-up pData & pFlt
	xar6 = mar(*ar3(#(-1)));
	xar7 = mar(*ar4(#(1)));
	bit(ST1, #ST1_FRCT) = #1;
	|| mar(t0 = #(-2));
; blocks 0, 1	
	blk_adapt_fl2	(ILEC_FR_SZ), 4
; block	2
	blk_adapt_fl2	(ILEC_FR_SZ/2), 6
; block	3
	blk_adapt_fl2	(ILEC_FR_SZ/2), 5
; block	4
	blk_adapt_fl2	(ILEC_FR_SZ/2), 4
; block	5
	blk_adapt_fl2	(ILEC_FR_SZ/2), 3
;
; ptr reset
;
	mar(ar3 + #(ILEC_FR_SZ*3+1));
	mar(ar4 - #(ILEC_FR_SZ*3));
	mar(ar5 - #(LEC_tSc.asNormErr-LEC_tSc.asErr2-1))
	
L305 ; loop end
	mar (*ar2+);
	mar(t3 + #1);
	|| bit(ST1, #ST1_FRCT) = #0;
	ac0 = t3 - #ILEC_FR_SZ;
;	ac0 = t3 - #2;
	if (ac0 != #0) goto L301
;	
; exit
;
	sp = sp + #2	
	t3 = pop();	
	xar5 = popboth();
	xar6 = popboth();
	xar7 = popboth();
	.arms_on
	bit(ST2, #ST2_ARMS) = #1;
	return
		
;-------------------------------------------------------------------------
	.global				_lec_dummya2
	.sym _lec_dummya2, _lec_dummya2, 32, 2, 0
;-------------------------------------------------------------------------
_lec_dummya2
	return

	

⌨️ 快捷键说明

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