Skip to content

Commit

Permalink
avif-decoder: Convert directly to RGBA
Browse files Browse the repository at this point in the history
e3f81a4 introduced a byte swap
conversion from BGRA to RGBA, which can be eliminated if we ask dcp to
convert directly to RGBA.
  • Loading branch information
linkmauve committed Apr 13, 2022
1 parent 8860c3d commit 3862f76
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/codecs/avif/decoder.rs
Expand Up @@ -112,7 +112,7 @@ impl<'a, R: 'a + Read> ImageDecoder<'a> for AvifDecoder<R> {
num_planes: 3,
};
let dst_format = dcp::ImageFormat {
pixel_format: dcp::PixelFormat::Bgra,
pixel_format: dcp::PixelFormat::Rgba,
color_space: dcp::ColorSpace::Lrgb,
num_planes: 1,
};
Expand Down Expand Up @@ -160,11 +160,6 @@ impl<'a, R: 'a + Read> ImageDecoder<'a> for AvifDecoder<R> {
}
}

// Convert Bgra to Rgba
for chunk in buf.chunks_exact_mut(4) {
chunk.swap(0, 2);
}

Ok(())
}
}

0 comments on commit 3862f76

Please sign in to comment.