While a limited range output isn’t what we were after (and reconstructing signals after full/limited conversion may not be exact due to rounding), I don’t think technically a limited range output is incorrect per se.
However, returning to the results from your captures. The values you have captured cannot be explained by a conversion from full to limited range RGB alone - but can be with incorrect color space conversions.
Taking the outer background as a concrete example. In the original png (full range 8-bit RGB) the value is (128, 16, 0) and the captured values are (119, 19, 17), even when included a conversion to align the ranges a significant differences (over 10) still exists.
However, the mp4 you made of the test pattern proved useful. This video is encoded in YCbCr (limited range), the values for the background are (49, 110, 178). These values correspond to a conversion from full range 8-bit RGB to YCbCr (limited range) using BT.709. Again, the values from the capture do not match a conversion back from BT.709 limited range YCbCr to limited range RGB.
What does, however, match the captured values is when the YCbCr values (obtained using BT.709 conversion) are incorrectly converted to limited RGB using the BT.601 conversion.
Oddly enough, this also appears to happen in the capture of the png. It appear that coreelec/kodi is taking the full range RGB image, converting to limited range YCbCr using a BT.709 conversion, and then incorrectly converting those values to limited range RGB using a BT.601 conversion. As to why a RGB image is being transformed to YCbCr and back in any form, I have no idea …
TL;DR
CoreELEC/kodi uses inconsistent/incorrect color space conversions that has resulted in significant errors when outputting RGB.
Questions from this result open for anyone to answer:
- Are any/the right conversions used when playing back BT.709 video with a YUV output? Probably need a capture to confirm
- Does anyone know how to tell via ssh what color space conversions are currently being used?
- Is this a known bug?
- Any pointers to where in the code the logic for selected which color space conversion to use exists?