mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 14:11:33 +00:00
Fix decoder reinitialization after test frame
This commit is contained in:
@@ -164,6 +164,31 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, int videoForma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IFFmpegRenderer* FFmpegVideoDecoder::createAcceleratedRenderer(const AVCodecHWConfig* hwDecodeCfg)
|
||||||
|
{
|
||||||
|
if (!(hwDecodeCfg->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for acceleration types we support
|
||||||
|
switch (hwDecodeCfg->device_type) {
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
case AV_HWDEVICE_TYPE_DXVA2:
|
||||||
|
return new DXVA2Renderer();
|
||||||
|
#endif
|
||||||
|
#ifdef Q_OS_DARWIN
|
||||||
|
case AV_HWDEVICE_TYPE_VIDEOTOOLBOX:
|
||||||
|
return VTRendererFactory::createRenderer();
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LIBVA
|
||||||
|
case AV_HWDEVICE_TYPE_VAAPI:
|
||||||
|
return new VAAPIRenderer();
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool FFmpegVideoDecoder::initialize(
|
bool FFmpegVideoDecoder::initialize(
|
||||||
StreamingPreferences::VideoDecoderSelection vds,
|
StreamingPreferences::VideoDecoderSelection vds,
|
||||||
SDL_Window* window,
|
SDL_Window* window,
|
||||||
@@ -210,28 +235,8 @@ bool FFmpegVideoDecoder::initialize(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)) {
|
m_Renderer = createAcceleratedRenderer(config);
|
||||||
continue;
|
if (!m_Renderer) {
|
||||||
}
|
|
||||||
|
|
||||||
// Look for acceleration types we support
|
|
||||||
switch (config->device_type) {
|
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
case AV_HWDEVICE_TYPE_DXVA2:
|
|
||||||
m_Renderer = new DXVA2Renderer();
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_DARWIN
|
|
||||||
case AV_HWDEVICE_TYPE_VIDEOTOOLBOX:
|
|
||||||
m_Renderer = VTRendererFactory::createRenderer();
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LIBVA
|
|
||||||
case AV_HWDEVICE_TYPE_VAAPI:
|
|
||||||
m_Renderer = new VAAPIRenderer();
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +245,9 @@ bool FFmpegVideoDecoder::initialize(
|
|||||||
if (m_Renderer->initialize(window, videoFormat, width, height) &&
|
if (m_Renderer->initialize(window, videoFormat, width, height) &&
|
||||||
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
|
||||||
if (m_Renderer->initialize(window, videoFormat, width, height) &&
|
reset();
|
||||||
|
if ((m_Renderer = createAcceleratedRenderer(config)) != nullptr &&
|
||||||
|
m_Renderer->initialize(window, videoFormat, width, height) &&
|
||||||
completeInitialization(decoder, videoFormat, width, height, false)) {
|
completeInitialization(decoder, videoFormat, width, height, false)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool completeInitialization(AVCodec* decoder, int videoFormat, int width, int height, bool testOnly);
|
bool completeInitialization(AVCodec* decoder, int videoFormat, int width, int height, bool testOnly);
|
||||||
|
|
||||||
|
IFFmpegRenderer* createAcceleratedRenderer(const AVCodecHWConfig* hwDecodeCfg);
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|||||||
Reference in New Issue
Block a user