mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 23:35:55 +00:00
Display the HDR option if the platform has a decoder that supports it
This commit is contained in:
parent
e0fd84d6f5
commit
1cbdd0e675
@ -64,16 +64,6 @@ SystemProperties::SystemProperties()
|
||||
hasDiscordIntegration = false;
|
||||
#endif
|
||||
|
||||
// TODO: Do something smarter than this. We should be able to query
|
||||
// this from the decoder (or just try VIDEO_FORMAT_H265_MAIN10 and
|
||||
// fail if we don't get a hardware accelerated decoder).
|
||||
#ifdef Q_OS_DARWIN
|
||||
// HDR is supported by the VideoToolbox renderer
|
||||
supportsHdr = true;
|
||||
#else
|
||||
supportsHdr = false;
|
||||
#endif
|
||||
|
||||
unmappedGamepads = SdlInputHandler::getUnmappedGamepads();
|
||||
|
||||
// Populate data that requires talking to SDL. We do it all in one shot
|
||||
@ -158,7 +148,7 @@ void SystemProperties::querySdlVideoInfoInternal()
|
||||
}
|
||||
}
|
||||
|
||||
Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen, maximumResolution);
|
||||
Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen, supportsHdr, maximumResolution);
|
||||
|
||||
SDL_DestroyWindow(testWindow);
|
||||
|
||||
|
@ -308,39 +308,55 @@ int Session::drSubmitDecodeUnit(PDECODE_UNIT du)
|
||||
}
|
||||
|
||||
void Session::getDecoderInfo(SDL_Window* window,
|
||||
bool& isHardwareAccelerated, bool& isFullScreenOnly, QSize& maxResolution)
|
||||
bool& isHardwareAccelerated, bool& isFullScreenOnly,
|
||||
bool& isHdrSupported, QSize& maxResolution)
|
||||
{
|
||||
IVideoDecoder* decoder;
|
||||
|
||||
if (!chooseDecoder(StreamingPreferences::VDS_AUTO,
|
||||
window, VIDEO_FORMAT_H264, 1920, 1080, 60,
|
||||
false, false, true, decoder)) {
|
||||
isHardwareAccelerated = isFullScreenOnly = false;
|
||||
// Try an HEVC Main10 decoder first to see if we have HDR support
|
||||
if (chooseDecoder(StreamingPreferences::VDS_FORCE_HARDWARE,
|
||||
window, VIDEO_FORMAT_H265_MAIN10, 1920, 1080, 60,
|
||||
false, false, true, decoder)) {
|
||||
isHardwareAccelerated = decoder->isHardwareAccelerated();
|
||||
isFullScreenOnly = decoder->isAlwaysFullScreen();
|
||||
isHdrSupported = decoder->isHdrSupported();
|
||||
maxResolution = decoder->getDecoderMaxResolution();
|
||||
delete decoder;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
isHardwareAccelerated = decoder->isHardwareAccelerated();
|
||||
isFullScreenOnly = decoder->isAlwaysFullScreen();
|
||||
maxResolution = decoder->getDecoderMaxResolution();
|
||||
// HDR can only be supported by a hardware codec that can handle HEVC Main10.
|
||||
// If we made it this far, we don't have one, so HDR will not be available.
|
||||
isHdrSupported = false;
|
||||
|
||||
delete decoder;
|
||||
// Try a regular hardware accelerated HEVC decoder now
|
||||
if (chooseDecoder(StreamingPreferences::VDS_FORCE_HARDWARE,
|
||||
window, VIDEO_FORMAT_H265, 1920, 1080, 60,
|
||||
false, false, true, decoder)) {
|
||||
isHardwareAccelerated = decoder->isHardwareAccelerated();
|
||||
isFullScreenOnly = decoder->isAlwaysFullScreen();
|
||||
maxResolution = decoder->getDecoderMaxResolution();
|
||||
delete decoder;
|
||||
|
||||
// If we don't get back a hardware H.264 decoder, see if we have a hardware
|
||||
// HEVC decoder. This can be the case on the Raspberry Pi with Full KMS
|
||||
// when not running in X11. Everything since Maxwell in 2014 can encode HEVC,
|
||||
// so we probably don't need to be concerned about a lack of fast H.264
|
||||
// decoding enough to bug the user about it every launch.
|
||||
if (!isHardwareAccelerated) {
|
||||
if (chooseDecoder(StreamingPreferences::VDS_FORCE_HARDWARE,
|
||||
window, VIDEO_FORMAT_H265, 1920, 1080, 60,
|
||||
false, false, true, decoder)) {
|
||||
isHardwareAccelerated = decoder->isHardwareAccelerated();
|
||||
isFullScreenOnly = decoder->isAlwaysFullScreen();
|
||||
maxResolution = decoder->getDecoderMaxResolution();
|
||||
|
||||
delete decoder;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If we still didn't find a hardware decoder, try H.264 now.
|
||||
// This will fall back to software decoding, so it should always work.
|
||||
if (chooseDecoder(StreamingPreferences::VDS_AUTO,
|
||||
window, VIDEO_FORMAT_H264, 1920, 1080, 60,
|
||||
false, false, true, decoder)) {
|
||||
isHardwareAccelerated = decoder->isHardwareAccelerated();
|
||||
isFullScreenOnly = decoder->isAlwaysFullScreen();
|
||||
maxResolution = decoder->getDecoderMaxResolution();
|
||||
delete decoder;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to find ANY working H.264 or HEVC decoder!");
|
||||
}
|
||||
|
||||
bool Session::isHardwareDecodeAvailable(SDL_Window* window,
|
||||
|
@ -28,7 +28,8 @@ public:
|
||||
|
||||
static
|
||||
void getDecoderInfo(SDL_Window* window,
|
||||
bool& isHardwareAccelerated, bool& isFullScreenOnly, QSize& maxResolution);
|
||||
bool& isHardwareAccelerated, bool& isFullScreenOnly,
|
||||
bool& isHdrSupported, QSize& maxResolution);
|
||||
|
||||
static Session* get()
|
||||
{
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
||||
virtual bool isHardwareAccelerated() = 0;
|
||||
virtual bool isAlwaysFullScreen() = 0;
|
||||
virtual bool isHdrSupported() = 0;
|
||||
virtual int getDecoderCapabilities() = 0;
|
||||
virtual int getDecoderColorspace() = 0;
|
||||
virtual QSize getDecoderMaxResolution() = 0;
|
||||
|
@ -410,8 +410,15 @@ enum AVPixelFormat DrmRenderer::getPreferredPixelFormat(int)
|
||||
|
||||
int DrmRenderer::getRendererAttributes()
|
||||
{
|
||||
int attributes = 0;
|
||||
|
||||
// This renderer can only draw in full-screen
|
||||
return RENDERER_ATTRIBUTE_FULLSCREEN_ONLY;
|
||||
attributes |= RENDERER_ATTRIBUTE_FULLSCREEN_ONLY;
|
||||
|
||||
// This renderer supports HDR
|
||||
attributes |= RENDERER_ATTRIBUTE_HDR_SUPPORT;
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
void DrmRenderer::setHdrMode(bool enabled)
|
||||
|
@ -90,6 +90,7 @@ private:
|
||||
|
||||
#define RENDERER_ATTRIBUTE_FULLSCREEN_ONLY 0x01
|
||||
#define RENDERER_ATTRIBUTE_1080P_MAX 0x02
|
||||
#define RENDERER_ATTRIBUTE_HDR_SUPPORT 0x04
|
||||
|
||||
class IFFmpegRenderer : public Overlay::IOverlayRenderer {
|
||||
public:
|
||||
|
@ -505,6 +505,12 @@ public:
|
||||
return COLORSPACE_REC_601;
|
||||
}
|
||||
|
||||
int getRendererAttributes() override
|
||||
{
|
||||
// AVSampleBufferDisplayLayer supports HDR output
|
||||
return RENDERER_ATTRIBUTE_HDR_SUPPORT;
|
||||
}
|
||||
|
||||
private:
|
||||
AVBufferRef* m_HwContext;
|
||||
AVSampleBufferDisplayLayer* m_DisplayLayer;
|
||||
|
@ -57,6 +57,11 @@ bool FFmpegVideoDecoder::isAlwaysFullScreen()
|
||||
return m_FrontendRenderer->getRendererAttributes() & RENDERER_ATTRIBUTE_FULLSCREEN_ONLY;
|
||||
}
|
||||
|
||||
bool FFmpegVideoDecoder::isHdrSupported()
|
||||
{
|
||||
return m_FrontendRenderer->getRendererAttributes() & RENDERER_ATTRIBUTE_HDR_SUPPORT;
|
||||
}
|
||||
|
||||
void FFmpegVideoDecoder::setHdrMode(bool enabled)
|
||||
{
|
||||
m_FrontendRenderer->setHdrMode(enabled);
|
||||
|
@ -18,6 +18,7 @@ public:
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool isHardwareAccelerated() override;
|
||||
virtual bool isAlwaysFullScreen() override;
|
||||
virtual bool isHdrSupported() override;
|
||||
virtual int getDecoderCapabilities() override;
|
||||
virtual int getDecoderColorspace() override;
|
||||
virtual QSize getDecoderMaxResolution() override;
|
||||
|
@ -9,19 +9,22 @@ class SLVideoDecoder : public IVideoDecoder
|
||||
public:
|
||||
SLVideoDecoder(bool testOnly);
|
||||
virtual ~SLVideoDecoder();
|
||||
virtual bool initialize(PDECODER_PARAMETERS params);
|
||||
virtual bool isHardwareAccelerated();
|
||||
virtual bool isAlwaysFullScreen();
|
||||
virtual int getDecoderCapabilities();
|
||||
virtual int getDecoderColorspace();
|
||||
virtual QSize getDecoderMaxResolution();
|
||||
virtual int submitDecodeUnit(PDECODE_UNIT du);
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool isHardwareAccelerated() override;
|
||||
virtual bool isAlwaysFullScreen() override;
|
||||
virtual int getDecoderCapabilities() override;
|
||||
virtual int getDecoderColorspace() override;
|
||||
virtual QSize getDecoderMaxResolution() override;
|
||||
virtual int submitDecodeUnit(PDECODE_UNIT du) override;
|
||||
|
||||
// Unused since rendering is done directly from the decode thread
|
||||
virtual void renderFrameOnMainThread() {}
|
||||
virtual void renderFrameOnMainThread() override {}
|
||||
|
||||
// HDR is not supported by SLVideo
|
||||
virtual void setHdrMode(bool) {}
|
||||
virtual void setHdrMode(bool) override {}
|
||||
virtual bool isHdrSupported() override {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
static void slLogCallback(void* context, ESLVideoLog logLevel, const char* message);
|
||||
|
Loading…
x
Reference in New Issue
Block a user