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

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

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

revision 851, Sat Feb 15 15:22:19 2003 UTC revision 1382, Mon Mar 22 22:36:25 2004 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    %ifdef FORMAT_COFF
54    SECTION .rodata data
55    %else
56    SECTION .rodata data align=16
57    %endif
58    
59    ;-----------------------------------------------------------------------------
60    ; Trigonometric Tables
61    ;-----------------------------------------------------------------------------
62    
63    ALIGN 16
64    wm1010:
65            dw 0, 0xffff, 0, 0xffff
66    
67    ALIGN 16
68    d40000:
69            dd 0x40000, 0
70    
71    ALIGN 16
72    coeffs:
73          dw      1<<(ROW_SHIFT-1), 0, 1<<(ROW_SHIFT-1), 0,               ; 0          dw      1<<(ROW_SHIFT-1), 0, 1<<(ROW_SHIFT-1), 0,               ; 0
74          dw      1<<(ROW_SHIFT-1), 1, 1<<(ROW_SHIFT-1), 0,               ; 8          dw      1<<(ROW_SHIFT-1), 1, 1<<(ROW_SHIFT-1), 0,               ; 8
75    
# Line 73  Line 93 
93    
94    
95  ;===========================================================================  ;===========================================================================
96  ; text  ; Helper macros
97  ;===========================================================================  ;===========================================================================
98  section .text  
99    ;---------------------------------------------------------------------------
100    ; DC_COND_IDCT
101    ;---------------------------------------------------------------------------
102    
103  %macro  DC_COND_IDCT    8  %macro  DC_COND_IDCT    8
104  %define src0            %1  %define src0            %1
# Line 182  Line 205 
205  %undef  shift  %undef  shift
206  %endmacro  %endmacro
207    
208    ;---------------------------------------------------------------------------
209    ; Z_COND_IDCT
210    ;---------------------------------------------------------------------------
211    
212  %macro  Z_COND_IDCT     9  %macro  Z_COND_IDCT     9
213  %define src0            %1  %define src0            %1
# Line 279  Line 304 
304  %undef  bt  %undef  bt
305  %endmacro  %endmacro
306    
307    ;---------------------------------------------------------------------------
308    ; IDCT0
309    ;---------------------------------------------------------------------------
310    
311  %macro  IDCT0           8  %macro  IDCT0           8
312  %define src0            %1  %define src0            %1
# Line 374  Line 401 
401  %undef  shift  %undef  shift
402  %endmacro  %endmacro
403    
404    ;---------------------------------------------------------------------------
405    ; IDCT4
406    ;---------------------------------------------------------------------------
407    
408  %macro  IDCT4           8  %macro  IDCT4           8
409  %define src0            %1  %define src0            %1
# Line 457  Line 486 
486  %undef  shift  %undef  shift
487  %endmacro  %endmacro
488    
489    ;---------------------------------------------------------------------------
490    ; IDCT6
491    ;---------------------------------------------------------------------------
492    
493  %macro  IDCT6           8  %macro  IDCT6           8
494  %define src0            %1  %define src0            %1
# Line 531  Line 562 
562  %undef  shift  %undef  shift
563  %endmacro  %endmacro
564    
565    ;---------------------------------------------------------------------------
566    ; IDCT2
567    ;---------------------------------------------------------------------------
568    
569  %macro  IDCT2           8  %macro  IDCT2           8
570  %define src0            %1  %define src0            %1
# Line 618  Line 650 
650  %undef  shift  %undef  shift
651  %endmacro  %endmacro
652    
653    ;---------------------------------------------------------------------------
654    ; IDCT3
655    ;---------------------------------------------------------------------------
656    
657  %macro  IDCT3           8  %macro  IDCT3           8
658  %define src0            %1  %define src0            %1
# Line 692  Line 726 
726  %undef  shift  %undef  shift
727  %endmacro  %endmacro
728    
729    ;---------------------------------------------------------------------------
730    ; IDCT5
731    ;---------------------------------------------------------------------------
732    
733  %macro  IDCT5           8  %macro  IDCT5           8
734  %define src0            %1  %define src0            %1
# Line 768  Line 804 
804  %undef  shift  %undef  shift
805  %endmacro  %endmacro
806    
807    ;---------------------------------------------------------------------------
808    ; IDCT1
809    ;---------------------------------------------------------------------------
810    
811  %macro  IDCT1           8  %macro  IDCT1           8
812  %define src0            %1  %define src0            %1
# Line 850  Line 889 
889  %undef  shift  %undef  shift
890  %endmacro  %endmacro
891    
892    ;---------------------------------------------------------------------------
893    ; IDCT7
894    ;---------------------------------------------------------------------------
895    
896  %macro  IDCT7           8  %macro  IDCT7           8
897  %define src0            %1  %define src0            %1
# Line 901  Line 941 
941  %undef  shift  %undef  shift
942  %endmacro  %endmacro
943    
944    ;---------------------------------------------------------------------------
945    ; Permutation helpers
946    ;---------------------------------------------------------------------------
947    
948    %macro XLODA 2
949      mov bx, [srcP+2*%2]   ; get src contents
950      mov ax, [srcP+2*%1]   ; get dest contents
951      mov [srcP+2*%1], bx     ; store new dest val
952    %endmacro
953    
954    %macro XCHGA 2
955      mov ax, [srcP+2*%1]   ; get dest contents
956      mov [srcP+2*%1], bx     ; store new dest val
957    %endmacro
958    
959  %macro cglobal 1  %macro XCHGB 2
960          %ifdef PREFIX    mov bx, [srcP+2*%1]       ; get dest contents
961                  global _%1    mov [srcP+2*%1], ax     ; store new dest val
962                  %define %1 _%1  %endmacro
963          %else  
964                  global %1  %macro XSTRA 2
965          %endif    mov [srcP+2*%1], bx     ; store dest val
966    %endmacro
967    
968    %macro XSTRB 2
969      mov [srcP+2*%1], ax     ; store dest val
970  %endmacro  %endmacro
971    
972    ;---------------------------------------------------------------------------
973    ; Permutation macro
974    ;---------------------------------------------------------------------------
975    
976    %macro PERMUTEP 1
977    %define srcP            %1
978      push ebx
979    
980    ;       XCHGA  0x00, 0x00      ; nothing to do
981    
982      XLODA 0x08, 0x01
983      XCHGB 0x10, 0x08
984      XCHGA 0x20, 0x10
985      XCHGB 0x02, 0x20
986      XCHGA 0x04, 0x02
987      XSTRB 0x01, 0x04
988    
989      XLODA 0x09, 0x03
990      XCHGB 0x18, 0x09
991      XCHGA 0x12, 0x18
992      XCHGB 0x24, 0x12
993      XSTRA 0x03, 0x24
994    
995      XLODA 0x0C, 0x05
996      XCHGB 0x11, 0x0C
997      XCHGA 0x28, 0x11
998      XCHGB 0x30, 0x28
999      XCHGA 0x22, 0x30
1000      XCHGB 0x06, 0x22
1001      XSTRA 0x05, 0x06
1002    
1003      XLODA 0x0D, 0x07
1004      XCHGB 0x1C, 0x0D
1005      XCHGA 0x13, 0x1C
1006      XCHGB 0x29, 0x13
1007      XCHGA 0x38, 0x29
1008      XCHGB 0x32, 0x38
1009      XCHGA 0x26, 0x32
1010      XSTRB 0x07, 0x26
1011    
1012      XLODA 0x14, 0x0A
1013      XCHGB 0x21, 0x14
1014      XSTRA 0x0A, 0x21
1015    
1016      XLODA 0x19, 0x0B
1017      XCHGB 0x1A, 0x19
1018      XCHGA 0x16, 0x1A
1019      XCHGB 0x25, 0x16
1020      XCHGA 0x0E, 0x25
1021      XCHGB 0x15, 0x0E
1022      XCHGA 0x2C, 0x15
1023      XCHGB 0x31, 0x2C
1024      XCHGA 0x2A, 0x31
1025      XCHGB 0x34, 0x2A
1026      XCHGA 0x23, 0x34
1027      XSTRB 0x0B, 0x23
1028    
1029      XLODA 0x1D, 0x0F
1030      XCHGB 0x1E, 0x1D
1031      XCHGA 0x17, 0x1E
1032      XCHGB 0x2D, 0x17
1033      XCHGA 0x3C, 0x2D
1034      XCHGB 0x33, 0x3C
1035      XCHGA 0x2B, 0x33
1036      XCHGB 0x39, 0x2B
1037      XCHGA 0x3A, 0x39
1038      XCHGB 0x36, 0x3A
1039      XCHGA 0x27, 0x36
1040      XSTRB 0x0F, 0x27
1041    
1042    ;       XCHGA  0x1B, 0x1B
1043    
1044    ;       XCHGA  0x1F, 0x1F
1045    
1046      XLODA 0x35, 0x2E
1047      XSTRB 0x2E, 0x35
1048    
1049      XLODA 0x3D, 0x2F
1050      XCHGB 0x3E, 0x3D
1051      XCHGA 0x37, 0x3E
1052      XSTRB 0x2F, 0x37
1053    
1054    ;       XCHGA  0x3B, 0x3B
1055    
1056    ;       XCHGA  0x3F, 0x3F
1057      pop ebx
1058    %undef  srcP
1059    %endmacro
1060    
1061    ;=============================================================================
1062    ;  Code
1063    ;=============================================================================
1064    
1065    SECTION .text
1066    
1067  ; void simple_idct_mmx(int16_t * const block);  cglobal simple_idct_mmx_P
 align 16  
