Add logging for cases where color range/encoding cannot be set

This commit is contained in:
Cameron Gutman 2022-03-19 13:12:41 -05:00
commit 99495cff90

View file

@ -569,7 +569,9 @@ void DrmRenderer::renderFrame(AVFrame* frame)
const char* desiredValue = getDrmColorRangeValue(frame);
if (m_ColorRangeProp != nullptr && desiredValue != nullptr) {
for (int i = 0; i < m_ColorRangeProp->count_enums; i++) {
int i;
for (i = 0; i < m_ColorRangeProp->count_enums; i++) {
if (!strcmp(desiredValue, m_ColorRangeProp->enums[i].name)) {
err = drmModeObjectSetProperty(m_DrmFd, m_PlaneId, DRM_MODE_OBJECT_PLANE,
m_ColorRangeProp->prop_id, m_ColorRangeProp->enums[i].value);
@ -590,6 +592,16 @@ void DrmRenderer::renderFrame(AVFrame* frame)
break;
}
}
if (i == m_ColorRangeProp->count_enums) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Unable to find matching COLOR_RANGE value for '%s'. Colors may be inaccurate!",
desiredValue);
}
}
else if (desiredValue != nullptr) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"COLOR_RANGE property does not exist on output plane. Colors may be inaccurate!");
}
m_LastColorRange = frame->color_range;
@ -599,7 +611,9 @@ void DrmRenderer::renderFrame(AVFrame* frame)
const char* desiredValue = getDrmColorEncodingValue(frame);
if (m_ColorEncodingProp != nullptr && desiredValue != nullptr) {
for (int i = 0; i < m_ColorEncodingProp->count_enums; i++) {
int i;
for (i = 0; i < m_ColorEncodingProp->count_enums; i++) {
if (!strcmp(desiredValue, m_ColorEncodingProp->enums[i].name)) {
err = drmModeObjectSetProperty(m_DrmFd, m_PlaneId, DRM_MODE_OBJECT_PLANE,
m_ColorEncodingProp->prop_id, m_ColorEncodingProp->enums[i].value);
@ -620,6 +634,16 @@ void DrmRenderer::renderFrame(AVFrame* frame)
break;
}
}
if (i == m_ColorEncodingProp->count_enums) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Unable to find matching COLOR_ENCODING value for '%s'. Colors may be inaccurate!",
desiredValue);
}
}
else if (desiredValue != nullptr) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"COLOR_ENCODING property does not exist on output plane. Colors may be inaccurate!");
}
m_LastColorSpace = frame->colorspace;