Use Rec 2020 colorspace for WCG support even if HDR is off on the host

This commit is contained in:
Cameron Gutman 2022-10-13 00:14:10 -05:00
parent c55af7fff3
commit 472e8ee92e
15 changed files with 21 additions and 17 deletions

View file

@ -415,8 +415,12 @@ bool Session::populateDecoderProperties(SDL_Window* window)
"Using colorspace override: %d", "Using colorspace override: %d",
m_StreamConfig.colorSpace); m_StreamConfig.colorSpace);
} }
else if (!m_StreamConfig.enableHdr) {
m_StreamConfig.colorSpace = decoder->getDecoderSdrColorspace();
}
else { else {
m_StreamConfig.colorSpace = decoder->getDecoderColorspace(); // In HDR mode, we opt for Rec 2020 for WCG displays
m_StreamConfig.colorSpace = COLORSPACE_REC_2020;
} }
m_StreamConfig.colorRange = qEnvironmentVariableIntValue("COLOR_RANGE_OVERRIDE", &ok); m_StreamConfig.colorRange = qEnvironmentVariableIntValue("COLOR_RANGE_OVERRIDE", &ok);

View file

@ -67,7 +67,7 @@ public:
virtual bool isAlwaysFullScreen() = 0; virtual bool isAlwaysFullScreen() = 0;
virtual bool isHdrSupported() = 0; virtual bool isHdrSupported() = 0;
virtual int getDecoderCapabilities() = 0; virtual int getDecoderCapabilities() = 0;
virtual int getDecoderColorspace() = 0; virtual int getDecoderSdrColorspace() = 0;
virtual int getDecoderColorRange() = 0; virtual int getDecoderColorRange() = 0;
virtual QSize getDecoderMaxResolution() = 0; virtual QSize getDecoderMaxResolution() = 0;
virtual int submitDecodeUnit(PDECODE_UNIT du) = 0; virtual int submitDecodeUnit(PDECODE_UNIT du) = 0;

View file

@ -989,7 +989,7 @@ Exit:
overlayVertexBuffer->Release(); overlayVertexBuffer->Release();
} }
int DXVA2Renderer::getDecoderColorspace() int DXVA2Renderer::getDecoderSdrColorspace()
{ {
if (m_DeviceQuirks & DXVA2_QUIRK_NO_VP) { if (m_DeviceQuirks & DXVA2_QUIRK_NO_VP) {
// StretchRect() assumes Rec 601 on Intel and Qualcomm GPUs. // StretchRect() assumes Rec 601 on Intel and Qualcomm GPUs.

View file

@ -19,7 +19,7 @@ public:
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override; virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
virtual void renderFrame(AVFrame* frame) override; virtual void renderFrame(AVFrame* frame) override;
virtual void notifyOverlayUpdated(Overlay::OverlayType type) override; virtual void notifyOverlayUpdated(Overlay::OverlayType type) override;
virtual int getDecoderColorspace() override; virtual int getDecoderSdrColorspace() override;
virtual int getDecoderCapabilities() override; virtual int getDecoderCapabilities() override;
private: private:

View file

@ -210,7 +210,7 @@ bool MmalRenderer::initialize(PDECODER_PARAMETERS params)
return true; return true;
} }
int MmalRenderer::getDecoderColorspace() int MmalRenderer::getDecoderSdrColorspace()
{ {
// MMAL seems to always use Rec. 709 colorspace for rendering // MMAL seems to always use Rec. 709 colorspace for rendering
// even when we try to set something else in the input format. // even when we try to set something else in the input format.

View file

@ -17,7 +17,7 @@ public:
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override; virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
virtual bool needsTestFrame() override; virtual bool needsTestFrame() override;
virtual int getRendererAttributes() override; virtual int getRendererAttributes() override;
virtual int getDecoderColorspace() override; virtual int getDecoderSdrColorspace() override;
private: private:
static void InputPortCallback(MMAL_PORT_T* port, MMAL_BUFFER_HEADER_T* buffer); static void InputPortCallback(MMAL_PORT_T* port, MMAL_BUFFER_HEADER_T* buffer);

View file

@ -153,7 +153,7 @@ public:
return 0; return 0;
} }
virtual int getDecoderColorspace() { virtual int getDecoderSdrColorspace() {
// Rec 601 is default // Rec 601 is default
return COLORSPACE_REC_601; return COLORSPACE_REC_601;
} }
@ -177,7 +177,7 @@ public:
default: default:
// If the colorspace is not populated, assume the encoder // If the colorspace is not populated, assume the encoder
// is sending the colorspace that we requested. // is sending the colorspace that we requested.
return getDecoderColorspace(); return getDecoderSdrColorspace();
} }
} }

View file

