(no title)
nightcracker | 4 years ago
QOI_DIFF24 {
u8 tag : 4; // b1110
u8 dr : 5; // 5-bit red channel difference: -15..16
u8 dg : 5; // 5-bit green channel difference: -15..16
u8 db : 5; // 5-bit blue channel difference: -15..16
u8 da : 5; // 5-bit alpha channel difference: -15..16
}
It bothers me more than it should that the 5-bit signed differences aren't -16..15 matching two's complement but -15..16 instead.
phoboslab|4 years ago
benlivengood|4 years ago
int intermediate = byte_or_word << N; // N chosen to put the five bits in the highest positions in the int.
int value = intermediate >> bits_per_int - 5;
Instead of masking rely on arithmetic shift right to keep the sign bit.
adgjlsfhk1|4 years ago
selcuka|4 years ago
hoseja|4 years ago