Subversion Repositories Kolibri OS

Rev

Rev 109 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 109 Rev 135
1
;405 412 586
1
;405 412 586
2
;
2
;
3
;
3
;
4
bufer_size=1024*16+2
4
bufer_size=1024*16+2
5
fichero=4
5
fichero=4
6
mcu_ptr=8
6
mcu_ptr=8
7
color_ptr=12
7
color_ptr=12
8
estado=16
8
estado=16
9
color_c=17
9
color_c=17
10
nbits=color_c
10
nbits=color_c
11
idct=20
11
idct=20
12
tmp_bits=24
12
tmp_bits=24
13
actable=28
13
actable=28
14
matriz_limit=32
14
matriz_limit=32
15
sourcebits=36
15
sourcebits=36
16
sourcebits_index=40
16
sourcebits_index=40
17
sourcebits_limit=44
17
sourcebits_limit=44
18
qt_ptrs=48
18
qt_ptrs=48
19
ht_dc_ptrs=64
19
ht_dc_ptrs=64
20
ht_ac_ptrs=80
20
ht_ac_ptrs=80
21
matrices=96
21
matrices=96
22
tmp_bufer=100
22
tmp_bufer=100
23
x_org=104
23
x_org=104
24
y_org=108
24
y_org=108
25
x_mcu=112
25
x_mcu=112
26
y_mcu=116
26
y_mcu=116
27
x_size=120
27
x_size=120
28
y_size=124
28
y_size=124
29
x_org2=128
29
x_org2=128
30
y_org2=132
30
y_org2=132
31
x_mcu2=136
31
x_mcu2=136
32
y_mcu2=140
32
y_mcu2=140
33
x_size2=144
33
x_size2=144
34
y_size2=148
34
y_size2=148
35
q_ptr=152
35
q_ptr=152
36
dc=164
36
dc=164
37
position=204
37
position=204
38
draw_ptr=208
38
draw_ptr=208
39
struct_size=212
39
struct_size=212
40
 
40
 
41
jpeg_info:  ;fichero en eax
41
jpeg_info:  ;fichero en eax
42
            ;retorna ebp
42
            ;retorna ebp
43
        xor ebp,ebp
43
        xor ebp,ebp
44
        pushad
44
        pushad
45
        mov ebp,esp
45
        mov ebp,esp
46
        mov ecx,6
46
        mov ecx,6
47
        sub esp,ecx
47
        sub esp,ecx
48
        mov edi,esp
48
        mov edi,esp
49
        call read
49
        call read
50
        pop dx
50
        pop dx
51
        cmp dx,0d8ffh
51
        cmp dx,0d8ffh
52
        je .l1
52
        je .l1
53
        mov esp,ebp
53
        mov esp,ebp
54
        popad
54
        popad
55
        ret
55
        ret
56
   .l1: push eax
56
   .l1: push eax
57
        mov ecx,struct_size
57
        mov ecx,struct_size
58
        call mallocz
58
        call mallocz
59
        mov [edi],ebp
59
        mov [edi],ebp
60
        mov ebp,edi
60
        mov ebp,edi
61
        pop dword [ebp+fichero]
61
        pop dword [ebp+fichero]
62
        pop ax
62
        pop ax
63
        pop cx
63
        pop cx
64
        jmp .l3
64
        jmp .l3
65
   .l2: mov ebx,[ebp+tmp_bufer]
65
   .l2: mov ebx,[ebp+tmp_bufer]
66
        add ebx,[ebx-4]
66
        add ebx,[ebx-4]
67
        mov cx,[ebx-2]
67
        mov cx,[ebx-2]
68
        mov ax,[ebx-4]
68
        mov ax,[ebx-4]
69
   .l3: push .l2
69
   .l3: push .l2
70
        xchg cl,ch
70
        xchg cl,ch
71
        add cx,2
71
        add cx,2
72
        cmp ch,3
72
        cmp ch,3
73
        jnc .l4
73
        jnc .l4
74
        cmp al,0ffh
74
        cmp al,0ffh
75
        jne eoi
75
        jne eoi
76
        cmp ah,0dbh
76
        cmp ah,0dbh
77
        je dqt
77
        je dqt
78
        cmp ah,0c4h
78
        cmp ah,0c4h
79
        je dht
79
        je dht
80
        cmp ah,0c0h
80
        cmp ah,0c0h
81
        je sof0
81
        je sof0
82
        cmp ah,0dah
82
        cmp ah,0dah
83
        je sos
83
        je sos
84
        cmp ah,0c2h
84
        cmp ah,0c2h
85
        je eoi
85
        je eoi
86
        cmp ah,0c9h
86
        cmp ah,0c9h
87
        je eoi
87
        je eoi
88
        cmp ah,0d9h
88
        cmp ah,0d9h
89
        je eoi
89
        je eoi
90
   .l4: lea edx,[ecx-4]
90
   .l4: lea edx,[ecx-4]
91
        xor ecx,ecx
91
        xor ecx,ecx
92
        mov eax,[ebp+fichero]
92
        mov eax,[ebp+fichero]
93
        call skip
93
        call skip
94
        mov ecx,4
94
        mov ecx,4
95
        call READ
95
        call READ
96
        cmp ecx,[edi-4]
96
        cmp ecx,[edi-4]
97
        jne eoi
97
        jne eoi
98
        ret
98
        ret
99
 
99
 
100
eoi:
100
eoi:
101
      mov esp,[ebp]
101
      mov esp,[ebp]
-
 
102
; do not close file - this will be done by caller
-
 
103
        and       dword [ebp+fichero], 0
102
      call jpeg_close
104
      call jpeg_close
103
      popad
105
      popad
104
      xor ebp,ebp
106
      xor ebp,ebp
105
      ret
107
      ret
106
 
108
 
107
jpeg_close:
109
jpeg_close:
108
      test ebp,ebp
110
      test ebp,ebp
109
      jz .l2
111
      jz .l2
110
      pushad
112
      pushad
111
      mov eax,[ebp+fichero]
113
      mov eax,[ebp+fichero]
112
      call close
114
      call close
113
      mov edi,[ebp+sourcebits]
115
      mov edi,[ebp+sourcebits]
114
      call free
116
      call free
115
      lea esi,[ebp+qt_ptrs]
117
      lea esi,[ebp+qt_ptrs]
116
      mov ecx,14
118
      mov ecx,14
117
 .l1: mov edi,[esi]
119
 .l1: mov edi,[esi]
118
      add esi,4
120
      add esi,4
119
      call free
121
      call free
120
      loop .l1
122
      loop .l1
121
      mov edi,ebp
123
      mov edi,ebp
122
      call free
124
      call free
123
      popad
125
      popad
124
 .l2: ret
126
 .l2: ret
125
 
127
 
126
dqt:  call READ
128
dqt:  call READ
127
      mov esi,edi
129
      mov esi,edi
128
      lea eax,[edi+ecx]
130
      lea eax,[edi+ecx]
129
      push eax
131
      push eax
130
 .l1: xor eax,eax
132
 .l1: xor eax,eax
131
      lodsb
133
      lodsb
132
      cmp al,4
134
      cmp al,4
133
      jnc eoi
135
      jnc eoi
134
      lea ebx,[ebp+qt_ptrs+eax*4]
136
      lea ebx,[ebp+qt_ptrs+eax*4]
135
      test dword [ebx],-1
137
      test dword [ebx],-1
136
      jnz eoi
138
      jnz eoi
137
      mov ecx,64
139
      mov ecx,64
138
      xor eax,eax
140
      xor eax,eax
139
      sub esp,128
141
      sub esp,128
140
      mov edi,esp
142
      mov edi,esp
141
 .l2: lodsb
143
 .l2: lodsb
142
      stosw
144
      stosw
143
      loop .l2
145
      loop .l2
144
      mov ecx,256
146
      mov ecx,256
145
      call malloc
147
      call malloc
146
      mov [ebx],edi
148
      mov [ebx],edi
147
      mov eax,esi
149
      mov eax,esi
148
      mov esi,esp
150
      mov esi,esp
149
      pushad
151
      pushad
150
      mov ebp,zigzag
152
      mov ebp,zigzag
151
      fninit
153
      fninit
152
      mov cl,64
154
      mov cl,64
153
      xor eax,eax
155
      xor eax,eax
154
  .l3: fild word[esi]
156
  .l3: fild word[esi]
155
      mov al,[ebp]
157
      mov al,[ebp]
156
      and al,-2
158
      and al,-2
157
      add ebp,2
159
      add ebp,2
158
      add esi,2
160
      add esi,2
159
      mov ebx,eax
161
      mov ebx,eax
160
      and ebx,28
162
      and ebx,28
161
      fmul dword [ebx+k2]
163
      fmul dword [ebx+k2]
162
      mov ebx,eax
164
      mov ebx,eax
163
      shr ebx,3
165
      shr ebx,3
164
      and ebx,4+8+16
166
      and ebx,4+8+16
165
      fmul dword [ebx+k2]
167
      fmul dword [ebx+k2]
166
      fstp dword [edi+eax]
168
      fstp dword [edi+eax]
167
      dec cl
169
      dec cl
168
      jnz .l3
170
      jnz .l3
169
      popad
171
      popad
170
      mov esi,eax
172
      mov esi,eax
171
      add esp,128
173
      add esp,128
172
      mov eax,[esp]
174
      mov eax,[esp]
173
      sub eax,esi
175
      sub eax,esi
174
      jc eoi
176
      jc eoi
175
      cmp eax,4
177
      cmp eax,4
176
      ja .l1
178
      ja .l1
177
      jne eoi
179
      jne eoi
178
      pop eax
180
      pop eax
179
      ret
181
      ret
180
 
182
 
181
sof0:  call READ
183
sof0:  call READ
182
       cmp byte [edi],8
184
       cmp byte [edi],8
183
       jne eoi  ;precision
185
       jne eoi  ;precision
184
       mov ax,[edi+1]
186
       mov ax,[edi+1]
