1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <stdint.h> 4 #include <memory.h> 5 #include <assert.h> 6 7 #if __x86_64__ || __i386__ || _M_X64 || _M_IX86 8 #ifdef _MSC_VER 9 # include <intrin.h> 10 #else 11 # include <x86intrin.h> 12 #endif 13 #endif //__x86_64__ || __i386__ || _M_X64 || _M_IX86 14 15 #include "encode_df.h" 16 #include "bitbuf2.h" 17 18 struct deflate_icf *encode_deflate_icf_base(struct deflate_icf *next_in, 19 struct deflate_icf *end_in, struct BitBuf2 *bb, 20 struct hufftables_icf *hufftables) 21 { 22 struct huff_code lsym, dsym; 23 24 while (next_in < end_in && !is_full(bb)) { 25 lsym = hufftables->lit_len_table[next_in->lit_len]; 26 dsym = hufftables->dist_table[next_in->lit_dist]; 27 28 // insert ll code, dist_code, and extra_bits 29 write_bits_unsafe(bb, lsym.code_and_extra, lsym.length); 30 write_bits_unsafe(bb, dsym.code, dsym.length); 31 write_bits_unsafe(bb, next_in->dist_extra, dsym.extra_bit_count); 32 flush_bits(bb); 33 34 next_in++; 35 } 36 37 return next_in; 38 } 39