To process 8-bit pixels, to do things like gamma correction, without losing information, we usually increase the values, work at 16 bits or something else, and then reduce them to 8 bits.
Now this is a slightly new area for me, so please excuse the wrong terminology, etc.
For my needs, I decided to work in the "non-standard" Q15, where I use only the upper half of the range (0.0-1.0), and 0x8000 represents 1.0 instead of -1.0. This makes things much easier to compute in C.
But I had a problem with SSSE3. It has a PMULHRSW instruction that multiplies Q15 numbers, but uses the “standard” range of Q15 [-1.1-2⁻¹⁵], so multplying (my) 0x8000 (1.0) by 0x4000 (0.5) gives 0xC000 (- 0, 5) since it considers 0x8000 to be -1. This is pretty annoying.
What am I doing wrong? Should I keep pixel values in the range 0000-7FFF? Doesn't that mean that the purpose of this is a fixed-point format? Is there any way around this? Maybe some trick?
Is there some final treatise on Q15 that discusses all this?
source
share