mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2025-01-18 22:13:53 +00:00
Handle custom hwaccel decoders
This commit is contained in:
parent
4dffac3c78
commit
d63a1b0eb0
1 changed files with 21 additions and 1 deletions
|
@ -599,6 +599,9 @@ bool FFmpegVideoDecoder::tryInitializeRenderer(AVCodec* decoder,
|
|||
if (renderer.getPreferredPixelFormat(params->videoFormat) == decoder->pix_fmts[i]) { \
|
||||
if (tryInitializeRenderer(decoder, params, nullptr, \
|
||||
[]() -> IFFmpegRenderer* { return new RENDERER_TYPE(); })) { \
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, \
|
||||
"Chose " #RENDERER_TYPE " for codec %s due to preferred pixel format: 0x%x", \
|
||||
decoder->name, decoder->pix_fmts[i]); \
|
||||
return true; \
|
||||
} \
|
||||
} \
|
||||
|
@ -610,6 +613,9 @@ bool FFmpegVideoDecoder::tryInitializeRenderer(AVCodec* decoder,
|
|||
if (renderer.isPixelFormatSupported(params->videoFormat, decoder->pix_fmts[i])) { \
|
||||
if (tryInitializeRenderer(decoder, params, nullptr, \
|
||||
[]() -> IFFmpegRenderer* { return new RENDERER_TYPE(); })) { \
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, \
|
||||
"Chose " #RENDERER_TYPE " for codec %s due to compatible pixel format: 0x%x", \
|
||||
decoder->name, decoder->pix_fmts[i]); \
|
||||
return true; \
|
||||
} \
|
||||
} \
|
||||
|
@ -623,6 +629,21 @@ bool FFmpegVideoDecoder::tryInitializeRendererForDecoderByName(const char *decod
|
|||
return false;
|
||||
}
|
||||
|
||||
// This might be a hwaccel decoder, so try any hw configs first
|
||||
for (int i = 0;; i++) {
|
||||
const AVCodecHWConfig *config = avcodec_get_hw_config(decoder, i);
|
||||
if (!config) {
|
||||
// No remaing hwaccel options
|
||||
break;
|
||||
}
|
||||
|
||||
// Initialize the hardware codec and submit a test frame if the renderer needs it
|
||||
if (tryInitializeRenderer(decoder, params, config,
|
||||
[config]() -> IFFmpegRenderer* { return createHwAccelRenderer(config, 0); })) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (decoder->pix_fmts == NULL) {
|
||||
// Supported output pixel formats are unknown. We'll just try SDL and hope it can cope.
|
||||
return tryInitializeRenderer(decoder, params, nullptr,
|
||||
|
@ -741,7 +762,6 @@ bool FFmpegVideoDecoder::initialize(PDECODER_PARAMETERS params)
|
|||
}
|
||||
|
||||
// Continue with special non-hwaccel hardware decoders
|
||||
|
||||
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||
QList<const char *> knownAvcCodecs = { "h264_mmal", "h264_rkmpp", "h264_nvmpi", "h264_v4l2m2m" };
|
||||
for (const char* codec : knownAvcCodecs) {
|
||||
|
|
Loading…
Reference in a new issue