The “Quite OK Image Format” for fast, lossless image compression
MIT License
6.92k
stars
330
forks
source link
Updated index function with larger primes to minimize hash collisions. Hardcoded black and white into unused values in QOI_OP_DIFF and QOI_OP_LUMA #187
Index function: using larger primes, especially ones that are relatively close to a power of 2, while avoiding a small difference between 3 primes yields in less colisions in the hash function, making qoi use the index slightly more often.
The values in QOI_OP_DIFF and QOI_OP_LUMA that represent no change at all (all zero's) are basically free, and can be used for any common value. Since black and white often occur in images, it makes sense to use these otherwise unused values for them.
These colors will take 1 and 2 bytes instead of 4(if no change in alpha channel occurs).
Index function: using larger primes, especially ones that are relatively close to a power of 2, while avoiding a small difference between 3 primes yields in less colisions in the hash function, making qoi use the index slightly more often.
The values in QOI_OP_DIFF and QOI_OP_LUMA that represent no change at all (all zero's) are basically free, and can be used for any common value. Since black and white often occur in images, it makes sense to use these otherwise unused values for them. These colors will take 1 and 2 bytes instead of 4(if no change in alpha channel occurs).