123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- %include "jsimdext.inc"
- %include "jdct.inc"
- %define CONST_BITS 8
- %define PASS1_BITS 2
- %if IFAST_SCALE_BITS != PASS1_BITS
- %error "'IFAST_SCALE_BITS' must be equal to 'PASS1_BITS'."
- %endif
- %if CONST_BITS == 8
- F_1_082 equ 277
- F_1_414 equ 362
- F_1_847 equ 473
- F_2_613 equ 669
- F_1_613 equ (F_2_613 - 256)
- %else
- %define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
- F_1_082 equ DESCALE(1162209775, 30 - CONST_BITS)
- F_1_414 equ DESCALE(1518500249, 30 - CONST_BITS)
- F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS)
- F_2_613 equ DESCALE(2805822602, 30 - CONST_BITS)
- F_1_613 equ (F_2_613 - (1 << 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_idct_ifast_mmx)
- EXTN(jconst_idct_ifast_mmx):
- PW_F1414 times 4 dw F_1_414 << CONST_SHIFT
- PW_F1847 times 4 dw F_1_847 << CONST_SHIFT
- PW_MF1613 times 4 dw -F_1_613 << CONST_SHIFT
- PW_F1082 times 4 dw F_1_082 << CONST_SHIFT
- PB_CENTERJSAMP times 8 db CENTERJSAMPLE
- alignz 32
- SECTION SEG_TEXT
- BITS 32
- %define dct_table(b) (b) + 8
- %define coef_block(b) (b) + 12
- %define output_buf(b) (b) + 16
- %define output_col(b) (b) + 20
- %define original_ebp ebp + 0
- %define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD
-
- %define WK_NUM 2
- %define workspace wk(0) - DCTSIZE2 * SIZEOF_JCOEF
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_ifast_mmx)
- EXTN(jsimd_idct_ifast_mmx):
- push ebp
- mov eax, esp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD)
- mov [esp], eax
- mov ebp, esp
- lea esp, [workspace]
- push ebx
- push esi
- push edi
- get_GOT ebx
-
- mov edx, POINTER [dct_table(eax)]
- mov esi, JCOEFPTR [coef_block(eax)]
- lea edi, [workspace]
- mov ecx, DCTSIZE/4
- alignx 16, 7
- .columnloop:
- %ifndef NO_ZERO_COLUMN_TEST_IFAST_MMX
- mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- jnz short .columnDCT
- movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- por mm1, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- por mm1, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- por mm1, mm0
- packsswb mm1, mm1
- movd eax, mm1
- test eax, eax
- jnz short .columnDCT
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- movq mm2, mm0
- punpcklwd mm0, mm0
- punpckhwd mm2, mm2
- movq mm1, mm0
- punpckldq mm0, mm0
- punpckhdq mm1, mm1
- movq mm3, mm2
- punpckldq mm2, mm2
- punpckhdq mm3, mm3
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
- movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm3
- jmp near .nextcolumn
- alignx 16, 7
- %endif
- .columnDCT:
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- pmullw mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw mm3, MMWORD [MMBLOCK(6,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- movq mm4, mm0
- movq mm5, mm1
- psubw mm0, mm2
- psubw mm1, mm3
- paddw mm4, mm2
- paddw mm5, mm3
- psllw mm1, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm1, [GOTOFF(ebx,PW_F1414)]
- psubw mm1, mm5
- movq mm6, mm4
- movq mm7, mm0
- psubw mm4, mm5
- psubw mm0, mm1
- paddw mm6, mm5
- paddw mm7, mm1
- movq MMWORD [wk(1)], mm4
- movq MMWORD [wk(0)], mm0
-
- movq mm2, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- pmullw mm2, MMWORD [MMBLOCK(1,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw mm3, MMWORD [MMBLOCK(3,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- movq mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- pmullw mm5, MMWORD [MMBLOCK(5,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw mm1, MMWORD [MMBLOCK(7,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- movq mm4, mm2
- movq mm0, mm5
- psubw mm2, mm1
- psubw mm5, mm3
- paddw mm4, mm1
- paddw mm0, mm3
- movq mm1, mm5
- psllw mm2, PRE_MULTIPLY_SCALE_BITS
- psllw mm5, PRE_MULTIPLY_SCALE_BITS
- movq mm3, mm4
- psubw mm4, mm0
- paddw mm3, mm0
- psllw mm4, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm4, [GOTOFF(ebx,PW_F1414)]
-
-
-
-
-
-
-
-
- movq mm0, mm5
- paddw mm5, mm2
- pmulhw mm5, [GOTOFF(ebx,PW_F1847)]
- pmulhw mm0, [GOTOFF(ebx,PW_MF1613)]
- pmulhw mm2, [GOTOFF(ebx,PW_F1082)]
- psubw mm0, mm1
- psubw mm2, mm5
- paddw mm0, mm5
-
- psubw mm0, mm3
- movq mm1, mm6
- movq mm5, mm7
- paddw mm6, mm3
- paddw mm7, mm0
- psubw mm1, mm3
- psubw mm5, mm0
- psubw mm4, mm0
- movq mm3, mm6
- punpcklwd mm6, mm7
- punpckhwd mm3, mm7
- movq mm0, mm5
- punpcklwd mm5, mm1
- punpckhwd mm0, mm1
- movq mm7, MMWORD [wk(0)]
- movq mm1, MMWORD [wk(1)]
- movq MMWORD [wk(0)], mm5
- movq MMWORD [wk(1)], mm0
- paddw mm2, mm4
- movq mm5, mm7
- movq mm0, mm1
- paddw mm7, mm4
- paddw mm1, mm2
- psubw mm5, mm4
- psubw mm0, mm2
- movq mm4, mm7
- punpcklwd mm7, mm0
- punpckhwd mm4, mm0
- movq mm2, mm1
- punpcklwd mm1, mm5
- punpckhwd mm2, mm5
- movq mm0, mm6
- punpckldq mm6, mm7
- punpckhdq mm0, mm7
- movq mm5, mm3
- punpckldq mm3, mm4
- punpckhdq mm5, mm4
- movq mm7, MMWORD [wk(0)]
- movq mm4, MMWORD [wk(1)]
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm6
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm3
- movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm5
- movq mm6, mm1
- punpckldq mm1, mm7
- punpckhdq mm6, mm7
- movq mm0, mm2
- punpckldq mm2, mm4
- punpckhdq mm0, mm4
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm6
- movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm0
- .nextcolumn:
- add esi, byte 4*SIZEOF_JCOEF
- add edx, byte 4*SIZEOF_IFAST_MULT_TYPE
- add edi, byte 4*DCTSIZE*SIZEOF_JCOEF
- dec ecx
- jnz near .columnloop
-
- mov eax, [original_ebp]
- lea esi, [workspace]
- mov edi, JSAMPARRAY [output_buf(eax)]
- mov eax, JDIMENSION [output_col(eax)]
- mov ecx, DCTSIZE/4
- alignx 16, 7
- .rowloop:
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- movq mm4, mm0
- movq mm5, mm1
- psubw mm0, mm2
- psubw mm1, mm3
- paddw mm4, mm2
- paddw mm5, mm3
- psllw mm1, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm1, [GOTOFF(ebx,PW_F1414)]
- psubw mm1, mm5
- movq mm6, mm4
- movq mm7, mm0
- psubw mm4, mm5
- psubw mm0, mm1
- paddw mm6, mm5
- paddw mm7, mm1
- movq MMWORD [wk(1)], mm4
- movq MMWORD [wk(0)], mm0
-
- movq mm2, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- movq mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- movq mm4, mm2
- movq mm0, mm5
- psubw mm2, mm1
- psubw mm5, mm3
- paddw mm4, mm1
- paddw mm0, mm3
- movq mm1, mm5
- psllw mm2, PRE_MULTIPLY_SCALE_BITS
- psllw mm5, PRE_MULTIPLY_SCALE_BITS
- movq mm3, mm4
- psubw mm4, mm0
- paddw mm3, mm0
- psllw mm4, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm4, [GOTOFF(ebx,PW_F1414)]
-
-
-
-
-
-
-
-
- movq mm0, mm5
- paddw mm5, mm2
- pmulhw mm5, [GOTOFF(ebx,PW_F1847)]
- pmulhw mm0, [GOTOFF(ebx,PW_MF1613)]
- pmulhw mm2, [GOTOFF(ebx,PW_F1082)]
- psubw mm0, mm1
- psubw mm2, mm5
- paddw mm0, mm5
-
- psubw mm0, mm3
- movq mm1, mm6
- movq mm5, mm7
- paddw mm6, mm3
- paddw mm7, mm0
- psraw mm6, (PASS1_BITS+3)
- psraw mm7, (PASS1_BITS+3)
- psubw mm1, mm3
- psubw mm5, mm0
- psraw mm1, (PASS1_BITS+3)
- psraw mm5, (PASS1_BITS+3)
- psubw mm4, mm0
- packsswb mm6, mm5
- packsswb mm7, mm1
- movq mm3, MMWORD [wk(0)]
- movq mm0, MMWORD [wk(1)]
- paddw mm2, mm4
- movq mm5, mm3
- movq mm1, mm0
- paddw mm3, mm4
- paddw mm0, mm2
- psraw mm3, (PASS1_BITS+3)
- psraw mm0, (PASS1_BITS+3)
- psubw mm5, mm4
- psubw mm1, mm2
- psraw mm5, (PASS1_BITS+3)
- psraw mm1, (PASS1_BITS+3)
- movq mm4, [GOTOFF(ebx,PB_CENTERJSAMP)]
- packsswb mm3, mm0
- packsswb mm1, mm5
- paddb mm6, mm4
- paddb mm7, mm4
- paddb mm3, mm4
- paddb mm1, mm4
- movq mm2, mm6
- punpcklbw mm6, mm7
- punpckhbw mm2, mm7
- movq mm0, mm3
- punpcklbw mm3, mm1
- punpckhbw mm0, mm1
- movq mm5, mm6
- punpcklwd mm6, mm3
- punpckhwd mm5, mm3
- movq mm4, mm0
- punpcklwd mm0, mm2
- punpckhwd mm4, mm2
- movq mm7, mm6
- punpckldq mm6, mm0
- punpckhdq mm7, mm0
- movq mm1, mm5
- punpckldq mm5, mm4
- punpckhdq mm1, mm4
- pushpic ebx
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm6
- movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm7
- mov edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
- mov ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
- movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm5
- movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm1
- poppic ebx
- add esi, byte 4*SIZEOF_JCOEF
- add edi, byte 4*SIZEOF_JSAMPROW
- dec ecx
- jnz near .rowloop
- emms
- pop edi
- pop esi
- pop ebx
- mov esp, ebp
- pop esp
- pop ebp
- ret
- align 32
|