From 704ce4ff0cd75e538bb4971ca8ff17891d00b6d7 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 14 Oct 2022 23:39:49 -0500 Subject: [PATCH] Add environment variable for overriding decoder capabilities --- app/streaming/video/ffmpeg.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/app/streaming/video/ffmpeg.cpp b/app/streaming/video/ffmpeg.cpp index fc362b38..e8909844 100644 --- a/app/streaming/video/ffmpeg.cpp +++ b/app/streaming/video/ffmpeg.cpp @@ -70,18 +70,31 @@ void FFmpegVideoDecoder::setHdrMode(bool enabled) int FFmpegVideoDecoder::getDecoderCapabilities() { - int capabilities = m_BackendRenderer->getDecoderCapabilities(); + bool ok; - if (!isHardwareAccelerated()) { - // Slice up to 4 times for parallel CPU decoding, once slice per core - int slices = qMin(MAX_SLICES, SDL_GetCPUCount()); - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Encoder configured for %d slices per frame", - slices); - capabilities |= CAPABILITY_SLICES_PER_FRAME(slices); + int capabilities = qEnvironmentVariableIntValue("DECODER_CAPS", &ok); + if (ok) { + SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, + "Using decoder capability override: 0x%x", + capabilities); + } + else { + // Start with the backend renderer's capabilities + capabilities = m_BackendRenderer->getDecoderCapabilities(); + + if (!isHardwareAccelerated()) { + // Slice up to 4 times for parallel CPU decoding, once slice per core + int slices = qMin(MAX_SLICES, SDL_GetCPUCount()); + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Encoder configured for %d slices per frame", + slices); + capabilities |= CAPABILITY_SLICES_PER_FRAME(slices); + } } - // We use our own decoder thread with the "pull" model + // We use our own decoder thread with the "pull" model. This cannot + // be overridden using the by the user because it is critical to + // our operation. capabilities |= CAPABILITY_PULL_RENDERER; return capabilities;