185
       xchg al,ah
187
       xchg al,ah
186
       mov [ebp+y_size],ax
188
       mov [ebp+y_size],ax
187
       mov ax,[edi+3]
189
       mov ax,[edi+3]
188
       xchg al,ah
190
       xchg al,ah
189
       mov [ebp+x_size],ax
191
       mov [ebp+x_size],ax
190
       mov al,[edi+5] ;ncomponentes
192
       mov al,[edi+5] ;ncomponentes
191
       mov cl,al
193
       mov cl,al
192
       mov [ebp+color_c],al
194
       mov [ebp+color_c],al
193
       mov edx,modes
195
       mov edx,modes
194
       dec al
196
       dec al
195
       jz .l1
197
       jz .l1
196
       dec al
198
       dec al
197
       dec al
199
       dec al
198
       jnz eoi
200
       jnz eoi
199
       mov al,[edi+10]
201
       mov al,[edi+10]
200
       mov ah,[edi+13]
202
       mov ah,[edi+13]
201
       cmp ax,1111h
203
       cmp ax,1111h
202
       jne eoi
204
       jne eoi
203
       mov al,[edi+7]
205
       mov al,[edi+7]
204
       add edx,16
206
       add edx,16
205
       cmp al,11h
207
       cmp al,11h
206
       je .l1
208
       je .l1
207
       add edx,16
209
       add edx,16
208
       cmp al,21h
210
       cmp al,21h
209
       je .l1
211
       je .l1
210
       add edx,16
212
       add edx,16
211
       cmp al,22h
213
       cmp al,22h
212
       jne eoi
214
       jne eoi
213
  .l1: lea ebx,[ebp+q_ptr]
215
  .l1: lea ebx,[ebp+q_ptr]
214
       lea esi,[ebp+qt_ptrs]
216
       lea esi,[ebp+qt_ptrs]
215
       mov [ebp+mcu_ptr],edx
217
       mov [ebp+mcu_ptr],edx
216
  .l2: movzx eax,byte [edi+8]
218
  .l2: movzx eax,byte [edi+8]
217
       add edi,3
219
       add edi,3
218
       cmp al,4
220
       cmp al,4
219
       jnc eoi
221
       jnc eoi
220
       lea eax,[eax*4+esi]
222
       lea eax,[eax*4+esi]
221
       mov [ebx],eax
223
       mov [ebx],eax
222
       add ebx,16
224
       add ebx,16
223
       dec cl
225
       dec cl
224
       jnz .l2
226
       jnz .l2
225
       ret
227
       ret
226
 
228
 
227
READ:  mov eax,[ebp+fichero]
229
READ:  mov eax,[ebp+fichero]
228
       mov edi,[ebp+tmp_bufer]
230
       mov edi,[ebp+tmp_bufer]
229
       movzx ecx,cx
231
       movzx ecx,cx
230
       call mresize
232
       call mresize
231
       mov [ebp+tmp_bufer],edi
233
       mov [ebp+tmp_bufer],edi
232
       jmp read
234
       jmp read
233
 
235
 
234
dht:    call READ
236
dht:    call READ
235
        mov esi,edi
237
        mov esi,edi
236
        lea eax,[edi+ecx]
238
        lea eax,[edi+ecx]
237
        push eax
239
        push eax
238
   .l1: lodsb
240
   .l1: lodsb
239
        mov edi,esi
241
        mov edi,esi
240
        mov ebx,3+16
242
        mov ebx,3+16
241
        and bl,al
243
        and bl,al
242
        cmp bl,al
244
        cmp bl,al
243
        jne eoi
245
        jne eoi
244
        shr bl,2
246
        shr bl,2
245
        and al,3
247
        and al,3
246
        or bl,al
248
        or bl,al
247
        lea ebx,[ebp+ht_dc_ptrs+ebx*4]
249
        lea ebx,[ebp+ht_dc_ptrs+ebx*4]
248
        test dword [ebx],-1
250
        test dword [ebx],-1
249
        jnz eoi
251
        jnz eoi
250
        mov cl,15
252
        mov cl,15
251
        mov al,[edi]
253
        mov al,[edi]
252
   .l2: inc edi  ;calcular numero de codigos
254
   .l2: inc edi  ;calcular numero de codigos
253
        add al,[edi]
255
        add al,[edi]
254
        jc eoi
256
        jc eoi
255
        dec cl
257
        dec cl
256
        jnz .l2
258
        jnz .l2
257
        movzx ecx,al
259
        movzx ecx,al
258
        lea ecx,[ecx*4+2]
260
        lea ecx,[ecx*4+2]
259
        call malloc
261
        call malloc
260
        mov [ebx],edi
262
        mov [ebx],edi
261
        call arbol_hf
263
        call arbol_hf
262
        mov eax,[esp]
264
        mov eax,[esp]
263
        sub eax,ebx
265
        sub eax,ebx
264
        jc eoi
266
        jc eoi
265
        mov esi,ebx
267
        mov esi,ebx
266
        cmp eax,4
268
        cmp eax,4
267
        ja .l1
269
        ja .l1
268
        jne eoi
270
        jne eoi
269
        pop eax
271
        pop eax
270
        ret
272
        ret
271
 
273
 
272
arbol_hf:   ;esi=ht edi=memoria para el arbol
274
arbol_hf:   ;esi=ht edi=memoria para el arbol
273
            ;retorna en ebx  el final de ht
275
            ;retorna en ebx  el final de ht
274
            ;codigos: bits 0-3=nbits del siguiente numero
276
            ;codigos: bits 0-3=nbits del siguiente numero
275
            ;         bits 4-7=numero de zeros
277
            ;         bits 4-7=numero de zeros
276
            ;         bits 8-14=longitud de este codigo o error si =127
278
            ;         bits 8-14=longitud de este codigo o error si =127
277
            ;         bit 15=codigo/puntero
279
            ;         bit 15=codigo/puntero
278
        push ebp
280
        push ebp
279
        lea ebx,[edi-2]
281
        lea ebx,[edi-2]
280
        add ebx,[ebx-2]
282
        add ebx,[ebx-2]
281
        mov word [ebx],-1 ;codigo de error si encontrado
283
        mov word [ebx],-1 ;codigo de error si encontrado
282
        push ebx
284
        push ebx
283
        push esi
285
        push esi
284
        lea ebx,[esi+16]
286
        lea ebx,[esi+16]
285
        mov ebp,esp
287
        mov ebp,esp
286
        xor ecx,ecx
288
        xor ecx,ecx
287
        push edi
289
        push edi
288
        push ecx
290
        push ecx
289
        add edi,2
291
        add edi,2
290
        mov dx,1
292
        mov dx,1
291
        add dh,[esi]
293
        add dh,[esi]
292
        jz .l3
294
        jz .l3
293
        jmp .l2
295
        jmp .l2
294
  .l1:  push edi
296
  .l1:  push edi
295
        push ecx
297
        push ecx
296
        add edi,2
298
        add edi,2
297
  .l2:  inc cl
299
  .l2:  inc cl
298
        cmp cl,dl
300
        cmp cl,dl
299
        jc .l1
301
        jc .l1
300
        mov al,[ebx]
302
        mov al,[ebx]
301
        inc ebx
303
        inc ebx
302
        mov ah,128 ;marca de codigo
304
        mov ah,128 ;marca de codigo
303
        or ah,dl
305
        or ah,dl
304
        cmp edi,[ebp+4]
306
        cmp edi,[ebp+4]
305
        jnc .l5
307
        jnc .l5
306
        stosw
308
        stosw
307
        cmp esp,ebp
309
        cmp esp,ebp
308
        jnc .l5
310
        jnc .l5
309
        pop ecx
311
        pop ecx
310
        pop esi
312
        pop esi
311
        lea eax,[edi-2]
313
        lea eax,[edi-2]
312
        sub eax,esi
314
        sub eax,esi
313
        mov [esi],ax
315
        mov [esi],ax
314
        dec dh
316
        dec dh
315
        jnz .l2 ;ncodigos
317
        jnz .l2 ;ncodigos
316
        mov esi,[ebp]
318
        mov esi,[ebp]
317
   .l3: inc esi
319
   .l3: inc esi
318
        inc dl
320
        inc dl
319
        cmp dl,17
321
        cmp dl,17
320
        jnc .l4
322
        jnc .l4
321
        add dh,[esi]
323
        add dh,[esi]
322
        jz .l3
324
        jz .l3
323
        mov [ebp],esi
325
        mov [ebp],esi
324
        jmp .l2
326
        jmp .l2
325
   .l4: lea esp,[ebp+8]
327
   .l4: lea esp,[ebp+8]
326
        pop ebp
328
        pop ebp
327
        ret
329
        ret
328
   .l5: mov ebp,[ebp+8]
330
   .l5: mov ebp,[ebp+8]
329
        jmp eoi
331
        jmp eoi
330
 
332
 
331
sos:   sub ecx,4  ;a continuacion vienen los datos de la imagen
333
sos:   sub ecx,4  ;a continuacion vienen los datos de la imagen
332
       call READ
334
       call READ
333
       mov eax,[ebp+fichero]
335
       mov eax,[ebp+fichero]
334
       call ftell
336
       call ftell
335
       mov [ebp+position],edx
337
       mov [ebp+position],edx
336
       mov esi,edi
338
       mov esi,edi
337
       lea edi,[ebp+q_ptr]
339
       lea edi,[ebp+q_ptr]
338
       lodsb ;numero de componentes
340
       lodsb ;numero de componentes
339
       sub [ebp+color_c],al
341
       sub [ebp+color_c],al
340
       jnz eoi
342
       jnz eoi
341
       mov dh,al
343
       mov dh,al
342
  .l1: mov ebx,[edi]
344
  .l1: mov ebx,[edi]
343
       mov eax,[ebx]
345
       mov eax,[ebx]
344
       stosd
346
       stosd
345
       lodsw
347
       lodsw
346
       mov cl,ah
348
       mov cl,ah
