mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-03 08:15:37 +00:00
Reduce code duplication in renderers
This commit is contained in:
parent
25e5175c54
commit
ada2270bd1
@ -704,23 +704,6 @@ bool DXVA2Renderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DXVA2Renderer::needsTestFrame()
|
|
||||||
{
|
|
||||||
// We validate the DXVA2 profiles are supported
|
|
||||||
// in initialize() so no test frame is required
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DXVA2Renderer::getDecoderCapabilities()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
IFFmpegRenderer::FramePacingConstraint DXVA2Renderer::getFramePacingConstraint()
|
|
||||||
{
|
|
||||||
return PACING_ANY;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DXVA2Renderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
void DXVA2Renderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@ -779,12 +762,6 @@ void DXVA2Renderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DXVA2Renderer::isRenderThreadSupported()
|
|
||||||
{
|
|
||||||
// renderFrame() may be called outside of the main thread
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DXVA2Renderer::renderFrame(AVFrame *frame)
|
void DXVA2Renderer::renderFrame(AVFrame *frame)
|
||||||
{
|
{
|
||||||
IDirect3DSurface9* surface = reinterpret_cast<IDirect3DSurface9*>(frame->data[3]);
|
IDirect3DSurface9* surface = reinterpret_cast<IDirect3DSurface9*>(frame->data[3]);
|
||||||
|
@ -15,15 +15,11 @@ class DXVA2Renderer : public IFFmpegRenderer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DXVA2Renderer();
|
DXVA2Renderer();
|
||||||
virtual ~DXVA2Renderer();
|
virtual ~DXVA2Renderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual bool needsTestFrame() override;
|
|
||||||
virtual int getDecoderCapabilities() override;
|
|
||||||
virtual FramePacingConstraint getFramePacingConstraint() override;
|
|
||||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
||||||
virtual bool isRenderThreadSupported() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool initializeDecoder();
|
bool initializeDecoder();
|
||||||
|
@ -20,10 +20,26 @@ public:
|
|||||||
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) = 0;
|
virtual bool prepareDecoderContext(AVCodecContext* context) = 0;
|
||||||
virtual void renderFrame(AVFrame* frame) = 0;
|
virtual void renderFrame(AVFrame* frame) = 0;
|
||||||
virtual bool needsTestFrame() = 0;
|
|
||||||
virtual int getDecoderCapabilities() = 0;
|
virtual bool needsTestFrame() {
|
||||||
virtual FramePacingConstraint getFramePacingConstraint() = 0;
|
// No test frame required by default
|
||||||
virtual bool isRenderThreadSupported() = 0;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int getDecoderCapabilities() {
|
||||||
|
// No special capabilities by default
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual FramePacingConstraint getFramePacingConstraint() {
|
||||||
|
// No pacing preference
|
||||||
|
return PACING_ANY;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isRenderThreadSupported() {
|
||||||
|
// Render thread is supported by default
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// IOverlayRenderer
|
// IOverlayRenderer
|
||||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override {
|
virtual void notifyOverlayUpdated(Overlay::OverlayType) override {
|
||||||
|
@ -67,12 +67,6 @@ bool SdlRenderer::prepareDecoderContext(AVCodecContext*)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SdlRenderer::needsTestFrame()
|
|
||||||
{
|
|
||||||
// This renderer should always work
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SdlRenderer::getDecoderCapabilities()
|
int SdlRenderer::getDecoderCapabilities()
|
||||||
{
|
{
|
||||||
// The FFmpeg CPU decoder can handle reference frame invalidation,
|
// The FFmpeg CPU decoder can handle reference frame invalidation,
|
||||||
@ -80,11 +74,6 @@ int SdlRenderer::getDecoderCapabilities()
|
|||||||
return CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC;
|
return CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFFmpegRenderer::FramePacingConstraint SdlRenderer::getFramePacingConstraint()
|
|
||||||
{
|
|
||||||
return PACING_ANY;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SdlRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
void SdlRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||||
{
|
{
|
||||||
// Construct the required font to render the overlay
|
// Construct the required font to render the overlay
|
||||||
|
@ -11,9 +11,7 @@ public:
|
|||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual bool needsTestFrame() override;
|
|
||||||
virtual int getDecoderCapabilities() override;
|
virtual int getDecoderCapabilities() override;
|
||||||
virtual FramePacingConstraint getFramePacingConstraint() override;
|
|
||||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
||||||
virtual bool isRenderThreadSupported() override;
|
virtual bool isRenderThreadSupported() override;
|
||||||
|
|
||||||
|
@ -171,23 +171,6 @@ VAAPIRenderer::needsTestFrame()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
VAAPIRenderer::getDecoderCapabilities()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
IFFmpegRenderer::FramePacingConstraint VAAPIRenderer::getFramePacingConstraint()
|
|
||||||
{
|
|
||||||
return PACING_ANY;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VAAPIRenderer::isRenderThreadSupported()
|
|
||||||
{
|
|
||||||
// renderFrame() may be called outside of the main thread
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VAAPIRenderer::renderFrame(AVFrame* frame)
|
VAAPIRenderer::renderFrame(AVFrame* frame)
|
||||||
{
|
{
|
||||||
|
@ -29,14 +29,11 @@ class VAAPIRenderer : public IFFmpegRenderer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VAAPIRenderer();
|
VAAPIRenderer();
|
||||||
virtual ~VAAPIRenderer();
|
virtual ~VAAPIRenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params);
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context);
|
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||||
virtual void renderFrame(AVFrame* frame);
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual bool needsTestFrame();
|
virtual bool needsTestFrame() override;
|
||||||
virtual int getDecoderCapabilities();
|
|
||||||
virtual FramePacingConstraint getFramePacingConstraint();
|
|
||||||
virtual bool isRenderThreadSupported();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_WindowSystem;
|
int m_WindowSystem;
|
||||||
|
@ -241,22 +241,6 @@ bool VDPAURenderer::needsTestFrame()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VDPAURenderer::getDecoderCapabilities()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
IFFmpegRenderer::FramePacingConstraint VDPAURenderer::getFramePacingConstraint()
|
|
||||||
{
|
|
||||||
return PACING_ANY;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VDPAURenderer::isRenderThreadSupported()
|
|
||||||
{
|
|
||||||
// renderFrame() may be called outside of the main thread
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VDPAURenderer::renderFrame(AVFrame* frame)
|
void VDPAURenderer::renderFrame(AVFrame* frame)
|
||||||
{
|
{
|
||||||
VdpStatus status;
|
VdpStatus status;
|
||||||
|
@ -12,14 +12,11 @@ class VDPAURenderer : public IFFmpegRenderer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VDPAURenderer();
|
VDPAURenderer();
|
||||||
virtual ~VDPAURenderer();
|
virtual ~VDPAURenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params);
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context);
|
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||||
virtual void renderFrame(AVFrame* frame);
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual bool needsTestFrame();
|
virtual bool needsTestFrame() override;
|
||||||
virtual int getDecoderCapabilities();
|
|
||||||
virtual FramePacingConstraint getFramePacingConstraint();
|
|
||||||
virtual bool isRenderThreadSupported();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t m_VideoWidth, m_VideoHeight;
|
uint32_t m_VideoWidth, m_VideoHeight;
|
||||||
|
@ -278,11 +278,6 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int getDecoderCapabilities() override
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual IFFmpegRenderer::FramePacingConstraint getFramePacingConstraint() override
|
virtual IFFmpegRenderer::FramePacingConstraint getFramePacingConstraint() override
|
||||||
{
|
{
|
||||||
// This renderer is inherently tied to V-sync due how we're
|
// This renderer is inherently tied to V-sync due how we're
|
||||||
@ -291,12 +286,6 @@ public:
|
|||||||
return PACING_FORCE_ON;
|
return PACING_FORCE_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isRenderThreadSupported() override
|
|
||||||
{
|
|
||||||
// renderFrame() may be called outside of the main thread
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AVBufferRef* m_HwContext;
|
AVBufferRef* m_HwContext;
|
||||||
AVSampleBufferDisplayLayer* m_DisplayLayer;
|
AVSampleBufferDisplayLayer* m_DisplayLayer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user