Rev 6888 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6888 | Rev 6889 | ||
---|---|---|---|
Line 1287... | Line 1287... | ||
1287 | ; Construct the Huffman tree for the bit lengths and return the index in |
1287 | ; Construct the Huffman tree for the bit lengths and return the index in |
1288 | ; bl_order of the last bit length code to send. |
1288 | ; bl_order of the last bit length code to send. |
Line 1289... | Line 1289... | ||
1289 | 1289 | ||
1290 | ;int (deflate_state* s) |
1290 | ;int (deflate_state* s) |
1291 | align 16 |
1291 | align 16 |
1292 | proc build_bl_tree uses ecx edi, s:dword |
- | |
1293 | locals |
1292 | proc build_bl_tree uses ebx ecx edi, s:dword |
1294 | max_blindex dd ? ;int ;index of last bit length code of non zero freq |
1293 | ;ebx - max_blindex ;index of last bit length code of non zero freq |
1295 | endl |
1294 | |
1296 | mov edi,[s] |
1295 | mov edi,[s] |
1297 | ; Determine the bit length frequencies for literal and distance trees |
1296 | ; Determine the bit length frequencies for literal and distance trees |
1298 | mov eax,edi |
1297 | mov eax,edi |
1299 | add eax,deflate_state.dyn_ltree |
1298 | add eax,deflate_state.dyn_ltree |
Line 1309... | Line 1308... | ||
1309 | 1308 | ||
1310 | ; Determine the number of bit length codes to send. The pkzip format |
1309 | ; Determine the number of bit length codes to send. The pkzip format |
1311 | ; requires that at least 4 bit length codes be sent. (appnote.txt says |
1310 | ; requires that at least 4 bit length codes be sent. (appnote.txt says |
Line 1312... | Line 1311... | ||
1312 | ; 3 but the actual value used is 4.) |
1311 | ; 3 but the actual value used is 4.) |
1313 | 1312 | ||
1314 | mov dword[max_blindex],BL_CODES-1 |
1313 | mov ebx,BL_CODES-1 |
1315 | jmp @f |
1314 | jmp @f |
1316 | align 4 |
1315 | align 4 |
1317 | .cycle0: ;for (..;..>=..;..) |
1316 | .cycle0: ;for (..;..>=..;..) |
1318 | dec dword[max_blindex] |
1317 | dec ebx |
1319 | @@: |
1318 | @@: |
1320 | cmp dword[max_blindex],3 |
- | |
1321 | jl .cycle0end |
1319 | cmp ebx,3 |
1322 | mov ecx,[max_blindex] |
1320 | jl .cycle0end |
1323 | movzx eax,byte[ecx+bl_order] |
1321 | movzx ecx,byte[ebx+bl_order] |
1324 | movzx ecx,word[edi+sizeof.ct_data*eax+deflate_state.bl_tree+Len] |
- | |
1325 | jecxz .cycle0 |
1322 | movzx ecx,word[edi+sizeof.ct_data*ecx+deflate_state.bl_tree+Len] |
1326 | jmp .cycle0end |
1323 | jecxz .cycle0 |
1327 | align 4 |
1324 | align 4 |
1328 | .cycle0end: |
1325 | .cycle0end: |
1329 | ; Update opt_len to include the bit length tree and counts |
1326 | ; Update opt_len to include the bit length tree and counts |
1330 | mov eax,[max_blindex] |
1327 | mov eax,ebx |
1331 | inc eax |
1328 | inc eax |
1332 | imul eax,3 |
1329 | imul eax,3 |
1333 | add eax,5+5+4 |
1330 | add eax,5+5+4 |
Line 1334... | Line 1331... | ||
1334 | add [edi+deflate_state.opt_len],eax |
1331 | add [edi+deflate_state.opt_len],eax |
1335 | ; Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", s->opt_len, s->static_len)); |
1332 | ; Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", s->opt_len, s->static_len)); |
1336 | 1333 | ||
Line 1337... | Line 1334... | ||
1337 | mov eax,[max_blindex] |
1334 | mov eax,ebx |
1338 | ret |
1335 | ret |
1339 | endp |
1336 | endp |
1340 | 1337 | ||
Line 1341... | Line 1338... | ||
1341 | ; =========================================================================== |
1338 | ; =========================================================================== |
1342 | ; Send the header for a block using dynamic Huffman trees: the counts, the |
- | |
1343 | ; lengths of the bit length codes, the literal tree and the distance tree. |
1339 | ; Send the header for a block using dynamic Huffman trees: the counts, the |
1344 | ; IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. |
1340 | ; lengths of the bit length codes, the literal tree and the distance tree. |
1345 | 1341 | ; IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. |
|
1346 | ;void (s, lcodes, dcodes, blcodes) |
1342 | |
1347 | ; deflate_state* s |
1343 | ;void (deflate_state* s, lcodes, dcodes, blcodes) |