123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- %include "jsimdext.inc"
- %include "jdct.inc"
- %define CONST_BITS 8
- %if CONST_BITS == 8
- F_0_382 equ 98
- F_0_541 equ 139
- F_0_707 equ 181
- F_1_306 equ 334
- %else
- %define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
- F_0_382 equ DESCALE( 410903207, 30 - CONST_BITS)
- F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS)
- F_0_707 equ DESCALE( 759250124, 30 - CONST_BITS)
- F_1_306 equ DESCALE(1402911301, 30 - CONST_BITS)
- %endif
- SECTION SEG_CONST
- %define PRE_MULTIPLY_SCALE_BITS 2
- %define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
- GLOBAL_DATA(jconst_fdct_ifast_mmx)
- EXTN(jconst_fdct_ifast_mmx):
- PW_F0707 times 4 dw F_0_707 << CONST_SHIFT
- PW_F0382 times 4 dw F_0_382 << CONST_SHIFT
- PW_F0541 times 4 dw F_0_541 << CONST_SHIFT
- PW_F1306 times 4 dw F_1_306 << CONST_SHIFT
- alignz 32
- SECTION SEG_TEXT
- BITS 32
- %define data(b) (b) + 8
- %define original_ebp ebp + 0
- %define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD
- %define WK_NUM 2
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_ifast_mmx)
- EXTN(jsimd_fdct_ifast_mmx):
- push ebp
- mov eax, esp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD)
- mov [esp], eax
- mov ebp, esp
- lea esp, [wk(0)]
- pushpic ebx
- get_GOT ebx
-
- mov edx, POINTER [data(eax)]
- mov ecx, DCTSIZE/4
- alignx 16, 7
- .rowloop:
- movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)]
- movq mm2, MMWORD [MMBLOCK(2,1,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(3,1,edx,SIZEOF_DCTELEM)]
-
-
- movq mm4, mm0
- punpcklwd mm0, mm1
- punpckhwd mm4, mm1
- movq mm5, mm2
- punpcklwd mm2, mm3
- punpckhwd mm5, mm3
- movq mm6, MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)]
- movq mm7, MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(1,1,edx,SIZEOF_DCTELEM)]
-
-
- movq MMWORD [wk(0)], mm4
- movq MMWORD [wk(1)], mm2
- movq mm4, mm6
- punpcklwd mm6, mm7
- punpckhwd mm4, mm7
- movq mm2, mm1
- punpcklwd mm1, mm3
- punpckhwd mm2, mm3
- movq mm7, mm6
- punpckldq mm6, mm0
- punpckhdq mm7, mm0
- movq mm3, mm2
- punpckldq mm2, mm5
- punpckhdq mm3, mm5
- movq mm0, mm7
- movq mm5, mm6
- psubw mm7, mm2
- psubw mm6, mm3
- paddw mm0, mm2
- paddw mm5, mm3
- movq mm2, MMWORD [wk(0)]
- movq mm3, MMWORD [wk(1)]
- movq MMWORD [wk(0)], mm7
- movq MMWORD [wk(1)], mm6
- movq mm7, mm4
- punpckldq mm4, mm2
- punpckhdq mm7, mm2
- movq mm6, mm1
- punpckldq mm1, mm3
- punpckhdq mm6, mm3
- movq mm2, mm7
- movq mm3, mm4
- paddw mm7, mm1
- paddw mm4, mm6
- psubw mm2, mm1
- psubw mm3, mm6
-
- movq mm1, mm5
- movq mm6, mm0
- psubw mm5, mm7
- psubw mm0, mm4
- paddw mm1, mm7
- paddw mm6, mm4
- paddw mm0, mm5
- psllw mm0, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm0, [GOTOFF(ebx,PW_F0707)]
- movq mm7, mm1
- movq mm4, mm5
- psubw mm1, mm6
- psubw mm5, mm0
- paddw mm7, mm6
- paddw mm4, mm0
- movq MMWORD [MMBLOCK(0,1,edx,SIZEOF_DCTELEM)], mm1
- movq MMWORD [MMBLOCK(2,1,edx,SIZEOF_DCTELEM)], mm5
- movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)], mm7
- movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)], mm4
-
- movq mm6, MMWORD [wk(0)]
- movq mm0, MMWORD [wk(1)]
- paddw mm2, mm3
- paddw mm3, mm6
- paddw mm6, mm0
- psllw mm2, PRE_MULTIPLY_SCALE_BITS
- psllw mm6, PRE_MULTIPLY_SCALE_BITS
- psllw mm3, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm3, [GOTOFF(ebx,PW_F0707)]
- movq mm1, mm2
- psubw mm2, mm6
- pmulhw mm2, [GOTOFF(ebx,PW_F0382)]
- pmulhw mm1, [GOTOFF(ebx,PW_F0541)]
- pmulhw mm6, [GOTOFF(ebx,PW_F1306)]
- paddw mm1, mm2
- paddw mm6, mm2
- movq mm5, mm0
- psubw mm0, mm3
- paddw mm5, mm3
- movq mm7, mm0
- movq mm4, mm5
- psubw mm0, mm1
- psubw mm5, mm6
- paddw mm7, mm1
- paddw mm4, mm6
- movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)], mm0
- movq MMWORD [MMBLOCK(3,1,edx,SIZEOF_DCTELEM)], mm5
- movq MMWORD [MMBLOCK(1,1,edx,SIZEOF_DCTELEM)], mm7
- movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)], mm4
- add edx, byte 4*DCTSIZE*SIZEOF_DCTELEM
- dec ecx
- jnz near .rowloop
-
- mov edx, POINTER [data(eax)]
- mov ecx, DCTSIZE/4
- alignx 16, 7
- .columnloop:
- movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)]
- movq mm2, MMWORD [MMBLOCK(6,0,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_DCTELEM)]
-
-
- movq mm4, mm0
- punpcklwd mm0, mm1
- punpckhwd mm4, mm1
- movq mm5, mm2
- punpcklwd mm2, mm3
- punpckhwd mm5, mm3
- movq mm6, MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)]
- movq mm7, MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(4,0,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(5,0,edx,SIZEOF_DCTELEM)]
-
-
- movq MMWORD [wk(0)], mm4
- movq MMWORD [wk(1)], mm2
- movq mm4, mm6
- punpcklwd mm6, mm7
- punpckhwd mm4, mm7
- movq mm2, mm1
- punpcklwd mm1, mm3
- punpckhwd mm2, mm3
- movq mm7, mm6
- punpckldq mm6, mm0
- punpckhdq mm7, mm0
- movq mm3, mm2
- punpckldq mm2, mm5
- punpckhdq mm3, mm5
- movq mm0, mm7
- movq mm5, mm6
- psubw mm7, mm2
- psubw mm6, mm3
- paddw mm0, mm2
- paddw mm5, mm3
- movq mm2, MMWORD [wk(0)]
- movq mm3, MMWORD [wk(1)]
- movq MMWORD [wk(0)], mm7
- movq MMWORD [wk(1)], mm6
- movq mm7, mm4
- punpckldq mm4, mm2
- punpckhdq mm7, mm2
- movq mm6, mm1
- punpckldq mm1, mm3
- punpckhdq mm6, mm3
- movq mm2, mm7
- movq mm3, mm4
- paddw mm7, mm1
- paddw mm4, mm6
- psubw mm2, mm1
- psubw mm3, mm6
-
- movq mm1, mm5
- movq mm6, mm0
- psubw mm5, mm7
- psubw mm0, mm4
- paddw mm1, mm7
- paddw mm6, mm4
- paddw mm0, mm5
- psllw mm0, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm0, [GOTOFF(ebx,PW_F0707)]
- movq mm7, mm1
- movq mm4, mm5
- psubw mm1, mm6
- psubw mm5, mm0
- paddw mm7, mm6
- paddw mm4, mm0
- movq MMWORD [MMBLOCK(4,0,edx,SIZEOF_DCTELEM)], mm1
- movq MMWORD [MMBLOCK(6,0,edx,SIZEOF_DCTELEM)], mm5
- movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)], mm7
- movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)], mm4
-
- movq mm6, MMWORD [wk(0)]
- movq mm0, MMWORD [wk(1)]
- paddw mm2, mm3
- paddw mm3, mm6
- paddw mm6, mm0
- psllw mm2, PRE_MULTIPLY_SCALE_BITS
- psllw mm6, PRE_MULTIPLY_SCALE_BITS
- psllw mm3, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm3, [GOTOFF(ebx,PW_F0707)]
- movq mm1, mm2
- psubw mm2, mm6
- pmulhw mm2, [GOTOFF(ebx,PW_F0382)]
- pmulhw mm1, [GOTOFF(ebx,PW_F0541)]
- pmulhw mm6, [GOTOFF(ebx,PW_F1306)]
- paddw mm1, mm2
- paddw mm6, mm2
- movq mm5, mm0
- psubw mm0, mm3
- paddw mm5, mm3
- movq mm7, mm0
- movq mm4, mm5
- psubw mm0, mm1
- psubw mm5, mm6
- paddw mm7, mm1
- paddw mm4, mm6
- movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)], mm0
- movq MMWORD [MMBLOCK(7,0,edx,SIZEOF_DCTELEM)], mm5
- movq MMWORD [MMBLOCK(5,0,edx,SIZEOF_DCTELEM)], mm7
- movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)], mm4
- add edx, byte 4*SIZEOF_DCTELEM
- dec ecx
- jnz near .columnloop
- emms
- poppic ebx
- mov esp, ebp
- pop esp
- pop ebp
- ret
- align 32
|