2016-10-03 23:50:52 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <memory.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2024-04-19 18:09:21 +02:00
|
|
|
#if __x86_64__ || __i386__ || _M_X64 || _M_IX86
|
2016-10-03 23:50:52 +02:00
|
|
|
#ifdef _MSC_VER
|
2024-04-19 18:09:21 +02:00
|
|
|
#include <intrin.h>
|
2016-10-03 23:50:52 +02:00
|
|
|
#else
|
2024-04-19 18:09:21 +02:00
|
|
|
#include <x86intrin.h>
|
2016-10-03 23:50:52 +02:00
|
|
|
#endif
|
2018-02-22 09:04:16 +01:00
|
|
|
#endif //__x86_64__ || __i386__ || _M_X64 || _M_IX86
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
#include "encode_df.h"
|
|
|
|
#include "bitbuf2.h"
|
|
|
|
|
2024-04-19 18:09:21 +02:00
|
|
|
struct deflate_icf *
|
|
|
|
encode_deflate_icf_base(struct deflate_icf *next_in, struct deflate_icf *end_in, struct BitBuf2 *bb,
|
|
|
|
struct hufftables_icf *hufftables)
|
2016-10-03 23:50:52 +02:00
|
|
|
{
|
2024-04-19 18:09:21 +02:00
|
|
|
struct huff_code lsym, dsym;
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2024-04-19 18:09:21 +02:00
|
|
|
while (next_in < end_in && !is_full(bb)) {
|
|
|
|
lsym = hufftables->lit_len_table[next_in->lit_len];
|
|
|
|
dsym = hufftables->dist_lit_table[next_in->lit_dist];
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2024-04-19 18:09:21 +02:00
|
|
|
// insert ll code, dist_code, and extra_bits
|
|
|
|
write_bits_unsafe(bb, lsym.code_and_extra, lsym.length);
|
|
|
|
write_bits_unsafe(bb, dsym.code, dsym.length);
|
|
|
|
write_bits_unsafe(bb, next_in->dist_extra, dsym.extra_bit_count);
|
|
|
|
flush_bits(bb);
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2024-04-19 18:09:21 +02:00
|
|
|
next_in++;
|
|
|
|
}
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2024-04-19 18:09:21 +02:00
|
|
|
return next_in;
|
2016-10-03 23:50:52 +02:00
|
|
|
}
|