Skip to content

Commit

Permalink
Minor improvements in bitstream.
Browse files Browse the repository at this point in the history
  • Loading branch information
yotarok committed Sep 29, 2023
1 parent a39af85 commit 07ee750
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions report/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Sources used: wikimedia.i_love_you_california, wikimedia.winter_kiss, wikimedia.

### Average compression speed (inverse RTF)
- Reference
- opt8lax: 255.90808971990495
- opt8: 260.20840564877153
- opt5: 501.4437823135729
- opt8lax: 259.31730941656474
- opt8: 256.19449736647505
- opt5: 498.1760928807853

- Ours
- default: 160.6740906413787
- st: 73.13241880734284
- dmse: 107.63095111470871
- bsbs: 9.577720986818926
- mae: 27.731935515942386
- default: 166.75753155120208
- st: 73.91379462491477
- dmse: 111.56016219091809
- bsbs: 9.53753985075257
- mae: 25.318101362135653


2 changes: 1 addition & 1 deletion src/bitsink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl ByteVec {
let r = self.tail_len();

if r != 0 {
let b: u8 = ((val >> (64 - r)) & ((1 << r) - 1)) as u8;
let b: u8 = (val >> (64 - r)) as u8;
let tail = self.bytes.len() - 1;
self.bytes[tail] |= b;
val <<= r;
Expand Down
10 changes: 5 additions & 5 deletions src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ fn encode_to_utf8like<S: BitSink>(val: u64, dest: &mut S) -> Result<(), RangeErr
val <<= first_bits;

for _i in 0..trailing_bytes {
dest.write_lsbs(0x02u8, 2);
dest.write_msbs(val, 6);
let b = 0x80u8 | (val >> 58) as u8;
dest.write(b);
val <<= 6;
}
}
Expand Down Expand Up @@ -201,7 +201,7 @@ impl BitRepr for Stream {
}

fn write<S: BitSink>(&self, dest: &mut S) -> Result<(), EncodeError> {
dest.write_lsbs(0x66_4c_61_43u32, 32); // fLaC
dest.write_bytes_aligned(&[0x66, 0x4c, 0x61, 0x43]); // fLaC
self.stream_info.write(dest)?;
for elem in &self.metadata {
elem.write(dest)?;
Expand Down Expand Up @@ -239,8 +239,8 @@ impl BitRepr for MetadataBlock {
}

fn write<S: BitSink>(&self, dest: &mut S) -> Result<(), EncodeError> {
let block_type = self.block_type as u32 + if self.is_last { 0x80 } else { 0x00 };
dest.write_lsbs(block_type, 8);
let block_type: u8 = self.block_type as u8 + if self.is_last { 0x80 } else { 0x00 };
dest.write(block_type);
let data_size: u32 = (self.data.count_bits() / 8) as u32;
dest.write_lsbs(data_size, 24);
self.data.write(dest)?;
Expand Down

0 comments on commit 07ee750

Please sign in to comment.