//printf("post-flush = %08x\n", rans);
uint32_t num_rans_bytes = out_end - ptr;
-#if 0
- if (num_rans_bytes == 4) {
- uint32_t block;
- memcpy(&block, ptr, 4);
-
- if (block == last_block) {
- write_varint(0, codedfp);
- clear();
- return 1;
- }
-
- last_block = block;
+ if (num_rans_bytes == last_block.size() &&
+ memcmp(last_block.data(), ptr, last_block.size()) == 0) {
+ write_varint(0, codedfp);
+ clear();
+ return 1;
} else {
- last_block = 0;
+ last_block = string((const char *)ptr, num_rans_bytes);
}
-#endif
write_varint(num_rans_bytes, codedfp);
//fwrite(&num_rans_bytes, 1, 4, codedfp);
RansEncSymbol esyms[NUM_SYMS];
uint32_t sign_bias;
- uint32_t last_block = 0; // Not a valid 4-byte rANS block (?)
+ std::string last_block;
};
static constexpr int dc_scalefac = 8; // Matches the FDCT's gain.