Closed
Description
After a discussion in #28, the QOI data format changes to accommodate some of the concerns. This will serve as the basis for final specification for QOI.
These changes are not yet reflected in the code of this repository. I'm working on it! The code in qoi.h
now implements all these changes.
Changes from the original implementation
- all values are encoded in big-endian byte order (already happened in c03edb2)
- the range of
QOI_DIFF
will shift -1, to be consistent with the range of a two's complement int QOI_DIFF
will explicitly allow to wrap around. Whether the encoder makes use of this is outside of the spec. The decoder must account for this wrapping.- the
size
field in the header will be removed width
andheight
in the header will be widened to 32bit- a
channels
field will be added to the header. This is purely informative and will not change the behavior of the en-/decoder - a
colorspace
bitmap will be added to the header. This is purely informative and will not change the behavior of the en-/decoder. - the spec will mandate that the alpha channel is un-premultiplied
The header then looks like this:
struct qoi_header_t {
char [4]; // magic bytes "qoif"
u32 width; // image width in pixels (BE)
u32 height; // image height in pixels (BE)
u8 channels; // must be 3 (RGB) or 4 (RGBA)
u8 colorspace; // a bitmap 0000rgba where
// - a zero bit indicates sRGBA,
// - a one bit indicates linear (user interpreted)
// colorspace for each channel
};
The ranges for QOI_DIFF
change to:
- 2bit:
-2..1
instead of the original range-1..2
- 4bit:
-8..7
instead of the original range-7..8
- 5bit:
-16..15
instead of the original range-15..16
The channels
field in the header serves only as a hint to the user on how to handle this image. It is valid for a QOI image to still encode alpha changes in a file with a header that denotes 3
channels. It is not the responsibility of the decoder to mask off alpha values. The color hash will always be computed as r^g^b^a
, irregardless of the number of channels denoted in the header.
Metadata
Metadata
Assignees
Labels
No labels