347
       and eax,0f00h
349
       and eax,0f00h
348
       and ecx,0f0h
350
       and ecx,0f0h
349
       shr eax,6
351
       shr eax,6
350
       shr ecx,2
352
       shr ecx,2
351
       lea ebx,[ebp+ht_ac_ptrs+eax]
353
       lea ebx,[ebp+ht_ac_ptrs+eax]
352
       mov eax,[ebx]
354
       mov eax,[ebx]
353
       lea ebx,[ebp+ht_dc_ptrs+ecx]
355
       lea ebx,[ebp+ht_dc_ptrs+ecx]
354
       mov ecx,[ebx]
356
       mov ecx,[ebx]
355
       test eax,eax
357
       test eax,eax
356
       jz eoi
358
       jz eoi
357
       test ecx,ecx
359
       test ecx,ecx
358
       jz eoi
360
       jz eoi
359
       stosd
361
       stosd
360
       mov eax,ecx
362
       mov eax,ecx
361
       stosd
363
       stosd
362
       add edi,4
364
       add edi,4
363
       dec dh
365
       dec dh
364
       jnz .l1
366
       jnz .l1
365
       mov edx,[ebp+mcu_ptr]
367
       mov edx,[ebp+mcu_ptr]
366
       cmp edx,modes
368
       cmp edx,modes
367
       jne .l2
369
       jne .l2
368
       lea esi,[ebp+q_ptr]
370
       lea esi,[ebp+q_ptr]
369
       lea edi,[ebp+q_ptr+32]
371
       lea edi,[ebp+q_ptr+32]
370
       movsd
372
       movsd
371
       movsd
373
       movsd
372
       movsd
374
       movsd
373
   .l2:
375
   .l2:
374
       mov esi,edx
376
       mov esi,edx
375
       push dword [esi]
377
       push dword [esi]
376
       pop dword [ebp+mcu_ptr]
378
       pop dword [ebp+mcu_ptr]
377
       push dword [esi+4]
379
       push dword [esi+4]
378
       pop dword[ebp+color_ptr]
380
       pop dword[ebp+color_ptr]
379
       push dword [esi+12]
381
       push dword [esi+12]
380
       pop dword [ebp+y_mcu]
382
       pop dword [ebp+y_mcu]
381
       push dword [esi+8]
383
       push dword [esi+8]
382
       pop dword [ebp+x_mcu]
384
       pop dword [ebp+x_mcu]
383
       mov ecx,64*18
385
       mov ecx,64*18
384
       call malloc
386
       call malloc
385
       mov [ebp+matrices],edi
387
       mov [ebp+matrices],edi
386
       mov ecx,bufer_size
388
       mov ecx,bufer_size
387
       call malloc
389
       call malloc
388
       mov [ebp+sourcebits],edi
390
       mov [ebp+sourcebits],edi
389
       mov esp,[ebp]
391
       mov esp,[ebp]
390
       mov [esp+8],ebp
392
       mov [esp+8],ebp
391
       popad
393
       popad
392
       ret
394
       ret
393
 
395
 
394
jpeg_display:
396
jpeg_display:
395
       test ebp,ebp
397
       test ebp,ebp
396
       jnz .inicio
398
       jnz .inicio
397
       ret
399
       ret
398
      .inicio:
400
      .inicio:
399
       pushad
401
       pushad
400
       mov [ebp],esp
402
       mov [ebp],esp
401
       mov eax,[ebp+fichero]
403
       mov eax,[ebp+fichero]
402
       mov edx,[ebp+position]
404
       mov edx,[ebp+position]
403
       call lseek
405
       call lseek
404
       mov edi,[ebp+sourcebits]
406
       mov edi,[ebp+sourcebits]
405
       add edi,bufer_size
407
       add edi,bufer_size
406
       mov [ebp+sourcebits_index],edi
408
       mov [ebp+sourcebits_index],edi
407
       sub edi,2
409
       sub edi,2
408
       mov [ebp+sourcebits_limit],edi
410
       mov [ebp+sourcebits_limit],edi
409
       mov edi,[ebp+matrices]
411
       mov edi,[ebp+matrices]
410
       mov [ebp+matriz_limit],edi
412
       mov [ebp+matriz_limit],edi
411
       xor eax,eax
413
       xor eax,eax
412
       mov [esp+8],eax
414
       mov [esp+8],eax
413
       mov [ebp+estado],eax
415
       mov [ebp+estado],eax
414
       mov [ebp+tmp_bits],eax
416
       mov [ebp+tmp_bits],eax
415
       mov [ebp+dc],eax
417
       mov [ebp+dc],eax
416
       mov [ebp+dc+16],eax
418
       mov [ebp+dc+16],eax
417
       mov [ebp+dc+32],eax
419
       mov [ebp+dc+32],eax
418
 
420
 
419
       mov eax,[ebp+y_mcu]
421
       mov eax,[ebp+y_mcu]
420
       mov ecx,[ebp+y_org]
422
       mov ecx,[ebp+y_org]
421
       sub ecx,eax
423
       sub ecx,eax
422
       mov [ebp+y_org2],ecx
424
       mov [ebp+y_org2],ecx
423
       mov [ebp+y_mcu2],eax
425
       mov [ebp+y_mcu2],eax
424
       push dword [ebp+y_size]
426
       push dword [ebp+y_size]
425
       pop dword [ebp+y_size2]
427
       pop dword [ebp+y_size2]
426
  .l3: push dword [ebp+x_org]
428
  .l3: push dword [ebp+x_org]
427
       pop dword [ebp+x_org2]
429
       pop dword [ebp+x_org2]
428
       push dword [ebp+x_mcu]
430
       push dword [ebp+x_mcu]
429
       pop dword [ebp+x_mcu2]
431
       pop dword [ebp+x_mcu2]
430
       push dword [ebp+x_size]
432
       push dword [ebp+x_size]
431
       pop dword [ebp+x_size2]
433
       pop dword [ebp+x_size2]
432
       mov eax,[ebp+y_mcu2]
434
       mov eax,[ebp+y_mcu2]
433
       add [ebp+y_org2],eax
435
       add [ebp+y_org2],eax
434
       sub [ebp+y_size2],eax
436
       sub [ebp+y_size2],eax
435
       jnc .l4
437
       jnc .l4
436
       add eax,[ebp+y_size2]
438
       add eax,[ebp+y_size2]
437
       jnz .cont
439
       jnz .cont
438
       mov [esp+8],ebp
440
       mov [esp+8],ebp
439
       popad
441
       popad
440
       ret
442
       ret
441
     .cont:
443
     .cont:
442
       mov dword [ebp+y_size2],0
444
       mov dword [ebp+y_size2],0
443
       mov [ebp+y_mcu2],eax
445
       mov [ebp+y_mcu2],eax
444
      .l4:
446
      .l4:
445
        mov eax,[ebp+x_mcu2]
447
        mov eax,[ebp+x_mcu2]
446
        sub [ebp+x_size2],eax
448
        sub [ebp+x_size2],eax
447
        jnc .l5
449
        jnc .l5
448
        add eax,[ebp+x_size2]
450
        add eax,[ebp+x_size2]
449
        jz .l3
451
        jz .l3
450
        mov dword [ebp+x_size2],0
452
        mov dword [ebp+x_size2],0
451
        mov [ebp+x_mcu2],eax
453
        mov [ebp+x_mcu2],eax
452
        call dword [ebp+mcu_ptr]
454
        call dword [ebp+mcu_ptr]
453
        mov eax,[ebp+x_mcu]
455
        mov eax,[ebp+x_mcu]
454
        mov ecx,[ebp+x_mcu2]
456
        mov ecx,[ebp+x_mcu2]
455
        mov edx,[ebp+y_mcu2]
457
        mov edx,[ebp+y_mcu2]
456
        call recortar
458
        call recortar
457
        jmp .l6
459
        jmp .l6
458
      .l5:
460
      .l5:
459
        call dword [ebp+mcu_ptr]
461
        call dword [ebp+mcu_ptr]
460
        mov ecx,[ebp+x_mcu2]
462
        mov ecx,[ebp+x_mcu2]
461
        mov edx,[ebp+y_mcu2]
463
        mov edx,[ebp+y_mcu2]
462
      .l6:
464
      .l6:
463
        mov eax,[ebp+x_org2]
465
        mov eax,[ebp+x_org2]
464
        mov ebx,[ebp+y_org2]
466
        mov ebx,[ebp+y_org2]
465
        call dword [ebp+draw_ptr]
467
        call dword [ebp+draw_ptr]
466
        add [ebp+x_org2],ecx
468
        add [ebp+x_org2],ecx
467
        mov ax,[ebp+estado]
469
        mov ax,[ebp+estado]
468
        test al,15
470
        test al,15
469
        jz .l4
471
        jz .l4
470
        cmp ah,8
472
        cmp ah,8
471
        jnc .l4
473
        jnc .l4
472
        xor edx,edx
474
        xor edx,edx
473
        mov [ebp+tmp_bits],edx
475
        mov [ebp+tmp_bits],edx
474
        mov [ebp+dc],edx
476
        mov [ebp+dc],edx
475
        mov [ebp+dc+16],edx
477
        mov [ebp+dc+16],edx
476
        mov [ebp+dc+32],edx
478
        mov [ebp+dc+32],edx
477
        add dword [ebp+sourcebits_index],2
479
        add dword [ebp+sourcebits_index],2
478
        and word [ebp+estado],0c0h
480
        and word [ebp+estado],0c0h
479
        test al,32
481
        test al,32
480
        jz .l4
482
        jz .l4
481
        jmp .l3
483
        jmp .l3
482
 
484
 
483
color100:
485
color100:
484
        push edi
486
        push edi
485
    .l1: lodsw
487
    .l1: lodsw
486
        mov dl,ah
488
        mov dl,ah
487
        mov ah,al
489
        mov ah,al
488
        stosw
490
        stosw
489
        mov ah,dl
491
        mov ah,dl
