📄 mpegsubb-60.a
字号:
;------------------------------------------------------------------------------;; File : MPEGSUBB.a;; Author : St閜hane TAVENARD;; (C) Copyright 1997-1998 St閜hane TAVENARD; All Rights Reserved;; #Rev| Date | Comment; ----|----------|--------------------------------------------------------; 0 |10/04/1997| Initial revision ST; 1 |18/05/1997| Optimized windowing for '060 ST; 2 |01/11/1997| Use link instead of static vars ST; 3 |08/04/1998| Use overflow optimization from ... (IRC man) ST; 4 |21/06/1998| Use external dewindow ST;; ------------------------------------------------------------------------;; MPEG SUBroutines optimized !;;------------------------------------------------------------------------------ XDEF @MPEGSUBB_antialias XDEF _MPEGSUBB_antialias XDEF @MPEGSUBB_filter_band XDEF _MPEGSUBB_filter_band XDEF @MPEGSUBB_window_band XDEF _MPEGSUBB_window_band; XDEF @MPEGSUBB_config ; #2; XDEF _MPEGSUBB_config ; #2 section ASMCODE,codeINT_FACTOR equ 14ALIAS_BITS equ 15;; ALIAS_U bu,csi,bd,cai,<tmp reg>,<reg>; performs: (bu * csi) - (bd * cai) -> <reg>; <tmp reg> is used for calculation; d6 must be set to ALIAS_BITS;ALIAS_U MACRO move.w \1,\6 muls.w \2,\6 move.w \3,\5 muls.w \4,\5 sub.l \5,\6 asr.l d6,\6 ENDM;; ALIAS_D bd,csi,bu,cai,<tmp reg>,<reg>; performs: (bd * csi) + (bu * cai) -> <reg>; <tmp reg> is used for calculation; d6 must be set to ALIAS_BITS;ALIAS_D MACRO move.w \1,\6 muls.w \2,\6 move.w \3,\5 muls.w \4,\5 add.l \5,\6 asr.l d6,\6 ENDMbd equr a1bu equr a2;; ALIAS_B csi,cai; perform 1 alias butterfly; uses d0..d3;ALIAS_B MACRO move.w -(bu),d2 move.w (bd),d3 ALIAS_U d2,\1,d3,\2,d0,d1 move.w d1,(bu) ALIAS_D d3,\1,d2,\2,d0,d1 move.w d1,(bd)+ ENDM; Layer III antialiasing filter;; a0 = sample buffer xr (INT16); d0 = sblimit;@MPEGSUBB_antialias_MPEGSUBB_antialias movem.l d2-d7/a2,-(sp) move.w d0,d7 subq.w #1,d7 bmi.w antialias2 clr.l d5 ; d5 =i = 0 moveq.l #ALIAS_BITS,d6 ; for alias multantialias1 add.l #18,d5 ; i += SSLIMIT lea (a0,d5.w*2),bu ; bu = xr[ i ] move.l bu,bd ; bd = bu ALIAS_B #28098,#-16858 ALIAS_B #28892,#-15457 ALIAS_B #31117,#-10268 ALIAS_B #32221,#-5960 ALIAS_B #32621,#-3099 ALIAS_B #32740,#-1342 ALIAS_B #32764,#-465 ALIAS_B #32767,#-121 subq.w #1,d7 bge.w antialias1 ;dbra d7,antialias1antialias2 movem.l (sp)+,d2-d7/a2 rtsps1 equr a3ps2 equr a4pd1 equr a5;pd2 equr a6 ; #2;; Filter COS values for fast cosine transform;SH equ 1 ; In order to preserve bits in multiplyMUL_SHIFT equ 16-SHCOS1_64 equ $8028>>SHCOS3_64 equ $8167>>SHCOS5_64 equ $83F4>>SHCOS7_64 equ $87F2>>SHCOS9_64 equ $8D98>>SHCOS11_64 equ $953B>>SHCOS13_64 equ $9F5C>>SHCOS15_64 equ $ACC0>>SHCOS17_64 equ $BE9A>>SHCOS19_64 equ $D6E0>>SHCOS21_64 equ $F8FA>>SHCOS23_64 equ $12B60>>SHCOS25_64 equ $17BF2>>SHCOS27_64 equ $20ECB>>SHCOS29_64 equ $36859>>SHCOS31_64 equ $A30A4>>SHCOS1_32 equ $809F>>SHCOS3_32 equ $85C2>>SHCOS5_32 equ $9123>>SHCOS7_32 equ $A596>>SHCOS9_32 equ $C9C5>>SHCOS11_32 equ $10F89>>SHCOS13_32 equ $1B8F2>>SHCOS15_32 equ $519E5>>SHCOS1_16 equ $8282>>SHCOS3_16 equ $99F2>>SHCOS5_16 equ $E665>>SHCOS7_16 equ $2901B>>SHCOS1_8 equ $8A8C>>SHCOS3_8 equ $14E7B>>SHCOS1_4 equ $B505>>SHMUL32 MACRO muls.l \1,\2 asr.l d6,\2 ENDMFFF_MUL MACRO move.l (ps1)+,d0 move.l d0,d1 move.l -(ps2),d2 add.l d2,d1 move.l d1,(pd1)+ sub.l d2,d0 MUL32 #\1,d0 move.l d0,\2*4-4(pd1) ENDM;; FF4_MUL s1,s2,s3,s4; s1..s4 must be registers; d0, s1, s2 modified;; s1 + s4 -> (pd1)+; s2 + s3 -> (pd1)+; (s1 - s4) * COS1_8 -> (pd1)+; (s2 - s3) * COS3_8 -> (pd1)+;FF4_MUL MACRO move.l \1,d0 add.l \4,d0 move.l d0,(pd1)+ move.l \2,d0 add.l \3,d0 move.l d0,(pd1)+ sub.l \4,\1 MUL32 #COS1_8,\1 move.l \1,(pd1)+ sub.l \3,\2 MUL32 #COS3_8,\2 move.l \2,(pd1)+ ENDM;; FF2_MUL s1,s2,COSx; s1..s2, COSx must be registers; d0, s1 modified;; s1 + s2 -> (pd1)+; (s1 - s2) * COSx -> (pd1)+;FF2_MUL MACRO move.l \1,d0 add.l \2,d0 move.l d0,(pd1)+ sub.l \2,\1 MUL32 \3,\1 move.l \1,(pd1)+ ENDMfast_filter_sub; lea filter_p,ps1 ; ps1=@p(0) lea -32*4(a6),ps1 ; ps1=@p(0) lea 16*4(ps1),ps2 ; ps2=@p(16); lea filter_pp,pd1 ; pd1=@pp(0) lea -16*4(a6),pd1 ; pd1=@pp(0) FFF_MUL COS1_32,8 ; pp(i=0..7) = p(i) + p(15-i) FFF_MUL COS3_32,8 ; pp(i=8..15) = COSx*[p(i) - p(15-i)] FFF_MUL COS5_32,8 FFF_MUL COS7_32,8 FFF_MUL COS9_32,8 FFF_MUL COS11_32,8 FFF_MUL COS13_32,8 FFF_MUL COS15_32,8; lea filter_pp,ps1 ; ps1=@pp(0) lea -16*4(a6),ps1 ; ps1=@pp(0) lea 8*4(ps1),ps2 ; ps2=@pp(8); lea filter_p,pd1 ; pd1=@p(0) lea -32*4(a6),pd1 ; pd1=@p(0) FFF_MUL COS1_16,4 ; p(i=0..3) = pp(i) + pp(7-i) FFF_MUL COS3_16,4 ; p(i=4..7) = COSx*[pp(i) - pp(7-i)] FFF_MUL COS5_16,4 FFF_MUL COS7_16,4 lea 4*4(ps1),ps1 ; ps1=@pp(8) lea 8*4(ps1),ps2 ; ps2=@pp(16) lea 4*4(pd1),pd1 ; pd1=@p(8) FFF_MUL COS1_16,4 FFF_MUL COS3_16,4 FFF_MUL COS5_16,4 FFF_MUL COS7_16,4; lea filter_p,ps1 ; ps1=@p(0) lea -32*4(a6),ps1 ; ps1=@p(0); lea filter_pp,pd1 ; pd1=@pp(0) lea -16*4(a6),pd1 ; pd1=@pp(0) movem.l (ps1)+,d1-d4 ; get p0..p3 FF4_MUL d1,d2,d3,d4 movem.l (ps1)+,d1-d4 ; get p4..p7 FF4_MUL d1,d2,d3,d4 movem.l (ps1)+,d1-d4 ; get p8..p11 FF4_MUL d1,d2,d3,d4 movem.l (ps1)+,d1-d4 ; get p12..p15 FF4_MUL d1,d2,d3,d4; lea filter_pp,ps1 ; ps1=@pp(0) lea -16*4(a6),ps1 ; ps1=@pp(0); lea filter_p,pd1 ; pd1=@p(0) lea -32*4(a6),pd1 ; pd1=@p(0) move.l #COS1_4,d3 moveq.l #8-1,d4fast_filter_s2 movem.l (ps1)+,d1-d2 FF2_MUL d1,d2,d3 subq.w #1,d4 bge.b fast_filter_s2 ;dbra d4,fast_filter_s2 rts;; GET_P <index> <dest ea>; copy p[ index ] into a destination <ea>; p is ps1;GET_P MACRO move.l \1*4(ps1),\2 ENDM;; ADD_P <index> <dest ea>; add p[ index ] to a destination <ea>; p is ps1;ADD_P MACRO add.l \1*4(ps1),\2 ENDM;; SET_S0 <index> <src ea>; copy a source <ea> into s0[ index ]; s0 is a1;SET_S0 MACRO move.w \2,\1*2*16(a1) ENDM;; SET_S1 <index> <src ea>; copy a source <ea> into s1[ index ]; s1 is a2;SET_S1 MACRO move.w \2,\1*2*16(a2) ENDM;; SET_S0_P <index> <src reg>; copy <reg> into s0[ index ]; copy -<reg> into s0[ 32-index ]; s0 is a1; <reg> is modified;SET_S0_P MACRO move.w \2,\1*2*16(a1) neg.l \2 move.w \2,-\1*2*16+1024(a1) ENDM;; SET_S1_P <index> <src reg>; copy -<reg> into s1[ index ]; copy -<reg> into s1[ 32-index ]; s1 is a2; <reg> is modified;SET_S1_P MACRO neg.l \2 move.w \2,\1*2*16(a2) move.w \2,-\1*2*16+1024(a2) ENDM; Apply the FAST synthesis filter to a sub band; Generate full frequency sample;; a0: bandPtr (=fraction); a1: out_filter_buffer 0; a2: out_filter_buffer 1; d0.w: freq_div ; #2;; registers allocation: d6=MUL_SHIFT;@MPEGSUBB_filter_band_MPEGSUBB_filter_band movem.l d2-d7/a2-a6,-(sp) move.w d0,d7 ; #2 link a6,#-32*4 ; #2 need of 2*16 longs moveq.l #MUL_SHIFT,d6 ; For MUL32 normalize shift move.l a0,ps1 ; ps1=fraction(0) lea 32*2(ps1),ps2 ; ps2=fraction(32); lea filter_p,pd1 ; pd1=@p(0) lea -32*4(a6),pd1 ; pd1=@p(0); move.w freq_div,d0; cmp.w #4,d0 cmp.w #4,d7 ; #2 bne.w filter_band1 ; Filter only 1/4 freq moveq.l #8-1,d2filter_band_q1 ; p(i=0..7) = f(i) move.w (ps1)+,d0 ext.l d0 move.l d0,(pd1)+ subq.w #1,d2 bge.b filter_band_q1 ;dbra d2,filter_band_q1; lea filter_p,ps1 ; ps1=@p(0) lea -32*4(a6),ps1 ; ps1=@p(0) lea 8*4(ps1),ps2 ; ps2=@p(8); lea filter_pp,pd1 ; pd1=@pp(0) lea -16*4(a6),pd1 ; pd1=@pp(0) FFF_MUL COS1_16,4 ; pp(i=0..3) = p(i) + p(7-i) FFF_MUL COS3_16,4 ; pp(i=4..7) = COSx*[p(i) - p(7-i)] FFF_MUL COS5_16,4 FFF_MUL COS7_16,4; lea filter_pp,ps1 ; ps1=@pp(0) lea -16*4(a6),ps1 ; ps1=@pp(0); lea filter_p,pd1 ; pd1=@p(0) lea -32*4(a6),pd1 ; pd1=@p(0) movem.l (ps1)+,d1-d4 ; get pp0..pp3 FF4_MUL d1,d2,d3,d4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -