Colour spaces and NV12 to RGB

For those curious

It’s funny that I never questioned why whenever a video playback was corrupted or malfunctioned it displayed a green screen.Even at my current job, having learned about color space conversion and the different ways to represent color it still never clicked. To be fair I think it’s because we are taught in school how to think with the RGB color space and not YUV. The answer though is really simple, but just found it interesting I had never connected the dots. The conversion of a YUV value of 0 to RGB is the dull green color!

YUV value of 0
YUV value of 0 produces this green color.

Converting NV12

I work with a lot of YUV (NV12) files. Found a few neat tools online to convert them to RGB and decide to roll my own. It’s pretty straightforward. There are a bunch of different ways to grab the y, u , v data and this one is a bit more intricate as it moves the cursor constantly to get the appropriate UV position for the current Y value. To get a better understanding of conversions from YUV to RGB and about colour spaces in general, I found that the MSDN was a great place. Check out this link.

I would like to rewrite this so that it is more generic for all YUV formats depending on their sample period.

Leave a Reply

Your email address will not be published. Required fields are marked *