[cvs] / xvidcore / src / dct / x86_asm / simple_idct_mmx.asm Repository:
ViewVC logotype

Diff of /xvidcore/src/dct/x86_asm/simple_idct_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Sat Feb 15 15:22:18 2003 UTC revision 1.2.2.2, Mon Oct 27 01:03:06 2003 UTC
# Line 20  Line 20 
20  ; * Ported to nasm by Peter Ross <pross@xvid.org>  ; * Ported to nasm by Peter Ross <pross@xvid.org>
21  ; */  ; */
22    
23  bits 32  BITS 32
24    
25    ;=============================================================================
26    ; Macros and other preprocessor constants
27    ;=============================================================================
28    
29  ;===========================================================================  %macro cglobal 1
30  ; data          %ifdef PREFIX
31  ;===========================================================================                  global _%1
32                    %define %1 _%1
 %ifdef FORMAT_COFF  
 section .data  
 align 8  
33  %else  %else
34  section .data data align=8                  global %1
35  %endif  %endif
36    %endmacro
 wm1010  dw              0, 0xffff, 0, 0xffff  
 d40000  dd              0x40000, 0  
   
37    
38  %define ROW_SHIFT 11  %define ROW_SHIFT 11
39  %define COL_SHIFT 20  %define COL_SHIFT 20
# Line 49  Line 46 
46  %define C6 8867         ;cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 = 8866.956905  %define C6 8867         ;cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 = 8866.956905
47  %define C7 4520         ;cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 = 4520.335430  %define C7 4520         ;cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 = 4520.335430
48    
49  coeffs  ;===========================================================================
50    ; Data (Read Only)
51    ;===========================================================================
52    
53    SECTION .rodata
54    
55    ;-----------------------------------------------------------------------------
56    ; Trigonometric Tables
57    ;-----------------------------------------------------------------------------
58    
59    ALIGN 16
60    wm1010:
61            dw 0, 0xffff, 0, 0xffff
62    
63    ALIGN 16
64    d40000:
65            dd 0x40000, 0
66    
67    ALIGN 16
68    coeffs:
69          dw      1<<(ROW_SHIFT-1), 0, 1<<(ROW_SHIFT-1), 0,               ; 0          dw      1<<(ROW_SHIFT-1), 0, 1<<(ROW_SHIFT-1), 0,               ; 0
70          dw      1<<(ROW_SHIFT-1), 1, 1<<(ROW_SHIFT-1), 0,               ; 8          dw      1<<(ROW_SHIFT-1), 1, 1<<(ROW_SHIFT-1), 0,               ; 8
71    
# Line 73  Line 89 
89    
90    
91  ;===========================================================================  ;===========================================================================
92  ; text  ; Helper macros
93  ;===========================================================================  ;===========================================================================
94  section .text  
95    ;---------------------------------------------------------------------------
96    ; DC_COND_IDCT
97    ;---------------------------------------------------------------------------
98    
99  %macro  DC_COND_IDCT    8  %macro  DC_COND_IDCT    8
100  %define src0            %1  %define src0            %1
# Line 182  Line 201 
201  %undef  shift  %undef  shift
202  %endmacro  %endmacro
203    
204    ;---------------------------------------------------------------------------
205    ; Z_COND_IDCT
206    ;---------------------------------------------------------------------------
207    
208  %macro  Z_COND_IDCT     9  %macro  Z_COND_IDCT     9
209  %define src0            %1  %define src0            %1
# Line 279  Line 300 
300  %undef  bt  %undef  bt
301  %endmacro  %endmacro
302    
303    ;---------------------------------------------------------------------------
304    ; IDCT0
305    ;---------------------------------------------------------------------------
306    
307  %macro  IDCT0           8  %macro  IDCT0           8
308  %define src0            %1  %define src0            %1
# Line 374  Line 397 
397  %undef  shift  %undef  shift
398  %endmacro  %endmacro
399    
400    ;---------------------------------------------------------------------------
401    ; IDCT4
402    ;---------------------------------------------------------------------------
403    
404  %macro  IDCT4           8  %macro  IDCT4           8
405  %define src0            %1  %define src0            %1
# Line 457  Line 482 
482  %undef  shift  %undef  shift
483  %endmacro  %endmacro
484    
485    ;---------------------------------------------------------------------------
486    ; IDCT6
487    ;---------------------------------------------------------------------------
488    
489  %macro  IDCT6           8  %macro  IDCT6           8
490  %define src0            %1  %define src0            %1
# Line 531  Line 558 
558  %undef  shift  %undef  shift
559  %endmacro  %endmacro
560    
561    ;---------------------------------------------------------------------------
562    ; IDCT2
563    ;---------------------------------------------------------------------------
564    
565  %macro  IDCT2           8  %macro  IDCT2           8
566  %define src0            %1  %define src0            %1
# Line 618  Line 646 
646  %undef  shift  %undef  shift
647  %endmacro  %endmacro
648    
649    ;---------------------------------------------------------------------------
650    ; IDCT3
651    ;---------------------------------------------------------------------------
652    
653  %macro  IDCT3           8  %macro  IDCT3           8
654  %define src0            %1  %define src0            %1
# Line 692  Line 722 
722  %undef  shift  %undef  shift
723  %endmacro  %endmacro
724    
725    ;---------------------------------------------------------------------------
726    ; IDCT5
727    ;---------------------------------------------------------------------------
728    
729  %macro  IDCT5           8  %macro  IDCT5           8
730  %define src0            %1  %define src0            %1
# Line 768  Line 800 
800  %undef  shift  %undef  shift
801  %endmacro  %endmacro
802    
803    ;---------------------------------------------------------------------------
804    ; IDCT1
805    ;---------------------------------------------------------------------------
806    
807  %macro  IDCT1           8  %macro  IDCT1           8
808  %define src0            %1  %define src0            %1
# Line 850  Line 885 
885  %undef  shift  %undef  shift
886  %endmacro  %endmacro
887    
888    ;---------------------------------------------------------------------------
889    ; IDCT7
890    ;---------------------------------------------------------------------------
891    
892  %macro  IDCT7           8  %macro  IDCT7           8
893  %define src0            %1  %define src0            %1
# Line 901  Line 937 
937  %undef  shift  %undef  shift
938  %endmacro  %endmacro
939    
940    ;---------------------------------------------------------------------------
941    ; Permutation helpers
942    ;---------------------------------------------------------------------------
943    
944    %macro XLODA 2
945            mov     bx, [srcP+2*%2]         ; get src contents
946            mov     ax, [srcP+2*%1]         ; get dest contents
947            mov     [srcP+2*%1], bx     ; store new dest val
948    %endmacro
949    
950    %macro XCHGA 2
951            mov     ax, [srcP+2*%1]         ; get dest contents
952            mov     [srcP+2*%1], bx     ; store new dest val
953    %endmacro
954    
955  %macro cglobal 1  %macro XCHGB 2
956          %ifdef PREFIX          mov     bx, [srcP+2*%1]     ; get dest contents
957                  global _%1          mov     [srcP+2*%1], ax     ; store new dest val
                 %define %1 _%1  
         %else  
                 global %1  
         %endif  
