Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/SZ3/predictor/ComposedPredictor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ class ComposedPredictor : public concepts::PredictorInterface<T, N> {
if (selection_size > 0) {
HuffmanEncoder<int> selection_encoder;
selection_encoder.load(c, remaining_length);
/// decode() advances `c` past the encoded stream but does not update `remaining_length`;
/// account for exactly the bytes it consumed so the bound stays tight for later reads.
const uchar *decode_start = c;
this->selection = selection_encoder.decode(c, selection_size);
selection_encoder.postprocess_decode();
remaining_length -= static_cast<size_t>(c - decode_start);
}
}

Expand Down
7 changes: 6 additions & 1 deletion include/SZ3/predictor/RegressionPredictor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,14 @@ class RegressionPredictor : public concepts::PredictorInterface<T, N> {
quantizer_liner.load(c, remaining_length);
HuffmanEncoder<int> encoder = HuffmanEncoder<int>();
encoder.load(c, remaining_length);
/// decode() advances `c` past the encoded stream but does not update `remaining_length`;
/// account for exactly the bytes it consumed. The previous `coeff_size * sizeof(int)` used the
/// uncompressed index count, which overshoots the (Huffman-compressed) stream and understates
/// remaining_length, making a later encoder.load() bound check spuriously reject valid data.
const uchar *decode_start = c;
regression_coeff_quant_inds = encoder.decode(c, coeff_size);
encoder.postprocess_decode();
remaining_length -= coeff_size * sizeof(int);
remaining_length -= static_cast<size_t>(c - decode_start);
std::fill(current_coeffs.begin(), current_coeffs.end(), 0);
regression_coeff_index = 0;
}
Expand Down