Subversion Repositories Kolibri OS

Rev

Rev 8341 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8341 Rev 8408
Line 46... Line 46...
46
proc png_set_sig_bytes uses eax edi, png_ptr:dword, num_bytes:dword
46
proc png_set_sig_bytes uses eax edi, png_ptr:dword, num_bytes:dword
47
	png_debug 1, 'in png_set_sig_bytes'
47
	png_debug 1, 'in png_set_sig_bytes'
48
 
48
 
Line 49... Line 49...
49
	mov edi,[png_ptr]
49
	mov edi,[png_ptr]
50
	cmp edi,0
50
	or edi,edi
51
	je .end_f ;if (..==0) return
51
	jz .end_f ;if (..==0) return
Line 52... Line 52...
52
 
52
 
53
	mov eax,[num_bytes]
53
	mov eax,[num_bytes]
54
	cmp eax,0
54
	cmp eax,0
55
	jge @f
55
	jge @f
Line 99... Line 99...
99
;voidpf (voidpf png_ptr, uInt items, uInt size)
99
;voidpf (voidpf png_ptr, uInt items, uInt size)
100
align 4
100
align 4
101
proc png_zalloc uses edx ecx, png_ptr:dword, items:dword, size:dword
101
proc png_zalloc uses edx ecx, png_ptr:dword, items:dword, size:dword
102
 
102
 
Line 103... Line -...
103
	cmp dword[png_ptr],0
-
 
104
	jne @f
-
 
105
		xor eax,eax
103
	xor eax,eax
-
 
104
	cmp dword[png_ptr],eax
106
		jmp .end_f ;if (..==0) return 0
105
	je .end_f ;if (..==0) return 0
107
	@@:
-
 
Line 108... Line -...
108
 
-
 
109
	xor eax,eax
106
 
110
	not eax
107
	not eax
111
	xor edx,edx
108
	xor edx,edx
112
	mov ecx,[size]
109
	mov ecx,[size]
113
	div ecx
110
	div ecx
Line 159... Line 156...
159
	safe_length dd ?
156
	safe_length dd ?
160
endl
157
endl
161
	mov edi,[png_ptr]
158
	mov edi,[png_ptr]
162
	PNG_CHUNK_ANCILLARY [edi+png_struct.chunk_name]
159
	PNG_CHUNK_ANCILLARY [edi+png_struct.chunk_name]
163
	cmp eax,0 ;if (..!=0)
160
	or eax,eax ;if (..!=0)
164
	je @f
161
	jz @f
165
		mov eax,[edi+png_struct.flags]
162
		mov eax,[edi+png_struct.flags]
166
		and eax,PNG_FLAG_CRC_ANCILLARY_MASK
163
		and eax,PNG_FLAG_CRC_ANCILLARY_MASK
167
		cmp eax,PNG_FLAG_CRC_ANCILLARY_USE or PNG_FLAG_CRC_ANCILLARY_NOWARN
164
		cmp eax,PNG_FLAG_CRC_ANCILLARY_USE or PNG_FLAG_CRC_ANCILLARY_NOWARN
168
		jne .end0 ;if (..==..)
165
		jne .end0 ;if (..==..)
169
			mov dword[need_crc],0
166
			mov dword[need_crc],0
170
		jmp .end0
167
		jmp .end0
Line 338... Line 335...
338
end if
335
end if
339
	; Call the general version checker (shared with read and write code):
336
	; Call the general version checker (shared with read and write code):
340
 
337
 
Line 341... Line 338...
341
		stdcall png_user_version_check, ebx, [user_png_ver]
338
		stdcall png_user_version_check, ebx, [user_png_ver]
342
		cmp eax,0
339
		or eax,eax
343
		je .end0 ;if (..!=0)
340
		jz .end0 ;if (..!=0)
344
			stdcall png_malloc_warn, ebx, sizeof.png_struct
341
			stdcall png_malloc_warn, ebx, sizeof.png_struct
345
			;eax = png_ptr
342
			;eax = png_ptr
346
			cmp eax,0
343
			or eax,eax
347
			je .end0 ;if (..!=0)
344
			jz .end0 ;if (..!=0)
348
				; png_ptr->zstream holds a back-pointer to the png_struct, so
345
				; png_ptr->zstream holds a back-pointer to the png_struct, so
349
				; this can only be done now:
346
				; this can only be done now:
Line 350... Line 347...
350
 
347
 
351
				mov [ebx+png_struct.zstream.zalloc], png_zalloc
348
				mov [ebx+png_struct.zstream.zalloc], png_zalloc
Line 377... Line 374...
377
 
374
 
Line 378... Line 375...
378
; Allocate the memory for an info_struct for the application.
375
; Allocate the memory for an info_struct for the application.
379
;png_infop (png_structrp png_ptr)
376
;png_infop (png_structrp png_ptr)
380
align 4
377
align 4
381
proc png_create_info_struct uses ebx ecx edi, png_ptr:dword
378
proc png_create_info_struct uses ecx edi, png_ptr:dword
382
	png_debug 1, 'in png_create_info_struct'
379
	png_debug 1, 'in png_create_info_struct'
383
	;ebx - info_ptr dd ? ;png_inforp
-
 
Line 384... Line 380...
384
 
380
 
385
	mov edi,[png_ptr]
381
	mov eax,[png_ptr]
386
	cmp edi,0
382
	or eax,eax
387
	jne @f ;if (..==0) return 0
-
 
388
		xor eax,eax
-
 
389
		jmp .end_f
-
 
Line 390... Line 383...
390
	@@:
383
	jz .end_f ;if (..==0) return 0
391
 
384
 
392
	; Use the internal API that does not (or at least should not) error out, so
385
	; Use the internal API that does not (or at least should not) error out, so
393
	; that this call always returns ok.  The application typically sets up the
386
	; that this call always returns ok.  The application typically sets up the
Line 394... Line 387...
394
	; error handling *after* creating the info_struct because this is the way it
387
	; error handling *after* creating the info_struct because this is the way it
395
	; has always been done in 'example.asm'.
388
	; has always been done in 'example.asm'.
396
 
-
 
397
	stdcall png_malloc_base, edi, sizeof.png_info_def
389
 
398
	mov ebx,eax
390
	stdcall png_malloc_base, eax, sizeof.png_info_def
399
 
391
	or eax,eax
400
	cmp eax,0
392
	jz .end_f
401
	je @f
393
		push eax
402
		mov edi,eax
394
		mov edi,eax
403
		xor eax,eax
-
 
404
		mov ecx,sizeof.png_info_def
-
 
405
		rep stosb ;memset(...
395
		xor eax,eax
406
	@@:
396
		mov ecx,sizeof.png_info_def
407
 
397
		rep stosb ;memset(...
408
	mov eax,ebx
398
		pop eax
Line 409... Line 399...
409
.end_f:
399
.end_f:
Line 426... Line 416...
426
	cmp dword[png_ptr],0
416
	cmp dword[png_ptr],0
427
	je .end_f ;if (..==0) return
417
	je .end_f ;if (..==0) return
Line 428... Line 418...
428
 
418
 
429
	mov edi,[info_ptr_ptr]
419
	mov edi,[info_ptr_ptr]
430
	cmp edi,0 ;if (..!=0)
420
	or edi,edi ;if (..!=0)
431
	je .end_f
421
	jz .end_f
432
		; Do this first in case of an error below; if the app implements its own
422
		; Do this first in case of an error below; if the app implements its own
433
		; memory management this can lead to png_free calling png_error, which
423
		; memory management this can lead to png_free calling png_error, which
434
		; will abort this routine and return control to the app error handler.
424
		; will abort this routine and return control to the app error handler.
435
		; An infinite loop may result if it then tries to free the same info
425
		; An infinite loop may result if it then tries to free the same info
Line 488... Line 478...
488
proc png_data_freer uses edi esi, png_ptr:dword, info_ptr:dword, freer:dword, mask:dword
478
proc png_data_freer uses edi esi, png_ptr:dword, info_ptr:dword, freer:dword, mask:dword
489
	png_debug 1, 'in png_data_freer'
479
	png_debug 1, 'in png_data_freer'
490
 
480
 
Line 491... Line 481...
491
	mov edi,[png_ptr]
481
	mov edi,[png_ptr]
492
	cmp edi,0
482
	or edi,edi
493
	je .end_f
483
	jz .end_f
494
	mov esi,[info_ptr]
484
	mov esi,[info_ptr]
495
	cmp esi,0
485
	or esi,esi
496
	je .end_f ;if (..==0 || ..==0) return
486
	jz .end_f ;if (..==0 || ..==0) return
Line 497... Line 487...
497
 
487
 
498
;   if (freer == PNG_DESTROY_WILL_FREE_DATA)
488
;   if (freer == PNG_DESTROY_WILL_FREE_DATA)
Line 499... Line 489...
499
;      info_ptr->free_me |= mask;
489
;      info_ptr->free_me |= mask;
Line 512... Line 502...
512
proc png_free_data uses eax edi esi, png_ptr:dword, info_ptr:dword, mask:dword, num:dword
502
proc png_free_data uses eax edi esi, png_ptr:dword, info_ptr:dword, mask:dword, num:dword
513
	png_debug 1, 'in png_free_data'
503
	png_debug 1, 'in png_free_data'
514
 
504
 
Line 515... Line 505...
515
	mov edi,[png_ptr]
505
	mov edi,[png_ptr]
516
	cmp edi,0
506
	or edi,edi
517
	je .end_f
507
	jz .end_f
518
	mov esi,[info_ptr]
508
	mov esi,[info_ptr]
519
	cmp esi,0
509
	or esi,esi
520
	je .end_f ;if (..==0 || ..==0) return
510
	jz .end_f ;if (..==0 || ..==0) return
Line 521... Line 511...
521
 
511
 
522
if PNG_TEXT_SUPPORTED eq 1
512
if PNG_TEXT_SUPPORTED eq 1
523
	; Free text item num or (if num == -1) all text items
513
	; Free text item num or (if num == -1) all text items
524
;   if (info_ptr->text != 0 &&
514
;   if (info_ptr->text != 0 &&
Line 720... Line 710...
720
;voidp (png_structrp png_ptr)
710
;voidp (png_structrp png_ptr)
721
align 4
711
align 4
722
proc png_get_io_ptr, png_ptr:dword
712
proc png_get_io_ptr, png_ptr:dword
723
	mov eax,[png_ptr]
713
	mov eax,[png_ptr]
724
	cmp eax,0
714
	or eax,eax
725
	je @f ;if (..==0) return 0
715
	jz @f ;if (..==0) return 0
726
		mov eax,[eax+png_struct.io_ptr]
716
		mov eax,[eax+png_struct.io_ptr]
727
	@@:
717
	@@:
728
	ret
718
	ret
729
endp
719
endp
Line 740... Line 730...
740
proc png_init_io uses eax edi, png_ptr:dword, fp:dword
730
proc png_init_io uses eax edi, png_ptr:dword, fp:dword
741
	png_debug 1, 'in png_init_io'
731
	png_debug 1, 'in png_init_io'
742
 
732
 
Line 743... Line 733...
743
	mov edi,[png_ptr]
733
	mov edi,[png_ptr]
744
	cmp edi,0
734
	or edi,edi
745
	je @f ;if (..==0) return
735
	jz @f ;if (..==0) return
746
		mov eax,[fp]
736
		mov eax,[fp]
747
		mov [edi+png_struct.io_ptr],eax
737
		mov [edi+png_struct.io_ptr],eax
748
	@@:
738
	@@:
749
	ret
739
	ret
750
endp
740
endp
Line 965... Line 955...
965
	; Check chunk_name and return "keep" value if it's on the list, else 0
955
	; Check chunk_name and return "keep" value if it's on the list, else 0
966
;   bytep p, p_end;
956
;   bytep p, p_end;
967
 
957
 
Line 968... Line 958...
968
	mov edi,[png_ptr]
958
	mov edi,[png_ptr]
969
	cmp edi,0
959
	or edi,edi
970
	je .end0
960
	jz .end0
971
	cmp dword[chunk_name],0
961
	cmp dword[chunk_name],0
972
	je .end0
962
	je .end0
973
	cmp dword[edi+png_struct.num_chunk_list],0
963
	cmp dword[edi+png_struct.num_chunk_list],0
974
	je .end0
964
	je .end0
975
		jmp @f
965
		jmp @f
Line 1018... Line 1008...
1018
;int (png_structrp png_ptr)
1008
;int (png_structrp png_ptr)
1019
align 4
1009
align 4
1020
proc png_reset_zstream, png_ptr:dword
1010
proc png_reset_zstream, png_ptr:dword
1021
	mov eax,[png_ptr]
1011
	mov eax,[png_ptr]
1022
	cmp eax,0
1012
	or eax,eax
1023
	jne @f ;if (..==0)
1013
	jnz @f ;if (..==0)
1024
		mov eax,Z_STREAM_ERROR
1014
		mov eax,Z_STREAM_ERROR
1025
		jmp .end_f
1015
		jmp .end_f
1026
	@@:
1016
	@@:
1027
	; WARNING: this resets the window bits to the maximum!
1017
	; WARNING: this resets the window bits to the maximum!
1028
	add eax,png_struct.zstream
1018
	add eax,png_struct.zstream
1029
	stdcall inflateReset,eax
1019
	stdcall inflateReset,eax
Line 1287... Line 1277...
1287
;void (png_structrp png_ptr, png_inforp info_ptr)
1277
;void (png_structrp png_ptr, png_inforp info_ptr)
1288
align 4
1278
align 4
1289
proc png_colorspace_sync uses ecx edi esi, png_ptr:dword, info_ptr:dword
1279
proc png_colorspace_sync uses ecx edi esi, png_ptr:dword, info_ptr:dword
1290
	mov edi,[info_ptr]
1280
	mov edi,[info_ptr]
1291
	cmp edi,0
1281
	or edi,edi
1292
	je @f ;if (..==0) ;reduce code size; check here not in the caller
1282
	jz @f ;if (..==0) ;reduce code size; check here not in the caller
1293
		mov ecx,sizeof.png_colorspace
1283
		mov ecx,sizeof.png_colorspace
1294
		mov esi,[png_ptr]
1284
		mov esi,[png_ptr]
1295
		add esi,png_struct.colorspace
1285
		add esi,png_struct.colorspace
1296
		add edi,png_info_def.colorspace
1286
		add edi,png_info_def.colorspace
1297
		rep movsb
1287
		rep movsb
Line 1933... Line 1923...
1933
	pos dd ? ;size_t
1923
	pos dd ? ;size_t
1934
	message rb 196 ;char[] ;see below for calculation
1924
	message rb 196 ;char[] ;see below for calculation
1935
endl
1925
endl
1936
	mov eax,[colorspace]
1926
	mov eax,[colorspace]
1937
	cmp eax,0
1927
	or eax,eax
1938
	je @f ;if (..!=0)
1928
	jz @f ;if (..!=0)
1939
		or word[eax+png_colorspace.flags], PNG_COLORSPACE_INVALID
1929
		or word[eax+png_colorspace.flags], PNG_COLORSPACE_INVALID
1940
	@@:
1930
	@@:
1941
 
1931
 
Line 1942... Line 1932...
1942
;   pos = png_safecat(message, (sizeof message), 0, "profile '"); /* 9 chars */
1932
;   pos = png_safecat(message, (sizeof message), 0, "profile '"); /* 9 chars */
1943
;   pos = png_safecat(message, pos+79, pos, name); /* Truncate to 79 chars */
1933
;   pos = png_safecat(message, pos+79, pos, name); /* Truncate to 79 chars */
Line 2855... Line 2845...
2855
		inc ebx
2845
		inc ebx
2856
	@@:
2846
	@@:
2857
end if
2847
end if
2858
 
2848
 
Line 2859... Line 2849...
2859
	cmp ebx,0
2849
	or ebx,ebx
2860
	je @f
2850
	jz @f
2861
		png_error edi, 'Invalid IHDR data'
2851
		png_error edi, 'Invalid IHDR data'
2862
	@@:
2852
	@@:
2863
	ret
2853
	ret
2864
endp
2854
endp
Line 4430... Line 4420...
4430
;int (png_structrp png_ptr, int option, int onoff)
4420
;int (png_structrp png_ptr, int option, int onoff)
4431
align 4
4421
align 4
4432
proc png_set_option uses ecx, png_ptr:dword, option:dword, onoff:dword
4422
proc png_set_option uses ecx, png_ptr:dword, option:dword, onoff:dword
4433
	mov eax,[png_ptr]
4423
	mov eax,[png_ptr]
4434
	cmp eax,0
4424
	or eax,eax
4435
	je @f
4425
	jz @f
4436
	mov ecx,[option]
4426
	mov ecx,[option]
4437
	cmp ecx,0
4427
	cmp ecx,0
4438
	jl @f
4428
	jl @f
4439
	cmp ecx,PNG_OPTION_NEXT
4429
	cmp ecx,PNG_OPTION_NEXT
4440
	jge @f
4430
	jge @f
4441
	bt ecx,0 ;cmp (ecx & 1), 0
4431
	bt ecx,0 ;cmp (ecx & 1), 0
Line 4693... Line 4683...
4693
	; (if not inside an error handling context).  Otherwise assume
4683
	; (if not inside an error handling context).  Otherwise assume
4694
	; png_safe_execute will call this API after the return.
4684
	; png_safe_execute will call this API after the return.
4695
 
4685
 
Line 4696... Line 4686...
4696
	mov ebx,[image]
4686
	mov ebx,[image]
4697
	cmp ebx,0
4687
	or ebx,ebx
4698
	je @f
4688
	jz @f
4699
	cmp dword[ebx+png_image.opaque],0
4689
	cmp dword[ebx+png_image.opaque],0
4700
	je @f
4690
	je @f
4701
	mov eax,[ebx+png_image.opaque]
4691
	mov eax,[ebx+png_image.opaque]
4702
	cmp dword[eax+png_control.error_buf],0
4692
	cmp dword[eax+png_control.error_buf],0
4703
	jne @f ;if (..!=0 && ..!=0 && ..==0)
4693
	jne @f ;if (..!=0 && ..!=0 && ..==0)