Select color range based on plane COLOR_RANGE property values

This commit is contained in:
Cameron Gutman
2026-08-05 23:48:51 -05:00
parent 4570fba87d
commit 3f26217df7
2 changed files with 17 additions and 0 deletions
@@ -2019,6 +2019,22 @@ int DrmRenderer::getDecoderColorspace()
return COLORSPACE_REC_601;
}
int DrmRenderer::getDecoderColorRange()
{
if (auto prop = m_VideoPlane.property("COLOR_RANGE")) {
// Prefer full range if the video plane supports it
if (prop->containsValue("YCbCr full range")) {
return COLOR_RANGE_FULL;
}
else if (prop->containsValue("YCbCr limited range")) {
return COLOR_RANGE_LIMITED;
}
}
// Default to limited if we couldn't find a valid COLOR_RANGE property
return COLOR_RANGE_LIMITED;
}
const char* DrmRenderer::getDrmColorEncodingValue(AVFrame* frame)
{
switch (getFrameColorspace(frame)) {
@@ -770,6 +770,7 @@ public:
virtual bool testRenderFrame(AVFrame* frame) override;
virtual bool isDirectRenderingSupported() override;
virtual int getDecoderColorspace() override;
virtual int getDecoderColorRange() override;
virtual void setHdrMode(bool enabled) override;
virtual void notifyOverlayUpdated(Overlay::OverlayType type) override;
#ifdef HAVE_EGL