Skip to content

Commit 0461bc0

Browse files
committed
calculate and encode window size correctly
1 parent 181ac6f commit 0461bc0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/encoding/frame_header.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ impl FrameHeader {
4545
// `Window_Descriptor
4646
// TODO: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#window_descriptor
4747
if !self.single_segment {
48-
let exponent = 7;
49-
output.push(exponent << 3);
48+
if let Some(window_size) = self.window_size {
49+
let log = window_size.next_power_of_two().ilog2();
50+
let exponent = if log > 10 { log - 10 } else { 1 } as u8;
51+
output.push(exponent << 3);
52+
}
5053
}
5154

5255
if let Some(id) = self.dictionary_id {

src/encoding/match_generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Matcher for MatchGeneratorDriver {
5050
}
5151

5252
fn window_size(&self) -> u64 {
53-
256 * 1024
53+
self.match_generator.max_window_size as u64
5454
}
5555

5656
fn get_next_space(&mut self) -> Vec<u8> {

0 commit comments

Comments
 (0)