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

📄 channel2.asm

📁 TI C54写的G729代码,视线8kbps高质量语音解码,汇编优化
💻 ASM
字号:
;==========================================================================
;  File Name
;  ----------
;  CHANNEL.ASM
;
;  Brief Description of the Code:
;  ------------------------------
;  SelectChannel : initialize pointers for the selected channel
;  ResetChannel  : initialize data for the selected channel
;
;
;  Ref
;  ------
;
;==========================================================================

        .mmregs

        .include  ..\include\const.h
        .include  ..\include\struct.h
        .include  ..\include\ld8amem.h
        .include  ..\include\tab_ld8a.h

        .def    SelEncChannel
        .def    ResetEncChannel
        .def    SelDecChannel
        .def    ResetDecChannel

;---------------------------------------------------------------------------
;   Function Name : SelectChannel
;
;      initialize pointers for the selected channel
;-----------------------------------------------------------------------
;      Initialize pointers to speech vector.
;
;
;   |--------------------|-------------|-------------|------------|
;     previous speech           sf1           sf2         L_NEXT
;
;   <----------------  Total speech vector (L_TOTAL)   ----------->
;   <----------------  LPC analysis window (L_WINDOW)  ----------->
;   |                   <-- present frame (L_FRAME) -->
; old_speech            |              <-- new speech (L_FRAME) -->
; p_window              |              |
;                     speech           |
;                             new_speech
;-----------------------------------------------------------------------
;
;  Input Registers :    A(bit 15 - bit 0) =  G729ASpeech = &speech_buf
;
;  Modified Registers : DP, A, B, AR2
;
;---------------------------------------------------------------------------
;
;  Output Data : ptr_speech_buf
;                ptr_old_speech
;                ptr_new_speech
;                ptr_speech
;                ptr_pre_hpf_u
;                ptr_wsp_un
;                ptr_lar_old
;                ptr_lsp_old
;                ptr_qlsp_old
;                ptr_prev_lsp_vec
;                ptr_bflat
;---------------------------------------------------------------------------
        .text

SelEncChannel
        PSHM    ST1
        RSBX    CPL
        LD      #ptr_old_speech, DP
        STLM    A, AR2
        nop
        STL     A, ptr_speech_buf
        STL     A, ptr_old_speech

        MAR     *+AR2(L_TOTAL >> 1)
        MVMD    AR2, ptr_speech

        MAR     *+AR2(L_NEXT)
        ADD     #L_TOTAL, A
        SFTL    A, -1, B              ; check even/odd address
        MVMD    AR2, ptr_new_speech
        SFTL    B, 1                  ; if even address
        XC      2, C                  ; else make sure ptr_pre_hpf_u -> even address
                ADD     #1, A, B

        STL     B, ptr_pre_hpf_u

        ADD     #4, B                 ; ptr_wsp_un -> even address
        STL     B, ptr_wsp_un

        ADD     #20, B
        STL     B, ptr_L_exc_err         ; exc_err

        ADD     #32, A
        STL     A, ptr_lar_old            ; lar

        ADD     #2, A
        STL     A, ptr_lsp_old            ; ptr_lsp_old -> lsp_coef

        ADD     #M, A
        STL     A, ptr_qlsp_old           ; ptr_qlsp_old -> lsp_coef_q

        ADD     #M, A
        STL     A, ptr_prev_lsp_vec       ; ptr_prev_lsp_vec -> prev_lsp_vec

        ADD     #(4 * M), A
        STL     A, ptr_bflat              ; ptr_bflat -> bflat

        ADD     #1, A
        STL     A, ptr_sharp              ; ptr_sharp -> sharp

        ADD     #1, A
        STL     A, ptr_prev_qua_eng       ; ptr_prev_qua_eng -> past_qua_eng

        ADD     #4, A
        STL     A, ptr_mem_syn            ; ptr_mem_syn -> mem_syn

        ADD     #M, A
        STL     A, ptr_mem_w0             ; ptr_mem_w0 -> mem_w0

        ADD     #M, A
        STL     A, ptr_mem_w             ; ptr_mem_w -> mem_w

        ADD     #M, A
        STL     A, ptr_mem_zero             ; ptr_mem_zero -> mem_zero

        ADD     #M, A
        STL     A, ptr_mem_err            ; ptr_mem_err -> mem_err

        ADD     #(M + PIT_MAX), A
        STL     A, ptr_wsp                            ; wsp = old_wsp + PIT_MAX

        ADD     #(L_FRAME + PIT_MAX + L_INTERPOL), A
        STL     A, ptr_exc                            ; exc = old_exc + PIT_MAX + L_INTERPOL

        POPM    ST1
        RET


;---------------------------------------------------------------------------
;   Function Name : ResetChannel
;
;          Initialize data for the selected channel.
;
;---------------------------------------------------------------------------
;
;  Modified Registers : A, AR2, AR3
;
;---------------------------------------------------------------------------
ResetEncChannel:

        MVDM    ptr_speech_buf, AR3

        RPTZ	A,  #G729ASpeechLen
                STL     A, *AR3+
InitData1:

        STM     #M - 1, BRC
        MVDM    ptr_prev_lsp_vec, AR3
        STM     #PrevLspVectQ13, AR2

        RPTB    EndResetLspVec - 1
                MVDD    *AR2,  *AR3+
                MVDD    *AR2,  *AR3+
                MVDD    *AR2,  *AR3+
                MVDD    *AR2+, *AR3+
