Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

closed as off-topic by congusbongus, Krom Stern, Byte56 Dec 30 '14 at 19:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – congusbongus, Krom Stern, Byte56
If this question can be reworded to fit the rules in the help center, please edit the 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

Browse other questions tagged or ask your own question.