Skip to content

Commit

Permalink
Special case RLE codes (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
fintelia authored Aug 2, 2024
1 parent 48fbf95 commit 22f23ef
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lossless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,15 @@ impl<R: Read> LosslessDecoder<R> {
return Err(DecodingError::BitStreamError);
}

for i in 0..length * 4 {
data[index * 4 + i] = data[index * 4 + i - dist * 4];
if dist == 1 {
let value: [u8; 4] = data[(index - dist) * 4..][..4].try_into().unwrap();
for i in 0..length {
data[index * 4 + i * 4..][..4].copy_from_slice(&value);
}
} else {
for i in 0..length * 4 {
data[index * 4 + i] = data[index * 4 + i - dist * 4];
}
}
index += length;
} else {
Expand Down

0 comments on commit 22f23ef

Please sign in to comment.