Chroma subsampling in VQ Analyzer
VQ Analyzer developed by ViCueSoft has a useful function of comparing two video streams with different chroma subsampling. In this article I will first explain the main qualities of a YUV file used in Analyzer and then I will provide practical examples of how VQ Analyzer deals with YUV files of different chroma subsampling.
To fully understand what YUV is, one first needs to consider RGB. RGB is a color model with three components — red, green, and blue. Different amounts of these components create a wide array of colors.
Despite its wide use in color-image producing technology, RGB model has a significant limitation: compression of a file with this color model leads to a negative effect on the quality of the picture. A solution to this issue was found when RGB was replaced with YUV color encoding system or model.
In contrast to RGB model based on three colors, in YUV model (also called YCbCr) one component is responsible for luma (brightness) and two for chroma (color). YUV components are easily deduced from RGB components using the formulas provided below:
where k are weighting factors;
A full description of a color image includes one luminance component Y and three chrominance components Cb, Cr, Cg. Until this moment, it is not clear what the benefit of storing images and videos in this format is because for three RGB components we get four in YUV. The answer to it is that the number Cb + Cr + Cg is constant, therefore one color component can be derived on the basis of the other two and, therefore, it is enough to store only two color components.
Turning back to the issue of compression, the resolution of the chroma channel in YUV can be reduced without visible damage to quality. This property of YUV system is reliant on the ability of a human eye to be more susceptible to a change in brightness than color.
Chroma Subsampling of a YUV file define the number of pixels in a chroma channel relative to a luma channel. We will now explain what the difference between different types of sampling is and how it applies to VQ Analyzer.
Chroma Subsampling used in VQ Analyzer
- 4:4:4 — luma and chroma channels have the same resolution, which results in high image accuracy;
- 4:2:2 — chroma channel has the same height as luma channel and twice shorter width, it is a popular format for high quality color video;
- 4:2:0 — chroma channel has half of height and half of width of luma channel resolution; it is usually used in digital TV, DVD discs and video conferencing;
- 4:0:0 — has no chroma channel at all, it is a monochrome image.
How to compare two YUV files with different chroma subsampling in VQ Analyzer?
VQ Analyzer has an option of comparing two files with different chroma subsampling. When you open a file with a .yuv extension, a dialog box for entering parameters will open.
In our example, a video stream has 1920x1080 resolution and 4:4:4 chroma subsampling. As I mentioned in the previous section, this means that the chroma channel has the same height and width as the luma channel.
After we have opened the file and set the necessary parameters, we can open the second .yuv file that we want to compare with the first one. To do this, select Open Debug YUV… option in the YUVDiff context menu.
As a way of example, we will open a stream with 4:2:0 subsampling. Mean resolution of the chroma channel is 960x540 in this case. If the files have different chroma subsampling (as is in our case) we will see chromatic distortion. The image below demonstrates how chromatic distortion is displayed.
Distortion appears due to the fact that the open debug YUV file has 4:2:0 subsampling, but the Analyzer reads the file as a 4:4:4 stream. Therefore, it takes the format of the reference stream as default. This happens because a .yuv file does not contain information about chroma subsampling.
To be able to compare two video streams, one needs to select chroma subsampling. To do this, go to YUVDiff context menu and select the actual subsampling of the debug file in the Subsampling tab.
Now that the chromatic distortion is gone, we can compare the two files. It is important to note that the frames of the video that we will see in Diff YUV are not the actual ones. Analyzer converts frames of the second stream to the format of the first one.
How does VQ Analyzer convert YUV images?
VQ Analyzer converts YUV images as follows: if the chroma channel of the first stream has a lower resolution than the second one, then the chroma channel of the second stream will be thinned out, otherwise they will be expanded. Let’s look at both processes using the example of 4:2:0 and 4:4:4 chroma subsampling streams.
If 4:4:4 sampling needs be converted to 4:2:0 sampling, the arithmetic mean of four neighboring pixels of the source channel is taken as the value of one pixel.
If 4:2:0 sampling needs to be converted to 4:4:4 sampling, then the value of four pixels is taken from the value of one pixel from the original channel.
Conversion of other samplings works on the same principle, the only difference is in the number of pixels that are compressed or obtained after expansion.
VQ Analyzer functionality makes it possible to compare two video streams with different chroma samplings. You can try this and many other features VQ Analyzer provides by downloading it from the link.
Thanks for reading. I hope this article was useful for you.