📄 normcorr1.asm
字号:
;==========================================================================
; File Name
; ------------
; NORMCORR.ASM
;
; Brief Description of the Code:
; ------------------------------
; Find the normalized correlation between the target vector and the
; filtered past excitation.
;
; Ref
; ------
; PITCH.C
;==========================================================================
; Norm_Corr
;--------------------------------------------------------------------------
; Input arguments:
; exc[] : excitation buffer
; xn[] : target vector
; h[] : impulse response of synthesis and weighting filters (Q12)
; L_subfr : Length of subframe
; t_min : minimum value of pitch lag.
; t_max : maximum value of pitch lag.
;
; Output arguments:
; corr_norm[]: normalized correlation (correlation between target and
; filtered excitation divided by the square root of
; energy of filtered excitation)
;--------------------------------------------------------------------------
; static void Norm_Corr(Word16 exc[], Word16 xn[], Word16 h[], Word16 L_subfr,
; Word16 t_min, Word16 t_max, Word16 corr_norm[])
;--------------------------------------------------------------------------
; Str_Norm_Corr .struct
; ptr_exc .word 1
; ptr_xn .word 1
; ptr_h .word 1
; t_min .word 1
; t_max .word 1
; ptr_corr .word 1
; Str_Norm_Corr_Len .endstruct
;--------------------------------------------------------------------------
; Constant : L_subfr = L_SUBFR
;--------------------------------------------------------------------------
; Modified Registers : AR0, AR1, AR2, AR3, AR4, AR5, AR6
;--------------------------------------------------------------------------
.mmregs
.include ..\include\const.h
.include ..\include\struct.h
.include ..\include\ld8amem.h
.include ..\include\convolve.h
.text
.def Norm_Corr
.ref Convolve
.ref Inv_sqrt
param_norm_corr .tag Str_Norm_Corr
.asg "AR1", pCorr_norm
.asg "AR2", pExcf
.asg "AR3", pXn
.asg "AR4", pExcfTemp
.asg "AR5", pExc
.asg "AR6", pH
.asg "TRN", ASM_Cache ; temp storage of ASM
.asg "Addr_norm_corr_buf", excf ; circular buffer
.asg "excf+L_SUBFR", norm
.asg "norm+2", m_L_corr
Norm_Corr:
LD #param_norm_corr, DP
LD param_norm_corr.ptr_exc, A
SUB param_norm_corr.t_min, A
STM #excf, pConv_Y
STLM A, pConv_X
STM #L_SUBFR-1, BRC
CALLD Convolve
MVDM param_norm_corr.ptr_h, pConv_H
STM #1, AR0 ; setup for circular buffer
STM #L_SUBFR, BK
LD #param_norm_corr, DP
LD param_norm_corr.ptr_exc, 16, A
SUB param_norm_corr.t_min, 16, A
SUB #1, 16, A
MVDM param_norm_corr.ptr_xn, pXn
MVDM param_norm_corr.ptr_h, pH
PSHM AH
MAR *pH-%
STM #excf, pExcf
RPTZ A, #L_SUBFR-1
SQURA *pExcf+, A
MAR *+pExcf(-40)
SUB #400h, 16, A, B
LD #-2, ASM
MVMM pExcf, pExcfTemp
LD *pExcfTemp+, 16, A
XC 2, BGT
RPT #L_SUBFR-1 ; one word instruction
ST A, *pExcf+0%
|| LD *pExcfTemp+, A
; ------------------------------------
LD param_norm_corr.t_max, A
SUB param_norm_corr.t_min, A
STLM A, AR4
MVDM param_norm_corr.ptr_corr, pCorr_norm
MAR *AR4-
STM #15-12, ASM_Cache
XC 2, BGT
STM #15-12-2, ASM_Cache
Outter_Loop_Start
PSHM AR4
RPTZ A, #L_SUBFR-1
SQURA *pExcf+, A
MAR *+pExcf(-40)
CALLD Inv_sqrt ; DP = 0
STM #norm, AR4
STL A,-16,*AR4
LD *AR4+,15,B
LD A,-1,A
SUB B,A
STL A,*AR4
RPTZ B, #L_SUBFR-1
MAC *pXn+0%, *pExcf+0%, B
MAR *pExcf-%
STM #m_L_corr, AR5
STL B, -16, *AR5
LD *AR5+,15,A
LD B,-1,B
SUB A,B
STL B,*AR5-
LD #0, A
LD #0, B
MACSU *AR4-, *AR5+, A
ld A,-16,A
LD A,1,A
MACSU *AR5-, *AR4 ,B
LD B, -16, B
LD B,1,B
ADD B,A
MAC *AR5, *AR4, A
STL A, *pCorr_norm+
POPM AR4
POPM pExc
NOP
NOP
LD ASM_Cache, ASM
STM #L_SUBFR-2, BRC
RPTBD Inner_Loop_End-1
LD *pExc-, T
PSHM pExc
MAR *pExcf-
MPY *pH-, A
LD A, ASM, A
ADD *pExcf+, 16, A
STL A, -16, *pExcf-
Inner_Loop_End
NOP
NOP
LD T, 16-3, A
Outter_Loop_End
MAR *pH-%
STL A,ASM
BANZD Outter_Loop_Start, *AR4-
STL A, -16, *pExcf
FRAME 1
RPTZ A, #L_SUBFR-1
SQURA *pExcf+%, A
CALLD Inv_sqrt ; DP = 0
STM #norm, AR4
STL A,-16,*AR4
LD *AR4+,15,B
LD A,-1,A
SUB B,A
STL A,*AR4
RPTZ B, #L_SUBFR-1
MAC *pXn+0%, *pExcf+0%, B
STM #m_L_corr, AR5
STL B,-16,*AR5
LD *AR5+,15,A
LD B,-1,B
SUB A,B
STL B,*AR5-
LD #0, A
LD #0, B
MACSU *AR4-, *AR5+, A
LD A,-16,A
LD A,1,A
MACSU *AR5-, *AR4 , B
LD B,-16,B
LD B,1,B
ADD B,A
RETD
MAC *AR5, *AR4, A
STL A, *pCorr_norm+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -