fix compress size

git-svn-id: svn://kolibrios.org@6780 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2016-12-03 19:06:49 +00:00
parent cdfe44d0b7
commit 9a564b1fbf
4 changed files with 23 additions and 99 deletions

View File

@ -743,40 +743,7 @@ PNG_ALL_MNG_FEATURES equ 0x05
; full explanation, see example.c for the summary. This just provides
; a simple one line description of the use of each function.
; The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in
; pngconf.h and in the *.dfn files in the scripts directory.
; PNG_EXPORT(ordinal, type, name, (args));
; ordinal: ordinal that is used while building
; *.def files. The ordinal value is only
; relevant when preprocessing png.h with
; the *.dfn files for building symbol table
; entries, and are removed by pngconf.h.
; type: return type of the function
; name: function name
; args: function arguments, with types
; When we wish to append attributes to a function prototype we use
; the PNG_EXPORTA() macro instead.
; PNG_EXPORTA(ordinal, type, name, (args), attributes);
; ordinal, type, name, and args: same as in PNG_EXPORT().
; attributes: function attributes
macro PNG_EXPORT ordinal, typ, nam, arg
{
align 4
nam:
local .end_t
local .m_txt
jmp .end_t
.m_txt db `nam,13,10,0
.end_t:
stdcall dbg_print,txt_zv,.m_txt
ret
}
; Simple signature checking function. This is the same as calling
; png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
@ -943,23 +910,6 @@ PNG_FILTER_HEURISTIC_UNWEIGHTED equ 1 ;Used by libpng < 0.95
PNG_FILTER_HEURISTIC_WEIGHTED equ 2 ;Experimental feature
PNG_FILTER_HEURISTIC_LAST equ 3 ;Not a valid value
; These next functions are called for input/output, memory, and error
; handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
; and call standard C I/O routines such as fread(), fwrite(), and
; fprintf(). These functions can be made to use other I/O routines
; at run time for those applications that need to handle I/O in a
; different manner by calling png_set_???_fn(). See libpng-manual.txt for
; more information.
; Replace the default data input function with a user supplied one.
PNG_EXPORT 78, void, png_set_read_fn, '(png_structrp png_ptr, voidp io_ptr, png_rw_ptr read_data_fn)'
; Reassign responsibility for freeing existing data, whether allocated
; by libpng or by the application; this works on the png_info structure passed
; in, it does not change the state for other png_info structures.
; It is unlikely that this function works correctly as of 1.6.0 and using it
; may result either in memory leaks or double free of allocated data.
@ -985,29 +935,16 @@ PNG_FREE_ALL equ 0x7fff
PNG_FREE_MUL equ 0x4220 ;PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN
;if PNG_ERROR_TEXT_SUPPORTED
; The same, but the chunk name is prepended to the error string.
;PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,
; charp error_message), PNG_NORETURN);
;#else
; Fatal error in PNG image of libpng - can't continue
;PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);
;# define png_chunk_error(s1,s2) png_err(s1)
;end if
; Non-fatal error in libpng, chunk name is prepended to message.
PNG_EXPORT 106, void, png_chunk_warning, '(png_const_structrp png_ptr, charp warning_message)'
;#else
;# define png_warning(s1,s2) ((void)(s1))
;# define png_chunk_warning(s1,s2) ((void)(s1))
; Benign error in libpng. Can continue, but may have a problem.
; User can choose whether to handle as a fatal error or as a warning.
PNG_EXPORT 107, void, png_benign_error, '(png_const_structrp png_ptr, charp warning_message)'
;if PNG_READ_SUPPORTED
; Same, chunk name is prepended to message (only during read)
PNG_EXPORT 108, void, png_chunk_benign_error, '(png_const_structrp png_ptr, charp warning_message)'
;#else
;# ifdef PNG_ALLOW_BENIGN_ERRORS

View File

@ -2946,7 +2946,8 @@ align 4
je .end1
add ecx,16*1024
sub cx,[edi+png_struct.zstream.avail_out]
movzx eax,word[edi+png_struct.zstream.avail_out]
sub ecx,eax
cmp word[edi+png_struct.zstream.avail_out],0
je .cycle4 ;while (strm.avail_out == 0)
if 0
@ -2967,7 +2968,6 @@ if PNG_WRITE_OPTIMIZE_CMF_SUPPORTED eq 1
stdcall optimize_cmf, [m1], eax
@@:
end if
stdcall png_write_complete_chunk, edi, png_IDAT, [m1], ecx
or dword[edi+png_struct.mode],PNG_HAVE_IDAT

View File

@ -410,8 +410,7 @@ end if
jne .end1 ;if (..==..)
mov eax,[edi+png_struct.flags]
and eax,PNG_FLAG_ZLIB_CUSTOM_STRATEGY
cmp eax,0
je @f ;if (..!=0)
jz @f ;if (..!=0)
mov eax,[edi+png_struct.zlib_strategy]
mov dword[strategy],eax
jmp .end2
@ -477,8 +476,7 @@ end if
; Check against the previous initialized values, if any.
mov eax,[edi+png_struct.flags]
and eax,PNG_FLAG_ZSTREAM_INITIALIZED
cmp eax,0
je .end4
jz .end4
mov eax,[level]
cmp [edi+png_struct.zlib_set_level],eax
jne @f
@ -520,8 +518,7 @@ end if
add ecx,png_struct.zstream
mov eax,[edi+png_struct.flags]
and eax,PNG_FLAG_ZSTREAM_INITIALIZED
cmp eax,0
je @f ;if (..!=0)
jz @f ;if (..!=0)
stdcall [deflateReset], ecx
jmp .end5
@@: ;else
@ -1100,8 +1097,7 @@ if PNG_MNG_FEATURES_SUPPORTED eq 1
jg @f
mov eax,[edi+png_struct.mng_features_permitted]
and eax,PNG_FLAG_MNG_EMPTY_PLTE
cmp eax,0
jne .end1
jnz .end1
cmp [num_pal],0
jne .end1
@@:
@ -1118,8 +1114,7 @@ end if
movzx eax,byte[edi+png_struct.color_type]
and eax,PNG_COLOR_MASK_COLOR
cmp eax,0
jne @f ;if (..==0)
jnz @f ;if (..==0)
png_warning edi, 'Ignoring request to write a PLTE chunk in grayscale PNG'
jmp .end_f
@@:
@ -1276,8 +1271,7 @@ align 4
if PNG_WRITE_OPTIMIZE_CMF_SUPPORTED eq 1
mov eax,[edi+png_struct.mode]
and eax,PNG_HAVE_IDAT
cmp eax,0
jne @f
jnz @f
cmp byte[edi+png_struct.compression_type],PNG_COMPRESSION_TYPE_BASE
jne @f ;if (..==0 && ..==..)
stdcall png_image_size, edi
@ -1327,15 +1321,15 @@ end if
mov edx,[edi+png_struct.zbuffer_list]
add edx,png_compression_buffer.output
mov ecx,[edi+png_struct.zbuffer_size]
sub cx,[edi+png_struct.zstream.avail_out]
movzx eax,word[edi+png_struct.zstream.avail_out]
sub ecx,eax
;edx = data
;ecx = size
if PNG_WRITE_OPTIMIZE_CMF_SUPPORTED eq 1
mov eax,[edi+png_struct.mode]
and eax,PNG_HAVE_IDAT
cmp eax,0
jne @f
jnz @f
cmp byte[edi+png_struct.compression_type],PNG_COMPRESSION_TYPE_BASE
jne @f ;if (..==0 && ..==..)
stdcall png_image_size, edi
@ -2423,8 +2417,7 @@ if PNG_WRITE_INTERLACING_SUPPORTED eq 1
je @f
mov eax,[edi+png_struct.transformations]
and eax,PNG_INTERLACE
cmp eax,0
jne @f ;if(..!=0 && ..==0)
jnz @f ;if(..!=0 && ..==0)
movzx ecx,byte[png_pass_yinc]
mov eax,[edi+png_struct.height]
add eax,ecx
@ -2479,8 +2472,7 @@ if PNG_WRITE_INTERLACING_SUPPORTED eq 1
mov dword[edi+png_struct.row_number],0
mov eax,[edi+png_struct.transformations]
and eax,PNG_INTERLACE
cmp eax,0
je @f ;if (..!=0)
jz @f ;if (..!=0)
inc byte[edi+png_struct.pass]
jmp .end1
@@: ;else
@ -2520,8 +2512,7 @@ if PNG_WRITE_INTERLACING_SUPPORTED eq 1
mov eax,[edi+png_struct.transformations]
and eax,PNG_INTERLACE
cmp eax,0
jne .cycle0end ;if(..!=0) break
jnz .cycle0end ;if(..!=0) break
cmp dword[edi+png_struct.usr_width],0
je .cycle0
@ -2876,7 +2867,7 @@ endl
shr ah,1
sub al,ah
stosb
png_setup_abs [sum]
png_setup_abs dword[sum]
inc ebx
loop .cycle0
@ -2897,7 +2888,7 @@ endl
rol eax,8
sub al,ah
stosb
png_setup_abs [sum]
png_setup_abs dword[sum]
mov eax,[sum]
cmp eax,[lmins]
jg .cycle1end ;if (..>..) ;We are already worse, don't continue.
@ -3140,8 +3131,7 @@ else
@@:
mov eax,[filter_to_do]
and eax,PNG_FILTER_NONE
cmp eax,0
je .end0
jz .end0
cmp dword[filter_to_do],PNG_FILTER_NONE
je .end0 ;else if (..!=0 && ..!=..)
; Overflow not possible and multiple filters in the list, including the
@ -3171,8 +3161,7 @@ else
jmp .end1
@@:
and eax,PNG_FILTER_SUB
cmp eax,0
je .end1 ;else if (..!=0)
jz .end1 ;else if (..!=0)
stdcall png_setup_sub_row, edi, [bpp], [row_bytes], [mins]
cmp eax,[mins]
jge .end1 ;if (..<..)
@ -3198,8 +3187,7 @@ else
jmp .end2
@@:
and eax,PNG_FILTER_UP
cmp eax,0
je .end2 ;else if (..!=0)
jz .end2 ;else if (..!=0)
stdcall png_setup_up_row, edi, [row_bytes], [mins]
cmp eax,[mins]
jge .end2 ;if (..<..)
@ -3225,8 +3213,7 @@ else
jmp .end3
@@:
and eax,PNG_FILTER_AVG
cmp eax,0
je .end3 ;else if (..!=0)
jz .end3 ;else if (..!=0)
stdcall png_setup_avg_row, edi, [bpp], [row_bytes], [mins]
cmp eax,[mins]
jge .end3 ;if (..<..)
@ -3252,8 +3239,7 @@ else
jmp .end4
@@:
and eax,PNG_FILTER_PAETH
cmp eax,0
je .end4 ;else if (..!=0)
jz .end4 ;else if (..!=0)
stdcall png_setup_paeth_row, edi, [bpp], [row_bytes], [mins]
cmp eax,[mins]
jge .end4 ;if (..<..)

View File

@ -893,7 +893,8 @@ proc flush_pending uses eax ebx ecx edx, strm:dword
stdcall _tr_flush_bits, edx
mov ecx,[edx+deflate_state.pending]
cmp cx,[ebx+z_stream.avail_out]
movzx eax,word[ebx+z_stream.avail_out]
cmp ecx,eax
jle @f ;if (..>..)
movzx ecx,word[ebx+z_stream.avail_out]
@@: