image_pack 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/README.md +29 -5
- data/ext/image_pack/extconf.rb +2 -2
- data/ext/image_pack/image_pack.c +742 -263
- data/ext/image_pack/mozjpeg_sources.rb +5 -0
- data/ext/image_pack/vendor/mozjpeg/transupp.c +2373 -0
- data/lib/image_pack/version.rb +1 -1
- data/lib/image_pack.rb +121 -7
- metadata +6 -104
- data/ext/image_pack/vendor/mozjpeg/croptest.in +0 -95
- data/ext/image_pack/vendor/mozjpeg/libjpeg.map.in +0 -11
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jsimd_neon.S +0 -1200
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch64/jsimd_neon.S +0 -2254
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolext-avx2.asm +0 -578
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolext-mmx.asm +0 -476
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolext-sse2.asm +0 -503
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolor-avx2.asm +0 -121
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolor-mmx.asm +0 -121
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolor-sse2.asm +0 -120
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgray-avx2.asm +0 -113
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgray-mmx.asm +0 -113
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgray-sse2.asm +0 -112
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgryext-avx2.asm +0 -457
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgryext-mmx.asm +0 -355
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgryext-sse2.asm +0 -382
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jchuff-sse2.asm +0 -761
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcphuff-sse2.asm +0 -662
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcsample-avx2.asm +0 -388
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcsample-mmx.asm +0 -324
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcsample-sse2.asm +0 -351
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolext-avx2.asm +0 -515
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolext-mmx.asm +0 -404
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolext-sse2.asm +0 -458
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolor-avx2.asm +0 -118
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolor-mmx.asm +0 -117
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolor-sse2.asm +0 -117
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmerge-avx2.asm +0 -136
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmerge-mmx.asm +0 -123
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmerge-sse2.asm +0 -135
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmrgext-avx2.asm +0 -575
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmrgext-mmx.asm +0 -460
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmrgext-sse2.asm +0 -517
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdsample-avx2.asm +0 -760
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdsample-mmx.asm +0 -731
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdsample-sse2.asm +0 -724
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctflt-3dn.asm +0 -318
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctflt-sse.asm +0 -369
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctfst-mmx.asm +0 -395
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctfst-sse2.asm +0 -403
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctint-avx2.asm +0 -331
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctint-mmx.asm +0 -620
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctint-sse2.asm +0 -633
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctflt-3dn.asm +0 -451
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctflt-sse.asm +0 -571
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctflt-sse2.asm +0 -497
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctfst-mmx.asm +0 -499
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctfst-sse2.asm +0 -501
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctint-avx2.asm +0 -453
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctint-mmx.asm +0 -851
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctint-sse2.asm +0 -858
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctred-mmx.asm +0 -704
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctred-sse2.asm +0 -592
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquant-3dn.asm +0 -230
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquant-mmx.asm +0 -276
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquant-sse.asm +0 -208
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquantf-sse2.asm +0 -168
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquanti-avx2.asm +0 -188
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquanti-sse2.asm +0 -201
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jsimdcpu.asm +0 -135
- data/ext/image_pack/vendor/mozjpeg/simd/mips/jsimd_dspr2.S +0 -4543
- data/ext/image_pack/vendor/mozjpeg/simd/mips/jsimd_dspr2_asm.h +0 -292
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcsample.h +0 -28
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jsimd_mmi.h +0 -69
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/loongson-mmintrin.h +0 -1334
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcsample.h +0 -28
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jsimd_altivec.h +0 -98
- data/ext/image_pack/vendor/mozjpeg/tjbenchtest.in +0 -256
- data/ext/image_pack/vendor/mozjpeg/tjbenchtest.java.in +0 -215
- data/ext/image_pack/vendor/mozjpeg/tjexampletest.in +0 -149
- data/ext/image_pack/vendor/mozjpeg/tjexampletest.java.in +0 -151
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
;
|
|
2
|
-
; jquanti.asm - sample data conversion and quantization (SSE2)
|
|
3
|
-
;
|
|
4
|
-
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
|
5
|
-
; Copyright (C) 2016, D. R. Commander.
|
|
6
|
-
;
|
|
7
|
-
; Based on the x86 SIMD extension for IJG JPEG library
|
|
8
|
-
; Copyright (C) 1999-2006, MIYASAKA Masaru.
|
|
9
|
-
; For conditions of distribution and use, see copyright notice in jsimdext.inc
|
|
10
|
-
;
|
|
11
|
-
; This file should be assembled with NASM (Netwide Assembler),
|
|
12
|
-
; can *not* be assembled with Microsoft's MASM or any compatible
|
|
13
|
-
; assembler (including Borland's Turbo Assembler).
|
|
14
|
-
; NASM is available from http://nasm.sourceforge.net/ or
|
|
15
|
-
; http://sourceforge.net/project/showfiles.php?group_id=6208
|
|
16
|
-
|
|
17
|
-
%include "jsimdext.inc"
|
|
18
|
-
%include "jdct.inc"
|
|
19
|
-
|
|
20
|
-
; --------------------------------------------------------------------------
|
|
21
|
-
SECTION SEG_TEXT
|
|
22
|
-
BITS 32
|
|
23
|
-
;
|
|
24
|
-
; Load data into workspace, applying unsigned->signed conversion
|
|
25
|
-
;
|
|
26
|
-
; GLOBAL(void)
|
|
27
|
-
; jsimd_convsamp_sse2(JSAMPARRAY sample_data, JDIMENSION start_col,
|
|
28
|
-
; DCTELEM *workspace);
|
|
29
|
-
;
|
|
30
|
-
|
|
31
|
-
%define sample_data ebp + 8 ; JSAMPARRAY sample_data
|
|
32
|
-
%define start_col ebp + 12 ; JDIMENSION start_col
|
|
33
|
-
%define workspace ebp + 16 ; DCTELEM *workspace
|
|
34
|
-
|
|
35
|
-
align 32
|
|
36
|
-
GLOBAL_FUNCTION(jsimd_convsamp_sse2)
|
|
37
|
-
|
|
38
|
-
EXTN(jsimd_convsamp_sse2):
|
|
39
|
-
push ebp
|
|
40
|
-
mov ebp, esp
|
|
41
|
-
push ebx
|
|
42
|
-
; push ecx ; need not be preserved
|
|
43
|
-
; push edx ; need not be preserved
|
|
44
|
-
push esi
|
|
45
|
-
push edi
|
|
46
|
-
|
|
47
|
-
pxor xmm6, xmm6 ; xmm6=(all 0's)
|
|
48
|
-
pcmpeqw xmm7, xmm7
|
|
49
|
-
psllw xmm7, 7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..}
|
|
50
|
-
|
|
51
|
-
mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *)
|
|
52
|
-
mov eax, JDIMENSION [start_col]
|
|
53
|
-
mov edi, POINTER [workspace] ; (DCTELEM *)
|
|
54
|
-
mov ecx, DCTSIZE/4
|
|
55
|
-
alignx 16, 7
|
|
56
|
-
.convloop:
|
|
57
|
-
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
|
|
58
|
-
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
|
|
59
|
-
|
|
60
|
-
movq xmm0, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE] ; xmm0=(01234567)
|
|
61
|
-
movq xmm1, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE] ; xmm1=(89ABCDEF)
|
|
62
|
-
|
|
63
|
-
mov ebx, JSAMPROW [esi+2*SIZEOF_JSAMPROW] ; (JSAMPLE *)
|
|
64
|
-
mov edx, JSAMPROW [esi+3*SIZEOF_JSAMPROW] ; (JSAMPLE *)
|
|
65
|
-
|
|
66
|
-
movq xmm2, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE] ; xmm2=(GHIJKLMN)
|
|
67
|
-
movq xmm3, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE] ; xmm3=(OPQRSTUV)
|
|
68
|
-
|
|
69
|
-
punpcklbw xmm0, xmm6 ; xmm0=(01234567)
|
|
70
|
-
punpcklbw xmm1, xmm6 ; xmm1=(89ABCDEF)
|
|
71
|
-
paddw xmm0, xmm7
|
|
72
|
-
paddw xmm1, xmm7
|
|
73
|
-
punpcklbw xmm2, xmm6 ; xmm2=(GHIJKLMN)
|
|
74
|
-
punpcklbw xmm3, xmm6 ; xmm3=(OPQRSTUV)
|
|
75
|
-
paddw xmm2, xmm7
|
|
76
|
-
paddw xmm3, xmm7
|
|
77
|
-
|
|
78
|
-
movdqa XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_DCTELEM)], xmm0
|
|
79
|
-
movdqa XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_DCTELEM)], xmm1
|
|
80
|
-
movdqa XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_DCTELEM)], xmm2
|
|
81
|
-
movdqa XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_DCTELEM)], xmm3
|
|
82
|
-
|
|
83
|
-
add esi, byte 4*SIZEOF_JSAMPROW
|
|
84
|
-
add edi, byte 4*DCTSIZE*SIZEOF_DCTELEM
|
|
85
|
-
dec ecx
|
|
86
|
-
jnz short .convloop
|
|
87
|
-
|
|
88
|
-
pop edi
|
|
89
|
-
pop esi
|
|
90
|
-
; pop edx ; need not be preserved
|
|
91
|
-
; pop ecx ; need not be preserved
|
|
92
|
-
pop ebx
|
|
93
|
-
pop ebp
|
|
94
|
-
ret
|
|
95
|
-
|
|
96
|
-
; --------------------------------------------------------------------------
|
|
97
|
-
;
|
|
98
|
-
; Quantize/descale the coefficients, and store into coef_block
|
|
99
|
-
;
|
|
100
|
-
; This implementation is based on an algorithm described in
|
|
101
|
-
; "How to optimize for the Pentium family of microprocessors"
|
|
102
|
-
; (http://www.agner.org/assem/).
|
|
103
|
-
;
|
|
104
|
-
; GLOBAL(void)
|
|
105
|
-
; jsimd_quantize_sse2(JCOEFPTR coef_block, DCTELEM *divisors,
|
|
106
|
-
; DCTELEM *workspace);
|
|
107
|
-
;
|
|
108
|
-
|
|
109
|
-
%define RECIPROCAL(m, n, b) \
|
|
110
|
-
XMMBLOCK(DCTSIZE * 0 + (m), (n), (b), SIZEOF_DCTELEM)
|
|
111
|
-
%define CORRECTION(m, n, b) \
|
|
112
|
-
XMMBLOCK(DCTSIZE * 1 + (m), (n), (b), SIZEOF_DCTELEM)
|
|
113
|
-
%define SCALE(m, n, b) \
|
|
114
|
-
XMMBLOCK(DCTSIZE * 2 + (m), (n), (b), SIZEOF_DCTELEM)
|
|
115
|
-
|
|
116
|
-
%define coef_block ebp + 8 ; JCOEFPTR coef_block
|
|
117
|
-
%define divisors ebp + 12 ; DCTELEM *divisors
|
|
118
|
-
%define workspace ebp + 16 ; DCTELEM *workspace
|
|
119
|
-
|
|
120
|
-
align 32
|
|
121
|
-
GLOBAL_FUNCTION(jsimd_quantize_sse2)
|
|
122
|
-
|
|
123
|
-
EXTN(jsimd_quantize_sse2):
|
|
124
|
-
push ebp
|
|
125
|
-
mov ebp, esp
|
|
126
|
-
; push ebx ; unused
|
|
127
|
-
; push ecx ; unused
|
|
128
|
-
; push edx ; need not be preserved
|
|
129
|
-
push esi
|
|
130
|
-
push edi
|
|
131
|
-
|
|
132
|
-
mov esi, POINTER [workspace]
|
|
133
|
-
mov edx, POINTER [divisors]
|
|
134
|
-
mov edi, JCOEFPTR [coef_block]
|
|
135
|
-
mov eax, DCTSIZE2/32
|
|
136
|
-
alignx 16, 7
|
|
137
|
-
.quantloop:
|
|
138
|
-
movdqa xmm4, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_DCTELEM)]
|
|
139
|
-
movdqa xmm5, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_DCTELEM)]
|
|
140
|
-
movdqa xmm6, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_DCTELEM)]
|
|
141
|
-
movdqa xmm7, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_DCTELEM)]
|
|
142
|
-
movdqa xmm0, xmm4
|
|
143
|
-
movdqa xmm1, xmm5
|
|
144
|
-
movdqa xmm2, xmm6
|
|
145
|
-
movdqa xmm3, xmm7
|
|
146
|
-
psraw xmm4, (WORD_BIT-1)
|
|
147
|
-
psraw xmm5, (WORD_BIT-1)
|
|
148
|
-
psraw xmm6, (WORD_BIT-1)
|
|
149
|
-
psraw xmm7, (WORD_BIT-1)
|
|
150
|
-
pxor xmm0, xmm4
|
|
151
|
-
pxor xmm1, xmm5
|
|
152
|
-
pxor xmm2, xmm6
|
|
153
|
-
pxor xmm3, xmm7
|
|
154
|
-
psubw xmm0, xmm4 ; if (xmm0 < 0) xmm0 = -xmm0;
|
|
155
|
-
psubw xmm1, xmm5 ; if (xmm1 < 0) xmm1 = -xmm1;
|
|
156
|
-
psubw xmm2, xmm6 ; if (xmm2 < 0) xmm2 = -xmm2;
|
|
157
|
-
psubw xmm3, xmm7 ; if (xmm3 < 0) xmm3 = -xmm3;
|
|
158
|
-
|
|
159
|
-
paddw xmm0, XMMWORD [CORRECTION(0,0,edx)] ; correction + roundfactor
|
|
160
|
-
paddw xmm1, XMMWORD [CORRECTION(1,0,edx)]
|
|
161
|
-
paddw xmm2, XMMWORD [CORRECTION(2,0,edx)]
|
|
162
|
-
paddw xmm3, XMMWORD [CORRECTION(3,0,edx)]
|
|
163
|
-
pmulhuw xmm0, XMMWORD [RECIPROCAL(0,0,edx)] ; reciprocal
|
|
164
|
-
pmulhuw xmm1, XMMWORD [RECIPROCAL(1,0,edx)]
|
|
165
|
-
pmulhuw xmm2, XMMWORD [RECIPROCAL(2,0,edx)]
|
|
166
|
-
pmulhuw xmm3, XMMWORD [RECIPROCAL(3,0,edx)]
|
|
167
|
-
pmulhuw xmm0, XMMWORD [SCALE(0,0,edx)] ; scale
|
|
168
|
-
pmulhuw xmm1, XMMWORD [SCALE(1,0,edx)]
|
|
169
|
-
pmulhuw xmm2, XMMWORD [SCALE(2,0,edx)]
|
|
170
|
-
pmulhuw xmm3, XMMWORD [SCALE(3,0,edx)]
|
|
171
|
-
|
|
172
|
-
pxor xmm0, xmm4
|
|
173
|
-
pxor xmm1, xmm5
|
|
174
|
-
pxor xmm2, xmm6
|
|
175
|
-
pxor xmm3, xmm7
|
|
176
|
-
psubw xmm0, xmm4
|
|
177
|
-
psubw xmm1, xmm5
|
|
178
|
-
psubw xmm2, xmm6
|
|
179
|
-
psubw xmm3, xmm7
|
|
180
|
-
movdqa XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_DCTELEM)], xmm0
|
|
181
|
-
movdqa XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_DCTELEM)], xmm1
|
|
182
|
-
movdqa XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_DCTELEM)], xmm2
|
|
183
|
-
movdqa XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_DCTELEM)], xmm3
|
|
184
|
-
|
|
185
|
-
add esi, byte 32*SIZEOF_DCTELEM
|
|
186
|
-
add edx, byte 32*SIZEOF_DCTELEM
|
|
187
|
-
add edi, byte 32*SIZEOF_JCOEF
|
|
188
|
-
dec eax
|
|
189
|
-
jnz near .quantloop
|
|
190
|
-
|
|
191
|
-
pop edi
|
|
192
|
-
pop esi
|
|
193
|
-
; pop edx ; need not be preserved
|
|
194
|
-
; pop ecx ; unused
|
|
195
|
-
; pop ebx ; unused
|
|
196
|
-
pop ebp
|
|
197
|
-
ret
|
|
198
|
-
|
|
199
|
-
; For some reason, the OS X linker does not honor the request to align the
|
|
200
|
-
; segment unless we do this.
|
|
201
|
-
align 32
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
;
|
|
2
|
-
; jsimdcpu.asm - SIMD instruction support check
|
|
3
|
-
;
|
|
4
|
-
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
|
5
|
-
; Copyright (C) 2016, D. R. Commander.
|
|
6
|
-
;
|
|
7
|
-
; Based on the x86 SIMD extension for IJG JPEG library
|
|
8
|
-
; Copyright (C) 1999-2006, MIYASAKA Masaru.
|
|
9
|
-
; For conditions of distribution and use, see copyright notice in jsimdext.inc
|
|
10
|
-
;
|
|
11
|
-
; This file should be assembled with NASM (Netwide Assembler),
|
|
12
|
-
; can *not* be assembled with Microsoft's MASM or any compatible
|
|
13
|
-
; assembler (including Borland's Turbo Assembler).
|
|
14
|
-
; NASM is available from http://nasm.sourceforge.net/ or
|
|
15
|
-
; http://sourceforge.net/project/showfiles.php?group_id=6208
|
|
16
|
-
|
|
17
|
-
%include "jsimdext.inc"
|
|
18
|
-
|
|
19
|
-
; --------------------------------------------------------------------------
|
|
20
|
-
SECTION SEG_TEXT
|
|
21
|
-
BITS 32
|
|
22
|
-
;
|
|
23
|
-
; Check if the CPU supports SIMD instructions
|
|
24
|
-
;
|
|
25
|
-
; GLOBAL(unsigned int)
|
|
26
|
-
; jpeg_simd_cpu_support(void)
|
|
27
|
-
;
|
|
28
|
-
|
|
29
|
-
align 32
|
|
30
|
-
GLOBAL_FUNCTION(jpeg_simd_cpu_support)
|
|
31
|
-
|
|
32
|
-
EXTN(jpeg_simd_cpu_support):
|
|
33
|
-
push ebx
|
|
34
|
-
; push ecx ; need not be preserved
|
|
35
|
-
; push edx ; need not be preserved
|
|
36
|
-
; push esi ; unused
|
|
37
|
-
push edi
|
|
38
|
-
|
|
39
|
-
xor edi, edi ; simd support flag
|
|
40
|
-
|
|
41
|
-
pushfd
|
|
42
|
-
pop eax
|
|
43
|
-
mov edx, eax
|
|
44
|
-
xor eax, 1<<21 ; flip ID bit in EFLAGS
|
|
45
|
-
push eax
|
|
46
|
-
popfd
|
|
47
|
-
pushfd
|
|
48
|
-
pop eax
|
|
49
|
-
xor eax, edx
|
|
50
|
-
jz near .return ; CPUID is not supported
|
|
51
|
-
|
|
52
|
-
; Check whether CPUID leaf 07H is supported
|
|
53
|
-
; (leaf 07H is used to check for AVX2 instruction support)
|
|
54
|
-
xor eax, eax
|
|
55
|
-
cpuid
|
|
56
|
-
test eax, eax
|
|
57
|
-
jz near .return
|
|
58
|
-
cmp eax, 7
|
|
59
|
-
jl short .no_avx2 ; Maximum leaf < 07H
|
|
60
|
-
|
|
61
|
-
; Check for AVX2 instruction support
|
|
62
|
-
mov eax, 7
|
|
63
|
-
xor ecx, ecx
|
|
64
|
-
cpuid
|
|
65
|
-
mov eax, ebx
|
|
66
|
-
test eax, 1<<5 ; bit5:AVX2
|
|
67
|
-
jz short .no_avx2
|
|
68
|
-
|
|
69
|
-
; Check for AVX2 O/S support
|
|
70
|
-
mov eax, 1
|
|
71
|
-
xor ecx, ecx
|
|
72
|
-
cpuid
|
|
73
|
-
test ecx, 1<<27
|
|
74
|
-
jz short .no_avx2 ; O/S does not support XSAVE
|
|
75
|
-
test ecx, 1<<28
|
|
76
|
-
jz short .no_avx2 ; CPU does not support AVX2
|
|
77
|
-
|
|
78
|
-
xor ecx, ecx
|
|
79
|
-
xgetbv
|
|
80
|
-
and eax, 6
|
|
81
|
-
cmp eax, 6 ; O/S does not manage XMM/YMM state
|
|
82
|
-
; using XSAVE
|
|
83
|
-
jnz short .no_avx2
|
|
84
|
-
|
|
85
|
-
or edi, JSIMD_AVX2
|
|
86
|
-
.no_avx2:
|
|
87
|
-
|
|
88
|
-
; Check CPUID leaf 01H for MMX, SSE, and SSE2 support
|
|
89
|
-
xor eax, eax
|
|
90
|
-
inc eax
|
|
91
|
-
cpuid
|
|
92
|
-
mov eax, edx ; eax = Standard feature flags
|
|
93
|
-
|
|
94
|
-
; Check for MMX instruction support
|
|
95
|
-
test eax, 1<<23 ; bit23:MMX
|
|
96
|
-
jz short .no_mmx
|
|
97
|
-
or edi, byte JSIMD_MMX
|
|
98
|
-
.no_mmx:
|
|
99
|
-
test eax, 1<<25 ; bit25:SSE
|
|
100
|
-
jz short .no_sse
|
|
101
|
-
or edi, byte JSIMD_SSE
|
|
102
|
-
.no_sse:
|
|
103
|
-
test eax, 1<<26 ; bit26:SSE2
|
|
104
|
-
jz short .no_sse2
|
|
105
|
-
or edi, byte JSIMD_SSE2
|
|
106
|
-
.no_sse2:
|
|
107
|
-
|
|
108
|
-
; Check for 3DNow! instruction support
|
|
109
|
-
mov eax, 0x80000000
|
|
110
|
-
cpuid
|
|
111
|
-
cmp eax, 0x80000000
|
|
112
|
-
jbe short .return
|
|
113
|
-
|
|
114
|
-
mov eax, 0x80000001
|
|
115
|
-
cpuid
|
|
116
|
-
mov eax, edx ; eax = Extended feature flags
|
|
117
|
-
|
|
118
|
-
test eax, 1<<31 ; bit31:3DNow!(vendor independent)
|
|
119
|
-
jz short .no_3dnow
|
|
120
|
-
or edi, byte JSIMD_3DNOW
|
|
121
|
-
.no_3dnow:
|
|
122
|
-
|
|
123
|
-
.return:
|
|
124
|
-
mov eax, edi
|
|
125
|
-
|
|
126
|
-
pop edi
|
|
127
|
-
; pop esi ; unused
|
|
128
|
-
; pop edx ; need not be preserved
|
|
129
|
-
; pop ecx ; need not be preserved
|
|
130
|
-
pop ebx
|
|
131
|
-
ret
|
|
132
|
-
|
|
133
|
-
; For some reason, the OS X linker does not honor the request to align the
|
|
134
|
-
; segment unless we do this.
|
|
135
|
-
align 32
|