From c55af7fff3534f5be9c782abb4ffed2c2f4e7b9f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 12 Oct 2022 23:59:01 -0500 Subject: [PATCH] Add a decoder/renderer callback to specify the desired color range --- app/streaming/session.cpp | 3 +-- app/streaming/video/decoder.h | 1 + app/streaming/video/ffmpeg-renderers/renderer.h | 5 +++++ app/streaming/video/ffmpeg.cpp | 5 +++++ app/streaming/video/ffmpeg.h | 1 + app/streaming/video/slvid.cpp | 6 ++++++ app/streaming/video/slvid.h | 1 + 7 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 0593f539..6cc0b7a0 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -426,8 +426,7 @@ bool Session::populateDecoderProperties(SDL_Window* window) m_StreamConfig.colorRange); } else { - // Limited is the default for GFE - m_StreamConfig.colorRange = COLOR_RANGE_LIMITED; + m_StreamConfig.colorRange = decoder->getDecoderColorRange(); } } diff --git a/app/streaming/video/decoder.h b/app/streaming/video/decoder.h index 020cfc20..e96350f8 100644 --- a/app/streaming/video/decoder.h +++ b/app/streaming/video/decoder.h @@ -68,6 +68,7 @@ public: virtual bool isHdrSupported() = 0; virtual int getDecoderCapabilities() = 0; virtual int getDecoderColorspace() = 0; + virtual int getDecoderColorRange() = 0; virtual QSize getDecoderMaxResolution() = 0; virtual int submitDecodeUnit(PDECODE_UNIT du) = 0; virtual void renderFrameOnMainThread() = 0; diff --git a/app/streaming/video/ffmpeg-renderers/renderer.h b/app/streaming/video/ffmpeg-renderers/renderer.h index 1ac89394..d71f1eb9 100644 --- a/app/streaming/video/ffmpeg-renderers/renderer.h +++ b/app/streaming/video/ffmpeg-renderers/renderer.h @@ -158,6 +158,11 @@ public: return COLORSPACE_REC_601; } + virtual int getDecoderColorRange() { + // Limited is the default + return COLOR_RANGE_LIMITED; + } + virtual int getFrameColorspace(const AVFrame* frame) { // Prefer the colorspace field on the AVFrame itself switch (frame->colorspace) { diff --git a/app/streaming/video/ffmpeg.cpp b/app/streaming/video/ffmpeg.cpp index bb1ecaf4..fc362b38 100644 --- a/app/streaming/video/ffmpeg.cpp +++ b/app/streaming/video/ffmpeg.cpp @@ -92,6 +92,11 @@ int FFmpegVideoDecoder::getDecoderColorspace() return m_FrontendRenderer->getDecoderColorspace(); } +int FFmpegVideoDecoder::getDecoderColorRange() +{ + return m_FrontendRenderer->getDecoderColorRange(); +} + QSize FFmpegVideoDecoder::getDecoderMaxResolution() { if (m_BackendRenderer->getRendererAttributes() & RENDERER_ATTRIBUTE_1080P_MAX) { diff --git a/app/streaming/video/ffmpeg.h b/app/streaming/video/ffmpeg.h index 847bb406..4caf2c74 100644 --- a/app/streaming/video/ffmpeg.h +++ b/app/streaming/video/ffmpeg.h @@ -21,6 +21,7 @@ public: virtual bool isHdrSupported() override; virtual int getDecoderCapabilities() override; virtual int getDecoderColorspace() override; + virtual int getDecoderColorRange() override; virtual QSize getDecoderMaxResolution() override; virtual int submitDecodeUnit(PDECODE_UNIT du) override; virtual void renderFrameOnMainThread() override; diff --git a/app/streaming/video/slvid.cpp b/app/streaming/video/slvid.cpp index f270ba64..5008847e 100644 --- a/app/streaming/video/slvid.cpp +++ b/app/streaming/video/slvid.cpp @@ -68,6 +68,12 @@ SLVideoDecoder::getDecoderColorspace() return COLORSPACE_REC_709; } +int +SLVideoDecoder::getDecoderColorRange() +{ + return COLOR_RANGE_LIMITED; +} + QSize SLVideoDecoder::getDecoderMaxResolution() { return QSize(1920, 1080); diff --git a/app/streaming/video/slvid.h b/app/streaming/video/slvid.h index acf226ae..e6adea6d 100644 --- a/app/streaming/video/slvid.h +++ b/app/streaming/video/slvid.h @@ -15,6 +15,7 @@ public: virtual bool isAlwaysFullScreen() override; virtual int getDecoderCapabilities() override; virtual int getDecoderColorspace() override; + virtual int getDecoderColorRange() override; virtual QSize getDecoderMaxResolution() override; virtual int submitDecodeUnit(PDECODE_UNIT du) override; virtual void notifyOverlayUpdated(Overlay::OverlayType) override;