# Graphics card and video codecs: are colors stored in a linear scale?

Is this saying correct ?

The graphics card and most video codecs store colors in a linear scale.

If by linear scale, the (Cinelerra manual) "saying" means gamma = 1.0, then that's not my understanding of most video codecs.

GPUs, OTOH, probably do operate upon values decoded and stored as a linear representation of a higher precision than the source, which would be typically 8-bits per channel.

The correctness of this statement depends on the color model. The statement will typically be correct for color models such as RGB and CMY. In HSx (HSV, HSL) color models the model doesn't store explicit colors, and their transformation to explicit colors is non-linear.

EDIT:

My comment below on YUV is incorrect, YUV transforms linearly to RGB, thanks @Mulvya!

• How about YUV (YCbCr) ? Dec 28, 2015 at 19:34
• YUV does not transform linearly to colors, see the transformation formula in en.wikipedia.org/wiki/YCbCr#YCbCr
– avnr
Dec 28, 2015 at 19:41
• a) the YUV<->RGB conversion is linear, they are of the form AX + BY + CZ + D b) the statement that the OP quotes is from the manual of a video editor (Cinelerra). CMY, HSx models don't come into it. Even those codecs which store video as RGB e.g. qtrle or x264rgb, don't store linear RGB values (by default).
– Gyan
Dec 30, 2015 at 12:44
• @Mulvya maybe you are correct, but I understood the OPs wording "YUV (YCbCr)" as meaning Y'CbCr which AFAIK maps to RGB non-linearly.
– avnr
Dec 30, 2015 at 13:23
• The wiki page you linked to, has the formulae, which are all linear.
– Gyan
Dec 30, 2015 at 13:34

Not likely, most monitors and most display devices have a nonlinear response. This is useful, as human eyes are not linearily sensitive.

Having the data stored in nonlinear scale is thus a very simple compression scheme. In fact, your display device depends on this gamma correction. If you would not have a gammacorected datasource then the image would appear dark. While this image could be corrected you would lose color data as the values would get nonliearily distributed. End result is that 8bit color would no longer be enough to display continious color without banding. This is why cameras have 10, 12 or 14 bit sensors, as he sensors themselves are linear in nature.

So while it certainly is possible to have colorspaces that are linear, most videosoursces would not be linear. Simply because that would mean need to store over 8 bits of color info. Codecs certainly can have different settings and many of the color modes would not be practical without nonlinear data.

In general its rather safe to assume that the data stored is not linear even if stored in a space that could represent linear data. Unless the source specifically mentions its linear and it stores more than 8 bit color then it most likely is not linear.

• From wiki: Human vision, under common illumination conditions (not pitch black nor blindingly bright), follows an approximate gamma or power function, with greater sensitivity to relative differences between darker tones than between lighter ones.
– Gyan
Dec 31, 2015 at 6:32
• @Mulvya hmm... Its a bit trickily worded to parse correctly. Fixed. Dec 31, 2015 at 6:43