From 330c9220986ce31082e47d85fab41a47c419b9b1 Mon Sep 17 00:00:00 2001 From: Scott Theisen Date: Fri, 9 Sep 2022 13:50:35 -0400 Subject: [PATCH] AvFormatDecoder::DecoderWillDownmix: don't use av_opt_find since it was causing segmentation faults in FFmpeg. Restore the prior switch case with two additions that also support the "downmix" option: MLP (Meridian Lossless Packing) DTS Coherent Acoustics (DCA, also just referred to as DTS) This should also be faster, since it doesn't have to iterate over any lists (arrays) of `AVOption`s. --- .../libs/libmythtv/decoders/avformatdecoder.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mythtv/libs/libmythtv/decoders/avformatdecoder.cpp b/mythtv/libs/libmythtv/decoders/avformatdecoder.cpp index 1f81cf4bd10..9cb7c7230e5 100644 --- a/mythtv/libs/libmythtv/decoders/avformatdecoder.cpp +++ b/mythtv/libs/libmythtv/decoders/avformatdecoder.cpp @@ -5240,7 +5240,20 @@ inline bool AvFormatDecoder::DecoderWillDownmix(const AVCodecContext *ctx) if (m_audio->CanDownmix() && AudioOutputUtil::has_optimized_SIMD()) return false; // use ffmpeg only for dolby codecs if we have to - return av_opt_find(ctx->priv_data, "downmix", nullptr, 0, 0); + //return av_opt_find(ctx->priv_data, "downmix", nullptr, 0, 0); + // av_opt_find was causing segmentation faults, so explicitly list the + // compatible decoders + switch (ctx->codec_id) + { + case AV_CODEC_ID_AC3: + case AV_CODEC_ID_TRUEHD: + case AV_CODEC_ID_EAC3: + case AV_CODEC_ID_MLP: + case AV_CODEC_ID_DTS: + return true; + default: + return false; + } } bool AvFormatDecoder::DoPassThrough(const AVCodecParameters *par, bool withProfile)