📄 enc_lag3.asm
字号:
;==========================================================================
; File Name
; ----------
; ENC_LAG3.ASM
;
; Brief Description of the Code:
; ------------------------------
; Encoding of fractional pitch lag with 1/3 resolution.
;
; Ref
; ------
; PITCH.C (enc_lag3)
;==========================================================================
.mmregs
.include ..\include\const.h
.include ..\include\tab_ld8a.h
.include ..\include\ld8amem.h
.def Enc_lag3
;----------------------------------------------------------------------
; Enc_lag3
;----------------------------------------------------------------------
; The pitch range for the first subframe is divided as follows:
; 19 1/3 to 84 2/3 resolution 1/3
; 85 to 143 resolution 1
;
; The period in the first subframe is encoded with 8 bits.
; For the range with fractions:
; index = (T-19)*3 + frac - 1; where T=[19..85] and frac=[-1,0,1]
; and for the integer only range
; index = (T - 85) + 197; where T=[86..143]
;----------------------------------------------------------------------
; For the second subframe a resolution of 1/3 is always used, and the
; search range is relative to the lag in the first subframe.
; If t0 is the lag in the first subframe then
; t_min=t0-5 and t_max=t0+4 and the range is given by
; t_min - 2/3 to t_max + 2/3
;
; The period in the 2nd subframe is encoded with 5 bits:
; index = (T-(t_min-1))*3 + frac - 1; where T[t_min-1 .. t_max+1]
;----------------------------------------------------------------------
; Word16 Enc_lag3( /* output: Return index of encoding */
; Word16 T0, /* input : Pitch delay */
; Word16 T0_frac, /* input : Fractional pitch delay */
; Word16 *T0_min, /* in/out: Minimum search delay */
; Word16 *T0_max, /* in/out: Maximum search delay */
; Word16 pit_min, /* input : Minimum pitch delay */
; Word16 pit_max, /* input : Maximum pitch delay */
; Word16 pit_flag /* input : Flag for 1st subframe */
; )
;----------------------------------------------------------------------
; Constants : Addr_T0 -> T0
; Addr_T0_frac -> T0_frac
; Addr_T0_min -> T0_min
; Addr_T0_max -> T0_max
;
; PIT_MIN = pit_min
; PIT_MAX = pit_max
;
; Input : A = pit_flag
;
; Output : B = Enc_lag3(xxxxxx)
;----------------------------------------------------------------------
; The following variables must be in same data page :
; Addr_T0 -> T0
; Addr_T0_frac -> T0_frac
; Addr_T0_min -> T0_min
; Addr_T0_max -> T0_max
;----------------------------------------------------------------------
.asg "Addr_T0", T0
.asg "Addr_T0_frac", T0_frac
.asg "Addr_T0_min", T0_min
.asg "Addr_T0_max", T0_max
Enc_lag3:
LD #T0, DP
LD T0, B
BC SecondSufr, ANEQ
FirstSufr:
SUB #85, B, A
BC T0_GT_85, AGT
LD B,1,A
ADD A, B
SUB #58,B
ADD T0_frac, B
STLM B,T
B T0_LT_85
T0_GT_85:
ADD #112, B, A
STLM A, T
T0_LT_85:
LD #-5, A
ADD T0, A
LD #PIT_MIN, B
MAX A
LD #PIT_MAX - 9, B
MIN A
ADD #9, A, B
STL A, T0_min
STL B, T0_max
RETD
LDM T, B
SecondSufr:
SUB T0_min, B
LD B,1,A
ADD A,B
ADD T0_frac, B
RETD
ADD #2, B
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -