Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6880 → Rev 6881

/programs/develop/libraries/libs-dev/libimg/png/libpng/png.asm
10,10 → 10,9
; For conditions of distribution and use, see the disclaimer
; and license in png.inc
 
crc_table rd 256
DEBUG equ 0
 
include '../../../../../../KOSfuncs.inc'
include '../../../../../../fs/kfar/trunk/kfar_arc/crc.inc'
include '../../../../../../fs/kfar/trunk/zlib/deflate.inc'
include 'pngtokos.inc' ;integrate png to kos
 
1294,8 → 1293,8
je @f ;if (..==0) ;reduce code size; check here not in the caller
mov ecx,sizeof.png_colorspace
mov esi,[png_ptr]
mov esi,[esi+png_struct.colorspace]
mov edi,[edi+png_info_def.colorspace]
add esi,png_struct.colorspace
add edi,png_info_def.colorspace
rep movsb
stdcall png_colorspace_sync_info, [png_ptr], [info_ptr]
@@:
/programs/develop/libraries/libs-dev/libimg/png/libpng/png.inc
554,6 → 554,7
 
struct png_unknown_chunk
name rb 5 ;byte[5] ;Textual chunk name with '\0' terminator
rb 3 ;align
podata dd ? ;byte* ;Data, should not be modified on read!
size dd ? ;png_size_t
 
/programs/develop/libraries/libs-dev/libimg/png/libpng/pngget.asm
1183,16 → 1183,16
end if
; {
if PNG_SEQUENTIAL_READ_SUPPORTED eq 1
; return png_ptr->IDAT_read_size;
mov eax,[eax+png_struct.IDAT_read_size]
else
mov eax,PNG_IDAT_READ_SIZE
jmp .end_f
end if
; }
 
if PNG_WRITE_SUPPORTED eq 1
jmp .end_f
; else
; return png_ptr->zbuffer_size;
mov eax,[eax+png_struct.zbuffer_size]
end if
.end_f:
ret
/programs/develop/libraries/libs-dev/libimg/png/libpng/pnginfo.inc
135,8 → 135,7
sig_bit png_color_8 ; significant bits in color channels
end if
 
;#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
;defined(PNG_READ_BACKGROUND_SUPPORTED)
if (PNG_tRNS_SUPPORTED eq 1) | (PNG_READ_EXPAND_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1)
; The tRNS chunk supplies transparency data for paletted images and
; other image types that don't need a full alpha channel. There are
; "num_trans" transparency values for a paletted image, stored in the
148,7 → 147,7
 
trans_alpha dd ? ;bytep ; alpha values for paletted image
trans_color png_color_16 ;transparent color for non-palette image
;end if
end if
 
if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1)
; The bKGD chunk gives the suggested image background color if the
/programs/develop/libraries/libs-dev/libimg/png/libpng/pngstruct.inc
126,7 → 126,7
 
struct png_struct
if PNG_SETJMP_SUPPORTED eq 1
jmp_buf_local dd ? ;jmp_buf ;New name in 1.6.0 for jmp_buf in png_struct
jmp_buf_local rb 64 ;jmp_buf ;New name in 1.6.0 for jmp_buf in png_struct
longjmp_fn dd ? ;png_longjmp_ptr ;setjmp non-local goto function.
jmp_buf_ptr dd ? ;jmp_buf * ;passed to longjmp_fn
jmp_buf_size dd ? ;size_t ;size of the above, if allocated
154,6 → 154,7
user_transform_ptr dd ? ;voidp ;user supplied struct for user transform
user_transform_depth db ? ;byte ;bit depth of user transformed pixels
user_transform_channels db ? ;byte ;channels in user transformed pixels
rb 2 ;align
end if
end if
 
216,7 → 217,7
crc dd ? ;uint_32 ;current chunk CRC value
palette dd ? ;png_colorp ;palette from the input file
num_palette dw ? ;uint_16 ;number of color entries in palette
 