958  %endmacro  %endmacro
959    
960    %macro XSTRA 2
961            mov     [srcP+2*%1], bx     ; store dest val
962    %endmacro
963    
964  ; void simple_idct_mmx(int16_t * const block);  %macro XSTRB 2
965  align 16          mov     [srcP+2*%1], ax     ; store dest val
966  cglobal simple_idct_mmx  %endmacro
967  simple_idct_mmx  
968    ;---------------------------------------------------------------------------
969    ; Permutation macro
970    ;---------------------------------------------------------------------------
971    
972    %macro PERMUTEP 1
973    %define srcP            %1
974            push ebx
975    
976    ;       XCHGA  0x00, 0x00      ; nothing to do
977    
978            XLODA  0x08, 0x01
979            XCHGB  0x10, 0x08
980            XCHGA  0x20, 0x10
981            XCHGB  0x02, 0x20
982            XCHGA  0x04, 0x02
983            XSTRB  0x01, 0x04
984    
985            XLODA  0x09, 0x03
986            XCHGB  0x18, 0x09
987            XCHGA  0x12, 0x18
988            XCHGB  0x24, 0x12
989            XSTRA  0x03, 0x24
990    
991            XLODA  0x0C, 0x05
992            XCHGB  0x11, 0x0C
993            XCHGA  0x28, 0x11
994            XCHGB  0x30, 0x28
995            XCHGA  0x22, 0x30
996            XCHGB  0x06, 0x22
997            XSTRA  0x05, 0x06
998    
999            XLODA  0x0D, 0x07
1000            XCHGB  0x1C, 0x0D
1001            XCHGA  0x13, 0x1C
1002            XCHGB  0x29, 0x13
1003            XCHGA  0x38, 0x29
1004            XCHGB  0x32, 0x38
1005            XCHGA  0x26, 0x32
1006            XSTRB  0x07, 0x26
1007    
1008            XLODA  0x14, 0x0A
1009            XCHGB  0x21, 0x14
1010            XSTRA  0x0A, 0x21
1011    
1012            XLODA  0x19, 0x0B
1013            XCHGB  0x1A, 0x19
1014            XCHGA  0x16, 0x1A
1015            XCHGB  0x25, 0x16
1016            XCHGA  0x0E, 0x25
1017            XCHGB  0x15, 0x0E
1018            XCHGA  0x2C, 0x15
1019            XCHGB  0x31, 0x2C
1020            XCHGA  0x2A, 0x31
1021            XCHGB  0x34, 0x2A
1022            XCHGA  0x23, 0x34
1023            XSTRB  0x0B, 0x23
1024    
1025            XLODA  0x1D, 0x0F
1026            XCHGB  0x1E, 0x1D
1027            XCHGA  0x17, 0x1E
1028            XCHGB  0x2D, 0x17
1029            XCHGA  0x3C, 0x2D
1030            XCHGB  0x33, 0x3C
1031            XCHGA  0x2B, 0x33
1032            XCHGB  0x39, 0x2B
1033            XCHGA  0x3A, 0x39
1034            XCHGB  0x36, 0x3A
1035            XCHGA  0x27, 0x36
1036            XSTRB  0x0F, 0x27
1037    
1038    ;       XCHGA  0x1B, 0x1B
1039    
1040    ;       XCHGA  0x1F, 0x1F
1041    
1042            XLODA  0x35, 0x2E
1043            XSTRB  0x2E, 0x35
1044    
1045            XLODA  0x3D, 0x2F
1046            XCHGB  0x3E, 0x3D
1047            XCHGA  0x37, 0x3E
1048            XSTRB  0x2F, 0x37
1049    
1050    ;       XCHGA  0x3B, 0x3B
1051    
1052    ;       XCHGA  0x3F, 0x3F
1053        pop  ebx
1054    %undef  srcP
1055    %endmacro
1056    
1057    ;=============================================================================
1058    ;  Code
1059    ;=============================================================================
1060    
1061    SECTION .text
1062    
1063    ;-----------------------------------------------------------------------------
1064    ; void simple_idct_mmx_P(int16_t * const block)
1065    ; expects input data to be permutated
1066    ;-----------------------------------------------------------------------------
1067    
1068    ALIGN 16
1069    cglobal simple_idct_mmx_P
1070    simple_idct_mmx_P:
1071          sub esp, 128          sub esp, 128
1072          mov edx, [esp+128+4]          mov edx, [esp+128+4]
1073    
1074  ;                               src0,   src4,   src1,   src5,   dst,    rndop,  rndarg,         shift,  bt  ;                               src0,   src4,   src1,   src5,   dst,    rndop,  rndarg,         shift,  bt
   
