mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-11-10 05:34:17 +00:00
Reduce code duplication in renderers
This commit is contained in:
parent
25e5175c54
commit
ada2270bd1
10 changed files with 31 additions and 105 deletions
|
@ -704,23 +704,6 @@ bool DXVA2Renderer::initialize(PDECODER_PARAMETERS params)
|
|||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
IDirect3DSurface9* surface = reinterpret_cast<IDirect3DSurface9*>(frame->data[3]);
|
||||
|
|
|
@ -15,15 +15,11 @@ class DXVA2Renderer : public IFFmpegRenderer
|
|||
{
|
||||
public:
|
||||
DXVA2Renderer();
|
||||
virtual ~DXVA2Renderer();
|
||||
virtual ~DXVA2Renderer() override;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) 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 bool isRenderThreadSupported() override;
|
||||
|
||||
private:
|
||||
bool initializeDecoder();
|
||||
|
|
|
@ -20,10 +20,26 @@ public:
|
|||
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) = 0;
|
||||
virtual void renderFrame(AVFrame* frame) = 0;
|
||||
virtual bool needsTestFrame() = 0;
|
||||
virtual int getDecoderCapabilities() = 0;
|
||||
virtual FramePacingConstraint getFramePacingConstraint() = 0;
|
||||
virtual bool isRenderThreadSupported() = 0;
|
||||
|
||||
virtual bool needsTestFrame() {
|
||||
// No test frame required by default
|
||||
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
|
||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override {
|
||||
|
|
|
@ -67,12 +67,6 @@ bool SdlRenderer::prepareDecoderContext(AVCodecContext*)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SdlRenderer::needsTestFrame()
|
||||
{
|
||||
// This renderer should always work
|
||||
return false;
|
||||
}
|
||||
|
||||
int SdlRenderer::getDecoderCapabilities()
|
||||
{
|
||||
// The FFmpeg CPU decoder can handle reference frame invalidation,
|
||||
|
@ -80,11 +74,6 @@ int SdlRenderer::getDecoderCapabilities()
|
|||
return CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC;
|
||||
}
|
||||
|
||||
IFFmpegRenderer::FramePacingConstraint SdlRenderer::getFramePacingConstraint()
|
||||
{
|
||||
return PACING_ANY;
|
||||
}
|
||||
|
||||
void SdlRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
{
|
||||
// Construct the required font to render the overlay
|
||||
|
|
|
@ -11,9 +11,7 @@ public:
|
|||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) 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 bool isRenderThreadSupported() override;
|
||||
|
||||
|
|
|
@ -171,23 +171,6 @@ VAAPIRenderer::needsTestFrame()
|
|||
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
|
||||
VAAPIRenderer::renderFrame(AVFrame* frame)
|
||||
{
|
||||
|
|
|
@ -29,14 +29,11 @@ class VAAPIRenderer : public IFFmpegRenderer
|
|||
{
|
||||
public:
|
||||
VAAPIRenderer();
|
||||
virtual ~VAAPIRenderer();
|
||||
virtual bool initialize(PDECODER_PARAMETERS params);
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context);
|
||||
virtual void renderFrame(AVFrame* frame);
|
||||
virtual bool needsTestFrame();
|
||||
virtual int getDecoderCapabilities();
|
||||
virtual FramePacingConstraint getFramePacingConstraint();
|
||||
virtual bool isRenderThreadSupported();
|
||||
virtual ~VAAPIRenderer() override;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||
virtual void renderFrame(AVFrame* frame) override;
|
||||
virtual bool needsTestFrame() override;
|
||||
|
||||
private:
|
||||
int m_WindowSystem;
|
||||
|
|
|
@ -241,22 +241,6 @@ bool VDPAURenderer::needsTestFrame()
|
|||
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)
|
||||
{
|
||||
VdpStatus status;
|
||||
|
|
|
@ -12,14 +12,11 @@ class VDPAURenderer : public IFFmpegRenderer
|
|||
{
|
||||
public:
|
||||
VDPAURenderer();
|
||||
virtual ~VDPAURenderer();
|
||||
virtual bool initialize(PDECODER_PARAMETERS params);
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context);
|
||||
virtual void renderFrame(AVFrame* frame);
|
||||
virtual bool needsTestFrame();
|
||||
virtual int getDecoderCapabilities();
|
||||
virtual FramePacingConstraint getFramePacingConstraint();
|
||||
virtual bool isRenderThreadSupported();
|
||||
virtual ~VDPAURenderer() override;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||
virtual void renderFrame(AVFrame* frame) override;
|
||||
virtual bool needsTestFrame() override;
|
||||
|
||||
private:
|
||||
uint32_t m_VideoWidth, m_VideoHeight;
|
||||
|
|
|
@ -278,11 +278,6 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
virtual int getDecoderCapabilities() override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual IFFmpegRenderer::FramePacingConstraint getFramePacingConstraint() override
|
||||
{
|
||||
// This renderer is inherently tied to V-sync due how we're
|
||||
|
@ -291,12 +286,6 @@ public:
|
|||
return PACING_FORCE_ON;
|
||||
}
|
||||
|
||||
virtual bool isRenderThreadSupported() override
|
||||
{
|
||||
// renderFrame() may be called outside of the main thread
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
AVBufferRef* m_HwContext;
|
||||
AVSampleBufferDisplayLayer* m_DisplayLayer;
|
||||
|
|
Loading…
Reference in a new issue