490
        stosb
492
        stosb
491
        mov al,dl
493
        mov al,dl
492
        stosb
494
        stosb
493
        stosw
495
        stosw
494
        dec cl
496
        dec cl
495
        jnz .l1
497
        jnz .l1
496
        pop edi
498
        pop edi
497
        ret
499
        ret
498
 
500
 
499
color111:
501
color111:
500
        push edi
502
        push edi
501
   .l1: lodsw
503
   .l1: lodsw
502
        mov bx,[esi+62]
504
        mov bx,[esi+62]
503
        mov dx,[esi+126]
505
        mov dx,[esi+126]
504
        xchg ah,bh
506
        xchg ah,bh
505
        xchg ah,dl
507
        xchg ah,dl
506
        xchg ah,bl
508
        xchg ah,bl
507
        stosw
509
        stosw
508
        mov ax,bx
510
        mov ax,bx
509
        stosw
511
        stosw
510
        mov ax,dx
512
        mov ax,dx
511
        stosw
513
        stosw
512
        dec cl
514
        dec cl
513
        jnz .l1
515
        jnz .l1
514
        pop edi
516
        pop edi
515
        mov ecx,64*3
517
        mov ecx,64*3
516
        jmp ybr_bgr
518
        jmp ybr_bgr
517
 
519
 
518
color411:
520
color411:
519
        push ebp
521
        push ebp
520
        push edi
522
        push edi
521
        lea ebp,[esi+ecx*8]
523
        lea ebp,[esi+ecx*8]
522
     .l1: push ecx
524
     .l1: push ecx
523
        mov ax,[esi]
525
        mov ax,[esi]
524
        mov cx,[ebp]
526
        mov cx,[ebp]
525
        mov dx,[ebp+64]
527
        mov dx,[ebp+64]
526
        add ebp,2
528
        add ebp,2
527
        xchg ch,dl
529
        xchg ch,dl
528
        mov bx,ax
530
        mov bx,ax
529
        mov ah,cl
531
        mov ah,cl
530
        mov bl,ch
532
        mov bl,ch
531
        mov [edi],ax
533
        mov [edi],ax
532
        mov [edi+2],bx
534
        mov [edi+2],bx
533
        mov [edi+4],cx
535
        mov [edi+4],cx
534
        mov ax,[esi+8]
536
        mov ax,[esi+8]
535
        mov bh,ah
537
        mov bh,ah
536
        mov ah,cl
538
        mov ah,cl
537
        mov [edi+48],ax
539
        mov [edi+48],ax
538
        mov [edi+48+2],bx
540
        mov [edi+48+2],bx
539
        mov [edi+48+4],cx
541
        mov [edi+48+4],cx
540
        mov ax,[esi+2]
542
        mov ax,[esi+2]
541
        mov bx,ax
543
        mov bx,ax
542
        mov ah,dl
544
        mov ah,dl
543
        mov bl,dh
545
        mov bl,dh
544
        mov [edi+6],ax
546
        mov [edi+6],ax
545
        mov [edi+2+6],bx
547
        mov [edi+2+6],bx
546
        mov [edi+4+6],dx
548
        mov [edi+4+6],dx
547
        mov ax,[esi+8+2]
549
        mov ax,[esi+8+2]
548
        mov bh,ah
550
        mov bh,ah
549
        mov ah,dl
551
        mov ah,dl
550
        mov [edi+48+6],ax
552
        mov [edi+48+6],ax
551
        mov [edi+48+2+6],bx
553
        mov [edi+48+2+6],bx
552
        mov [edi+48+4+6],dx
554
        mov [edi+48+4+6],dx
553
        pop ecx
555
        pop ecx
554
        add edi,12
556
        add edi,12
555
        dec ecx
557
        dec ecx
556
        add esi,4
558
        add esi,4
557
        test cl,1
559
        test cl,1
558
        jnz .l1
560
        jnz .l1
559
        add esi,64-8
561
        add esi,64-8
560
        test cl,2
562
        test cl,2
561
        jnz .l1
563
        jnz .l1
562
        sub esi,128-16
564
        sub esi,128-16
563
        add edi,48
565
        add edi,48
564
        test cl,15
566
        test cl,15
565
        jnz .l1
567
        jnz .l1
566
        add esi,64
568
        add esi,64
567
        test cl,cl
569
        test cl,cl
568
        jnz .l1
570
        jnz .l1
569
        pop edi
571
        pop edi
570
        pop ebp
572
        pop ebp
571
        mov ecx,64*4*3
573
        mov ecx,64*4*3
572
        jmp ybr_bgr
574
        jmp ybr_bgr
573
 
575
 
574
color211:
576
color211:
575
        push ebp
577
        push ebp
576
        push edi
578
        push edi
577
        lea ebp,[esi+ecx*4]
579
        lea ebp,[esi+ecx*4]
578
    .l1: push ecx
580
    .l1: push ecx
579
        mov ax,[esi]
581
        mov ax,[esi]
580
        mov cx,[ebp]
582
        mov cx,[ebp]
581
        mov dx,[ebp+64]
583
        mov dx,[ebp+64]
582
        add ebp,2
584
        add ebp,2
583
        xchg ch,dl
585
        xchg ch,dl
584
        mov bx,ax
586
        mov bx,ax
585
        mov ah,cl
587
        mov ah,cl
586
        mov bl,ch
588
        mov bl,ch
587
        mov [edi],ax
589
        mov [edi],ax
588
        mov [edi+2],bx
590
        mov [edi+2],bx
589
        mov [edi+4],cx
591
        mov [edi+4],cx
590
        mov ax,[esi+2]
592
        mov ax,[esi+2]
591
        mov bx,ax
593
        mov bx,ax
592
        mov ah,dl
594
        mov ah,dl
593
        mov bl,dh
595
        mov bl,dh
594
        mov [edi+6],ax
596
        mov [edi+6],ax
595
        mov [edi+2+6],bx
597
        mov [edi+2+6],bx
596
        mov [edi+4+6],dx
598
        mov [edi+4+6],dx
597
        pop ecx
599
        pop ecx
598
        add edi,12
600
        add edi,12
599
        dec cl
601
        dec cl
600
        add esi,4
602
        add esi,4
601
        test cl,1
603
        test cl,1
602
        jnz .l1
604
        jnz .l1
603
        add esi,64-8
605
        add esi,64-8
604
        test cl,2
606
        test cl,2
605
        jnz .l1
607
        jnz .l1
606
        sub esi,128-8
608
        sub esi,128-8
607
        test cl,cl
609
        test cl,cl
608
        jnz .l1
610
        jnz .l1
609
        pop edi
611
        pop edi
610
        pop ebp
612
        pop ebp
611
        mov ecx,64*3*2
613
        mov ecx,64*3*2
612
        jmp ybr_bgr
614
        jmp ybr_bgr
613
 
615
 
614
 
616
 
615
mcu411: lea ebx,[ebp+q_ptr]
617
mcu411: lea ebx,[ebp+q_ptr]
616
        call hufdecode
618
        call hufdecode
617
        lea ebx,[ebp+q_ptr]
619
        lea ebx,[ebp+q_ptr]
618
        call hufdecode
620
        call hufdecode
619
mcu211: lea ebx,[ebp+q_ptr]
621
mcu211: lea ebx,[ebp+q_ptr]
620
        call hufdecode
622
        call hufdecode
621
mcu111: lea ebx,[ebp+q_ptr]
623
mcu111: lea ebx,[ebp+q_ptr]
622
        call hufdecode
624
        call hufdecode
623
        lea ebx,[ebp+q_ptr+16]
625
        lea ebx,[ebp+q_ptr+16]
624
        call hufdecode
626
        call hufdecode
625
mcu100: lea ebx,[ebp+q_ptr+32]
627
mcu100: lea ebx,[ebp+q_ptr+32]
626
        call hufdecode
628
        call hufdecode
627
        mov esi,[ebp+matrices]
629
        mov esi,[ebp+matrices]
628
        mov dword [ebp+matriz_limit],esi
630
        mov dword [ebp+matriz_limit],esi
629
        mov ecx,32
631
        mov ecx,32
630
        lea edi,[esi+64*6]
632
        lea edi,[esi+64*6]
631
        jmp dword [ebp+color_ptr]
633
        jmp dword [ebp+color_ptr]
632
 
634
 
633
cargar_bits: ;edx=bits,cl=nbits,
635
cargar_bits: ;edx=bits,cl=nbits,
634
             ;bp=data struct
636
             ;bp=data struct
635
             ;cr: cl,edx,eax,si
637
             ;cr: cl,edx,eax,si
636
             ;ncr bx,bp,di,ch
638
             ;ncr bx,bp,di,ch
637
 
639
 
638
        mov esi,[ebp+sourcebits_index]
640
        mov esi,[ebp+sourcebits_index]
639
        cmp esi,[ebp+sourcebits_limit]
641
        cmp esi,[ebp+sourcebits_limit]
640
        jnc .l6
642
        jnc .l6
641
        movzx eax,byte [esi]
643
        movzx eax,byte [esi]
642
        inc esi
644
        inc esi
643
        add cl,8
645
        add cl,8
644
        cmp al,-1
646
        cmp al,-1
645
        je .l2
647
        je .l2
646
        mov ah,al
648
        mov ah,al
647
        lodsb
649
        lodsb
648
        add cl,8
650
        add cl,8
649
        cmp al,-1
651
        cmp al,-1
650
        je .l2
652
        je .l2
651
   .l1: ror eax,cl
653
   .l1: ror eax,cl
652
        or edx,eax
654
        or edx,eax
653
        mov [ebp+sourcebits_index],esi
655
        mov [ebp+sourcebits_index],esi
654
        ret
656
        ret
655
   .l2: lodsb
657
   .l2: lodsb
656
        test al,al
658
        test al,al
657
        jnz .l3
659
        jnz .l3
658
        mov al,-1
660
        mov al,-1
659
        call .l1
661
        call .l1
