Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster JPEG decoding with jpeg_decoder #1879

Closed
wants to merge 5 commits into from

Conversation

Shnatsel
Copy link
Contributor

Avoid a memset() + memcpy() of the entire decompressed image, saving 10%-15% of the time in decoding JPEGs as measured on

ImageReader::open(input)?.with_guessed_format()?.decode()?;

Supersedes #1878 but only implements JPEG, not BMP. I'll file issues for BMP and HDR.


I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to choose either at their option.

@fintelia
Copy link
Contributor

This converts decoder_to_vec from an internal API to a public API. Before we go down that path, I'd like to understand whether it would be possible for zune-jpeg to conform to the same interface we already use.

@etemesi254 would it be possible to add a decode_into method to zune-jpeg so users can pass an already allocated/initialized buffer?

fn decode_into(&mut self, buf: &mut [u8]) -> Result<(), Error> { ... }

@etemesi254
Copy link

Possible

Should it be a hard error if space is too small or?

@HeroicKatora
Copy link
Member

When it's too small, yes, hard error. When it's too large, it's your choice. Allowing is actually easier, the extra space might be useful padding. (As in, the extra bytes might make the whole slice castable to [__m256d]). But definitely not critical.

@Shnatsel Shnatsel changed the title Faster JPEG with any backend, take 2 Faster JPEG decoding with jpeg_decoder Mar 13, 2023
@Shnatsel
Copy link
Contributor Author

Shnatsel commented Mar 13, 2023

I switched the zune_jpeg integration to use decode_into(), so now this PR is only a win for jpeg_decoder.

As a result this now conflicts with #1877

@fintelia fintelia closed this Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants