Monday, March 13, 2006

On color spaces and gamma correction in the Flash Player

Now that we are part of Adobe, we are subject to the huge body of knowledge when it comes to color technologies. One of the earliest questions we got was how we handle gamma correction in the player. The simple answer is: we don't.

The Flash Player is currently using 8 bits per component and this has traditionally limited what we can do. So in essence we use sRGB throughout the renderer without correcting our compositing functions for linearity (see some of the links below to understand why this is a problem). This has been done mostly for performance reasons, as any kind of correction would require more than 8 bits per component and an additional pass using table lookups to get the correct results.

In addition OS X's native gamma is 1.8, whereas sRGB is close to 2.2. This means content on these machines looks different. Unfortunate, but pretty much all image formats for the web have the same problem (GIF, JPEG and PNG), that includes plain HTML/CSS colors. Safari has made the situation a little more complicated, since it does some gamma correction, but is not always consistent.

What does the future hold? Well, probably not too much in the immediate future. But as I look at how we could take advantage of using GPUs we will have to revisit this (Disclaimer: I do NOT know what we will do in this regard, this is pure speculation from my side). Currently most GPUs will use linearRGB internally and gamma correct their output for displays in the last stage of the pipeline (linearRGB is essentially a linear version of the sRGB color space). This is the 'correct' thing to do and does improve compositing quality quite a bit. It also does not impact on performance in the context of GPU rendering. But using linearRGB internally means drastic changes to rendering, the effect would be that content will look different in a software implementation versus a hardware implementation. The other option is to take a huge hit performance wise for the software implementation, something we might not be ready to do.

Some links on this might be of interest, they pretty much explain everything about the problems I scratched on here:

3 Comments:

Blogger liquidat said...

This is not post specific but I didn't find any other place to post it:

As you probably know mplug provides prepacked flash packages and offers them in distribution specific repositories - thank you very much for this cooperation because it really works and helps keeping my machine up2date:
The unfortunate security flaw was updated today by the automatic update system of my boxes :)

Thanks for making this possible!

liquidat

Wednesday, March 15, 2006 12:41:00 PM  
Anonymous Roger Braunstein said...

I put together a simple proof-of-concept that you can use to correct gamma using BitmapData.
See the post.

Tuesday, October 17, 2006 12:40:00 PM  
Anonymous Roger Braunstein said...

Sorry, I keep changing my blog so here's the permanent location of the example. http://partlyhuman.com/flash/demo/gamma/

Friday, February 16, 2007 6:33:00 PM  

Post a Comment

<< Home