Add new rust-based coder implementation#4
Open
Lolle2000la wants to merge 83 commits intomihonapp:mainfrom
Open
Add new rust-based coder implementation#4Lolle2000la wants to merge 83 commits intomihonapp:mainfrom
Lolle2000la wants to merge 83 commits intomihonapp:mainfrom
Conversation
…F+AVIF, JPEG, JXL)
… out while developing and use the same AGP version as mihon
Since the Rust compiler also needs to see it, its a bit of a weird setup
Resolves `unresolved link` errors
…and reduced bounds checks
…use slice directly for decoding
…adability and maintainability
…adability and maintainability
…mproving readability and reducing code duplication
…anicking when the output buffer is different from what it expects before scaling Since it doesn't take into account the size after scaling, we need to go around it. (also add back the test I accidentally deleted)
…otentially unsafe length init and indexing
…dling Using an iterator allows evading a lot of unsafe indexing on potentially uninitialized memory
…e pixel conversion Using an iterator gets us around some of the indexing stuff
…ckend-to-choose C++ lib The benchmark code has renames of the jni methods so that the benchmark code can use both. In case of the prod code, the libraries are transparently switchable, so no rename necessary. BUT this approach breaks the bench, so that needs a separate name.
Otherwise this will accidentally test C++ against C++
… v3 API for cropping and respecting MCU alignment
…heif Basically, the prior impl. reads a bit better but since it loses what the final size will be and needs to do some copying etc., it can not optimize as much (same as before with the heif decoder).
…duce memory bandwidth usage.
`lib.rs` in particular is about the usage of a pointer without proper (un)safety markings
…nder way, satisfying clippy. It is factually equivalent but does provide a bit more safety by only setting the size on the vector once it has actually been filled.
The case where AVIFs don't have an alphachannel leads to the `*4` and `/4` calculation to be off. Specifically the division will cause the an unreasonable number to be passed for avif 3 channel pictures.
…tant reallocation of buffers
It was there in an initial design matching the C++ design, but handling color transformations inside the decoders yields more performance as specific optimizations can be done.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new fully-compatible drop-in compatible (once enabled) backend written in Rust. It can be integrated into Mihon and forks without any changes except adding a way to enable it. Note that the existing C++ based backend remains fully available and enabled by default. Without the consumer enabling it, this new backend will not affect existing behavior (requiring WIP PR #3048).
Aside from superior performance with up-to-date libraries that are easier to update due to Cargo, the main reason I even implemented is that it implements a much-superior Catmull-Rom bicubic filter. This should help with all the complaints surrounding moire. As can be seen from the benchmarks below, the performance is still at the worst equal, usually better than the C++ implementation despite using a higher quality filter.
Benchmarks
These benchmarks were done on a S24 Ultra with a Snapdragon processor. They compare the C++ implementation against the new rust implementation. The benchmarks are also included.
Why a rewrite to Rust?
When I went to see what might be necessary to implement better filtering, I noticed that:
Rust, aside from being a lot saner, has the nice plus of being a lot more approachable, meaning that its much easier to make changes. I found that it was much easier for me to implement the filter (with a nice crate that provided a lot of juicy SIMD uplift) and then optimize the rest of the decoders with more confidence.