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

QOI-plane, a 1 and 2 channels (grey and grey + alpha) codec like QOI #40

Open
p0nce opened this issue Jul 25, 2022 · 0 comments
Open

QOI-plane, a 1 and 2 channels (grey and grey + alpha) codec like QOI #40

p0nce opened this issue Jul 25, 2022 · 0 comments

Comments

@p0nce
Copy link

p0nce commented Jul 25, 2022

This "QOI-plane" codec breaks byte alignment and works in groups of 4-bits in order to encode greyscale.
https://github.com/AuburnSounds/gamut/blob/main/source/gamut/codecs/qoiplane.d#L79

Typically it encodes a uint8 image with 4.55 bit / pixel, and a luminance + alpha image with lower number of bits, but I fear my test suite is too easy with alpha + grey images. Didn't find the opcode room to have a FIFO.

So it beat a qoiavg2 that would instead encode a greyscale input as rgb color, which leads to more than 8-bit / per pixel.
All these numbers are after a LZ4, I haven't tried a naked QOI-plane.

/// Encoding:
///
/// QOIPLANE_DIFF1     0xxx                          => diff -4..+3 vs average of rounded up left pixel and top pixel
/// QOIPLANE_DIFF2     100x xxxx                     => diff -16..15 vs average of rounded up left pixel and top pixel
/// QOIPLANE_ADIFF     1011 xxxx                     => diff -7..+7 in alpha channel
/// QOIPLANE_LA        1011 0000 xxxx xxxx aaaa aaaa => encode direct full values
/// QOIPLANE_DIRECT    1010 xxxx xxxx                => direct value
///                                                   If channels == 2 and the last opcode is not a QOIPLANE_ADIFF
///                                                   then QOIPLANE_DIRECT encodes an alpha value.
/// QOIPLANE_REPEAT1   11xx                          => repeat 1 to 3 times the last pixel
/// QOIPLANE_REPEAT2   1111 xxxx xxxx                => repeat 4 to 258 times a pixel.
///                                                     (1111 1111 1111 disallowed, indicates end of stream)
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

1 participant