660
        cmp cl,16
662
        cmp cl,16
661
        jc cargar_bits
663
        jc cargar_bits
662
        ret
664
        ret
663
   .l3: sub esi,2
665
   .l3: sub esi,2
664
        sub cl,8
666
        sub cl,8
665
        sub al,0d0h
667
        sub al,0d0h
666
        cmp al,8
668
        cmp al,8
667
        jc .l4
669
        jc .l4
668
        sub al,9
670
        sub al,9
669
        mov al,63
671
        mov al,63
670
        jz .l4
672
        jz .l4
671
        mov al,127
673
        mov al,127
672
    .l4: inc al
674
    .l4: inc al
673
        or [ebp+estado],al
675
        or [ebp+estado],al
674
        movzx eax,ah
676
        movzx eax,ah
675
        jmp .l1
677
        jmp .l1
676
    .l5: mov [ebp+sourcebits_limit],edi
678
    .l5: mov [ebp+sourcebits_limit],edi
677
        mov word [edi],0d9ffh
679
        mov word [edi],0d9ffh
678
        popad
680
        popad
679
        jmp cargar_bits
681
        jmp cargar_bits
680
   .l6: ;read file
682
   .l6: ;read file
681
        pushad
683
        pushad
682
        mov ecx,bufer_size-2
684
        mov ecx,bufer_size-2
683
        mov edx,[ebp+sourcebits_limit]
685
        mov edx,[ebp+sourcebits_limit]
684
        mov edi,[ebp+sourcebits]
686
        mov edi,[ebp+sourcebits]
685
        mov ax,[edx]
687
        mov ax,[edx]
686
        sub edx,edi
688
        sub edx,edi
687
        stosw
689
        stosw
688
        sub esi,edx
690
        sub esi,edx
689
        mov [ebp+sourcebits_index],esi
691
        mov [ebp+sourcebits_index],esi
690
        cmp edx,ecx
692
        cmp edx,ecx
691
        jne .l5
693
        jne .l5
692
        mov eax,[ebp+fichero]
694
        mov eax,[ebp+fichero]
693
        call read
695
        call read
694
        lea ecx,[edi+ecx-2]
696
        lea ecx,[edi+ecx-2]
695
        mov [ebp+sourcebits_limit],ecx
697
        mov [ebp+sourcebits_limit],ecx
696
        popad
698
        popad
697
        jmp cargar_bits
699
        jmp cargar_bits
698
 
700
 
699
 
701
 
700
hufdecode:  ;si->dctable [bp+20]->actable di->outbufer edx->bits cl->bits en edx
702
hufdecode:  ;si->dctable [bp+20]->actable di->outbufer edx->bits cl->bits en edx
701
 
703
 
702
 
704
 
703
            ;[bp+24]->sourcebits
705
            ;[bp+24]->sourcebits
704
            ;[bp+22]=outbufer+128
706
            ;[bp+22]=outbufer+128
705
            ;[bx]       q ptr para aa&n
707
            ;[bx]       q ptr para aa&n
706
            ;[bx+2]     a ptr
708
            ;[bx+2]     a ptr
707
            ;[bx+4]     d ptr
709
            ;[bx+4]     d ptr
708
            ;[bx+8]     dc componente
710
            ;[bx+8]     dc componente
709
        fninit
711
        fninit
710
        push dword [ebx]
712
        push dword [ebx]
711
        mov cl,[ebp+nbits]
713
        mov cl,[ebp+nbits]
712
        mov edx,[ebp+tmp_bits]
714
        mov edx,[ebp+tmp_bits]
713
        cmp cl,16
715
        cmp cl,16
714
        jnc .l1
716
        jnc .l1
715
        call cargar_bits
717
        call cargar_bits
716
    .l1: mov eax,[ebx+4]
718
    .l1: mov eax,[ebx+4]
717
        mov esi,[ebx+8]
719
        mov esi,[ebx+8]
718
        mov [ebp+actable],eax
720
        mov [ebp+actable],eax
719
        movzx eax,word [esi]
721
        movzx eax,word [esi]
720
        add esi,2
722
        add esi,2
721
   .l2: add edx,edx
723
   .l2: add edx,edx
722
        jnc .l3
724
        jnc .l3
723
        add esi,eax
725
        add esi,eax
724
   .l3: lodsw
726
   .l3: lodsw
725
        test ax,ax
727
        test ax,ax
726
        jns .l2
728
        jns .l2
727
        ;codigo encontrado
729
        ;codigo encontrado
728
        and ax,7f0fh
730
        and ax,7f0fh
729
        mov edi,[ebp+matriz_limit] ;arrays
731
        mov edi,[ebp+matriz_limit] ;arrays
730
        sub cl,ah
732
        sub cl,ah
731
        jns .l4
733
        jns .l4
732
        fldz
734
        fldz
733
   .error:
735
   .error:
734
        xor ecx,ecx
736
        xor ecx,ecx
735
        or byte [ebp+estado],32
737
        or byte [ebp+estado],32
736
        jmp .l12
738
        jmp .l12
737
   .l4: cmp cl,al
739
   .l4: cmp cl,al
738
        jnc .l5
740
        jnc .l5
739
        push eax
741
        push eax
740
        call cargar_bits
742
        call cargar_bits
741
        pop eax
743
        pop eax
742
   .l5: sub cl,al
744
   .l5: sub cl,al
743
        mov ch,cl
745
        mov ch,cl
744
        mov cl,al
746
        mov cl,al
745
        mov eax,edx
747
        mov eax,edx
746
        shl edx,cl
748
        shl edx,cl
747
        sar eax,17
749
        sar eax,17
748
        xor ax,8000h
750
        xor ax,8000h
749
        xor cl,15
751
        xor cl,15
750
        sar ax,cl
752
        sar ax,cl
751
        mov cl,ch
753
        mov cl,ch
752
        mov ch,2
754
        mov ch,2
753
        add ax,8000h ;incrementar si negativo
755
        add ax,8000h ;incrementar si negativo
754
        adc ax,8000h
756
        adc ax,8000h
755
        add [ebx+12],ax
757
        add [ebx+12],ax
756
        fild word [ebx+12]
758
        fild word [ebx+12]
757
        push ecx
759
        push ecx
758
        mov ecx,64
760
        mov ecx,64
759
        xor eax,eax
761
        xor eax,eax
760
        add [ebp+matriz_limit],ecx
762
        add [ebp+matriz_limit],ecx
761
        rep stosd
763
        rep stosd
762
        pop ecx
764
        pop ecx
763
        sub edi,64*4
765
        sub edi,64*4
764
        mov ebx,[esp]
766
        mov ebx,[esp]
765
        fmul dword [ebx]
767
        fmul dword [ebx]
766
    .l6: cmp cl,16
768
    .l6: cmp cl,16
767
        jnc .l7
769
        jnc .l7
768
        call cargar_bits
770
        call cargar_bits
769
   .l7: mov esi,[ebp+actable]
771
   .l7: mov esi,[ebp+actable]
770
        movzx eax,word[esi]
772
        movzx eax,word[esi]
771
        add esi,2
773
        add esi,2
772
   .l8: add edx,edx
774
   .l8: add edx,edx
773
        jnc .l9
775
        jnc .l9
774
        add esi,eax
776
        add esi,eax
775
   .l9: lodsw
777
   .l9: lodsw
776
        test ax,ax
778
        test ax,ax
777
        jns .l8
779
        jns .l8
778
        ;codigo encontrado
780
        ;codigo encontrado
779
        and ah,127
781
        and ah,127
780
        xor ebx,ebx
782
        xor ebx,ebx
781
        sub cl,ah
783
        sub cl,ah
782
        js .error
784
        js .error
783
        or bl,al
785
        or bl,al
784
        jz .l12
786
        jz .l12
785
        and al,0f0h
787
        and al,0f0h
786
        shr al,3
788
        shr al,3
787
        add ch,al
789
        add ch,al
788
        js .error
790
        js .error
789
        and bl,0fh
791
        and bl,0fh
790
        jz .l11
792
        jz .l11
791
        cmp cl,bl
793
        cmp cl,bl
792
        jnc .l10
794
        jnc .l10
793
        call cargar_bits
795
        call cargar_bits
794
    .l10: sub cl,bl
796
    .l10: sub cl,bl
795
        xchg bl,cl
797
        xchg bl,cl
796
        mov eax,edx
798
        mov eax,edx
797
        shl edx,cl
799
        shl edx,cl
798
        sar eax,17
800
        sar eax,17
799
        xor cl,15
801
        xor cl,15
800
        xor ax,8000h
802
        xor ax,8000h
801
        sar ax,cl
803
        sar ax,cl
802
        add ax,8000h ;incrementar si negativo
804
        add ax,8000h ;incrementar si negativo
803
        adc ax,8000h
805
        adc ax,8000h
804
        mov cl,bl
806
        mov cl,bl
805
        mov bl,ch
807
        mov bl,ch
806
        mov [ebp+tmp_bits],ax
808
        mov [ebp+tmp_bits],ax
807
        mov ax,[ebx+zigzag]
809
        mov ax,[ebx+zigzag]
808
        mov ebx,[esp]
810
        mov ebx,[esp]
809
        fild word [ebp+tmp_bits]
811
        fild word [ebp+tmp_bits]
810
        or [ebp+idct],ax
812
        or [ebp+idct],ax
811
        and eax,11111100b
813
        and eax,11111100b
812
        fmul dword [ebx+eax]
814
        fmul dword [ebx+eax]
813
        fstp dword [edi+eax]
815
        fstp dword [edi+eax]
814
  .l11: add ch,2
816
  .l11: add ch,2
815
        jns .l6
817
        jns .l6
816
  .l12: mov [ebp+nbits],cl
818
  .l12: mov [ebp+nbits],cl
817
        mov [ebp+tmp_bits],edx
819
        mov [ebp+tmp_bits],edx
818
        xor ebx,ebx
820
        xor ebx,ebx
819
        add esp,4