1075          DC_COND_IDCT edx+0,     edx+8,  edx+16, edx+24, esp,    paddd,  [coeffs+8],     11          DC_COND_IDCT edx+0,     edx+8,  edx+16, edx+24, esp,    paddd,  [coeffs+8],     11
1076          Z_COND_IDCT     edx+32, edx+40, edx+48, edx+56, esp+32, paddd,  [coeffs],       11,             .four          Z_COND_IDCT     edx+32, edx+40, edx+48, edx+56, esp+32, paddd,  [coeffs],       11,             .four
1077          Z_COND_IDCT     edx+64, edx+72, edx+80, edx+88, esp+64, paddd,  [coeffs],       11,             .two          Z_COND_IDCT     edx+64, edx+72, edx+80, edx+88, esp+64, paddd,  [coeffs],       11,             .two
# Line 932  Line 1082 
1082          IDCT0           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20          IDCT0           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1083          jmp     .ret          jmp     .ret
1084    
1085  align 16  ALIGN 16
1086  .four  .four
1087          Z_COND_IDCT     edx+64, edx+72, edx+80, edx+88, esp+64, paddd,  [coeffs],       11,             .six          Z_COND_IDCT     edx+64, edx+72, edx+80, edx+88, esp+64, paddd,  [coeffs],       11,             .six
1088          Z_COND_IDCT     edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],       11,             .five          Z_COND_IDCT     edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],       11,             .five
# Line 942  Line 1092 
1092          IDCT4           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20          IDCT4           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1093          jmp     .ret          jmp     .ret
1094    
1095  align 16  ALIGN 16
1096  .six  .six
1097          Z_COND_IDCT     edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],       11,             .seven          Z_COND_IDCT     edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],       11,             .seven
1098          IDCT6           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT6           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
# Line 951  Line 1101 
1101          IDCT6           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20          IDCT6           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1102          jmp     .ret          jmp     .ret
1103    
1104  align 16  ALIGN 16
1105  .two  .two
1106          Z_COND_IDCT     edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],       11,             .three          Z_COND_IDCT     edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],       11,             .three
1107          IDCT2           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT2           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
# Line 960  Line 1110 
1110          IDCT2           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20          IDCT2           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1111          jmp     .ret          jmp     .ret
1112    
1113  align 16  ALIGN 16
1114  .three  .three
1115          IDCT3           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT3           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1116          IDCT3           esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20          IDCT3           esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
# Line 968  Line 1118 
1118          IDCT3           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20          IDCT3           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1119          jmp     .ret          jmp     .ret
1120    
1121  align 16  ALIGN 16
1122  .five  .five
1123          IDCT5           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT5           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1124          ; IDCT5         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20          ; IDCT5         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
# Line 976  Line 1126 
1126          ; IDCT5         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20          ; IDCT5         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1127          jmp     .ret          jmp     .ret
1128    
1129  align 16  ALIGN 16
1130  .one  .one
1131          IDCT1           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT1           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1132          IDCT1           esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20          IDCT1           esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
# Line 984  Line 1134 
1134          IDCT1           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20          IDCT1           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1135          jmp     .ret          jmp     .ret
1136    
1137  align 16  ALIGN 16
1138  .seven  .seven
1139          IDCT7           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT7           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1140          ; IDCT7         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20          ; IDCT7         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
# Line 993  Line 1143 
1143    
1144  .ret  .ret
1145          add esp, 128          add esp, 128
1146    
1147            ret
1148    
1149    
1150    ;-----------------------------------------------------------------------------
1151    ; void simple_idct_mmx(int16_t * const block)
1152    ;
1153    ; simple_idct_mmx is the same function as simple_idct_mmx_P above except that
1154    ; on entry it will do a fast in-line and in-place permutation on the iDCT parm
1155    ; list.  This means that same parm list will also not have to be copied on the
1156    ; way out. - trbarry 6/2003
1157    ;-----------------------------------------------------------------------------
1158    
1159    ALIGN 16
1160    cglobal simple_idct_mmx
1161    simple_idct_mmx:
1162            sub esp, 128
1163            mov edx, [esp+128+4]
1164            PERMUTEP edx                    ; permute parm list in place
1165    
1166    ;                               src0,   src4,   src1,   src5,   dst,    rndop,  rndarg,         shift,  bt
1167            DC_COND_IDCT edx+0,     edx+8,  edx+16, edx+24, esp,    paddd,  [coeffs+8],     11
1168            Z_COND_IDCT     edx+32, edx+40, edx+48, edx+56, esp+32, paddd,  [coeffs],       11,             .fourP
1169            Z_COND_IDCT     edx+64, edx+72, edx+80, edx+88, esp+64, paddd,  [coeffs],       11,             .twoP
1170            Z_COND_IDCT     edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],       11,             .oneP
1171            IDCT0           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1172            IDCT0           esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
1173            IDCT0           esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,                      20
1174            IDCT0           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1175            jmp     .retP
1176    
1177    ALIGN 16
1178    .fourP
1179            Z_COND_IDCT     edx+64, edx+72, edx+80, edx+88, esp+64, paddd,  [coeffs],       11,             .sixP
1180            Z_COND_IDCT     edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],       11,             .fiveP
1181            IDCT4           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1182            IDCT4           esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
1183            IDCT4           esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,                      20
1184            IDCT4           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1185            jmp     .retP
1186    
1187    ALIGN 16
1188    .sixP
1189            Z_COND_IDCT     edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],       11,             .sevenP
1190            IDCT6           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1191            IDCT6           esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
1192            IDCT6           esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,                      20
1193            IDCT6           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1194            jmp     .retP
1195    
1196    ALIGN 16
1197    .twoP
1198            Z_COND_IDCT     edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],       11,             .threeP
1199            IDCT2           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1200            IDCT2           esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
1201            IDCT2           esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,                      20
1202            IDCT2           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1203            jmp     .retP
1204    
1205    ALIGN 16
1206    .threeP
1207            IDCT3           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1208            IDCT3           esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
1209            IDCT3           esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,                      20
1210            IDCT3           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1211            jmp     .retP
1212    
1213    ALIGN 16
1214    .fiveP
1215            IDCT5           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1216            ; IDCT5         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
1217            IDCT5           esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,                      20
1218            ; IDCT5         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1219            jmp     .retP
1220    
1221    ALIGN 16
1222    .oneP
1223            IDCT1           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1224            IDCT1           esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
1225            IDCT1           esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,                      20
1226            IDCT1           esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1227            jmp     .retP
1228    
1229    ALIGN 16
1230    .sevenP
1231            IDCT7           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1232            ; IDCT7         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,                      20
1233            IDCT7           esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,                      20
1234            ; IDCT7         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,                      20
1235    
1236    .retP
1237            add     esp, 128
1238    
1239          ret          ret
1240    
1241    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.2.2.2

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4