1068  cglobal simple_idct_mmx  cglobal simple_idct_mmx
1069  simple_idct_mmx  
1070    ;-----------------------------------------------------------------------------
1071    ; void simple_idct_mmx_P(int16_t * const block)
1072    ; expects input data to be permutated
1073    ;-----------------------------------------------------------------------------
1074    
1075    ALIGN 16
1076    simple_idct_mmx_P:
1077          sub esp, 128          sub esp, 128
1078          mov edx, [esp+128+4]          mov edx, [esp+128+4]
1079    
1080  ;                               src0,   src4,   src1,   src5,   dst,    rndop,  rndarg,         shift,  bt  ;                               src0,   src4,   src1,   src5,   dst,    rndop,  rndarg,         shift,  bt
   
1081          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
1082          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
1083          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 1088 
1088          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
1089          jmp     .ret          jmp     .ret
1090    
1091  align 16  ALIGN 16
1092  .four  .four
1093          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
1094          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 1098 
1098          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
1099          jmp     .ret          jmp     .ret
1100    
1101  align 16  ALIGN 16
1102  .six  .six
1103          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
1104          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 1107 
1107          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
1108          jmp     .ret          jmp     .ret
1109    
1110  align 16  ALIGN 16
1111  .two  .two
1112          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
1113          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 1116 
1116          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
1117          jmp     .ret          jmp     .ret
1118    
1119  align 16  ALIGN 16
1120  .three  .three
1121          IDCT3           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT3           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1122          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 1124 
1124          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
1125          jmp     .ret          jmp     .ret
1126    
1127  align 16  ALIGN 16
1128  .five  .five
1129          IDCT5           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT5           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1130          ; 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 1132 
1132          ; 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
1133          jmp     .ret          jmp     .ret
1134    
1135  align 16  ALIGN 16
1136  .one  .one
1137          IDCT1           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT1           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1138          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 1140 
1140          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
1141          jmp     .ret          jmp     .ret
1142    
1143  align 16  ALIGN 16
1144  .seven  .seven
1145          IDCT7           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT7           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1146          ; 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 1149 
1149    
1150  .ret  .ret
1151          add esp, 128          add esp, 128
1152    
1153          ret          ret
1154    
1155    
1156    ;-----------------------------------------------------------------------------
1157    ; void simple_idct_mmx(int16_t * const block)
1158    ;
1159    ; simple_idct_mmx is the same function as simple_idct_mmx_P above except that
1160    ; on entry it will do a fast in-line and in-place permutation on the iDCT parm
1161    ; list.  This means that same parm list will also not have to be copied on the
1162    ; way out. - trbarry 6/2003
1163    ;-----------------------------------------------------------------------------
1164    
1165    ALIGN 16
1166    simple_idct_mmx:
1167      sub esp, 128
1168      mov edx, [esp+128+4]
1169      PERMUTEP edx                  ; permute parm list in place
1170    
1171    ;               src0,   src4,   src1,   src5,   dst,    rndop,  rndarg,     shift,  bt
1172      DC_COND_IDCT  edx+0,  edx+8,  edx+16, edx+24, esp,    paddd,  [coeffs+8], 11
1173      Z_COND_IDCT   edx+32, edx+40, edx+48, edx+56, esp+32, paddd,  [coeffs],   11,     .fourP
1174      Z_COND_IDCT   edx+64, edx+72, edx+80, edx+88, esp+64, paddd,  [coeffs],   11,     .twoP
1175      Z_COND_IDCT   edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],   11,     .oneP
1176      IDCT0         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1177      IDCT0         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1178      IDCT0         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1179      IDCT0         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1180      jmp .retP
1181    
1182    ALIGN 16
1183    .fourP
1184      Z_COND_IDCT   edx+64, edx+72, edx+80, edx+88, esp+64, paddd,  [coeffs],   11,     .sixP
1185      Z_COND_IDCT   edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],   11,     .fiveP
1186      IDCT4         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1187      IDCT4         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1188      IDCT4         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1189      IDCT4         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1190      jmp .retP
1191    
1192    ALIGN 16
1193    .sixP
1194      Z_COND_IDCT   edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],   11,     .sevenP
1195      IDCT6         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1196      IDCT6         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1197      IDCT6         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1198      IDCT6         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1199      jmp .retP
1200    
1201    ALIGN 16
1202    .twoP
1203      Z_COND_IDCT   edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],   11,     .threeP
1204      IDCT2         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1205      IDCT2         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1206      IDCT2         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1207      IDCT2         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1208      jmp .retP
1209    
1210    ALIGN 16
1211    .threeP
1212      IDCT3         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1213      IDCT3         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1214      IDCT3         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1215      IDCT3         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1216      jmp .retP
1217    
1218    ALIGN 16
1219    .fiveP
1220      IDCT5         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1221      ; IDCT5       esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1222      IDCT5         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1223      ; IDCT5       esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1224      jmp .retP
1225    
1226    ALIGN 16
1227    .oneP
1228      IDCT1         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1229      IDCT1         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1230      IDCT1         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1231      IDCT1         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1232      jmp .retP
1233    
1234    ALIGN 16
1235    .sevenP
1236      IDCT7         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1237      ; IDCT7       esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1238      IDCT7         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1239      ; IDCT7       esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1240    
1241    .retP
1242      add esp, 128
1243    
1244      ret

Legend:
Removed from v.851  
changed lines
  Added in v.1382

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