821
        add esp,4
820
        xchg ebx,[ebp+idct]
822
        xchg ebx,[ebp+idct]
821
        cmp ch,2
823
        cmp ch,2
822
        je idctf1
824
        je idctf1
823
        fstp dword [edi]
825
        fstp dword [edi]
824
        test bh,0feh
826
        test bh,0feh
825
        jnz idctf3
827
        jnz idctf3
826
idctf2a: test bh,1
828
idctf2a: test bh,1
827
        mov esi,edi
829
        mov esi,edi
828
        jz .l1
830
        jz .l1
829
        test bl,1
831
        test bl,1
830
        jnz idctf3
832
        jnz idctf3
831
        push idctf2b
833
        push idctf2b
832
        jmp idctf3b
834
        jmp idctf3b
833
   .l1: call idctf3a
835
   .l1: call idctf3a
834
        mov cl,4
836
        mov cl,4
835
        call limit
837
        call limit
836
        mov eax,[edi-8]
838
        mov eax,[edi-8]
837
        mov edx,[edi-4]
839
        mov edx,[edi-4]
838
        mov cl,7
840
        mov cl,7
839
   .l2: mov [edi],eax
841
   .l2: mov [edi],eax
840
        mov [edi+4],edx
842
        mov [edi+4],edx
841
        add edi,8
843
        add edi,8
842
        dec cl
844
        dec cl
843
        jnz .l2
845
        jnz .l2
844
        ret
846
        ret
845
 
847
 
846
idctf1: fistp word[edi+64]
848
idctf1: fistp word[edi+64]
847
        mov ax,128
849
        mov ax,128
848
        add ax,[edi+64]
850
        add ax,[edi+64]
849
        jz .l2
851
        jz .l2
850
        test ah,ah
852
        test ah,ah
851
        jz .l1
853
        jz .l1
852
        mov al,-1
854
        mov al,-1
853
        js .l2
855
        js .l2
854
   .l1: mov ah,al
856
   .l1: mov ah,al
855
        stosw
857
        stosw
856
        stosw
858
        stosw
857
        mov eax,[edi-4]
859
        mov eax,[edi-4]
858
        mov ecx,15
860
        mov ecx,15
859
        rep stosd
861
        rep stosd
860
   .l2: ret
862
   .l2: ret
861
 
863
 
862
idctf3: mov bl,8
864
idctf3: mov bl,8
863
        mov esi,edi
865
        mov esi,edi
864
    .l1: rcr bh,1
866
    .l1: rcr bh,1
865
        jc .l3
867
        jc .l3
866
        mov eax,[esi]
868
        mov eax,[esi]
867
        test eax,eax
869
        test eax,eax
868
        jz .l4
870
        jz .l4
869
        mov cl,7
871
        mov cl,7
870
    .l2: add esi,32
872
    .l2: add esi,32
871
        mov [esi],eax
873
        mov [esi],eax
872
        dec cl
874
        dec cl
873
        jnz .l2
875
        jnz .l2
874
        sub esi,32*7-4
876
        sub esi,32*7-4
875
        dec bl
877
        dec bl
876
        jnz .l1
878
        jnz .l1
877
        jmp .l5
879
        jmp .l5
878
   .l3: call idctf3b
880
   .l3: call idctf3b
879
   .l4: add esi,4
881
   .l4: add esi,4
880
        dec bl
882
        dec bl
881
        jnz .l1
883
        jnz .l1
882
   .l5: mov esi,edi
884
   .l5: mov esi,edi
883
        mov cl,8
885
        mov cl,8
884
   .l6: call idctf3a
886
   .l6: call idctf3a
885
        add esi,32
887
        add esi,32
886
        add edi,16
888
        add edi,16
887
        dec cl
889
        dec cl
888
        jnz .l6
890
        jnz .l6
889
        sub edi,128
891
        sub edi,128
890
        mov esi,edi
892
        mov esi,edi
891
        mov cl,32
893
        mov cl,32
892
limit:  mov dx,[esi]
894
limit:  mov dx,[esi]
893
        mov bx,[esi+2]
895
        mov bx,[esi+2]
894
        add esi,4
896
        add esi,4
895
        add dx,128
897
        add dx,128
896
        add bx,128
898
        add bx,128
897
        test dh,dh
899
        test dh,dh
898
        mov ax,dx
900
        mov ax,dx
899
        jz .l1
901
        jz .l1
900
        mov al,0
902
        mov al,0
901
        js .l1
903
        js .l1
902
        mov al,-1
904
        mov al,-1
903
   .l1: test bh,bh
905
   .l1: test bh,bh
904
        mov ah,bl
906
        mov ah,bl
905
        jz .l2
907
        jz .l2
906
        mov ah,0
908
        mov ah,0
907
        js .l2
909
        js .l2
908
        mov ah,-1
910
        mov ah,-1
909
   .l2: stosw
911
   .l2: stosw
910
        dec cl
912
        dec cl
911
        jnz limit
913
        jnz limit
912
        ret
914
        ret
913
 
915
 
914
idctf2b:
916
idctf2b:
915
        mov dl,8
917
        mov dl,8
916
  .l1:  fld dword[esi]
918
  .l1:  fld dword[esi]
917
        add esi,32
919
        add esi,32
918
        mov ax,128
920
        mov ax,128
919
        fistp word [edi]
921
        fistp word [edi]
920
        add ax,[edi]
922
        add ax,[edi]
921
        test ah,ah
923
        test ah,ah
922
        jz .l2
924
        jz .l2
923
        mov al,0
925
        mov al,0
924
        js .l2
926
        js .l2
925
        mov al,-1
927
        mov al,-1
926
  .l2:  mov ah,al
928
  .l2:  mov ah,al
927
        stosw
929
        stosw
928
        stosw
930
        stosw
929
        stosw
931
        stosw
930
        stosw
932
        stosw
931
        dec dl
933
        dec dl
932
        jnz .l1
934
        jnz .l1
933
        ret
935
        ret
934
 
936
 
