8 #include "strings/range.h" 24 enum { BLOCK_SIZE_LOG = 17, BLOCK_SIZE = 1 << BLOCK_SIZE_LOG };
31 if (compress_block_size_ == 0) {
34 buf_start()[pos_++] = b;
35 if (pos_ == BLOCK_SIZE) {
40 void Add(strings::ByteRange br);
49 void Compress() { CompressInternal(
false); }
51 const std::vector<strings::ByteRange>& compressed_blocks()
const {
52 return compressed_blocks_;
55 size_t compressed_size()
const {
return compressed_size_; }
56 size_t pending_size()
const {
return pos_; }
63 strings::MutableByteRange BlockBuffer();
67 bool Commit(
size_t sz);
70 void ClearCompressedData();
74 void CompressInternal(
bool finalize_frame);
76 const uint8_t* buf_start()
const {
77 return double_buf_.get() + (BLOCK_SIZE + 1) * cur_buf_index_;
80 uint8_t* buf_start() {
81 return double_buf_.get() + (BLOCK_SIZE + 1) * cur_buf_index_;
84 void* zstd_cntx_ =
nullptr;
85 size_t compress_block_size_ = 0;
88 std::vector<std::unique_ptr<uint8_t[]>> compressed_bufs_;
89 std::vector<strings::ByteRange> compressed_blocks_;
90 size_t compressed_size_ = 0;
91 std::unique_ptr<uint8_t[]> double_buf_;
92 unsigned cur_buf_index_ = 0;
97 enum { BLOCK_SIZE = BlockCompressor::BLOCK_SIZE};
107 int Decompress(strings::ByteRange br, uint32_t* consumed);
110 strings::ByteRange GetDecompressedBlock()
const;
113 void* zstd_dcntx_ =
nullptr;
114 unsigned frame_state_ = 2;
115 std::unique_ptr<uint8_t[]> buf_;
116 size_t decompress_size_ = 0;