Rev 6797 | Rev 6883 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6797 | Rev 6881 | ||
---|---|---|---|
Line 80... | Line 80... | ||
80 | locals |
80 | locals |
81 | buf rb 8 ;ebp-8 |
81 | buf rb 8 ;ebp-8 |
82 | endl |
82 | endl |
83 | 83 | ||
Line 84... | Line 84... | ||
84 | ;#if defined(PNG_DEBUG) && (PNG_DEBUG > 0) |
84 | if (PNG_DEBUG eq 1) & (PNG_DEBUG > 0) |
85 | ; PNG_CSTRING_FROM_CHUNK(buf, chunk_name); |
85 | ; PNG_CSTRING_FROM_CHUNK(buf, chunk_name); |
86 | ; png_debug2(0, "Writing %s chunk, length = %lu", buf, (unsigned long)length); |
86 | ; png_debug2(0, "Writing %s chunk, length = %lu", buf, (unsigned long)length); |
87 | ;end if |
87 | end if |
Line 88... | Line 88... | ||
88 | 88 | ||
89 | mov edi,[png_ptr] |
89 | mov edi,[png_ptr] |
90 | cmp edi,0 |
90 | test edi,edi |
Line 91... | Line 91... | ||
91 | je .end_f ;if (png_ptr == NULL) return |
91 | jz .end_f ;if (..==0) return |
92 | 92 | ||
93 | if PNG_IO_STATE_SUPPORTED eq 1 |
93 | if PNG_IO_STATE_SUPPORTED eq 1 |
Line 94... | Line 94... | ||
94 | ; Inform the I/O callback that the chunk header is being written. |
94 | ; Inform the I/O callback that the chunk header is being written. |
95 | ; PNG_IO_CHUNK_HDR requires a single I/O call. |
95 | ; PNG_IO_CHUNK_HDR requires a single I/O call. |
Line 96... | Line 96... | ||
96 | 96 | ||
97 | mov dword[edi+png_struct.io_state], PNG_IO_WRITING or PNG_IO_CHUNK_HDR |
97 | mov dword[edi+png_struct.io_state], PNG_IO_WRITING or PNG_IO_CHUNK_HDR |
98 | end if |
- | |
99 | 98 | end if |
|
100 | ; Write the length and the chunk name |
99 | |
101 | mov ebx,ebp |
100 | ; Write the length and the chunk name |
Line 102... | Line 101... | ||
102 | sub ebx,8 |
101 | lea ebx,[ebp-8] |
103 | stdcall png_save_uint_32, ebx, [length] |
102 | stdcall png_save_uint_32, ebx, [length] |
Line 104... | Line 103... | ||
104 | m2m dword[ebx+4],dword[chunk_name] |
103 | m2m dword[ebx+4],dword[chunk_name] |
105 | stdcall png_write_data, edi, ebx, 8 |
104 | stdcall png_write_data, edi, ebx, 8 |
106 | - | ||
107 | ; Put the chunk name into png_ptr->chunk_name |
- | |
108 | m2m dword[edi+png_struct.chunk_name],dword[chunk_name] |
105 | |
109 | 106 | ; Put the chunk name into png_ptr->chunk_name |
|
Line 110... | Line 107... | ||
110 | ; Reset the crc and run it over the chunk name |
107 | m2m dword[edi+png_struct.chunk_name],dword[chunk_name] |
111 | stdcall png_reset_crc, edi |
108 | |
112 | 109 | ; Reset the crc and run it over the chunk name |
|
Line 197... | Line 194... | ||
197 | ;void (png_structrp png_ptr, uint_32 chunk_name, bytep data, png_size_t length) |
194 | ;void (png_structrp png_ptr, uint_32 chunk_name, bytep data, png_size_t length) |
198 | align 4 |
195 | align 4 |
199 | proc png_write_complete_chunk uses edi, png_ptr:dword, chunk_name:dword, p3data:dword, length:dword |
196 | proc png_write_complete_chunk uses edi, png_ptr:dword, chunk_name:dword, p3data:dword, length:dword |
200 | mov edi,[png_ptr] |
197 | mov edi,[png_ptr] |
201 | cmp edi,0 |
198 | test edi,edi |
202 | je .end_f ;if (..==0) return |
199 | jz .end_f ;if (..==0) return |
Line 203... | Line 200... | ||
203 | 200 | ||
204 | ; On 64-bit architectures 'length' may not fit in a uint_32. |
201 | ; On 64-bit architectures 'length' may not fit in a uint_32. |
205 | cmp dword[length],PNG_UINT_31_MAX ;if(..>..) |
202 | cmp dword[length],PNG_UINT_31_MAX ;if(..>..) |
206 | jle @f |
203 | jle @f |
Line 676... | Line 673... | ||
676 | 673 | ||
Line 677... | Line 674... | ||
677 | mov eax,[edx] |
674 | mov eax,[edx] |
678 | mov [next],eax |
675 | mov [next],eax |
Line 679... | Line 676... | ||
679 | 676 | ||
680 | cmp eax,0 |
677 | test eax,eax |
681 | jne .end1 ;if (..==0) |
678 | jnz .end1 ;if (..==0) |
682 | PNG_COMPRESSION_BUFFER_SIZE edi |
679 | PNG_COMPRESSION_BUFFER_SIZE edi |
683 | stdcall png_malloc, edi, eax |
680 | stdcall png_malloc, edi, eax |
Line 684... | Line 681... | ||
684 | mov [next],eax |
681 | mov [next],eax |
685 | 682 | ||
686 | cmp eax,0 |
683 | test eax,eax |
687 | jne @f ;if (..==0) |
684 | jnz @f ;if (..==0) |
688 | mov esi,Z_MEM_ERROR |
685 | mov esi,Z_MEM_ERROR |
Line 689... | Line 686... | ||
689 | jmp .cycle0end |
686 | jmp .cycle0end |
Line 1178... | Line 1175... | ||
1178 | ; edi - png_ptr |
1175 | ; edi - png_ptr |
1179 | align 4 |
1176 | align 4 |
1180 | proc png_compress_IDAT uses eax ebx ecx edx, input:dword, input_len:dword, flush:dword |
1177 | proc png_compress_IDAT uses eax ebx ecx edx, input:dword, input_len:dword, flush:dword |
1181 | png_debug 1, 'in png_compress_IDAT' |
1178 | png_debug 1, 'in png_compress_IDAT' |
1182 | cmp dword[edi+png_struct.zowner],png_IDAT |
1179 | |
- | 1180 | cmp dword[edi+png_struct.zowner],png_IDAT |
|
1183 | je .end0 ;if (..!=..) |
1181 | je .end0 ;if (..!=..) |
1184 | ; First time. Ensure we have a temporary buffer for compression and |
1182 | ; First time. Ensure we have a temporary buffer for compression and |
1185 | ; trim the buffer list if it has more than one entry to free memory. |
1183 | ; trim the buffer list if it has more than one entry to free memory. |
1186 | ; If 'WRITE_COMPRESSED_TEXT' is not set the list will never have been |
1184 | ; If 'WRITE_COMPRESSED_TEXT' is not set the list will never have been |
1187 | ; created at this point, but the check here is quick and safe. |
1185 | ; created at this point, but the check here is quick and safe. |
Line 1230... | Line 1228... | ||
1230 | ;INPUT: from the row data |
1228 | ;INPUT: from the row data |
1231 | mov eax,ZLIB_IO_MAX |
1229 | mov eax,ZLIB_IO_MAX |
1232 | 1230 | ||
Line 1233... | Line 1231... | ||
1233 | cmp eax,[input_len] |
1231 | cmp eax,[input_len] |
1234 | jle @f ;if (..>..) |
1232 | jbe @f ;if (..>..) |
1235 | mov eax,[input_len] ;safe because of the check |
1233 | mov eax,[input_len] ;safe because of the check |
1236 | @@: |
1234 | @@: |
Line 1237... | Line 1235... | ||
1237 | 1235 | ||
1238 | mov [edi+png_struct.zstream.avail_in],eax |
1236 | mov [edi+png_struct.zstream.avail_in],eax |
Line 1449... | Line 1447... | ||
1449 | sub ebx,81 ;ebx = &new_name |
1447 | sub ebx,81 ;ebx = &new_name |
1450 | stdcall png_check_keyword, edi, [name], ebx |
1448 | stdcall png_check_keyword, edi, [name], ebx |
1451 | mov [name_len],eax |
1449 | mov [name_len],eax |
1452 | 1450 | ||
Line 1453... | Line 1451... | ||
1453 | cmp eax,0 |
1451 | test eax,eax |
1454 | jne @f ;if (..==0) |
1452 | jnz @f ;if (..==0) |
1455 | png_error edi, 'iCCP: invalid keyword' |
1453 | png_error edi, 'iCCP: invalid keyword' |
1456 | @@: |
1454 | @@: |
Line 1457... | Line 1455... | ||
1457 | 1455 | ||
1458 | inc dword[name_len] |
1456 | inc dword[name_len] |
Line 1953... | Line 1951... | ||
1953 | sub ebx,82+sizeof.compression_state |
1951 | sub ebx,82+sizeof.compression_state |
1954 | stdcall png_check_keyword, edi, [key], ebx |
1952 | stdcall png_check_keyword, edi, [key], ebx |
1955 | mov [key_len],eax |
1953 | mov [key_len],eax |
1956 | 1954 | ||
Line 1957... | Line 1955... | ||
1957 | cmp eax,0 |
1955 | test eax,eax |
1958 | jne @f ;if (..==0) |
1956 | jnz @f ;if (..==0) |
1959 | png_error edi, 'iTXt: invalid keyword' |
1957 | png_error edi, 'iTXt: invalid keyword' |
1960 | @@: |
1958 | @@: |
Line 1961... | Line 1959... | ||
1961 | 1959 | ||
1962 | ; Set the compression flag |
1960 | ; Set the compression flag |
Line 2101... | Line 2099... | ||
2101 | sub ebx,84 ;ebx = &new_purpose |
2099 | sub ebx,84 ;ebx = &new_purpose |
2102 | stdcall png_check_keyword, edi, [purpose], ebx |
2100 | stdcall png_check_keyword, edi, [purpose], ebx |
2103 | mov [purpose_len],eax |
2101 | mov [purpose_len],eax |
2104 | 2102 | ||
Line 2105... | Line 2103... | ||
2105 | cmp eax,0 |
2103 | test eax,eax |
2106 | jne @f ;if(..==0) |
2104 | jnz @f ;if(..==0) |
2107 | png_error edi, 'pCAL: invalid keyword' |
2105 | png_error edi, 'pCAL: invalid keyword' |
2108 | @@: |
2106 | @@: |
Line 2109... | Line 2107... | ||
2109 | 2107 | ||
Line 2458... | Line 2456... | ||
2458 | inc dword[edi+png_struct.row_number] |
2456 | inc dword[edi+png_struct.row_number] |
2459 | 2457 | ||
Line 2460... | Line 2458... | ||
2460 | ; See if we are done |
2458 | ; See if we are done |
2461 | mov eax,[edi+png_struct.row_number] |
2459 | mov eax,[edi+png_struct.row_number] |
2462 | ;png_debug1 2, ' row_number = %d', eax |
- | |
2463 | ;png_debug1 2, ' num_rows = %d', [edi+png_struct.num_rows] |
- | |
2464 | cmp eax,[edi+png_struct.num_rows] |
2460 | cmp eax,[edi+png_struct.num_rows] |
2465 | jl .end_f ;if (..<..) return |
2461 | jl .end_f ;if (..<..) return |
Line 2466... | Line 2462... | ||
2466 | 2462 | ||
2467 | if PNG_WRITE_INTERLACING_SUPPORTED eq 1 |
2463 | if PNG_WRITE_INTERLACING_SUPPORTED eq 1 |
Line 3061... | Line 3057... | ||
3061 | row_bytes dd ? ;png_size_t ;= row_info->rowbytes |
3057 | row_bytes dd ? ;png_size_t ;= row_info->rowbytes |
3062 | endl |
3058 | endl |
3063 | pushad |
3059 | pushad |
3064 | mov edi,[png_ptr] |
3060 | mov edi,[png_ptr] |
3065 | if PNG_WRITE_FILTER_SUPPORTED eq 1 |
3061 | if PNG_WRITE_FILTER_SUPPORTED eq 0 |
3066 | mov eax,[edi+png_struct.rowbytes] |
3062 | mov eax,[edi+png_struct.row_number] |
- | 3063 | png_debug1 2, ' (3)= %d', eax |
|
- | 3064 | mov eax,[edi+png_struct.rowbytes] |
|
3067 | inc eax |
3065 | inc eax |
3068 | stdcall png_write_filtered_row, edi, [edi+png_struct.row_buf], eax |
3066 | stdcall png_write_filtered_row, edi, [edi+png_struct.row_buf], eax |
3069 | else |
3067 | mov eax,[edi+png_struct.row_number] |
- | 3068 | png_debug1 2, ' (4)= %d', eax |
|
- | 3069 | else |
|
3070 | mov esi,[row_info] |
3070 | mov esi,[row_info] |
3071 | mov eax,[edi+png_struct.do_filter] |
3071 | movzx eax,byte[edi+png_struct.do_filter] |
3072 | mov [filter_to_do],eax |
3072 | mov [filter_to_do],eax |
3073 | mov eax,[esi+png_row_info.rowbytes] |
3073 | mov eax,[esi+png_row_info.rowbytes] |
3074 | mov [row_bytes],eax |
3074 | mov [row_bytes],eax |
3075 | 3075 | ||
Line 3076... | Line 3076... | ||
3076 | png_debug 1, 'in png_write_find_filter' |
3076 | png_debug 1, 'in png_write_find_filter' |
Line 3117... | Line 3117... | ||
3117 | 3117 | ||
Line 3118... | Line 3118... | ||
3118 | mov eax,[edi+png_struct.row_buf] |
3118 | mov eax,[edi+png_struct.row_buf] |
3119 | mov [best_row],eax |
3119 | mov [best_row],eax |
Line 3120... | Line 3120... | ||
3120 | 3120 | ||
3121 | cmp PNG_SIZE_MAX/128, dword[row_bytes] |
3121 | cmp dword[row_bytes],PNG_SIZE_MAX/128 |
3122 | jg @f ;if (..<=..) |
3122 | jl @f ;if (..>=..) |
3123 | ; Overflow can occur in the calculation, just select the lowest set |
3123 | ; Overflow can occur in the calculation, just select the lowest set |
Line 3124... | Line 3124... | ||
3124 | ; filter. |
3124 | ; filter. |
3125 | 3125 | ||
Line 3166... | Line 3166... | ||
3166 | jge .end1 ;if (..<..) |
3166 | jge .end1 ;if (..<..) |
3167 | mov [mins],eax |
3167 | mov [mins],eax |
3168 | mov eax,[edi+png_struct.try_row] |
3168 | mov eax,[edi+png_struct.try_row] |
3169 | mov [best_row],eax |
3169 | mov [best_row],eax |
3170 | cmp eax,0 |
3170 | test eax,eax |
3171 | je .end1 ;if (..!=0) |
3171 | jz .end1 ;if (..!=0) |
3172 | mov eax,[edi+png_struct.tst_row] |
3172 | mov eax,[edi+png_struct.tst_row] |
3173 | mov [edi+png_struct.try_row],eax |
3173 | mov [edi+png_struct.try_row],eax |
3174 | mov eax,[best_row] |
3174 | mov eax,[best_row] |
3175 | mov [edi+png_struct.tst_row],eax |
3175 | mov [edi+png_struct.tst_row],eax |
3176 | .end1: |
3176 | .end1: |
3177 | 3177 | ||
Line 3192... | Line 3192... | ||
3192 | jge .end2 ;if (..<..) |
3192 | jge .end2 ;if (..<..) |
3193 | mov [mins],eax |
3193 | mov [mins],eax |
3194 | mov eax,[edi+png_struct.try_row] |
3194 | mov eax,[edi+png_struct.try_row] |
3195 | mov [best_row],eax |
3195 | mov [best_row],eax |
3196 | cmp eax,0 |
3196 | test eax,eax |
3197 | je .end2 ;if (..!=0) |
3197 | jz .end2 ;if (..!=0) |
3198 | mov eax,[edi+png_struct.tst_row] |
3198 | mov eax,[edi+png_struct.tst_row] |
3199 | mov [edi+png_struct.try_row],eax |
3199 | mov [edi+png_struct.try_row],eax |
3200 | mov eax,[best_row] |
3200 | mov eax,[best_row] |
3201 | mov [edi+png_struct.tst_row],eax |
3201 | mov [edi+png_struct.tst_row],eax |
3202 | .end2: |
3202 | .end2: |
3203 | 3203 | ||
Line 3218... | Line 3218... | ||
3218 | jge .end3 ;if (..<..) |
3218 | jge .end3 ;if (..<..) |
3219 | mov [mins],eax |
3219 | mov [mins],eax |
3220 | mov eax,[edi+png_struct.try_row] |
3220 | mov eax,[edi+png_struct.try_row] |
3221 | mov [best_row],eax |
3221 | mov [best_row],eax |
3222 | cmp eax,0 |
3222 | test eax,eax |
3223 | je .end3 ;if (..!=0) |
3223 | jz .end3 ;if (..!=0) |
3224 | mov eax,[edi+png_struct.tst_row] |
3224 | mov eax,[edi+png_struct.tst_row] |
3225 | mov [edi+png_struct.try_row],eax |
3225 | mov [edi+png_struct.try_row],eax |
3226 | mov eax,[best_row] |
3226 | mov eax,[best_row] |
3227 | mov [edi+png_struct.tst_row],eax |
3227 | mov [edi+png_struct.tst_row],eax |
3228 | .end3: |
3228 | .end3: |
3229 | 3229 | if 0 ;;; tmp |
|
3230 | ; Paeth filter |
3230 | ; Paeth filter |
3231 | mov eax,[filter_to_do] |
3231 | mov eax,[filter_to_do] |
3232 | cmp eax,PNG_FILTER_PAETH |
3232 | cmp eax,PNG_FILTER_PAETH |
3233 | jne @f ;if (..==..) |
3233 | jne @f ;if (..==..) |
3234 | ; It's the only filter so no testing is needed |
3234 | ; It's the only filter so no testing is needed |
3235 | stdcall png_setup_paeth_row_only, edi, [bpp], [row_bytes] |
3235 | stdcall png_setup_paeth_row_only, edi, [bpp], [row_bytes] |
Line 3244... | Line 3244... | ||
3244 | jge .end4 ;if (..<..) |
3244 | jge .end4 ;if (..<..) |
3245 | mov [mins],eax |
3245 | mov [mins],eax |
3246 | mov eax,[edi+png_struct.try_row] |
3246 | mov eax,[edi+png_struct.try_row] |
3247 | mov [best_row],eax |
3247 | mov [best_row],eax |
3248 | cmp eax,0 |
3248 | test eax,eax |
3249 | je .end4 ;if (..!=0) |
3249 | jz .end4 ;if (..!=0) |
3250 | mov eax,[edi+png_struct.tst_row] |
3250 | mov eax,[edi+png_struct.tst_row] |
3251 | mov [edi+png_struct.try_row],eax |
3251 | mov [edi+png_struct.try_row],eax |
3252 | mov eax,[best_row] |
3252 | mov eax,[best_row] |
3253 | mov [edi+png_struct.tst_row],eax |
3253 | mov [edi+png_struct.tst_row],eax |
3254 | .end4: |
3254 | .end4: |
3255 | 3255 | end if |
|
3256 | ; Do the actual writing of the filtered row data from the chosen filter. |
3256 | ; Do the actual writing of the filtered row data from the chosen filter. |
3257 | mov eax,[esi+png_row_info.rowbytes] |
3257 | mov eax,[esi+png_row_info.rowbytes] |
3258 | inc eax |
3258 | inc eax |
3259 | stdcall png_write_filtered_row, edi, [best_row], eax |
3259 | stdcall png_write_filtered_row, edi, [best_row], eax |
3260 | end if ;WRITE_FILTER |
3260 | end if ;WRITE_FILTER |
3261 | popad |
3261 | popad |
Line 3279... | Line 3279... | ||
3279 | 3279 | ||
Line 3280... | Line 3280... | ||
3280 | if PNG_WRITE_FILTER_SUPPORTED eq 1 |
3280 | if PNG_WRITE_FILTER_SUPPORTED eq 1 |
3281 | ; Swap the current and previous rows |
3281 | ; Swap the current and previous rows |
3282 | mov eax,[edi+png_struct.prev_row] |
3282 | mov eax,[edi+png_struct.prev_row] |
3283 | cmp eax,0 |
3283 | test eax,eax |
3284 | je @f ;if (..!=0) |
3284 | jz @f ;if (..!=0) |
3285 | ;eax = tptr |
3285 | ;eax = tptr |
3286 | mov ebx,[edi+png_struct.row_buf] |
3286 | mov ebx,[edi+png_struct.row_buf] |
3287 | mov [edi+png_struct.prev_row],ebx |
3287 | mov [edi+png_struct.prev_row],ebx |
3288 | mov [edi+png_struct.row_buf],eax |
3288 | mov [edi+png_struct.row_buf],eax |
3289 | @@: |
3289 | @@: |