Evaluating an Application's Video Color
Describes how to evaluate your application's video color.
Introduction
Both AV Foundation and QTKit automatically apply color management to video during playback. See Technical Note TN2227 Video Color Management in AV Foundation and QTKit, which is considered a prerequisite for this document.
As discussed in Technical Note TN2227, ColorSync creates a color transform that provides a perceptual match between a known broadcast video color space (as specified by the 'nclc'
tag) and the specific chromaticity and gamma characteristics of your display (as defined by the display's ICC profile). This color transformation is then applied to every pixel of each frame by the GPU in realtime as the video is played back on screen.
It is important to note that the pixel values are changed by the color management process. This means that values read back from the display buffer via the DigitalColor Meter utility will be different than the actual pixels encoded in the video file. Further, it might not be obvious that the pixel values will likely differ between different displays (even seemingly identical displays) because their display profiles may be different.
This document describes various techniques to evaluate how your application renders video.
Evaluating Your Application's Video Using Color Bars
Introduction
The video industry commonly evaluates color using known test patterns. In this way, it is straightforward to learn how video was processed based on how the pattern deviates from that known standard. Classically, in an analog video environment, SMPTE (Society of Motion Picture and Television Engineers) color bars are used (these are generally referred to as Engineering Guideline EG 1-1990, see the SMPTE website for more information).
QuickTime Test Pattern movie files
QuickTime Test Pattern movie files are available for download on the QuickTime Developer page. These color bars have been designed to better help you to check the color reproduction of your QuickTime-based application or workflow. See Figure 1 for an example test pattern.
The test patterns contain color and grayscale patterns that let you test issues such as:
a) 16 black levels on black (black crush test/range expansion)
b) Continuous gradient (quantization/super-black,super-white handling)
c) 100% color bars (matrix, color match)
d) 75% color bars (matrix, color match)
e) Quantized gradient (gamma)
f) 16 white levels on white (white crush test/range expansion)
These features can be evaluated by opening the test pattern in the desired application and visually inspecting it, reading back the display buffer pixel values using the DigitalColor Meter utility (see Interpreting 75% Grey Levels), or via a professional waveform monitor and/or vectorscope (see Output to Vectorscope and/or Waveform Analyzer).
Interpreting 75% Grey Levels
As shown in Figure 1, the QuickTime Test Pattern movie files contain 75% color bars.
The easiest way to check the color management in your application is to use 75% grey bars.
On Mac OS X 10.6 Snow Leopard and later with modern media, 75% grey bars will be processed by a 1.96 to 2.2 gamma conversion, resulting in a 198 value. See Figure 3. Here's a detailed explanation:
AV Foundation and QTKit will use a value of approximately 1.96 as the gamma of video, which is the gamma value without the boost required for classic dim surround viewing environments. Here's how that number is derived: if you had measured the response of a CRT, most had a gamma of between 2.4 and 2.5 (it is dependent on how the brightness and contrast is set on the monitor). If you choose a value halfway in between, 2.45, and remove the contrast enhancement (the 1.25 gamma boost provided for viewing in dimly lit environments) you'll get a value very close to 1.96 (2.45/1.25 = 1.96).
On Mac OS X 10.6 Snow Leopard and later, the video gamma is then converted to the 2.2 display buffer gamma when the application performs the color match to the display.
To recap, if you take the 75% grey bar and perform the 1.96 to 2.2 gamma conversion, the calculations are as follows: 191/255 (75% grey bars in an 8-bit (0-255) RGB space have 191 energy levels, because 191 is 75% of 255), raised to the 1.961/2.2 exponent (gamma conversion), scaled back to 255, producing a value of approximately 198:
With rounding error, the results will be in this range.
That's the default behavior for a modern AV Foundation, QTKit and QuickTime Visual Context application during playback. If you get 191's or other values, it probably means there's no color management being applied. See How to ensure your app video is color managed.
Color match will keep grey levels 'pure' grey
In a color managed application, given a correct display profile, a color match won't change a grey value from appearing grey. It may adjust the brightness based on the gamma correction, but it won't add color to it (grey's remain R=G=B). Therefore, the RGB components of a given grey value from one of the color bars will have identical values after the color match. If they don't, that's an issue you should investigate (see How to ensure your app video is color managed).
Interpreting 'pure' (non-grey) colors in the color bar
Pixel values that aren't grey may change due to the color match. As discussed in the Introduction, color matches are performed using perceptual rendering intent. This means a 75% green may get any one of a number of color shifts during the color match, depending on the nature of the source profile and display profile. For example, a 75% Green value (0, 191, 0) may change to (40, 200, 8) after the color match.
Output to Vectorscope and/or Waveform Analyzer
You can output your video to a vectorscope and/or waveform analyzer to analyze the video signals. For example, gamma, quantization errors and range expansion/compression can be verified by viewing the test pattern on a waveform monitor. Similarly, the correct colorspace conversion matrices (and the presence of a colormatch) can be verified by viewing the test pattern on a vector scope.
Vectorscope
A vectorscope is a type of instrument that measures the color relationship of a video signal by plotting the two chroma components of a signal. Vectorscopes often include printed boxes indicating standard colors. Ideally, a correctly reproduced color bar signal should 'hit' the vectorscope boxes.
Typically, there is a set of six boxes (Yellow, Cyan, Green, Magenta, Red and Blue) representing 75% color bars, and another set for 100% color bars -- these correspond to sections c) and d) of the QuickTime Test Pattern movie files as shown in Figure 1. If the representation's color vector 'hits' inside the corresponding box during testing, then that color is correct.
Waveform Monitor
A waveform monitor displays the composite of the amplitude of all of the lines of a given frame of video over time. Among other things, this instrument can help ensure that all values are used with no range of blacks or whites being truncated (crushed). Here's elements of the QuickTime Test Pattern Movie file (see Figure 1) to examine on a waveform monitor:
a) Black boxes on a black background. On the waveform monitor, this portion of the test signal should be visible as 16 steps beginning with true black.
b) Gradient. This monotonically increasing gradient includes super-whites and super-blacks that are expected to be crushed by a rendering process that includes full-range RGB. Consequently, the result on the waveform monitor should range from true-black to full-white, but the beginning and end of the repeating pattern may be clamped to black or white for the extent of the range corresponding to super-white and super-black. The gradient should form a straight line on the waveform monitor's display (otherwise it indicates a gamma conversion was applied). The line should also be smooth, otherwise quantization may have occurred.
f) White boxes on a full-white background. On the waveform monitor this portion of the test signal should be visible as 16 steps beginning from full-white.
Additional pattern features
e) Quantized gradient. This is used to perform a numerical method on plotting the area under those targets and solving for the gamma of the signal.
How to ensure your app video is color managed
To ensure that the appropriate color management is applied to your video during playback, you should do the following:
Use high-level frameworks
Mac OS X offers implicit color management of video through frameworks integrated with ColorSync, such as QTKit and AV Foundation.
Tag all content
It is critical that all video content be tagged with an
'nclc'
color tag. You can use the QuickTime X Automator tagging action to perform this operation. The QuickTime X device exporters will also properly tag content for you. If you have applications or components that produce video make sure that you provide the'nclc'
information in the files that you write. See Technical Note TN2227, 'Video Color Management in AV Foundation and QTKit' for more information.Evaluate all results
Use the techniques described in this tech note to evaluate your results and verify that your video is being properly color managed.
Document Revision History
Date | Notes |
---|---|
2013-06-11 | Editorial. |
2013-06-10 | New document that discusses how to evaluate your application's video color. |
Copyright © 2013 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2013-06-11