From 81cfacaa3dd329f9d5c659218656ec846ac8788d Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 11 Sep 2022 23:13:10 -0500 Subject: [PATCH] Add fallback logic when the host doesn't send valid colorspace data --- .../video/ffmpeg-renderers/d3d11va.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/d3d11va.cpp b/app/streaming/video/ffmpeg-renderers/d3d11va.cpp index 66307e9a..6e6346b0 100644 --- a/app/streaming/video/ffmpeg-renderers/d3d11va.cpp +++ b/app/streaming/video/ffmpeg-renderers/d3d11va.cpp @@ -720,8 +720,22 @@ void D3D11VARenderer::bindColorConversion(AVFrame* frame) rawCscMatrix = fullRange ? k_CscMatrix_Bt2020Full : k_CscMatrix_Bt2020Lim; break; default: - SDL_assert(false); - return; + // Sunshine doesn't always populate this data correctly, + // so fallback to assuming they're sending what we asked for. + switch (getDecoderColorspace()) { + case COLORSPACE_REC_601: + rawCscMatrix = fullRange ? k_CscMatrix_Bt601Full : k_CscMatrix_Bt601Lim; + break; + case COLORSPACE_REC_709: + rawCscMatrix = fullRange ? k_CscMatrix_Bt709Full : k_CscMatrix_Bt709Lim; + break; + case COLORSPACE_REC_2020: + rawCscMatrix = fullRange ? k_CscMatrix_Bt2020Full : k_CscMatrix_Bt2020Lim; + break; + default: + SDL_assert(false); + return; + } } // We need to adjust our raw CSC matrix to be column-major and with float3 vectors