Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

To process 8-bit pixels, to do things like gamma correction without losing information, we normally upsample the values, work in 16 bits or whatever, and then downsample them to 8 bits.

Now, this is a somewhat new area for me, so please excuse incorrect terminology etc.

For my needs I have chosen to work in "non-standard" Q15, where I only use the upper half of the range (0.0-1.0), and 0x8000 represents 1.0 instead of -1.0. This makes it much easier to calculate things in C.

But I ran into a problem with SSSE3. It has the PMULHRSW instruction which multiplies Q15 numbers, but it uses the "standard" range of Q15 is [-1,1-2⁻¹⁵], so multplying (my) 0x8000 (1.0) by 0x4000 (0.5) gives 0xC000 (-0.5), because it thinks 0x8000 is -1. This is quite annoying.

What am I doing wrong? Should I keep my pixel values in the 0000-7FFF range? This kind of defeats the purpose of it being a fixed-point format. Is there a way around this? Maybe some trick?

Is there some kind of definitive treatise on Q15 which discusses all this?

share|improve this question
if 0x8000 expresses 1, what is the meaning of 0x0000? I'm pretty sure you know in the standard floating point system (16bit) 0x0000 means 1 and 0x8000 means -1. –  Ali.S Aug 29 '12 at 21:30
You may get better answers on StackOverflow –  John McDonald Aug 30 '12 at 1:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.