phoboslab / qoi

The “Quite OK Image Format” for fast, lossless image compression

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

abhaychirania2411 opened this issue · comments

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

commented

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.