1 | | |
2 | | |
3 | | |
4 | | |
5 | | |
6 | | |
7 | | |
8 | | |
9 | | |
10 | | |
11 | | |
12 | | |
13 | | |
14 | | |
15 | | |
16 | | |
17 | | |
18 | | |
19 | | |
20 | | |
21 | | |
22 | | |
23 | | |
24 | | |
25 | | |
26 | | |
27 | | |
28 | | |
29 | | |
30 | | |
31 | | |
32 | | |
33 | | |
34 | | |
35 | | |
36 | | |
37 | | |
38 | | |
39 | | |
40 | | |
41 | | |
42 | | |
43 | | |
44 | | |
45 | | |
46 | | |
47 | | |
48 | | |
49 | | |
50 | | |
51 | | |
52 | | |
53 | | |
54 | | |
55 | | |
56 | | |
57 | | |
58 | | |
59 | | |
60 | | |
61 | | |
62 | | |
63 | | |
64 | | |
65 | | |
66 | | |
67 | | |
68 | | |
69 | | |
70 | | |
71 | | |
72 | | |
73 | | |
74 | | |
75 | | |
76 | | |
77 | | |
78 | | |
79 | | |
80 | | |
81 | | |
82 | | |
83 | | |
84 | | |
85 | | |
86 | | |
87 | | |
88 | | |
89 | | |
90 | | |
91 | | |
92 | | |
93 | | |
94 | | |
95 | | |
96 | | |
97 | | |
98 | | |
99 | | |
100 | | |
101 | | |
102 | | |
103 | | |
104 | | |
105 | | |
106 | | |
107 | | |
108 | | |
109 | | |
110 | | |
111 | | |
112 | | |
113 | | |
114 | | |
115 | | |
116 | | |
117 | | |
118 | | |
119 | | |
120 | | |
121 | | |
122 | | |
123 | | |
124 | | |
125 | | |
126 | | |
127 | | |
128 | | |
129 | | |
130 | | |
131 | | |
132 | | |
133 | | |
134 | | |
135 | | |
136 | | |
137 | | |
138 | | |
139 | | |
140 | | |
141 | | |
142 | | |
143 | | |
144 | | |
145 | | |
146 | | |
147 | | |
148 | | |
149 | | |
150 | | |
151 | | |
152 | | |
153 | | |
154 | | |
155 | | |
156 | | |
157 | | |
158 | | |
159 | | |
160 | | |
161 | | |
162 | | |
163 | | |
164 | | |
165 | | |
166 | | |
167 | | |
168 | | |
169 | | |
170 | | |
171 | | |
172 | | |
173 | | |
174 | | |
175 | | |
176 | | |
177 | | |
178 | | |
179 | | |
180 | | |
181 | | |
182 | | |
183 | | |
184 | | |
185 | | |
186 | | |
187 | | |
188 | | |
189 | | |
190 | | |
191 | | |
192 | | |
193 | | |
194 | | |
195 | | |
196 | | |
197 | | |
198 | | |
199 | | |
200 | | |
201 | | |
202 | | |
203 | | |
204 | | |
205 | | |
206 | | |
207 | | |
208 | | |
209 | | |
210 | | |
211 | | |
212 | | |
213 | | |
214 | | |
215 | | |
216 | | |
217 | | |
218 | | |
219 | | |
220 | | |
221 | | |
222 | | |
223 | | |
224 | | |
225 | | |
226 | | |
227 | | |
228 | | |
229 | | |
230 | | |
231 | | |
232 | | |
233 | | |
234 | | |
235 | | |
236 | | |
237 | | |
| ; depends on nasm | | global image_mult_buffer_mmx_x86asm | global image_mult_buffers_mmx_x86asm | global image_add_buffers_mmx_x86asm | global image_add_buffer_mmx_x86asm | global image_sub_buffer_mmx_x86asm | | ; Add two images | ; | ; void image_add_buffer_mmx_x86asm( char *s1, char *s2, int npixels_div_8 ) | image_add_buffers_mmx_x86asm: | enter 0,0 | mov eax, [ebp+8] | mov edx, [ebp+12] | mov ecx, [ebp+16] | | .loop: | movq mm0, [edx] | add edx, 8 | paddusb mm0, [eax] | movq [eax],mm0 | add eax, 8 | loopnz .loop,ecx | | emms | leave | ret | | | | | ; Multiply two images | | ; Add a fixed rgb value to an image | ; | ; void image_mult_buffers_mmx_x86asm( char *s1, char *s2, int npixels_div_4 ) | image_mult_buffers_mmx_x86asm: | enter 0,0 | mov eax, [ebp+8] | mov edx, [ebp+12] | mov ecx, [ebp+16] | | pxor mm4,mm4 | | .loop: | movd mm0, [eax] | movd mm1, [edx] | punpcklbw mm0,mm4 | add edx, 4 | punpcklbw mm1,mm4 | pmullw mm0,mm1 | psrlw mm0, 8 | packuswb mm0,mm0 | movd [eax],mm0 | add eax, 4 | loopnz .loop,ecx | | emms | leave | ret | | | ; Subtract a RGB-value value to an image | ; | ; void image_sub_buffer_mmx_x86asm( char *source, int npixels, | ; int rgbr, int gbrg, int brgb ) | ; | ; eax address ebp+8 | ; mm0 sourcedata [eax] | ; ecx numpixels ebp+12 | ; mm1 mult1 <rgbr> ebp+16 | ; mm2 mult2 <gbrg> ebp+20 | ; mm3 mult3 <brgb> ebp+24 | ; mm4 null | image_sub_buffer_mmx_x86asm: | enter 0,0 | | mov eax, [ebp+8] | | mov ecx, [ebp+12] | | movd mm1,[ebp+16] ; rgb r | movd mm2,[ebp+20] ; gb rg | movd mm3,[ebp+24] ; b rgb | | ; r g b r g b r g b r g b r g b r g ... | ; 0 4 8 12 16 | ; | ; int is 0: r b g r | ; 4: g r b g | ; 8: b g r b | .loop: | movd mm0,[eax] | psubusb mm0,mm1 | movd [eax],mm0 | add eax,4 | | | movd mm0,[eax] | psubusb mm0,mm2 | movd [eax],mm0 | add eax,4 | | movd mm0,[eax] | psubusb mm0,mm3 | movd [eax],mm0 | add eax,4 | | loopnz .loop,ecx | | emms | leave | ret | | ; Add a RGB-value value to an image | ; | ; void image_add_buffer_mmx_x86asm( char *source, int npixels, | ; int rgbr, int gbrg, int brgb ) | ; | ; eax address ebp+8 | ; mm0 sourcedata [eax] | ; ecx numpixels ebp+12 | ; mm1 mult1 <rgbr> ebp+16 | ; mm2 mult2 <gbrg> ebp+20 | ; mm3 mult3 <brgb> ebp+24 | ; mm4 null | image_add_buffer_mmx_x86asm: | enter 0,0 | | mov eax, [ebp+8] | | mov ecx, [ebp+12] | | movd mm1,[ebp+16] ; rgb r | movd mm2,[ebp+20] ; gb rg | movd mm3,[ebp+24] ; b rgb | | | ; r g b r g b r g b r g b r g b r g ... | ; 0 4 8 12 16 | ; | ; int is 0: r b g r | ; 4: g r b g | ; 8: b g r b | .loop: | movd mm0,[eax] | paddusb mm0,mm1 | movd [eax],mm0 | add eax,4 | | movd mm0,[eax] | paddusb mm0,mm2 | movd [eax],mm0 | add eax,4 | | movd mm0,[eax] | paddusb mm0,mm3 | movd [eax],mm0 | add eax,4 | | loopnz .loop,ecx | | emms | leave | ret | | ; Multiply an image with a fixed rgb value | ; | ; void image_mult_buffer_mmx_x86asm( char *source, int npixels, | ; int rgbr, int gbrg, int brgb ) | ; | ; eax address ebp+8 | ; mm0 sourcedata [eax] | ; ecx numpixels ebp+12 | ; mm1 mult1 <rgbr> ebp+16 | ; mm2 mult2 <gbrg> ebp+20 | ; mm3 mult3 <brgb> ebp+24 | ; mm4 null | image_mult_buffer_mmx_x86asm: | enter 0,0 | | mov eax, [ebp+8] | | mov ecx, [ebp+12] | | pxor mm4,mm4 | | movd mm1,[ebp+16] ; rgb r | punpcklbw mm1, mm4 | | movd mm2,[ebp+20] ; gb rg | punpcklbw mm2, mm4 | | movd mm3,[ebp+24] ; b rgb | punpcklbw mm3, mm4 | | | | ; r g b r g b r g b r g b r g b r g ... | ; 0 4 8 12 16 | ; | ; int is 0: r b g r | ; 4: g r b g | ; 8: b g r b | .loop: | movd mm0,[eax] | punpcklbw mm0,mm4 | pmullw mm0,mm1 | psrlw mm0,8 | packuswb mm0,mm0 | movd [eax],mm0 | add eax,4 | | | movd mm0,[eax] | punpcklbw mm0,mm4 | pmullw mm0,mm2 | psrlw mm0,8 | packuswb mm0,mm0 | movd [eax],mm0 | add eax,4 | | movd mm0,[eax] | punpcklbw mm0,mm4 | pmullw mm0,mm3 | psrlw mm0,8 | packuswb mm0,mm0 | movd [eax],mm0 | add eax,4 | | loopnz .loop,ecx | | emms | leave | ret | |
|