[svn] / branches / dev-api-4 / xvidcore / src / dct / x86_asm / simple_idct_mmx.asm Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/src/dct/x86_asm/simple_idct_mmx.asm

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

trunk/xvidcore/src/dct/x86_asm/simple_idct_mmx.asm revision 851, Sat Feb 15 15:22:19 2003 UTC branches/dev-api-4/xvidcore/src/dct/x86_asm/simple_idct_mmx.asm revision 1192, Tue Oct 28 22:23:03 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    %macro XSTRB 2
965      mov [srcP+2*%1], ax     ; store dest val
966    %endmacro
967    
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  ; void simple_idct_mmx(int16_t * const block);  SECTION .text
1062  align 16  
1063    cglobal simple_idct_mmx_P
1064  cglobal simple_idct_mmx  cglobal simple_idct_mmx
1065  simple_idct_mmx  
1066    ;-----------------------------------------------------------------------------
1067    ; void simple_idct_mmx_P(int16_t * const block)
1068    ; expects input data to be permutated
1069    ;-----------------------------------------------------------------------------
1070    
1071    ALIGN 16
1072    simple_idct_mmx_P:
1073          sub esp, 128          sub esp, 128
1074          mov edx, [esp+128+4]          mov edx, [esp+128+4]
1075    
1076  ;                               src0,   src4,   src1,   src5,   dst,    rndop,  rndarg,         shift,  bt  ;                               src0,   src4,   src1,   src5,   dst,    rndop,  rndarg,         shift,  bt
   
1077          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
1078          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
1079          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 1084 
1084          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
1085          jmp     .ret          jmp     .ret
1086    
1087  align 16  ALIGN 16
1088  .four  .four
1089          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
1090          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 1094 
1094          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
1095          jmp     .ret          jmp     .ret
1096    
1097  align 16  ALIGN 16
1098  .six  .six
1099          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
1100          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 1103 
1103          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
1104          jmp     .ret          jmp     .ret
1105    
1106  align 16  ALIGN 16
1107  .two  .two
1108          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
1109          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 1112 
1112          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
1113          jmp     .ret          jmp     .ret
1114    
1115  align 16  ALIGN 16
1116  .three  .three
1117          IDCT3           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT3           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1118          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 1120 
1120          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
1121          jmp     .ret          jmp     .ret
1122    
1123  align 16  ALIGN 16
1124  .five  .five
1125          IDCT5           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT5           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1126          ; 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 1128 
1128          ; 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
1129          jmp     .ret          jmp     .ret
1130    
1131  align 16  ALIGN 16
1132  .one  .one
1133          IDCT1           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT1           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1134          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 1136 
1136          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
1137          jmp     .ret          jmp     .ret
1138    
1139  align 16  ALIGN 16
1140  .seven  .seven
1141          IDCT7           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20          IDCT7           esp,    esp+64, esp+32, esp+96, edx,    nop,    0,                      20
1142          ; 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 1145 
1145    
1146  .ret  .ret
1147          add esp, 128          add esp, 128
1148    
1149          ret          ret
1150    
1151    
1152    ;-----------------------------------------------------------------------------
1153    ; void simple_idct_mmx(int16_t * const block)
1154    ;
1155    ; simple_idct_mmx is the same function as simple_idct_mmx_P above except that
1156    ; on entry it will do a fast in-line and in-place permutation on the iDCT parm
1157    ; list.  This means that same parm list will also not have to be copied on the
1158    ; way out. - trbarry 6/2003
1159    ;-----------------------------------------------------------------------------
1160    
1161    ALIGN 16
1162    simple_idct_mmx:
1163      sub esp, 128
1164      mov edx, [esp+128+4]
1165      PERMUTEP edx                  ; permute parm list in place
1166    
1167    ;               src0,   src4,   src1,   src5,   dst,    rndop,  rndarg,     shift,  bt
1168      DC_COND_IDCT  edx+0,  edx+8,  edx+16, edx+24, esp,    paddd,  [coeffs+8], 11
1169      Z_COND_IDCT   edx+32, edx+40, edx+48, edx+56, esp+32, paddd,  [coeffs],   11,     .fourP
1170      Z_COND_IDCT   edx+64, edx+72, edx+80, edx+88, esp+64, paddd,  [coeffs],   11,     .twoP
1171      Z_COND_IDCT   edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],   11,     .oneP
1172      IDCT0         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1173      IDCT0         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1174      IDCT0         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1175      IDCT0         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1176      jmp .retP
1177    
1178    ALIGN 16
1179    .fourP
1180      Z_COND_IDCT   edx+64, edx+72, edx+80, edx+88, esp+64, paddd,  [coeffs],   11,     .sixP
1181      Z_COND_IDCT   edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],   11,     .fiveP
1182      IDCT4         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1183      IDCT4         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1184      IDCT4         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1185      IDCT4         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1186      jmp .retP
1187    
1188    ALIGN 16
1189    .sixP
1190      Z_COND_IDCT   edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],   11,     .sevenP
1191      IDCT6         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1192      IDCT6         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1193      IDCT6         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1194      IDCT6         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1195      jmp .retP
1196    
1197    ALIGN 16
1198    .twoP
1199      Z_COND_IDCT   edx+96, edx+104,edx+112,edx+120,esp+96, paddd,  [coeffs],   11,     .threeP
1200      IDCT2         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1201      IDCT2         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1202      IDCT2         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1203      IDCT2         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1204      jmp .retP
1205    
1206    ALIGN 16
1207    .threeP
1208      IDCT3         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1209      IDCT3         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1210      IDCT3         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1211      IDCT3         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1212      jmp .retP
1213    
1214    ALIGN 16
1215    .fiveP
1216      IDCT5         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1217      ; IDCT5       esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1218      IDCT5         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1219      ; IDCT5       esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1220      jmp .retP
1221    
1222    ALIGN 16
1223    .oneP
1224      IDCT1         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1225      IDCT1         esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1226      IDCT1         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1227      IDCT1         esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1228      jmp .retP
1229    
1230    ALIGN 16
1231    .sevenP
1232      IDCT7         esp,    esp+64, esp+32, esp+96, edx,    nop,    0,          20
1233      ; IDCT7       esp+8,  esp+72, esp+40, esp+104,edx+4,  nop,    0,          20
1234      IDCT7         esp+16, esp+80, esp+48, esp+112,edx+8,  nop,    0,          20
1235      ; IDCT7       esp+24, esp+88, esp+56, esp+120,edx+12, nop,    0,          20
1236    
1237    .retP
1238      add esp, 128
1239    
1240      ret

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

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