From 160684f23e5b383cdaec67c7fb2c92ed60004197 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 14 Dec 2019 15:25:56 -0800 Subject: [PATCH] Allow decoders to choose a desired colorspace --- app/streaming/session.cpp | 2 ++ 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, 21 insertions(+) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index b4a8eb8f..0f7e9604 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -284,6 +284,8 @@ bool Session::populateDecoderProperties(SDL_Window* window) m_VideoCallbacks.capabilities |= decoder->getDecoderCapabilities(); + m_StreamConfig.colorSpace = decoder->getDecoderColorspace(); + delete decoder; return true; diff --git a/app/streaming/video/decoder.h b/app/streaming/video/decoder.h index 81565faf..b0a6ba03 100644 --- a/app/streaming/video/decoder.h +++ b/app/streaming/video/decoder.h @@ -44,6 +44,7 @@ public: virtual bool initialize(PDECODER_PARAMETERS params) = 0; virtual bool isHardwareAccelerated() = 0; virtual int getDecoderCapabilities() = 0; + virtual int getDecoderColorspace() = 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 0580c81f..2c13e678 100644 --- a/app/streaming/video/ffmpeg-renderers/renderer.h +++ b/app/streaming/video/ffmpeg-renderers/renderer.h @@ -31,6 +31,11 @@ public: return 0; } + virtual int getDecoderColorspace() { + // Rec 601 is default + return COLORSPACE_REC_601; + } + virtual FramePacingConstraint getFramePacingConstraint() { // No pacing preference return PACING_ANY; diff --git a/app/streaming/video/ffmpeg.cpp b/app/streaming/video/ffmpeg.cpp index a4cf96bf..53daac75 100644 --- a/app/streaming/video/ffmpeg.cpp +++ b/app/streaming/video/ffmpeg.cpp @@ -50,6 +50,11 @@ int FFmpegVideoDecoder::getDecoderCapabilities() return m_BackendRenderer->getDecoderCapabilities(); } +int FFmpegVideoDecoder::getDecoderColorspace() +{ + return m_FrontendRenderer->getDecoderColorspace(); +} + enum AVPixelFormat FFmpegVideoDecoder::ffGetFormat(AVCodecContext* context, const enum AVPixelFormat* pixFmts) { diff --git a/app/streaming/video/ffmpeg.h b/app/streaming/video/ffmpeg.h index 4a3319c0..655ff25c 100644 --- a/app/streaming/video/ffmpeg.h +++ b/app/streaming/video/ffmpeg.h @@ -17,6 +17,7 @@ public: virtual bool initialize(PDECODER_PARAMETERS params) override; virtual bool isHardwareAccelerated() override; virtual int getDecoderCapabilities() override; + virtual int getDecoderColorspace() 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 65f2e439..b0d05393 100644 --- a/app/streaming/video/slvid.cpp +++ b/app/streaming/video/slvid.cpp @@ -31,6 +31,12 @@ SLVideoDecoder::getDecoderCapabilities() return 0; } +int +SLVideoDecoder::getDecoderColorspace() +{ + return COLORSPACE_REC_709; +} + bool SLVideoDecoder::initialize(PDECODER_PARAMETERS params) { diff --git a/app/streaming/video/slvid.h b/app/streaming/video/slvid.h index 38490574..dc6796d0 100644 --- a/app/streaming/video/slvid.h +++ b/app/streaming/video/slvid.h @@ -12,6 +12,7 @@ public: virtual bool initialize(PDECODER_PARAMETERS params); virtual bool isHardwareAccelerated(); virtual int getDecoderCapabilities(); + virtual int getDecoderColorspace(); virtual int submitDecodeUnit(PDECODE_UNIT du); // Unused since rendering is done directly from the decode thread