[Solved] Faulty Colors resulting from CUDA Video Decoder

Hi everyone,
when you compare the results from the CUDA Video Decoder to those of e.g. VLC or the MATLAB VideoReader you’ll notice that the CUDA results have a lower contrast and higher brightness, which does not look good at all.

I tried the different color conversion matrices as found in the sample code (ITU709 being the correct one for HD content), but both don’t give the desired results. I even verified the ITU709 color conversion matrix by comparing it to the respective standard document. Everything is fine here, which means that the error must lie somewhere deeper in the decoder. My next step is to look into the NV12 to ARGB conversion as found in NV12toARGB_drvapi.cu and check whether everything is ok there, but I somehow doubt it has anything to do with that.

Do you guys have any other ideas??

Ah, I found the issue. According to this website, not only Cb and Cr have an offset (-128) that must be corrected prior to transformation, but Y has too (-16).

So, since we work in a 10 Bit representation rather than the above 8 Bits, we subtract 64 from Y in YUV2RGB() and use the Matrix
{1.164, 0.0, 1.793,
1.164, -0.213, -0.533,
1.164, 2.112, 0.0}
to transform to RGB. Everything looks good now! :)

I thought, I’d share my findings so that they are documented.

I am working on CUDA 4.2 here by the way, since we have a very complex setup here that prevents us from upgrading (without major pain that is). So I don’t know if this issue has maybe already been fixed or not in succeeding version of the SDK.