rb 2 ;align
; Added at libpng-1.5.10
if PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED eq 1
num_palette_max dd ? ;int ;maximum palette index found in IDAT
237,9 → 238,9
sig_bytes db ? ;byte ;magic bytes read/written from start of file
maximum_pixel_depth db ? ;byte ;pixel depth used for the row buffers
transformed_pixel_depth db ? ;byte ;pixel depth after read/write transforms
;#if PNG_ZLIB_VERNUM >= 0x1240
zstream_start db ? ;byte ;at start of an input zlib stream
;end if /* Zlib >= 1.2.4 */
;if PNG_ZLIB_VERNUM >= 0x1240
;zstream_start db 1 ;byte ;at start of an input zlib stream
;end if ;Zlib >= 1.2.4
if (PNG_READ_FILLER_SUPPORTED eq 1) | (PNG_WRITE_FILLER_SUPPORTED eq 1)
filler dw ? ;uint_16 ; filler bytes for pixel expansion
end if
247,10 → 248,13
if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) | \
(PNG_READ_ALPHA_MODE_SUPPORTED eq 1)
background_gamma_type db ? ;byte
rb 1 ;align
background_gamma dd ? ;png_fixed_point
background png_color_16 ;background color in screen gamma space
rb 1 ;align
if PNG_READ_GAMMA_SUPPORTED eq 1
background_1 png_color_16 ;background normalized to gamma 1.0
rb 1 ;align
end if
end if ;bKGD
 
282,6 → 286,7
 
if (PNG_READ_SHIFT_SUPPORTED eq 1) | (PNG_WRITE_SHIFT_SUPPORTED eq 1)
shift png_color_8 ;shift for significant bit tranformation
rb 2 ;align
end if
 
if (PNG_tRNS_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) \
288,6 → 293,7
| (PNG_READ_EXPAND_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1)
trans_alpha dd ? ;bytep ;alpha values for paletted files
trans_color png_color_16 ;transparent color for non-paletted files
rb 3 ;align
end if
 
read_row_fn dd ? ;png_read_status_ptr ;called after each row is decoded
325,6 → 331,7
; To do: remove this from libpng-1.7
if PNG_TIME_RFC1123_SUPPORTED eq 1
time_buffer rb 29 ;char[29] ;String to hold RFC 1123 time text
rb 2 ;align
end if
;end if
 
355,6 → 362,7
rgb_to_gray_red_coeff dw ? ;uint_16
rgb_to_gray_green_coeff dw ? ;uint_16
; deleted in 1.5.5: rgb_to_gray_blue_coeff;
rb 2 ;align
end if
 
if PNG_MNG_FEATURES_SUPPORTED eq 1
364,6 → 372,7
 
; New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0
filter_type db ? ;byte
rb 3 ;align
end if
 
; New members added in libpng-1.2.0
387,6 → 396,7
 
; New members added in libpng-1.0.16 and 1.2.6
compression_type db ? ;byte
rb 3 ;align
 
if PNG_USER_LIMITS_SUPPORTED eq 1
user_width_max dd ? ;uint_32
408,7 → 418,8
; Temporary storage for unknown chunk that the library doesn't recognize,
; used while reading the chunk.
 
; png_unknown_chunk unknown_chunk;
unknown_chunk png_unknown_chunk
rb 3 ;align
end if
 
; New member added in libpng-1.2.26
432,8 → 443,7
big_prev_row dd ? ;bytep
 
; New member added in libpng-1.5.7
; void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
; bytep row, bytep prev_row);
read_filter rd PNG_FILTER_VALUE_LAST-1
 
if PNG_READ_SUPPORTED eq 1
if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwrite.asm
631,8 → 631,8
stdcall png_create_png_struct, [user_png_ver], [error_ptr], [error_fn], [warn_fn], 0, 0, 0
;eax = png_ptr
end if ;USER_MEM
cmp eax,0
je .end0 ;if (..!=0)
test eax,eax
jz .end0 ;if (..!=0)
; Set the zlib control values to defaults; they can be overridden by the
; application after the struct has been created.
 
1839,20 → 1839,20
stdcall png_create_write_struct, PNG_LIBPNG_VER_STRING, ebx, png_safe_error, png_safe_warning
;eax = png_ptr
 
