Pass the maximum frame rate into FFmpeg renderers

This commit is contained in:
Cameron Gutman
2018-08-15 20:41:19 -07:00
parent e467ce7ce8
commit f171588616
11 changed files with 21 additions and 14 deletions
@@ -430,7 +430,7 @@ bool DXVA2Renderer::isDecoderBlacklisted()
return result; return result;
} }
bool DXVA2Renderer::initialize(SDL_Window* window, int videoFormat, int width, int height) bool DXVA2Renderer::initialize(SDL_Window* window, int videoFormat, int width, int height, int)
{ {
m_VideoFormat = videoFormat; m_VideoFormat = videoFormat;
m_VideoWidth = width; m_VideoWidth = width;
+2 -1
View File
@@ -17,7 +17,8 @@ public:
virtual bool initialize(SDL_Window* window, virtual bool initialize(SDL_Window* window,
int videoFormat, int videoFormat,
int width, int width,
int height); int height,
int maxFps);
virtual bool prepareDecoderContext(AVCodecContext* context); virtual bool prepareDecoderContext(AVCodecContext* context);
virtual void renderFrame(AVFrame* frame); virtual void renderFrame(AVFrame* frame);
@@ -12,7 +12,8 @@ public:
virtual bool initialize(SDL_Window* window, virtual bool initialize(SDL_Window* window,
int videoFormat, int videoFormat,
int width, int width,
int height) = 0; int height,
int maxFps) = 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;
}; };
@@ -24,7 +25,8 @@ public:
virtual bool initialize(SDL_Window* window, virtual bool initialize(SDL_Window* window,
int videoFormat, int videoFormat,
int width, int width,
int height); int height,
int maxFps);
virtual bool prepareDecoderContext(AVCodecContext* context); virtual bool prepareDecoderContext(AVCodecContext* context);
virtual void renderFrame(AVFrame* frame); virtual void renderFrame(AVFrame* frame);
+2 -1
View File
@@ -33,7 +33,8 @@ bool SdlRenderer::prepareDecoderContext(AVCodecContext*)
bool SdlRenderer::initialize(SDL_Window* window, bool SdlRenderer::initialize(SDL_Window* window,
int, int,
int width, int width,
int height) int height,
int)
{ {
m_Renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); m_Renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if (!m_Renderer) { if (!m_Renderer) {
@@ -27,7 +27,7 @@ VAAPIRenderer::~VAAPIRenderer()
} }
bool bool
VAAPIRenderer::initialize(SDL_Window* window, int, int width, int height) VAAPIRenderer::initialize(SDL_Window* window, int, int width, int height, int)
{ {
int err; int err;
SDL_SysWMinfo info; SDL_SysWMinfo info;
+2 -1
View File
@@ -33,7 +33,8 @@ public:
virtual bool initialize(SDL_Window* window, virtual bool initialize(SDL_Window* window,
int videoFormat, int videoFormat,
int width, int width,
int height); int height,
int maxFps);
virtual bool prepareDecoderContext(AVCodecContext* context); virtual bool prepareDecoderContext(AVCodecContext* context);
virtual void renderFrame(AVFrame* frame); virtual void renderFrame(AVFrame* frame);
@@ -54,7 +54,7 @@ VDPAURenderer::~VDPAURenderer()
} }
} }
bool VDPAURenderer::initialize(SDL_Window* window, int, int width, int height) bool VDPAURenderer::initialize(SDL_Window* window, int, int width, int height, int)
{ {
int err; int err;
VdpStatus status; VdpStatus status;
+2 -1
View File
@@ -16,7 +16,8 @@ public:
virtual bool initialize(SDL_Window* window, virtual bool initialize(SDL_Window* window,
int videoFormat, int videoFormat,
int width, int width,
int height); int height,
int maxFps);
virtual bool prepareDecoderContext(AVCodecContext* context); virtual bool prepareDecoderContext(AVCodecContext* context);
virtual void renderFrame(AVFrame* frame); virtual void renderFrame(AVFrame* frame);
@@ -130,6 +130,7 @@ public:
virtual bool initialize(SDL_Window* window, virtual bool initialize(SDL_Window* window,
int videoFormat, int videoFormat,
int, int,
int,
int) override int) override
{ {
int err; int err;
+4 -4
View File
@@ -218,7 +218,7 @@ bool FFmpegVideoDecoder::initialize(
int videoFormat, int videoFormat,
int width, int width,
int height, int height,
int) int maxFps)
{ {
AVCodec* decoder; AVCodec* decoder;
@@ -253,7 +253,7 @@ bool FFmpegVideoDecoder::initialize(
m_HwDecodeCfg = nullptr; m_HwDecodeCfg = nullptr;
m_Renderer = new SdlRenderer(); m_Renderer = new SdlRenderer();
if (vds != StreamingPreferences::VDS_FORCE_HARDWARE && if (vds != StreamingPreferences::VDS_FORCE_HARDWARE &&
m_Renderer->initialize(window, videoFormat, width, height) && m_Renderer->initialize(window, videoFormat, width, height, maxFps) &&
completeInitialization(decoder, videoFormat, width, height, false)) { completeInitialization(decoder, videoFormat, width, height, false)) {
return true; return true;
} }
@@ -270,12 +270,12 @@ bool FFmpegVideoDecoder::initialize(
m_HwDecodeCfg = config; m_HwDecodeCfg = config;
// Submit test frame to ensure this codec really works // Submit test frame to ensure this codec really works
if (m_Renderer->initialize(window, videoFormat, width, height) && if (m_Renderer->initialize(window, videoFormat, width, height, maxFps) &&
completeInitialization(decoder, videoFormat, width, height, true)) { completeInitialization(decoder, videoFormat, width, height, true)) {
// OK, it worked, so now let's initialize it for real // OK, it worked, so now let's initialize it for real
reset(); reset();
if ((m_Renderer = createAcceleratedRenderer(config)) != nullptr && if ((m_Renderer = createAcceleratedRenderer(config)) != nullptr &&
m_Renderer->initialize(window, videoFormat, width, height) && m_Renderer->initialize(window, videoFormat, width, height, maxFps) &&
completeInitialization(decoder, videoFormat, width, height, false)) { completeInitialization(decoder, videoFormat, width, height, false)) {
return true; return true;
} }
+1 -1
View File
@@ -16,7 +16,7 @@ public:
int videoFormat, int videoFormat,
int width, int width,
int height, int height,
int frameRate) override; int maxFps) override;
virtual bool isHardwareAccelerated() override; virtual bool isHardwareAccelerated() override;
virtual int submitDecodeUnit(PDECODE_UNIT du) override; virtual int submitDecodeUnit(PDECODE_UNIT du) override;
virtual void renderFrame(SDL_UserEvent* event) override; virtual void renderFrame(SDL_UserEvent* event) override;