Skip to content

Commit

Permalink
commit the catable header before getting lost in stitching, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrh committed Sep 26, 2018
1 parent 4300b73 commit 7fa9060
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/enc/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2763,6 +2763,7 @@ fn EncodeData<Alloc: BrotliAlloc,
(*s).storage_.slice_mut()[0] = (*s).last_bytes_ as u8;
(*s).storage_.slice_mut()[1] = ((*s).last_bytes_ >> 8) as u8;
}
let mut catable_header_size = 0;
if !s.params.catable {
s.is_first_mb = false;
} else if bytes != 0 && (bytes <= 2 || s.is_first_mb) {
Expand Down Expand Up @@ -2797,6 +2798,9 @@ fn EncodeData<Alloc: BrotliAlloc,
if num_bytes_to_write_uncompressed >= 2 {
s.is_first_mb = false;
}
catable_header_size = storage_ix >> 3;
(*s).next_out_ = NextOut::DynamicStorage(0);
*out_size = catable_header_size;
delta = UnprocessedInputSize(s);
}
let mut wrapped_last_processed_pos: u32 = WrapPosition((*s).last_processed_pos_);
Expand All @@ -2811,7 +2815,7 @@ fn EncodeData<Alloc: BrotliAlloc,
{
let table: &mut [i32];
if delta == 0 && (is_last == 0) {
*out_size = 0usize;
*out_size = catable_header_size;
return 1i32;
}
let data = &mut (*s).ringbuffer_.data_mo.slice_mut ()[((*s).ringbuffer_.buffer_index as (usize))..];
Expand Down Expand Up @@ -2951,7 +2955,7 @@ fn EncodeData<Alloc: BrotliAlloc,
if UpdateLastProcessedPos(s) != 0 {
HasherReset(&mut (*s).hasher_);
}
*out_size = 0usize;
*out_size = catable_header_size;
return 1i32;
}
}
Expand All @@ -2966,7 +2970,7 @@ fn EncodeData<Alloc: BrotliAlloc,
(*s).last_insert_len_ = 0usize;
}
if is_last == 0 && ((*s).input_pos_ == (*s).last_flush_pos_) {
*out_size = 0usize;
*out_size = catable_header_size;
return 1i32;
}
{
Expand Down

0 comments on commit 7fa9060

Please sign in to comment.