935
idctf3a: ;si(d float),di(w int) ncr
937
idctf3a: ;si(d float),di(w int) ncr
936
fld dword[esi+1*4]      ;f1                ;t21=f1+f7
938
fld dword[esi+1*4]      ;f1                ;t21=f1+f7
937
fld st0
939
fld st0
938
fld dword[esi+7*4]          ;f7
940
fld dword[esi+7*4]          ;f7
939
fadd st2,st0
941
fadd st2,st0
940
fsubp st1,st0          ;t22=f1-f7
942
fsubp st1,st0          ;t22=f1-f7
941
fld dword[esi+5*4]
943
fld dword[esi+5*4]
942
fld st0           ;f5       ;t23=f5+f3
944
fld st0           ;f5       ;t23=f5+f3
943
fld dword[esi+3*4]                   ;f3
945
fld dword[esi+3*4]                   ;f3
944
fadd st2,st0
946
fadd st2,st0
945
fsubp st1,st0          ;t20=f5-f3
947
fsubp st1,st0          ;t20=f5-f3
946
fld st0
948
fld st0
947
fadd st0,st3                ;t25=(t20+t22)*k2
949
fadd st0,st3                ;t25=(t20+t22)*k2
948
fmul dword[k+4]                 ;k2 ;t25,t20,t23,t22,t21
950
fmul dword[k+4]                 ;k2 ;t25,t20,t23,t22,t21
949
fld st4                         ;t7=t21+t23
951
fld st4                         ;t7=t21+t23
950
fadd st0,st3                        ;t7,t25,t20,t23,t22,t21
952
fadd st0,st3                        ;t7,t25,t20,t23,t22,t21
951
fld dword[k+12]                 ;k4     ;t6=k4*t20+t25-t7
953
fld dword[k+12]                 ;k4     ;t6=k4*t20+t25-t7
952
fmulp st3,st0
954
fmulp st3,st0
953
fsub st2,st0
955
fsub st2,st0
954
fld st1
956
fld st1
955
faddp st3,st0                   ;t7,t25,t6,t23,t22,t21
957
faddp st3,st0                   ;t7,t25,t6,t23,t22,t21
956
fld st5                         ;t5=(t21-t23)*k1-t6
958
fld st5                         ;t5=(t21-t23)*k1-t6
957
fsub st0,st4
959
fsub st0,st4
958
fmul dword[k]          ;k1
960
fmul dword[k]          ;k1
959
fsub st0,st3
961
fsub st0,st3
960
fstp st6               ;t7,t25,t6,t23,t22,t5
962
fstp st6               ;t7,t25,t6,t23,t22,t5
961
fstp st3                        ;t25,t6,t7,t22,t5
963
fstp st3                        ;t25,t6,t7,t22,t5
962
fxch st3
964
fxch st3
963
fmul dword[k+8]    ;k3      ;t4=k3*t22-t25+t5
965
fmul dword[k+8]    ;k3      ;t4=k3*t22-t25+t5
964
fadd st0,st4                        ;t22*k3+t5,t6,t7,t25,t5
966
fadd st0,st4                        ;t22*k3+t5,t6,t7,t25,t5
965
fsubrp st3,st0                  ;t6,t7,t4,t5
967
fsubrp st3,st0                  ;t6,t7,t4,t5
966
fld dword[esi]                       ;f0           ;t10=f0+f4
968
fld dword[esi]                       ;f0           ;t10=f0+f4
967
fst st5                         ;f0,t4,t5,t6,t7,f0
969
fst st5                         ;f0,t4,t5,t6,t7,f0
968
fld dword[esi+4*4]                   ;f4
970
fld dword[esi+4*4]                   ;f4
969
fsub st6,st0                    ;t11=f0-f4
971
fsub st6,st0                    ;t11=f0-f4
970
faddp st1,st0
972
faddp st1,st0
971
fld st0               ;t10,t10,t6,t7,t4,t5,t11
973
fld st0               ;t10,t10,t6,t7,t4,t5,t11
972
fld dword[esi+2*4]                   ;f2      ;t13=f2+f6
974
fld dword[esi+2*4]                   ;f2      ;t13=f2+f6
973
fadd dword[esi+6*4]                  ;f6      ;t13,t10,t10,t6,t7,t4,t5,t11
975
fadd dword[esi+6*4]                  ;f6      ;t13,t10,t10,t6,t7,t4,t5,t11
974
fadd st2,st0                    ;t13,t10,t0,t6,t7,t4,t5,t11 ;t0=t10+t13
976
fadd st2,st0                    ;t13,t10,t0,t6,t7,t4,t5,t11 ;t0=t10+t13
975
fsubp st1,st0                      ;t3,t0,t6,t7,t4,t5,t11 ;t3=t10-t13
977
fsubp st1,st0                      ;t3,t0,t6,t7,t4,t5,t11 ;t3=t10-t13
976
fld st0                         ;p3=t3-t4
978
fld st0                         ;p3=t3-t4
977
fsub st0,st5
979
fsub st0,st5
978
fistp word [edi+3*2]        ;p3
980
fistp word [edi+3*2]        ;p3
979
fadd st0,st4                        ;p4=t3+t4
981
fadd st0,st4                        ;p4=t3+t4
980
fld dword[esi+2*4]                   ;f2
982
fld dword[esi+2*4]                   ;f2
981
fstp st5
983
fstp st5
982
fistp word [edi+4*2]        ;p4 ;t0,t6,t7,f2,t5,t11
984
fistp word [edi+4*2]        ;p4 ;t0,t6,t7,f2,t5,t11
983
fld st0                         ;p0=t0+t7
985
fld st0                         ;p0=t0+t7
984
fsub st0,st3
986
fsub st0,st3
985
fistp word [edi+7*2]        ;p7
987
fistp word [edi+7*2]        ;p7
986
fadd st0,st2                        ;p7=t0-t7
988
fadd st0,st2                        ;p7=t0-t7
987
fistp word [edi]                     ;p0 ;t6,t7,f2,t5,t11
989
fistp word [edi]                     ;p0 ;t6,t7,f2,t5,t11
988
fld st2                         ;f2  ;f2,t6,t7,f2,t5,t11  ;t12=(f2-f6)*k1-t13
990
fld st2                         ;f2  ;f2,t6,t7,f2,t5,t11  ;t12=(f2-f6)*k1-t13
989
fld dword[esi+6*4]                   ;f6
991
fld dword[esi+6*4]                   ;f6
990
fadd st4,st0                    ;f6,f2,t6,t7,t13,t5,t11
992
fadd st4,st0                    ;f6,f2,t6,t7,t13,t5,t11
991
fsubp st1,st0
993
fsubp st1,st0
992
fmul dword[k]         ;k1
994
fmul dword[k]         ;k1
993
fsub st0,st3
995
fsub st0,st3
994
fst st3                ;t12,t6,t7,t12,t5,t11
996
fst st3                ;t12,t6,t7,t12,t5,t11
995
fadd st0,st5                        ;t1=t11+t12
997
fadd st0,st5                        ;t1=t11+t12
996
fst st2                         ;t1,t6,t1,t12,t5,t11
998
fst st2                         ;t1,t6,t1,t12,t5,t11
997
fadd st0,st1                        ;p1=t1+t6
999
fadd st0,st1                        ;p1=t1+t6
998
fistp word [edi+2]                   ;p1    ;t6,t1,t12,t5,t11
1000
fistp word [edi+2]                   ;p1    ;t6,t1,t12,t5,t11
999
fsubp st1,st0                       ;p6=t1-t6
1001
fsubp st1,st0                       ;p6=t1-t6
1000
fistp word [edi+6*2]                 ;p6  ;t12,t5,t11
1002
fistp word [edi+6*2]                 ;p6  ;t12,t5,t11
1001
fsubp st2,st0                   ;t2=t11-t12  ;t5,t2
1003
fsubp st2,st0                   ;t2=t11-t12  ;t5,t2
1002
fld st0
1004
fld st0
1003
fadd st0,st2                ;p2=t2+t5
1005
fadd st0,st2                ;p2=t2+t5
1004
fistp word [edi+2*2]                 ;p2
1006
fistp word [edi+2*2]                 ;p2
1005
fsubp st1,st0                       ;p5=t2-t5   ;t5,t2
1007
fsubp st1,st0                       ;p5=t2-t5   ;t5,t2
1006
fistp word [edi+5*2]
1008
fistp word [edi+5*2]
1007
ret             ;p5
1009
ret             ;p5
1008
 
1010
 
1009
 
1011
 
1010
 
1012
 
1011
 
1013
 
1012
idctf3b: ;si ncr
1014
idctf3b: ;si ncr
1013
fld dword[esi+1*32]
1015
fld dword[esi+1*32]
1014
fld st0          ;f1       ;t21=f1+f7
1016
fld st0          ;f1       ;t21=f1+f7
1015
fld dword[esi+7*32]
1017
fld dword[esi+7*32]
1016
fadd st2,st0     ;f7
1018
fadd st2,st0     ;f7
1017
fsubp st1,st0                       ;t22=f1-f7
1019
fsubp st1,st0                       ;t22=f1-f7
1018
fld dword[esi+5*32]
1020
fld dword[esi+5*32]
1019
fld st0          ;f5       ;t23=f5+f3
1021
fld st0          ;f5       ;t23=f5+f3
1020
fld dword[esi+3*32]                  ;f3
1022
fld dword[esi+3*32]                  ;f3
1021
fadd st2,st0
1023
fadd st2,st0
1022
fsubp st1,st0
1024
fsubp st1,st0
1023
fld st0  ;t20=f5-f3
1025
fld st0  ;t20=f5-f3
1024
fadd st0,st3                        ;t25=(t20+t22)*k2
1026
fadd st0,st3                        ;t25=(t20+t22)*k2
1025
fmul dword[k+4]                 ;k2 ;t25,t20,t23,t22,t21
1027
fmul dword[k+4]                 ;k2 ;t25,t20,t23,t22,t21
1026
fld st4                         ;t7=t21+t23
1028
fld st4                         ;t7=t21+t23
1027
fadd st0,st3                        ;t7,t25,t20,t23,t22,t21
1029
fadd st0,st3                        ;t7,t25,t20,t23,t22,t21
1028
fld dword[k+12]                 ;k4     ;t6=k4*t20+t25-t7
1030
fld dword[k+12]                 ;k4     ;t6=k4*t20+t25-t7
1029
fmulp st3,st0
1031
fmulp st3,st0
1030
fsub st2,st0
1032
fsub st2,st0
1031
fld st1
1033
fld st1
1032
faddp st3,st0                   ;t7,t25,t6,t23,t22,t21
1034
faddp st3,st0                   ;t7,t25,t6,t23,t22,t21
1033
fld st5                         ;t5=(t21-t23)*k1-t6
1035
fld st5                         ;t5=(t21-t23)*k1-t6
1034
fsub st0,st4
1036
fsub st0,st4
1035
fmul dword[k]          ;k1
1037
fmul dword[k]          ;k1
1036
fsub st0,st3
1038
fsub st0,st3
1037
fstp st6               ;t7,t25,t6,t23,t22,t5
1039
fstp st6               ;t7,t25,t6,t23,t22,t5
1038
fstp st3
1040
fstp st3
1039
fxch st3               ;t25,t6,t7,t22,t5
1041
fxch st3               ;t25,t6,t7,t22,t5
1040
fmul dword[k+8]                 ;k3      ;t4=k3*t22-t25+t5
1042
fmul dword[k+8]                 ;k3      ;t4=k3*t22-t25+t5
1041
fadd st0,st4                        ;t22*k3+t5,t6,t7,t25,t5
1043
fadd st0,st4                        ;t22*k3+t5,t6,t7,t25,t5
1042
fsubrp st3,st0                  ;t6,t7,t4,t5
1044
fsubrp st3,st0                  ;t6,t7,t4,t5
1043
fld dword[esi]                       ;f0           ;t10=f0+f4
1045
fld dword[esi]                       ;f0           ;t10=f0+f4
1044
fst st5                         ;f0,t4,t5,t6,t7,f0
1046
fst st5                         ;f0,t4,t5,t6,t7,f0
1045
fld dword[esi+4*32]                  ;f4
1047
fld dword[esi+4*32]                  ;f4
1046
fsub st6,st0                    ;t11=f0-f4
1048
fsub st6,st0                    ;t11=f0-f4
1047
faddp st1,st0
1049
faddp st1,st0
1048
fld st0               ;t10,t10,t6,t7,t4,t5,t11
1050
fld st0               ;t10,t10,t6,t7,t4,t5,t11
1049
fld dword[esi+2*32]                  ;f2      ;t13=f2+f6
1051
fld dword[esi+2*32]                  ;f2      ;t13=f2+f6
1050
fadd dword[esi+6*32]                 ;f6      ;t13,t10,t10,t6,t7,t4,t5,t11
1052
fadd dword[esi+6*32]                 ;f6      ;t13,t10,t10,t6,t7,t4,t5,t11
1051
fadd st2,st0                    ;t13,t10,t0,t6,t7,t4,t5,t11 ;t0=t10+t13
1053
fadd st2,st0                    ;t13,t10,t0,t6,t7,t4,t5,t11 ;t0=t10+t13
1052
fsubp st1,st0                       ;t3,t0,t6,t7,t4,t5,t11 ;t3=t10-t13
1054
fsubp st1,st0                       ;t3,t0,t6,t7,t4,t5,t11 ;t3=t10-t13
1053
fld st0                         ;p3=t3-t4
1055
fld st0                         ;p3=t3-t4
1054
fsub st0,st5
1056
fsub st0,st5
1055
fstp dword[esi+3*32]        ;p3
1057
fstp dword[esi+3*32]        ;p3
1056
fadd st0,st4                        ;p4=t3+t4
1058
fadd st0,st4                        ;p4=t3+t4
1057
fld dword[esi+2*32]                  ;f2
1059
fld dword[esi+2*32]                  ;f2
1058
fstp st5
1060
fstp st5
1059
fstp dword[esi+4*32]        ;p4 ;t0,t6,t7,f2,t5,t11
1061
fstp dword[esi+4*32]        ;p4 ;t0,t6,t7,f2,t5,t11
1060
fld st0
1062
fld st0
1061
fsub st0,st3                ;p0=t0+t7
1063
fsub st0,st3                ;p0=t0+t7
1062
fstp dword[esi+7*32]                 ;p7
1064
fstp dword[esi+7*32]                 ;p7
1063
fadd st0,st2                        ;p7=t0-t7
1065
fadd st0,st2                        ;p7=t0-t7
1064
fstp dword[esi]                      ;p0 ;t6,t7,f2,t5,t11
1066
fstp dword[esi]                      ;p0 ;t6,t7,f2,t5,t11
1065
fld st2                         ;f2  ;f2,t6,t7,f2,t5,t11  ;t12=(f2-f6)*k1-t13
1067
fld st2                         ;f2  ;f2,t6,t7,f2,t5,t11  ;t12=(f2-f6)*k1-t13
1066
fld dword[esi+6*32]                  ;f6
1068
fld dword[esi+6*32]                  ;f6
1067
fadd st4,st0                    ;f6,f2,t6,t7,t13,t5,t11
1069
fadd st4,st0                    ;f6,f2,t6,t7,t13,t5,t11
1068
fsubp st1,st0
1070
fsubp st1,st0
1069
fmul dword[k]         ;k1
1071
fmul dword[k]         ;k1
1070
fsub st0,st3
1072
fsub st0,st3
1071
fst st3                ;t12,t6,t7,t12,t5,t11
1073
fst st3                ;t12,t6,t7,t12,t5,t11
1072
fadd st0,st5                        ;t1=t11+t12
1074
fadd st0,st5                        ;t1=t11+t12
1073
fst st2                         ;t1,t6,t1,t12,t5,t11
1075
fst st2                         ;t1,t6,t1,t12,t5,t11
1074
fadd st0,st1                        ;p1=t1+t6
1076
fadd st0,st1                        ;p1=t1+t6
1075
fstp dword[esi+1*32]                 ;p1    ;t6,t1,t12,t5,t11
1077
fstp dword[esi+1*32]                 ;p1    ;t6,t1,t12,t5,t11
1076
fsubp st1,st0                       ;p6=t1-t6
1078
fsubp st1,st0                       ;p6=t1-t6
1077
fstp dword[esi+6*32]                 ;p6  ;t12,t5,t11
1079
fstp dword[esi+6*32]                 ;p6  ;t12,t5,t11
1078
fsubp st2,st0
1080
fsubp st2,st0
1079
fld st0           ;t2=t11-t12  ;t5,t2
1081
fld st0           ;t2=t11-t12  ;t5,t2
1080
fadd st0,st2                        ;p2=t2+t5
1082
fadd st0,st2                        ;p2=t2+t5
1081
fstp dword[esi+2*32]                 ;p2
1083
fstp dword[esi+2*32]                 ;p2
1082
fsubp st1,st0                       ;p5=t2-t5   ;t5,t2
1084
fsubp st1,st0                       ;p5=t2-t5   ;t5,t2
1083
fstp dword[esi+5*32]
1085
fstp dword[esi+5*32]
1084
ret             ;p5
1086
ret             ;p5
1085
 