@ -470,7 +470,7 @@ VAAPIRenderer::isDirectRenderingSupported()
return false; return false;
} }
int VAAPIRenderer::getDecoderColorspace() int VAAPIRenderer::getDecoderSdrColorspace()
{ {
// Gallium drivers don't support Rec 709 yet - https://gitlab.freedesktop.org/mesa/mesa/issues/1915 // Gallium drivers don't support Rec 709 yet - https://gitlab.freedesktop.org/mesa/mesa/issues/1915
// Intel-vaapi-driver defaults to Rec 601 - https://github.com/intel/intel-vaapi-driver/blob/021bcb79d1bd873bbd9fbca55f40320344bab866/src/i965_output_dri.c#L186 // Intel-vaapi-driver defaults to Rec 601 - https://github.com/intel/intel-vaapi-driver/blob/021bcb79d1bd873bbd9fbca55f40320344bab866/src/i965_output_dri.c#L186

View file

@ -41,7 +41,7 @@ public:
virtual void renderFrame(AVFrame* frame) override; virtual void renderFrame(AVFrame* frame) override;
virtual bool needsTestFrame() override; virtual bool needsTestFrame() override;
virtual bool isDirectRenderingSupported() override; virtual bool isDirectRenderingSupported() override;
virtual int getDecoderColorspace() override; virtual int getDecoderSdrColorspace() override;
virtual int getDecoderCapabilities() override; virtual int getDecoderCapabilities() override;
virtual void notifyOverlayUpdated(Overlay::OverlayType) override; virtual void notifyOverlayUpdated(Overlay::OverlayType) override;

View file

@ -428,7 +428,7 @@ bool VDPAURenderer::needsTestFrame()
return true; return true;
} }
int VDPAURenderer::getDecoderColorspace() int VDPAURenderer::getDecoderSdrColorspace()
{ {
// VDPAU defaults to Rec 601. // VDPAU defaults to Rec 601.
// https://http.download.nvidia.com/XFree86/vdpau/doxygen/html/group___vdp_video_mixer.html#ga65580813e9045d94b739ed2bb8b62b46 // https://http.download.nvidia.com/XFree86/vdpau/doxygen/html/group___vdp_video_mixer.html#ga65580813e9045d94b739ed2bb8b62b46

View file

@ -19,7 +19,7 @@ public:
virtual void waitToRender() override; virtual void waitToRender() override;
virtual void renderFrame(AVFrame* frame) override; virtual void renderFrame(AVFrame* frame) override;
virtual bool needsTestFrame() override; virtual bool needsTestFrame() override;
virtual int getDecoderColorspace() override; virtual int getDecoderSdrColorspace() override;
virtual int getDecoderCapabilities() override; virtual int getDecoderCapabilities() override;
private: private:

View file

@ -87,9 +87,9 @@ int FFmpegVideoDecoder::getDecoderCapabilities()
return capabilities; return capabilities;
} }
int FFmpegVideoDecoder::getDecoderColorspace() int FFmpegVideoDecoder::getDecoderSdrColorspace()
{ {
return m_FrontendRenderer->getDecoderColorspace(); return m_FrontendRenderer->getDecoderSdrColorspace();
} }
int FFmpegVideoDecoder::getDecoderColorRange() int FFmpegVideoDecoder::getDecoderColorRange()

View file

@ -20,7 +20,7 @@ public:
virtual bool isAlwaysFullScreen() override; virtual bool isAlwaysFullScreen() override;
virtual bool isHdrSupported() override; virtual bool isHdrSupported() override;
virtual int getDecoderCapabilities() override; virtual int getDecoderCapabilities() override;
virtual int getDecoderColorspace() override; virtual int getDecoderSdrColorspace() override;
virtual int getDecoderColorRange() override; virtual int getDecoderColorRange() override;
virtual QSize getDecoderMaxResolution() override; virtual QSize getDecoderMaxResolution() override;
virtual int submitDecodeUnit(PDECODE_UNIT du) override; virtual int submitDecodeUnit(PDECODE_UNIT du) override;

View file

@ -63,7 +63,7 @@ SLVideoDecoder::getDecoderCapabilities()
} }
int int
SLVideoDecoder::getDecoderColorspace() SLVideoDecoder::getDecoderSdrColorspace()
{ {
return COLORSPACE_REC_709; return COLORSPACE_REC_709;
} }

View file

@ -14,7 +14,7 @@ public:
virtual bool isHardwareAccelerated() override; virtual bool isHardwareAccelerated() override;
virtual bool isAlwaysFullScreen() override; virtual bool isAlwaysFullScreen() override;
virtual int getDecoderCapabilities() override; virtual int getDecoderCapabilities() override;
virtual int getDecoderColorspace() override; virtual int getDecoderSdrColorspace() override;
virtual int getDecoderColorRange() override; virtual int getDecoderColorRange() override;
virtual QSize getDecoderMaxResolution() override; virtual QSize getDecoderMaxResolution() override;
virtual int submitDecodeUnit(PDECODE_UNIT du) override; virtual int submitDecodeUnit(PDECODE_UNIT du) override;