From 8373a8b94788f943f25d6d1d7d5b3720d3591e1d Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 6 Feb 2024 19:30:22 -0600 Subject: [PATCH] Avoid recreating the display when no display parameters have changed --- src/video.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/video.cpp b/src/video.cpp index 53ef6ecb255..1914faaa181 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -2353,12 +2353,7 @@ namespace video { }; int - validate_config(std::shared_ptr &disp, const encoder_t &encoder, const config_t &config) { - reset_display(disp, encoder.platform_formats->dev_type, config::video.output_name, config); - if (!disp) { - return -1; - } - + validate_config(std::shared_ptr disp, const encoder_t &encoder, const config_t &config) { auto encode_device = make_encode_device(*disp, encoder, config); if (!encode_device) { return -1; @@ -2561,6 +2556,12 @@ namespace video { hevc.videoFormat = 1; av1.videoFormat = 2; + // Reset the display since we're switching from SDR to HDR + reset_display(disp, encoder.platform_formats->dev_type, config::video.output_name, config); + if (!disp) { + return false; + } + // HDR is not supported with H.264. Don't bother even trying it. encoder.h264[flag] = flag != encoder_t::DYNAMIC_RANGE && validate_config(disp, encoder, h264) >= 0;