1087
 
1086
ybr_bgr:  ;edi=bmp ecx=n_BYTES
1088
ybr_bgr:  ;edi=bmp ecx=n_BYTES
1087
	  ;retorna edi+=ecx
1089
	  ;retorna edi+=ecx
1088
	pushad
1090
	pushad
1089
	mov esi,edi
1091
	mov esi,edi
1090
	add edi,ecx
1092
	add edi,ecx
1091
	push edi
1093
	push edi
1092
	mov edi,[colortabla]
1094
	mov edi,[colortabla]
1093
   .l1: lodsw
1095
   .l1: lodsw
1094
	movzx ebx,ah
1096
	movzx ebx,ah
1095
	movzx ebp,al
1097
	movzx ebp,al
1096
	movzx eax,al
1098
	movzx eax,al
1097
	movzx ecx,byte[esi]
1099
	movzx ecx,byte[esi]
1098
	lea ebx,[ebx*4+edi+1024]
1100
	lea ebx,[ebx*4+edi+1024]
1099
	lea ecx,[ecx*4+edi]
1101
	lea ecx,[ecx*4+edi]
1100
	add eax,[ebx] ;cb   ;solo se usan 16 bits
1102
	add eax,[ebx] ;cb   ;solo se usan 16 bits
1101
	mov edx,[ebx+2]     ;pero el codigo de 32 bits es mas rapido
1103
	mov edx,[ebx+2]     ;pero el codigo de 32 bits es mas rapido
1102
	mov ebx,[ecx] ;cr
1104
	mov ebx,[ecx] ;cr
1103
	add eax,[ecx+2]
1105
	add eax,[ecx+2]
1104
	add ebx,ebp ;b
1106
	add ebx,ebp ;b
1105
	add edx,ebp ;r
1107
	add edx,ebp ;r
1106
	test ah,ah
1108
	test ah,ah
1107
	jz .l2
1109
	jz .l2
1108
	mov al,0
1110
	mov al,0
1109
	js .l2
1111
	js .l2
1110
	mov al,-1
1112
	mov al,-1
1111
   .l2: test dh,dh
1113
   .l2: test dh,dh
1112
	jz .l3
1114
	jz .l3
1113
	mov dl,0
1115
	mov dl,0
1114
	js .l3
1116
	js .l3
1115
	mov dl,-1
1117
	mov dl,-1
1116
   .l3: test bh,bh
1118
   .l3: test bh,bh
1117
	mov dh,al
1119
	mov dh,al
1118
	jz .l4
1120
	jz .l4
1119
	mov bl,0
1121
	mov bl,0
1120
	js .l4
1122
	js .l4
1121
	mov bl,-1
1123
	mov bl,-1
1122
   .l4: mov [esi-2],dx
1124
   .l4: mov [esi-2],dx
1123
	mov [esi],bl
1125
	mov [esi],bl
1124
	inc esi
1126
	inc esi
1125
	cmp esi,[esp]
1127
	cmp esi,[esp]
1126
	jc .l1
1128
	jc .l1
1127
	pop edi
1129
	pop edi
1128
	popad
1130
	popad
1129
	ret
1131
	ret
1130
 
1132
 
1131
recortar:  ;edi=bufer eax=ancho en pixels (ecx,edx)tama¤o deseado
1133
recortar:  ;edi=bufer eax=ancho en pixels (ecx,edx)tama¤o deseado
1132
        pushad
1134
        pushad
1133
        dec edx
1135
        dec edx
1134
        jz .l2
1136
        jz .l2
1135
        lea ebx,[ecx*3]
1137
        lea ebx,[ecx*3]
1136
        lea eax,[eax*3]
1138
        lea eax,[eax*3]
1137
        lea esi,[edi+eax]
1139
        lea esi,[edi+eax]
1138
        add edi,ebx
1140
        add edi,ebx
1139
        sub eax,ebx
1141
        sub eax,ebx
1140
  .l1:  mov ecx,ebx
1142
  .l1:  mov ecx,ebx
1141
        call movedata
1143
        call movedata
1142
        add esi,eax
1144
        add esi,eax
1143
        dec edx
1145
        dec edx
1144
        jnz .l1
1146
        jnz .l1
1145
   .l2: popad
1147
   .l2: popad
1146
        ret
1148
        ret
1147
 
1149
 
1148
;R = Y                    + 1.402  *(Cr-128)
1150
;R = Y                    + 1.402  *(Cr-128)
1149
;G = Y - 0.34414*(Cb-128) - 0.71414*(Cr-128)
1151
;G = Y - 0.34414*(Cb-128) - 0.71414*(Cr-128)
1150
;B = Y + 1.772  *(Cb-128)
1152
;B = Y + 1.772  *(Cb-128)
1151
 
1153
 
1152
colortabla: dd 0
1154
colortabla: dd 0
1153
 
1155
 
1154
colorprecalc: ;prepara la tabla para convertir ycb a rgb
1156
colorprecalc: ;prepara la tabla para convertir ycb a rgb
1155
	 mov ecx,1024*2
1157
	 mov ecx,1024*2
1156
	 call malloc
1158
	 call malloc
1157
	 mov [colortabla],edi
1159
	 mov [colortabla],edi
1158
	 fninit
1160
	 fninit
1159
	 fld dword [.k+4]
1161
	 fld dword [.k+4]
1160
	 fld dword [.k]
1162
	 fld dword [.k]
1161
	 mov dl,0
1163
	 mov dl,0
1162
	 call .l1
1164
	 call .l1
1163
	 fld dword [.k+12]
1165
	 fld dword [.k+12]
1164
	 fld dword[.k+8]
1166
	 fld dword[.k+8]
1165
    .l1: mov cx,-128
1167
    .l1: mov cx,-128
1166
    .l2: mov [edi],ecx
1168
    .l2: mov [edi],ecx
1167
	 inc ecx
1169
	 inc ecx
1168
	 fild word[edi]
1170
	 fild word[edi]
1169
	 fld st0
1171
	 fld st0
1170
	 fmul st0,st2
1172
	 fmul st0,st2
1171
	 fistp word[edi]
1173
	 fistp word[edi]
1172
	 fmul st0,st2
1174
	 fmul st0,st2
1173
	 fistp word[edi+2]
1175
	 fistp word[edi+2]
1174
	 add edi,4
1176
	 add edi,4
1175
	 inc dl
1177
	 inc dl
1176
	 jnz .l2
1178
	 jnz .l2
1177
	 ret
1179
	 ret
1178
 
1180
 
1179
     .k: dd 1.402,-0.71414,-0.34414,+1.772
1181
     .k: dd 1.402,-0.71414,-0.34414,+1.772