Fix some codec selection bugs

This commit is contained in:
Cameron Gutman 2019-04-19 20:57:21 -07:00
parent ed170b8092
commit d65e29111f

View file

@ -463,11 +463,13 @@ bool FFmpegVideoDecoder::initialize(PDECODER_PARAMETERS params)
return false;
}
// Look for the first matching hwaccel
// Look for a hardware decoder first unless software-only
if (params->vds != StreamingPreferences::VDS_FORCE_SOFTWARE) {
// Look for the first matching hwaccel hardware decoder
for (int i = 0;; i++) {
const AVCodecHWConfig *config = avcodec_get_hw_config(decoder, i);
if (!config || params->vds == StreamingPreferences::VDS_FORCE_SOFTWARE) {
// No remaing hwaccel options or software decoding requested
if (!config) {
// No remaing hwaccel options
break;
}
@ -478,25 +480,29 @@ bool FFmpegVideoDecoder::initialize(PDECODER_PARAMETERS params)
}
}
// Continue with special non-hwaccel hardware decoders
#ifdef HAVE_MMAL
// MMAL is a non-hwaccel hardware decoder for the Raspberry Pi
if ((params->videoFormat & VIDEO_FORMAT_MASK_H264) &&
(params->vds != StreamingPreferences::VDS_FORCE_SOFTWARE)) {
// MMAL is the decoder for the Raspberry Pi
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
AVCodec* mmalDecoder = avcodec_find_decoder_by_name("h264_mmal");
if (mmalDecoder != nullptr &&
tryInitializeRenderer(decoder, params, nullptr,
tryInitializeRenderer(mmalDecoder, params, nullptr,
[]() -> IFFmpegRenderer* { return new MmalRenderer(); })) {
return true;
}
}
#endif
}
// We must fall back to a non-hardware accelerated decoder as
// all other possibilities have been exhausted.
// Fallback to software if no matching hardware decoder was found
// and if software fallback is allowed
if (params->vds != StreamingPreferences::VDS_FORCE_HARDWARE) {
if (tryInitializeRenderer(decoder, params, nullptr,
[]() -> IFFmpegRenderer* { return new SdlRenderer(); })) {
return true;
}
}
// No decoder worked
return false;