Improve performance without breaking API#7
Improve performance without breaking API#7alanmcgovern wants to merge 5 commits intoNUlliiON:mainfrom
Conversation
The original PR was pushed a bit too late and wasn't reviewed before 1.0 was released. As such, the changes can't be included now without breaking API. Redo some of the changes to gain most of the benefits without the API breakage. 1. Nothing in the library uses the public mutable state defined in QoiCodec.These properties/fields have been replaced with immutable/readonly properties instead. 2. QoiEncoder has been optimised a bit to leverage the performance gains from BinaryPrimitives and Span<T>. Also, a Span<T> based overload was added so that images could be encoded into a reusable buffer. 3. QoiDecoder has a new overload which receives a Span<T>, allowing images to be decoded from anything which can create a Span<byte>, and also allows for multiple images to be decoded from the same underlying array.
|
@NUlliiON I closed the other PRs and submitted this instead. Some of the changes from the older PRs are still needed, but at least this one is API compatible with the current 1.0 release. |
It's a little faster with one fewer copies
|
Optimised:
Original:
NOTE: There are further improvements possible but I want to get a few PRs landed before I start adding new API. Specifically, i want the |
I don't see any difference, even putting these on top of each other with a "difference" blend in aseprite. (other than the time and moved crate) are you sure these are the right images? |
|
ah, that's probably from the changes in the way the lookup table is initialized. seems like an easy fix. in any case i don't think the author of this repo is maintaining it anymore, someone (@alanmcgovern ?) should fork it. we'd swap from this repo for the loading time boost for sure. |
|
also @alanmcgovern it'd be good to see a benchmark for a large atlas-sized image (like 2k, 4k, 8k) |



The original PR was pushed a bit too late and
wasn't reviewed before 1.0 was released. As such,
the changes can't be included now without breaking
API.
Redo some of the changes to gain most of the benefits
without the API breakage.
Nothing in the library uses the public mutable
state defined in QoiCodec.These properties/fields
have been replaced with immutable/readonly properties
instead.
QoiEncoder has been optimised a bit to leverage
the performance gains from BinaryPrimitives and Span.
Also, a Span based overload was added so that images
could be encoded into a reusable buffer.
QoiDecoder has a new overload which receives a
Span, allowing images to be decoded from anything
which can create a Span, and also allows for
multiple images to be decoded from the same underlying
array.