Add reference frame invalidation for the software decoder

This commit is contained in:
Cameron Gutman 2018-08-25 12:38:04 -07:00
parent 55f0e1e1d5
commit 9be9934b8c
14 changed files with 46 additions and 0 deletions

View file

@ -19,6 +19,7 @@ public:
int frameRate,
bool enableVsync) = 0;
virtual bool isHardwareAccelerated() = 0;
virtual int getDecoderCapabilities() = 0;
virtual int submitDecodeUnit(PDECODE_UNIT du) = 0;
virtual void renderFrame(SDL_UserEvent* event) = 0;
virtual void dropFrame(SDL_UserEvent* event) = 0;

View file

@ -619,6 +619,11 @@ bool DXVA2Renderer::needsTestFrame()
return false;
}
int DXVA2Renderer::getDecoderCapabilities()
{
return 0;
}
void DXVA2Renderer::renderFrameAtVsync(AVFrame *frame)
{
IDirect3DSurface9* surface = reinterpret_cast<IDirect3DSurface9*>(frame->data[3]);

View file

@ -24,6 +24,7 @@ public:
virtual bool prepareDecoderContext(AVCodecContext* context);
virtual void renderFrameAtVsync(AVFrame* frame);
virtual bool needsTestFrame();
virtual int getDecoderCapabilities();
private:
bool initializeDecoder();

View file

@ -18,6 +18,7 @@ public:
virtual bool prepareDecoderContext(AVCodecContext* context) = 0;
virtual void renderFrameAtVsync(AVFrame* frame) = 0;
virtual bool needsTestFrame() = 0;
virtual int getDecoderCapabilities() = 0;
};
class SdlRenderer : public IFFmpegRenderer {
@ -33,6 +34,7 @@ public:
virtual bool prepareDecoderContext(AVCodecContext* context);
virtual void renderFrameAtVsync(AVFrame* frame);
virtual bool needsTestFrame();
virtual int getDecoderCapabilities();
private:
SDL_Renderer* m_Renderer;

View file

@ -36,6 +36,12 @@ bool SdlRenderer::needsTestFrame()
return false;
}
int SdlRenderer::getDecoderCapabilities()
{
// The FFmpeg CPU decoder can handle reference frame invalidation
return CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC | CAPABILITY_REFERENCE_FRAME_INVALIDATION_HEVC;
}
bool SdlRenderer::initialize(SDL_Window* window,
int,
int width,

View file

@ -149,6 +149,12 @@ VAAPIRenderer::needsTestFrame()
return true;
}
int
VAAPIRenderer::getDecoderCapabilities()
{
return 0;
}
void
VAAPIRenderer::renderFrameAtVsync(AVFrame* frame)
{

View file

@ -39,6 +39,7 @@ public:
virtual bool prepareDecoderContext(AVCodecContext* context);
virtual void renderFrameAtVsync(AVFrame* frame);
virtual bool needsTestFrame();
virtual int getDecoderCapabilities();
private:
int m_WindowSystem;

View file

@ -230,6 +230,11 @@ bool VDPAURenderer::needsTestFrame()
return true;
}
int VDPAURenderer::getDecoderCapabilities()
{
return 0;
}
void VDPAURenderer::renderFrameAtVsync(AVFrame* frame)
{
VdpStatus status;

View file

@ -22,6 +22,7 @@ public:
virtual bool prepareDecoderContext(AVCodecContext* context);
virtual void renderFrameAtVsync(AVFrame* frame);
virtual bool needsTestFrame();
virtual int getDecoderCapabilities();
private:
uint32_t m_VideoWidth, m_VideoHeight;

View file

@ -196,6 +196,11 @@ public:
return false;
}
virtual int getDecoderCapabilities() override
{
return 0;
}
private:
void setupDisplayLayer()
{

View file

@ -27,6 +27,11 @@ bool FFmpegVideoDecoder::isHardwareAccelerated()
return m_HwDecodeCfg != nullptr;
}
int FFmpegVideoDecoder::getDecoderCapabilities()
{
return m_Renderer->getDecoderCapabilities();
}
enum AVPixelFormat FFmpegVideoDecoder::ffGetFormat(AVCodecContext* context,
const enum AVPixelFormat* pixFmts)
{

View file

@ -20,6 +20,7 @@ public:
int maxFps,
bool enableVsync) override;
virtual bool isHardwareAccelerated() override;
virtual int getDecoderCapabilities() override;
virtual int submitDecodeUnit(PDECODE_UNIT du) override;
virtual void renderFrame(SDL_UserEvent* event) override;
virtual void dropFrame(SDL_UserEvent* event) override;

View file

@ -25,6 +25,12 @@ SLVideoDecoder::isHardwareAccelerated()
return true;
}
int
SLVideoDecoder::getDecoderCapabilities()
{
return 0;
}
bool
SLVideoDecoder::initialize(StreamingPreferences::VideoDecoderSelection vds,
SDL_Window*,

View file

@ -17,6 +17,7 @@ public:
int frameRate,
bool enableVsync);
virtual bool isHardwareAccelerated();
virtual int getDecoderCapabilities();
virtual int submitDecodeUnit(PDECODE_UNIT du);
// Unused since rendering is done directly from the decode thread