Skip to content
Merged
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: 2 additions & 2 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions src/lossless_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,19 @@ pub(crate) fn apply_color_transform(
let width = usize::from(width);

for (y, row) in image_data.chunks_exact_mut(width * 4).enumerate() {
for (block_x, block) in row.chunks_mut(4 << size_bits).enumerate() {
let block_index = (y >> size_bits) * block_xsize + block_x;
let red_to_blue = transform_data[block_index * 4];
let green_to_blue = transform_data[block_index * 4 + 1];
let green_to_red = transform_data[block_index * 4 + 2];
let row_transform_data_start = (y >> size_bits) * block_xsize * 4;
// the length of block_tf_data should be `block_xsize * 4`, so we could slice it with [..block_xsize * 4]
// but there is no point - `.zip()` runs until either of the iterators is consumed,
// so the extra slicing operation would be doing more work for no reason
let row_tf_data = &transform_data[row_transform_data_start..];

for (block, transform) in row
.chunks_mut(4 << size_bits)
.zip(row_tf_data.chunks_exact(4))
{
let red_to_blue = transform[0];
let green_to_blue = transform[1];
let green_to_red = transform[2];

for pixel in block.chunks_exact_mut(4) {
let green = u32::from(pixel[1]);
Expand Down
Loading