Refactor Codec Map Code

This commit is contained in:
copecone committed 2026-06-09 22:09:59 +09:00
1 parent 1f3d612b5f
commit a17c867fba
2 files changed
+8 -8

No files matched your search

+7 -7
View File
@@ -20,13 +20,13 @@ namespace ADOFAIRenderer.Util
private const string IntelPattern =
@"^Intel(?>\(R\))* (?>U*HD Graphics [0-9]+$|Arc\(TM\) [A-C][0-9]+ Graphics)";
private static Dictionary<Codec, List<(GPUVendor, string)>> _codecMap = new Dictionary<Codec, List<(GPUVendor, string)>>
private static readonly Dictionary<Codec, List<(GPUVendor, string)>> CodecMap = new Dictionary<Codec, List<(GPUVendor, string)>>
{
{ Codec.H264, new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "h264_nvenc"), (GPUVendor.Intel, "h264_qsv"), (GPUVendor.AMD, "h264_amf"), (GPUVendor.Unknown, "libx264") } },
{ Codec.H265, new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "hevc_nvenc"), (GPUVendor.Intel, "hevc_qsv"), (GPUVendor.AMD, "hevc_amf"), (GPUVendor.Unknown, "libx265") } },
{ Codec.VP9, new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "vp9_nvenc"), (GPUVendor.Intel, "vp9_qsv"), (GPUVendor.Unknown, "libvpx-vp9") } },
{ Codec.AV1, new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "av1_nvenc"), (GPUVendor.Intel, "av1_qsv"), (GPUVendor.AMD, "av1_amf"), (GPUVendor.Unknown, "libsvtav1"), (GPUVendor.Unknown, "libaom-av1") } },
{ Codec.VVC, new List<(GPUVendor, string)> { (GPUVendor.Unknown, "libvvenc") }}
[Codec.H264] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "h264_nvenc"), (GPUVendor.Intel, "h264_qsv"), (GPUVendor.AMD, "h264_amf"), (GPUVendor.Unknown, "libx264") },
[Codec.H265] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "hevc_nvenc"), (GPUVendor.Intel, "hevc_qsv"), (GPUVendor.AMD, "hevc_amf"), (GPUVendor.Unknown, "libx265") },
[Codec.VP9] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "vp9_nvenc"), (GPUVendor.Intel, "vp9_qsv"), (GPUVendor.Unknown, "libvpx-vp9") },
[Codec.AV1] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "av1_nvenc"), (GPUVendor.Intel, "av1_qsv"), (GPUVendor.AMD, "av1_amf"), (GPUVendor.Unknown, "libsvtav1"), (GPUVendor.Unknown, "libaom-av1") },
[Codec.VVC] = new List<(GPUVendor, string)> { (GPUVendor.Unknown, "libvvenc") }
};
public static GPUVendor GetActiveGPUVendor()
@@ -49,7 +49,7 @@ namespace ADOFAIRenderer.Util
public static List<string> GetPrioritizedEncoderCandidates(Codec codec)
{
if (!_codecMap.TryGetValue(codec, out var list)) return new List<string>();
if (!CodecMap.TryGetValue(codec, out var list)) return new List<string>();
var vendor = GetActiveGPUVendor();
var prioritized = new List<string>();