cmp eax,0
je .end0 ;if (..!=0)
test eax,eax
jz .end0 ;if (..!=0)
mov edi,eax
stdcall png_create_info_struct, edi
;eax = info_ptr
 
cmp eax,0
je .end1 ;if (..!=0)
test eax,eax
jz .end1 ;if (..!=0)
mov esi,eax
stdcall png_malloc_warn, edi, sizeof.png_control
;control = eax
 
cmp eax,0
je .end2 ;if (..!=0)
test eax,eax
jz .end2 ;if (..!=0)
push eax
mov edx,edi ; edx = png_ptr
mov ecx,sizeof.png_control
2745,8 → 2745,8
stdcall png_free, edi, ecx
 
; Skip the 'write_end' on error:
cmp eax,0
je .end_f ;if (..==0) return 0
test eax,eax
jz .end_f ;if (..==0) return 0
jmp .end8
 
; Otherwise this is the case where the input is in a format currently
2793,8 → 2793,8
 
;create buffer with filters
stdcall png_zalloc, edi, 1, [len]
cmp eax,0
je .end_f
test eax,eax
jz .end_f
mov [buf_f],eax
 
mov eax,ZLIB_IO_MAX
2803,8 → 2803,8
mov eax,[len]
@@:
stdcall png_zalloc, edi, 1, eax
cmp eax,0
je .end0
test eax,eax
jz .end0
mov [m1],eax
 
;init buffer with filters
3100,8 → 3100,8
@@:
 
stdcall png_image_write_init, ebx
cmp eax,0
je .end3 ;if (..!=0)
test eax,eax
jz .end3 ;if (..!=0)
mov ecx,sizeof.png_image_write_control
mov edi,ebp
sub edi,ecx
/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwutil.asm
82,14 → 82,14
buf rb 8 ;ebp-8
endl
 
;#if defined(PNG_DEBUG) && (PNG_DEBUG > 0)
if (PNG_DEBUG eq 1) & (PNG_DEBUG > 0)
; PNG_CSTRING_FROM_CHUNK(buf, chunk_name);
; png_debug2(0, "Writing %s chunk, length = %lu", buf, (unsigned long)length);
;end if
end if
 
mov edi,[png_ptr]
cmp edi,0
je .end_f ;if (png_ptr == NULL) return
test edi,edi
jz .end_f ;if (..==0) return
 
if PNG_IO_STATE_SUPPORTED eq 1
; Inform the I/O callback that the chunk header is being written.
99,8 → 99,7
end if
 
; Write the length and the chunk name
mov ebx,ebp
sub ebx,8
lea ebx,[ebp-8]
stdcall png_save_uint_32, ebx, [length]
m2m dword[ebx+4],dword[chunk_name]
stdcall png_write_data, edi, ebx, 8
110,9 → 109,7
 
; Reset the crc and run it over the chunk name
stdcall png_reset_crc, edi
 
mov ebx,ebp
sub ebx,4 ;buf + 4
lea ebx,[ebp-4] ;buf + 4
stdcall png_calculate_crc, edi, ebx, 4
 
if PNG_IO_STATE_SUPPORTED eq 1
199,8 → 196,8
align 4
proc png_write_complete_chunk uses edi, png_ptr:dword, chunk_name:dword, p3data:dword, length:dword
mov edi,[png_ptr]
cmp edi,0
je .end_f ;if (..==0) return
test edi,edi
jz .end_f ;if (..==0) return
 
; On 64-bit architectures 'length' may not fit in a uint_32.
cmp dword[length],PNG_UINT_31_MAX ;if(..>..)
678,14 → 675,14
mov eax,[edx]
mov [next],eax
 
cmp eax,0
jne .end1 ;if (..==0)
test eax,eax
jnz .end1 ;if (..==0)
PNG_COMPRESSION_BUFFER_SIZE edi
stdcall png_malloc, edi, eax
mov [next],eax
 
