-
Notifications
You must be signed in to change notification settings - Fork 623
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
Add zune-jpeg
as an alternative backend for JPEG decoding
#1876
Conversation
Depends on etemesi254/zune-image#98 upstream, that must be merged and released first |
Question to maintainers: what should this be integrated into on top of just providing a |
I'd say the important part is choosing between the decoder implementations in That should be pretty much it, in terms of decoder, that's the central translation from a file format to its decoder. One possible concept for dynamically choosing this would be to pass a preference hash map for each format and falling back to the current choice when no preference is given. |
I haven't thought it through fully, but my initial reaction is that if we use zune-jpeg it should probably replace our current use of jpeg-decoder for decoding JPEGs. |
Do you mean it should be set as the decoder to be used by default, but keep |
I mean removing |
It should be possible to stuff |
I've opened #1877 to show what outright replacing |
Sounds good to me, once the dust settles to have a period in which unanticipated feedback can arrive. |
### Why It is much faster. On my Mac, it takes objectron JPEG decoding from 15 to 10 ms. On the web the difference is smaller: 35ms -> 29ms. See https://github.com/emilk/image-decode-bench for more. It can also decode directly to RGBA, which means we don't need to spend cycles later padding RGB to RGBA. This takes the entire `objectron` demo `App::update` down from 21 ms to 14 ms. Sadly, the `gltf` crate still use the `"jpeg"` feature of the `image` crate, so weneed to pay for the compilation and code bloat of two jpeg decoders. The `.wasm` of the web-viewer increases by 23kB (pre-compression) because of this PR. This PR also adds support for monochrome JPEGs. ### Related * image-rs/image#1845 * image-rs/image#1876 ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) <!-- This line will get updated when the PR build summary job finishes. --> PR Build Summary: https://build.rerun.io/pr/2376 <!-- pr-link-docs:start --> Docs preview: https://rerun.io/preview/1aae8d4/docs Examples preview: https://rerun.io/preview/1aae8d4/examples <!-- pr-link-docs:end -->
jpeg-decoder
to zune-jpeg
as JPEG decoding backend
jpeg-decoder
to zune-jpeg
as JPEG decoding backendzune-jpeg
as an alternative backend for JPEG decoding
I'm going to go ahead and close this in favor of #1877 |
This is an initial implementation to get the ball rolling. I've implemented a decoder but it's not yet wired up to decoder selection based on format, or any other machinery. Haven't tested it either.
Right now this buffers the entire input in memory, but this requirement may be relaxed soon..
It also parses headers twice, because
zune_jpeg::JpegDecoder
accepts a lifetime parameter and putting it into the same struct as the input data would create a self-referential struct. This should not be a big deal because it is offset by the efficiency gains overjpeg-decoder
.Fixes #1845 once complete
I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to choose either at their option.