phoboslab / qoi

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

Closed wouter-rombouts closed 2 years ago

wouter-rombouts commented 2 years ago

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).

oscardssmith commented 2 years ago

This isn't a valid change without a new major version of the QOI standard.

wouter-rombouts commented 2 years ago

seems like this isn't working as intended, might try to redo this at a later time.