cmp eax,0
jne @f ;if (..==0)
test eax,eax
jnz @f ;if (..==0)
mov esi,Z_MEM_ERROR
jmp .cycle0end
@@:
1180,6 → 1177,7
align 4
proc png_compress_IDAT uses eax ebx ecx edx, input:dword, input_len:dword, flush:dword
png_debug 1, 'in png_compress_IDAT'
 
cmp dword[edi+png_struct.zowner],png_IDAT
je .end0 ;if (..!=..)
; First time. Ensure we have a temporary buffer for compression and
1232,7 → 1230,7
mov eax,ZLIB_IO_MAX
 
cmp eax,[input_len]
jle @f ;if (..>..)
jbe @f ;if (..>..)
mov eax,[input_len] ;safe because of the check
@@:
 
1451,8 → 1449,8
stdcall png_check_keyword, edi, [name], ebx
mov [name_len],eax
 
cmp eax,0
jne @f ;if (..==0)
test eax,eax
jnz @f ;if (..==0)
png_error edi, 'iCCP: invalid keyword'
@@:
 
1955,8 → 1953,8
stdcall png_check_keyword, edi, [key], ebx
mov [key_len],eax
 
cmp eax,0
jne @f ;if (..==0)
test eax,eax
jnz @f ;if (..==0)
png_error edi, 'iTXt: invalid keyword'
@@:
 
2103,8 → 2101,8
stdcall png_check_keyword, edi, [purpose], ebx
mov [purpose_len],eax
 
cmp eax,0
jne @f ;if(..==0)
test eax,eax
jnz @f ;if(..==0)
png_error edi, 'pCAL: invalid keyword'
@@:
 
2460,8 → 2458,6
 
; See if we are done
mov eax,[edi+png_struct.row_number]
;png_debug1 2, ' row_number = %d', eax
;png_debug1 2, ' num_rows = %d', [edi+png_struct.num_rows]
cmp eax,[edi+png_struct.num_rows]
jl .end_f ;if (..<..) return
 
3063,13 → 3059,17
endl
pushad
mov edi,[png_ptr]
if PNG_WRITE_FILTER_SUPPORTED eq 1
if PNG_WRITE_FILTER_SUPPORTED eq 0
mov eax,[edi+png_struct.row_number]
png_debug1 2, ' (3)= %d', eax
mov eax,[edi+png_struct.rowbytes]
inc eax
stdcall png_write_filtered_row, edi, [edi+png_struct.row_buf], eax
mov eax,[edi+png_struct.row_number]
png_debug1 2, ' (4)= %d', eax
else
mov esi,[row_info]
mov eax,[edi+png_struct.do_filter]
movzx eax,byte[edi+png_struct.do_filter]
mov [filter_to_do],eax
mov eax,[esi+png_row_info.rowbytes]
mov [row_bytes],eax
3119,8 → 3119,8
mov eax,[edi+png_struct.row_buf]
mov [best_row],eax
 
cmp PNG_SIZE_MAX/128, dword[row_bytes]
jg @f ;if (..<=..)
cmp dword[row_bytes],PNG_SIZE_MAX/128
jl @f ;if (..>=..)
; Overflow can occur in the calculation, just select the lowest set
; filter.
 
3168,8 → 3168,8
mov [mins],eax
mov eax,[edi+png_struct.try_row]
mov [best_row],eax
cmp eax,0
je .end1 ;if (..!=0)
test eax,eax
jz .end1 ;if (..!=0)
mov eax,[edi+png_struct.tst_row]
mov [edi+png_struct.try_row],eax
mov eax,[best_row]
3194,8 → 3194,8
mov [mins],eax
mov eax,[edi+png_struct.try_row]
mov [best_row],eax
cmp eax,0
je .end2 ;if (..!=0)
test eax,eax
jz .end2 ;if (..!=0)
mov eax,[edi+png_struct.tst_row]
mov [edi+png_struct.try_row],eax
mov eax,[best_row]
3220,14 → 3220,14
mov [mins],eax
mov eax,[edi+png_struct.try_row]
mov [best_row],eax
cmp eax,0
je .end3 ;if (..!=0)
test eax,eax
jz .end3 ;if (..!=0)
mov eax,[edi+png_struct.tst_row]
mov [edi+png_struct.try_row],eax
mov eax,[best_row]
mov [edi+png_struct.tst_row],eax
.end3:
 