EndResetLspVec:

        ; initialize lsp coefficients ans bflat

        MVDM    ptr_lsp_old, AR2
        RPT     #M - 1
                MVPD    lsp_coef_init, *AR2+

        MVDM    ptr_qlsp_old, AR2
        RPT     #M - 1
                MVPD    lsp_coef_init, *AR2+

        MVDM    ptr_bflat, AR3
        MVDM    ptr_sharp, AR2
        ST      #1, *AR3             ; bflat = 1
        ST      #SHARPMIN, *AR2      ; sharp = SHARPMIN

        LD      #-14336, A
        MVDM    ptr_prev_qua_eng, AR3
        RPT     #4 - 1
                STL     A, *AR3+


    ; for(i=0; i<4; i++) L_exc_err[i] = 0x00004000L;   /* Q14 */

        MVDM    ptr_L_exc_err , AR3
        LD      #04000h, A
        DST     A, *AR3+           ; DST is not working with RPT
        DST     A, *AR3+
        DST     A, *AR3+
        DST     A, *AR3+

        RET

lsp_coef_init:
        .word   30000, 26000, 21000, 15000, 8000, 0, -8000,-15000,-21000,-26000



;---------------------------------------------------------------------------
;-----------------------------------------------------------------------
;   Function Name : SelDecChannel
;
;      Initialize decoder's pointers for the selected channel
;-----------------------------------------------------------------------

SelDecChannel:
        PSHM    ST1
        RSBX    CPL
        LD      #ptr_lsp_old, DP
        LD      #1, B
        nop

        STL     A, ptr_codeword

        ADD     #PRM_SIZE+1, A
        STL     A, ptr_status              ; control status

        ADD     B, A
        STL     A, ptr_T0_old              ; ptr_bflat -> bflat

        ADD     B, A
        STL     A, ptr_T0_first

        ADD     B, A
        STL     A, ptr_sharp              ; ptr_sharp -> sharp

        ADD     B, A
        STL     A, ptr_prev_ma            ; ptr_prev_ma -> prev_ma

        ADD     B, A
        STL     A, ptr_voicing            ; ptr_voicing -> voicing

        ADD     B, A
        STL     A, ptr_gain_prec          ; ptr_gain_prec -> gain_prec

        ADD     B, A
        STL     A, ptr_prev_qua_eng       ; ptr_prev_qua_eng -> past_qua_eng

        ADD     #4, A
        STL     A, ptr_prev_lsp_vec       ; ptr_prev_lsp_vec -> prev_lsp_vec

        LD      #M, B
        ADD     #(4 * M), A
        STL     A, ptr_lsp_old            ; ptr_lsp_old -> lsp_coef

        ADD     B, A
        STL     A, ptr_qlsp_old           ; ptr_qlsp_old -> lsp_coef_q

        ADD     B, A
        STL     A, ptr_mem_syn            ; ptr_mem_syn -> mem_syn

        ADD     B, A
        STL     A, ptr_mem_stp            ; ptr_mem_stp -> mem_stp

        ADD     B, A
        SFTL    A, -1, B              ; check even/odd address
        NOP
        SFTL    B, 1                  ; if even address
        XC      2, C                  ; else make sure ptr_hpf_u -> even address
                ADD     #1, A, B

        STL     B, ptr_hpf_u

        ADD     #5, A
        STL     A, ptr_apond2             ; ptr_apond2 -> apond2

        ADD     #LONG_H_ST, A
        STL     A, ptr_pst_out            ; ptr_pst_out -> pst_out

        ADD     #(L_FRAME + M), A
        STL     A, ptr_synth              ; ptr_synth -> synth_buf

        ADD     #L_FRAME, A
        STL     A, ptr_res2               ; ptr_res2 -> res2
        ADDM    #MEM_RES2, ptr_res2

        ADD     #(SIZ_RES2 + PIT_MAX + L_INTERPOL), A
        STL     A, ptr_exc                            ; exc = old_exc + PIT_MAX + L_INTERPOL

        POPM    ST1
        RET

;---------------------------------------------------------------------------
;   Function Name : ResetDecChannel
;
;          Initialize data for the selected channel for the decoder.
;
;---------------------------------------------------------------------------
;
;  Modified Registers : A, AR2, AR3
;
;---------------------------------------------------------------------------


xBuf0Size   .set   M+M+5+LONG_H_ST+L_FRAME+M+L_FRAME+SIZ_RES2+PIT_MAX+L_INTERPOL

ResetDecChannel:

        MVDM    ptr_T0_old, AR3
        MVDM    ptr_sharp, AR2
        ST      #60, *AR3            ; old_T0 = 60
        ST      #SHARPMIN, *AR2      ; sharp = SHARPMIN

        LD      #-14336, A
        MVDM    ptr_prev_qua_eng, AR3
        MVDM    ptr_gain_prec, AR2
        RPT     #4 - 1
                STL     A, *AR3+

        ST      #16384, *AR2          ; gain_prev = 16384

        STM     #M - 1, BRC
        MVDM    ptr_prev_lsp_vec, AR3
        STM     #PrevLspVectQ13, AR2

        RPTB    EndResetLspVec2 - 1
                MVDD    *AR2,  *AR3+
                MVDD    *AR2,  *AR3+
                MVDD    *AR2,  *AR3+
                MVDD    *AR2+, *AR3+
EndResetLspVec2:

        ; initialize lsp coefficients and bflat

        MVDM    ptr_lsp_old, AR2
        RPT     #M - 1
                MVPD    lsp_coef_init, *AR2+

        MVDM    ptr_qlsp_old, AR2
        RPT     #M - 1
                MVPD    lsp_coef_init, *AR2+

        LD      #0, A

        LDM     AR2, B
        AND     #1, B
        STM     #(xBuf0Size >> 1) + 1, BRC
        XC      1, BNEQ
                STL     A, *AR2+               ; check for long word boundary

        RPTB    #InitData2 - 1
                DST     A, *AR2+               ; init mem_syn and exc_buf to 0
InitData2:

        RET

⌨️ 快捷键说明

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