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

No option to provide pre-allocated memory to encode and decode #285

Open
abhaychirania2411 opened this issue Sep 14, 2023 · 1 comment
Open

Comments

@abhaychirania2411
Copy link

Hi,

I have been working on a project that needs qoi encoding and decoding, but the final results should be put in a pre allocated memory. Although we can provide our own allocator, but i want to provide a pre allocated memory to the encoded function.

Something like this:
void *qoi_encode(const void *data, const qoi_desc *desc, int *out_len, void *dest);

This dest adress can be optional, i.e if NULL then go ahead and allocate the memory using QOI_MALLOC

@N-R-K
Copy link
Contributor

N-R-K commented Apr 14, 2024

For decoding, I have a small header only decoder that accepts caller allocated memory: qoi-dec.c.

It also does a couple small optimization around redundant table insertion and bounds checking so it's a bit faster (especially with clang) than the official decoder:

          decode ms   decode mpps
qoi:            2.1        148.65
qoi-dec:        1.6        199.59

Maybe that interests you. The code is public domain so you can do whatever you want with it.

I don't have any encoder though. But @skeeto has one here: qoi.c. It's a streaming encoder and the caller is in control of the buffer where the encoder writes into.

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

No branches or pull requests

2 participants