if 0 ;;; tmp
; Paeth filter
mov eax,[filter_to_do]
cmp eax,PNG_FILTER_PAETH
3246,14 → 3246,14
mov [mins],eax
mov eax,[edi+png_struct.try_row]
mov [best_row],eax
cmp eax,0
je .end4 ;if (..!=0)
test eax,eax
jz .end4 ;if (..!=0)
mov eax,[edi+png_struct.tst_row]
mov [edi+png_struct.try_row],eax
mov eax,[best_row]
mov [edi+png_struct.tst_row],eax
.end4:
 
end if
; Do the actual writing of the filtered row data from the chosen filter.
mov eax,[esi+png_row_info.rowbytes]
inc eax
3281,8 → 3281,8
if PNG_WRITE_FILTER_SUPPORTED eq 1
; Swap the current and previous rows
mov eax,[edi+png_struct.prev_row]
cmp eax,0
je @f ;if (..!=0)
test eax,eax
jz @f ;if (..!=0)
;eax = tptr
mov ebx,[edi+png_struct.row_buf]
mov [edi+png_struct.prev_row],ebx
/programs/fs/kfar/trunk/zlib/crc32.asm
17,14 → 17,10
 
; Definitions for doing the crc four data bytes at a time.
 
TBLS equ 1
 
if DYNAMIC_CRC_TABLE eq 1
 
align 4
crc_table_empty dd 1
;align 4
;crc_table rd TBLS*256
 
; Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
; x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
100,15 → 96,12
endp
 
; =========================================================================
;unsigned long (crc, buf, len)
; unsigned long crc
; unsigned char *buf
; uInt len
;unsigned long (unsigned long crc, unsigned char *buf, uInt len)
align 4
proc calc_crc32 uses ecx esi, p1crc:dword, buf:dword, len:dword
xor eax,eax
mov esi,[buf]
zlib_debug 'calc_crc32 buf = %d',esi
 
cmp esi,Z_NULL
je .end_f ;if (..==0) return 0
 
121,7 → 114,9
 
mov eax,[p1crc]
mov ecx,[len]
push edx
call crc
pop edx
.end_f:
ret
endp
129,9 → 124,7
GF2_DIM equ 32 ;dimension of GF(2) vectors (length of CRC)
 
; =========================================================================
;unsigned long (mat, vec)
; unsigned long *mat
; unsigned long vec
;unsigned long (unsigned long *mat, unsigned long vec)
align 4
proc gf2_matrix_times, mat:dword, vec:dword
; unsigned long sum;
148,9 → 141,7
endp
 
; =========================================================================
;local void (square, mat)
; unsigned long *square
; unsigned long *mat
;local void (unsigned long *square, unsigned long *mat)
align 4
proc gf2_matrix_square, square:dword, mat:dword
; int n;
161,10 → 152,7
endp
 
; =========================================================================
;uLong (crc1, crc2, len2)
; uLong crc1
; uLong crc2
; z_off64_t len2
;uLong (uLong crc1, uLong crc2, z_off64_t len2)
align 4
proc crc32_combine_, crc1:dword, crc2:dword, len2:dword
; int n;
219,10 → 207,7
endp
 
; =========================================================================
;uLong (crc1, crc2, len2)
; uLong crc1
; uLong crc2
; z_off_t len2
;uLong (uLong crc1, uLong crc2, z_off_t len2)
align 4
proc crc32_combine, crc1:dword, crc2:dword, len2:dword
stdcall crc32_combine_, [crc1], [crc2], [len2]
229,10 → 214,7
ret
endp
 
;uLong (crc1, crc2, len2)
; uLong crc1
; uLong crc2
; z_off64_t len2
;uLong (uLong crc1, uLong crc2, z_off64_t len2)
align 4
proc crc32_combine64, crc1:dword, crc2:dword, len2:dword
stdcall crc32_combine_, [crc1], [crc2], [len2]