From 0bde9325507a392c36b9d82a1716a4930ac9b6c7 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 26 Jul 2018 19:26:22 -0700 Subject: [PATCH] Prevent HEVC streaming with the software decoder for performance reasons --- app/streaming/session.cpp | 33 ++++++++++++-------- app/streaming/video/ffmpeg-renderers/sdl.cpp | 12 ++++++- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index e4bb74cb..f6639583 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -310,23 +310,30 @@ bool Session::validateLaunch() QStringList warningList; if (m_StreamConfig.supportsHevc) { - if (m_Preferences.videoCodecConfig == StreamingPreferences::VCC_FORCE_HEVC || - m_Preferences.videoCodecConfig == StreamingPreferences::VCC_FORCE_HEVC_HDR) { - if (m_Computer->maxLumaPixelsHEVC == 0) { - emit displayLaunchWarning("Your host PC GPU doesn't support HEVC. " - "A GeForce GTX 900-series (Maxwell) or later GPU is required for HEVC streaming."); - } - } - else if (!isHardwareDecodeAvailable(m_Preferences.videoDecoderSelection, - VIDEO_FORMAT_H265, - m_StreamConfig.width, - m_StreamConfig.height, - m_StreamConfig.fps)) { + bool hevcForced = m_Preferences.videoCodecConfig == StreamingPreferences::VCC_FORCE_HEVC || + m_Preferences.videoCodecConfig == StreamingPreferences::VCC_FORCE_HEVC_HDR; + + if (!isHardwareDecodeAvailable(m_Preferences.videoDecoderSelection, + VIDEO_FORMAT_H265, + m_StreamConfig.width, + m_StreamConfig.height, + m_StreamConfig.fps)) { // NOTE: HEVC currently uses only 1 slice regardless of what // we provide in CAPABILITY_SLICES_PER_FRAME(), so we should // never use it for software decoding (unless common-c starts // respecting it for HEVC). m_StreamConfig.supportsHevc = false; + + if (hevcForced) { + emit displayLaunchWarning("This PC's GPU doesn't support HEVC decoding."); + } + } + + if (hevcForced) { + if (m_Computer->maxLumaPixelsHEVC == 0) { + emit displayLaunchWarning("Your host PC GPU doesn't support HEVC. " + "A GeForce GTX 900-series (Maxwell) or later GPU is required for HEVC streaming."); + } } } @@ -348,7 +355,7 @@ bool Session::validateLaunch() m_StreamConfig.width, m_StreamConfig.height, m_StreamConfig.fps)) { - emit displayLaunchWarning("Your client PC GPU doesn't support HEVC Main10 decoding for HDR streaming."); + emit displayLaunchWarning("This PC's GPU doesn't support HEVC Main10 decoding for HDR streaming."); } else { // TODO: Also validate display capabilites diff --git a/app/streaming/video/ffmpeg-renderers/sdl.cpp b/app/streaming/video/ffmpeg-renderers/sdl.cpp index 69ad5e40..5244172a 100644 --- a/app/streaming/video/ffmpeg-renderers/sdl.cpp +++ b/app/streaming/video/ffmpeg-renderers/sdl.cpp @@ -1,5 +1,7 @@ #include "renderer.h" +#include + SdlRenderer::SdlRenderer() : m_Renderer(nullptr), m_Texture(nullptr) @@ -25,10 +27,18 @@ bool SdlRenderer::prepareDecoderContext(AVCodecContext*) } bool SdlRenderer::initialize(SDL_Window* window, - int, + int videoFormat, int width, int height) { + // NOTE: HEVC currently uses only 1 slice regardless of what + // we provide in CAPABILITY_SLICES_PER_FRAME(), so we should + // never use it for software decoding (unless common-c starts + // respecting it for HEVC). + if (videoFormat != VIDEO_FORMAT_H264) { + return false; + } + m_Renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); if (!m_Renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,