Video levels and color space

From Official Kodi Wiki
(Redirected from Color Space)
Jump to: navigation, search
Home icon grey.png   ▶ Displays
▶ Troubleshooting
▶ Video levels and color space
Attention talk.png Questions? Comments? See the discussion thread

(Thanks to GrammatonKlerik for putting together this guide)

Setting proper video levels in your video chain from Kodi --> GPU --> TV is paramount to getting the best possible picture quality but the hows and whys are often a mystery. This tutorial aims to demystify what actually happens when you change video level settings. After reading this tutorial you should not only have a good understanding of what video level settings are best for your application but more importantly the why behind it.

1 A Crash Course On color spaces

Video content made for consumption on a television are encoded in the Y'CbCr color space. As it turns out, our eyes are much more sensitive to changes in the brightness of an image (a fully de-saturated Black & White image) than they are to changes to the color of an image. This means that color information (the Cb & Cr components) can be compressed at a much higher rate compared to the brightness information (the Y' component) with little to no loss in perceived picture quality with a significant reduction in storage space and bandwidth.

Although Y'CbCr is great for encoding color information for storage and transmission, it cannot be used to display that information; for that we need to convert to another color space called RGB. If you were to magnify the pixels of your TV you would see that each pixel is actually made up of three smaller sub-pixels: Red, Green and Blue. When each of these three sub-pixels are driven to various intensities, our brain combines them to visualize a single unique color -- this is called an additive color system. The actual math to convert from the Y'CbCr to RGB color space is beyond the scope of this tutorial as it involves a matrix transformation who's coefficients are defined by standards such as BT.709 for HDTV.

2 Limited vs Full Video Levels

Now that we have a preliminary understanding of color spaces, lets talk about video levels. Video levels are 8bit values and thus range from values 0 - 255. TV video content is completely contained within the range 16 - 235 and we call this limited range. Anything from level 16 and below is treated as pure black (often called blacker-than-black) and anything from 235 - 255 is treated as pure white (often called whiter-than-white.) In contrast, PC's generate video content using the Full 0-255 range where pure black is level 0 and pure white is level 255. When attempting to play limited TV video content on a PC that uses Full video levels (such is an HTPC), we can get undesirable results if we set our video levels incorrectly -- such as complete loss of shadow detail (aka crushed blacks) or conversely really washed out colors.

The 8 images below show all the possible combinations of Full or Limited video levels in the chain from Kodi --> GPU --> TV. After the images are tables that summarize the results and offer advice on the combination that should be used for your application. Note that the happy face was added so you can better visualize the scaling that may occur.









2.1 Notable Occurrences

  • Setting Kodi to Full causes a color space transformation from Y'CbCr to RGB and the video levels are expanded from 16-235 to 0-255 -- WtW & BtB are clipped in the process
  • Setting Kodi to Limited causes only a color space transformation from Y'CbCr to RGB, video levels are kept as-is
  • Setting GPU to Full leaves the incoming video untouched, i.e. pass-through
  • Setting GPU to Limited causes the video to compress from 0-255 to 16-235
  • Setting your TV to Full or Limited defines where the TV expects Reference Black and Reference White to be: 0/255 for the former and 16/235 for the latter.

2.2 Summary of Results

  • Full, Full, Full -- Video Level CORRECT : WtW & BtW Clipped, Single scaling
  • Full, Full, Limited -- Video Level WRONG : Crushed Blacks
  • Full, Limited, Full -- Video Level WRONG : Washed Out Colors
  • Full, Limited, Limited -- Video Level CORRECT : WtW & BtW Clipped, Double scaling
  • Limited, Full, Full -- Video Level WRONG : Washed Out Colors
  • Limited, Full, Limited -- Video Level CORRECT : WtW & BtB preserved, Zero scaling
  • Limited, Limited, Full -- Video Level WRONG : Extreme Washed Out Colors
  • Limited, Limited, Limited -- Video Level WRONG : Washed Out Colors

2.3 Which Combination to Use

Out of the eight combinations, only three have correct video levels by the time they reach the TV:

  1. Full,Full,Full -- Both Desktop & Video Content will look correct but video content is also scaled during the Y'CbCr --> RGB color space transformation. BtB & WtW are clipped so calibration will be more difficult
  2. Full, Limited, Limited -- This should be avoided since there are two levels of scaling which will likely cause unnecessary banding.
  3. Limited, Full, Limited -- Best option for embedded video player as there is zero video content scaling during the Y'CbCr --> RGB color space transformation. BtB & WtW are preserved to make calibration easier. If using a Desktop it will look overly dark

2.4 Pulling it All Together with Calibration

Go get the free AVSHD709 calibration media from HERE.

  1. Make sure to grab the MP4 version
  2. If all you want to do is basic calibration: Video Levels (brightness/contrast), overscan, picture & tint then just keep the 'Basic Calibration' folder as well as the 'Misc Patterns' folders, especially the ones that have the grayscale ramps (smooth & step.)
  3. The one important thing this awesome calibration disk is missing is Audio sync test patterns. Fortunately you can find two great free ones HERE. Make sure to get the MP4 versions.
  4. If you used the Limited -> Full -> Limited combination (and disabled hardware decoding) you can verify everything is working by playing the *Black Clipping Pattern* and verifying that you can get levels below 16 to flash when you raise your TV's brightness setting.

2.5 Changing Video Level Settings

  • Kodi can be set to use limited video levels through the settings menu.
**NOTE: There is a limitation of the VAAPI Hardware Decoder where it converts to Full video levels despite setting Kodi to use limited. To get limited video content to output from Kodi, you must disable hardware decoding in Video Settings for the time being. This will be fixed in Kodi 17
  • Your GPU can (and should) be set to output FULL video levels by running the command: `xrandr --output HDMI1 --set "Broadcast RGB" "Full"`.
  • What to do with your TV depends on the TV you have. When you set your GPU to output 'Full' levels, it actually notifies your TV of this fact via 'Infoframes.' If your TV honors infoframe information (and many don't) your TV will likely default to 'Full' video levels and you'll need to change it manually to 'Limited.' Note that your TV might call Limited and Full something else; my Samsung HU8550 calls Full as 'Normal' and Limited as 'Low.' Consult your manual to be sure.

3 See also