From c53ee418551e44bc457740866ad553f1621d9764 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max.kellermann@gmail.com>
Date: Sun, 12 Mar 2023 19:34:55 +0100
Subject: [PATCH] decoder/ffmpeg: check for DSD codec

DSD uses a generic demuxer, therefore it does not appear in the
demuxer list.
---
 src/decoder/plugins/FfmpegDecoderPlugin.cxx | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx
index a11729777..a24594a98 100644
--- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx
@@ -29,6 +29,7 @@
 #include "util/IterableSplitString.hxx"
 #include "util/ScopeExit.hxx"
 #include "util/StringAPI.hxx"
+#include "util/StringCompare.hxx"
 #include "Log.hxx"
 
 extern "C" {
@@ -705,6 +706,15 @@ ffmpeg_suffixes() noexcept
 			suffixes.emplace(input_format->name);
 	}
 
+	void *codec_opaque = nullptr;
+	while (const auto codec = av_codec_iterate(&codec_opaque)) {
+		if (StringStartsWith(codec->name, "dsd_")) {
+			/* FFmpeg was compiled with DSD support */
+			suffixes.emplace("dff");
+			suffixes.emplace("dsf");
+		}
+	}
+
 	return suffixes;
 }