Use hasFrameFormatChanged() in DRMRenderer

This commit is contained in:
Cameron Gutman
2025-11-06 00:04:08 -06:00
parent c54e6e4459
commit a2670dd568
2 changed files with 61 additions and 70 deletions
+6 -13
View File
@@ -166,8 +166,6 @@ DrmRenderer::DrmRenderer(AVHWDeviceType hwDeviceType, IFFmpegRenderer *backendRe
m_CrtcId(0), m_CrtcId(0),
m_PlaneId(0), m_PlaneId(0),
m_CurrentFbId(0), m_CurrentFbId(0),
m_LastFullRange(false),
m_LastColorSpace(-1),
m_Plane(nullptr), m_Plane(nullptr),
m_ColorEncodingProp(nullptr), m_ColorEncodingProp(nullptr),
m_ColorRangeProp(nullptr), m_ColorRangeProp(nullptr),
@@ -1251,12 +1249,9 @@ void DrmRenderer::renderFrame(AVFrame* frame)
return; return;
} }
int colorspace = getFrameColorspace(frame); if (hasFrameFormatChanged(frame)) {
bool fullRange = isFrameFullRange(frame); // Set COLOR_RANGE property for the plane
{
// We also update the color range when the colorspace changes in order to handle initialization
// where the last color range value may not actual be applied to the plane.
if (fullRange != m_LastFullRange || colorspace != m_LastColorSpace) {
const char* desiredValue = getDrmColorRangeValue(frame); const char* desiredValue = getDrmColorRangeValue(frame);
if (m_ColorRangeProp != nullptr && desiredValue != nullptr) { if (m_ColorRangeProp != nullptr && desiredValue != nullptr) {
@@ -1294,11 +1289,10 @@ void DrmRenderer::renderFrame(AVFrame* frame)
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"COLOR_RANGE property does not exist on output plane. Colors may be inaccurate!"); "COLOR_RANGE property does not exist on output plane. Colors may be inaccurate!");
} }
m_LastFullRange = fullRange;
} }
if (colorspace != m_LastColorSpace) { // Set COLOR_ENCODING property for the plane
{
const char* desiredValue = getDrmColorEncodingValue(frame); const char* desiredValue = getDrmColorEncodingValue(frame);
if (m_ColorEncodingProp != nullptr && desiredValue != nullptr) { if (m_ColorEncodingProp != nullptr && desiredValue != nullptr) {
@@ -1336,8 +1330,7 @@ void DrmRenderer::renderFrame(AVFrame* frame)
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"COLOR_ENCODING property does not exist on output plane. Colors may be inaccurate!"); "COLOR_ENCODING property does not exist on output plane. Colors may be inaccurate!");
} }
}
m_LastColorSpace = colorspace;
} }
// Update the overlay // Update the overlay
@@ -95,8 +95,6 @@ private:
uint32_t m_CrtcId; uint32_t m_CrtcId;
uint32_t m_PlaneId; uint32_t m_PlaneId;
uint32_t m_CurrentFbId; uint32_t m_CurrentFbId;
bool m_LastFullRange;
int m_LastColorSpace;
drmModePlanePtr m_Plane; drmModePlanePtr m_Plane;
drmModePropertyPtr m_ColorEncodingProp; drmModePropertyPtr m_ColorEncodingProp;
drmModePropertyPtr m_ColorRangeProp; drmModePropertyPtr m_ColorRangeProp;