@@ -5,74 +5,93 @@ namespace Jellyfin.HardwareVisualizer.Server.Database.Configuration;
5
5
6
6
public class TestCaseArgumentConfig : IEntityTypeConfiguration < TestCaseArgument >
7
7
{
8
- private class TestCaseGen
8
+ private record TestCaseGen
9
9
{
10
- public string Template ;
11
- public ( Guid codec , string type ) [ ] Source ;
12
- public ( Guid codec , string type ) [ ] Target ;
10
+ public required string Template { get ; set ; }
11
+ public ( Guid codec , string type ) [ ] Source { get ; set ; }
12
+ public ( Guid codec , string type ) [ ] Target { get ; set ; }
13
13
}
14
14
15
15
public void Configure ( EntityTypeBuilder < TestCaseArgument > modelBuilder )
16
16
{
17
- var generators = new Dictionary < ( TestCaseArgumentDeviceType Device , Guid [ ] ffmpegGroup ) , TestCaseGen > ( )
17
+ var cpuBase = new TestCaseGen ( )
18
18
{
19
- {
20
- ( TestCaseArgumentDeviceType . Cpu , [ FfmpegVersionConfig . GenericLinuxVersionGroup , FfmpegVersionConfig . WindowsVersionGroup , FfmpegVersionConfig . MacVersionGroup ] ) ,
21
- new TestCaseGen ( ) {
22
- Template = """-c:v {SOURCE} -i {video_file} -noautoscale -an -sn -vf "scale=trunc(min(max(iw\,ih*a)\,{scale})/2)*2:trunc(ow/a/2)*2,format=yuv420p" -c:v {TARGET} -preset veryfast -b:v {bitrate} -maxrate {bitrate} -f null - -benchmark""" ,
23
- Source = [
19
+ Template = """-c:v {SOURCE} -i {video_file} -noautoscale -an -sn -vf "scale=trunc(min(max(iw\,ih*a)\,{scale})/2)*2:trunc(ow/a/2)*2,format=yuv420p" -c:v {TARGET} -preset veryfast -b:v {bitrate} -maxrate {bitrate} -f null - -benchmark""" ,
20
+ Source = [
24
21
( HardwareCodecConfig . h264CodecId , "h264" ) ,
25
22
( HardwareCodecConfig . hvecCodecId , "hevc" ) ,
26
23
( HardwareCodecConfig . av1CodecId , "dav1d" ) ,
27
24
] ,
28
- Target = [
25
+ Target = [
29
26
( HardwareCodecConfig . h264CodecId , "libx264" ) ,
30
27
( HardwareCodecConfig . hvecCodecId , "libx265" ) ,
31
28
( HardwareCodecConfig . av1CodecId , "svt-av1" ) ,
32
29
]
33
- }
34
- } ,
35
- {
36
- ( TestCaseArgumentDeviceType . Nvidia , [ FfmpegVersionConfig . GenericLinuxVersionGroup , FfmpegVersionConfig . WindowsVersionGroup ] ) ,
37
- new TestCaseGen ( ) {
38
- Template = """-init_hw_device cuda=cu:{gpu} -hwaccel cuda -hwaccel_output_format cuda -c:v {SOURCE} -i {video_file} -noautoscale -an -sn -vf "scale_cuda=-1:{scale}:yuv420p" -c:v {TARGET} -preset p1 -b:v {bitrate} -maxrate {bitrate} -f null - -benchmark""" ,
39
- Source = [
30
+ } ;
31
+
32
+ var nvidiaBase = new TestCaseGen ( )
33
+ {
34
+ Template = """-init_hw_device cuda=cu:{gpu} -hwaccel cuda -hwaccel_output_format cuda -c:v {SOURCE} -i {video_file} -noautoscale -an -sn -vf "scale_cuda=-1:{scale}:yuv420p" -c:v {TARGET} -preset p1 -b:v {bitrate} -maxrate {bitrate} -f null - -benchmark""" ,
35
+ Source = [
40
36
( HardwareCodecConfig . h264CodecId , "h264_cuvid" ) ,
41
37
( HardwareCodecConfig . hvecCodecId , "hevc_cuvid" ) ,
42
38
( HardwareCodecConfig . av1CodecId , "av1_cuvid" ) ,
43
39
] ,
44
- Target = [
40
+ Target = [
45
41
( HardwareCodecConfig . h264CodecId , "h264_nvenc" ) ,
46
42
( HardwareCodecConfig . hvecCodecId , "hevc_nvenc" ) ,
47
43
( HardwareCodecConfig . av1CodecId , "av1_nvenc" ) ,
48
44
]
49
- }
50
- } ,
51
- {
52
- ( TestCaseArgumentDeviceType . Amd , [ FfmpegVersionConfig . GenericLinuxVersionGroup ] ) ,
53
- new TestCaseGen ( ) {
54
- Template = """-init_hw_device vaapi=va:/dev/dri/by-path/{gpu}-render -hwaccel vaapi -hwaccel_output_format vaapi -c:v {SOURCE} -i {video_file} -noautoscale -an -sn -vf "scale_vaapi=-1:{scale}:format=nv12" -c:v {TARGET} -b:v {bitrate} -maxrate {bitrate} -f null - -benchmark""" ,
55
- Source = [
45
+ } ;
46
+
47
+ var amdBase = new TestCaseGen ( )
48
+ {
49
+ Template = """-init_hw_device vaapi=va:/dev/dri/by-path/{gpu}-render -hwaccel vaapi -hwaccel_output_format vaapi -c:v {SOURCE} -i {video_file} -noautoscale -an -sn -vf "scale_vaapi=-1:{scale}:format=nv12" -c:v {TARGET} -b:v {bitrate} -maxrate {bitrate} -f null - -benchmark""" ,
50
+ Source = [
56
51
( HardwareCodecConfig . h264CodecId , "h264" ) ,
57
52
( HardwareCodecConfig . hvecCodecId , "hevc" ) ,
58
53
( HardwareCodecConfig . av1CodecId , "dav1d" ) ,
59
54
] ,
60
- Target = [
55
+ Target = [
61
56
( HardwareCodecConfig . h264CodecId , "h264_vaapi" ) ,
62
57
( HardwareCodecConfig . hvecCodecId , "hevc_vaapi" ) ,
63
58
( HardwareCodecConfig . av1CodecId , "av1_vaapi" ) ,
64
59
]
65
- }
60
+ } ;
61
+
62
+ var intelbase = new TestCaseGen ( )
63
+ {
64
+ Template = """-init_hw_device vaapi=va:/dev/dri/by-path/{gpu}-render -init_hw_device qsv=qs@va -hwaccel qsv -hwaccel_output_format qsv -c:v {SOURCE} -i {video_file} -noautoscale -an -sn -vf "scale_qsv=-1:{scale}:format=nv12" -c:v {TARGET} -preset veryfast -b:v {bitrate} -maxrate {bitrate} -f null - -benchmark""" ,
65
+ Source = [
66
+ ( HardwareCodecConfig . h264CodecId , "h264_qsv" ) ,
67
+ ( HardwareCodecConfig . hvecCodecId , "hevc_qsv" ) ,
68
+ ( HardwareCodecConfig . av1CodecId , "av1_qsv" ) ,
69
+ ] ,
70
+ Target = [
71
+ ( HardwareCodecConfig . h264CodecId , "h264_qsv" ) ,
72
+ ( HardwareCodecConfig . hvecCodecId , "hevc_qsv" ) ,
73
+ ( HardwareCodecConfig . av1CodecId , "av1_qsv" ) ,
74
+ ]
75
+ } ;
76
+
77
+ var generators = new Dictionary < ( TestCaseArgumentDeviceType Device , Guid [ ] ffmpegGroup ) , TestCaseGen > ( )
78
+ {
79
+ {
80
+ ( TestCaseArgumentDeviceType . Cpu , [ FfmpegVersionConfig . GenericLinuxVersionGroup , FfmpegVersionConfig . WindowsVersionGroup , FfmpegVersionConfig . MacVersionGroup ] ) ,
81
+ cpuBase
82
+ } ,
83
+ {
84
+ ( TestCaseArgumentDeviceType . Nvidia , [ FfmpegVersionConfig . GenericLinuxVersionGroup , FfmpegVersionConfig . WindowsVersionGroup ] ) ,
85
+ nvidiaBase
86
+ } ,
87
+ {
88
+ ( TestCaseArgumentDeviceType . Amd , [ FfmpegVersionConfig . GenericLinuxVersionGroup ] ) ,
89
+ amdBase
66
90
} ,
67
91
{
68
92
( TestCaseArgumentDeviceType . Amd , [ FfmpegVersionConfig . WindowsVersionGroup ] ) ,
69
- new TestCaseGen ( ) {
93
+ amdBase with {
70
94
Template = """-init_hw_device d3d11va:{gpu} -hwaccel d3d11va -hwaccel_output_format d3d11 -c:v {SOURCE} -i {video_file} -noautoscale -an -sn -vf "scale=-1:{scale}:format=nv12" -c:v {TARGET} -b:v {bitrate} -maxrate {bitrate} -f null - -benchmark""" ,
71
- Source = [
72
- ( HardwareCodecConfig . h264CodecId , "h264" ) ,
73
- ( HardwareCodecConfig . hvecCodecId , "hevc" ) ,
74
- ( HardwareCodecConfig . av1CodecId , "dav1d" ) ,
75
- ] ,
76
95
Target = [
77
96
( HardwareCodecConfig . h264CodecId , "h264_amf" ) ,
78
97
( HardwareCodecConfig . hvecCodecId , "hevc_amf" ) ,
@@ -82,20 +101,14 @@ public void Configure(EntityTypeBuilder<TestCaseArgument> modelBuilder)
82
101
} ,
83
102
{
84
103
( TestCaseArgumentDeviceType . Intel , [ FfmpegVersionConfig . GenericLinuxVersionGroup ] ) ,
85
- new TestCaseGen ( ) {
86
- Template = """-init_hw_device vaapi=va:/dev/dri/by-path/{gpu}-render -init_hw_device qsv=qs@va -hwaccel qsv -hwaccel_output_format qsv -c:v {SOURCE} -i {video_file} -noautoscale -an -sn -vf "scale_qsv=-1:{scale}:format=nv12" -c:v {TARGET} -preset veryfast -b:v {bitrate} -maxrate {bitrate} -f null - -benchmark""" ,
87
- Source = [
88
- ( HardwareCodecConfig . h264CodecId , "h264_qsv" ) ,
89
- ( HardwareCodecConfig . hvecCodecId , "hevc_qsv" ) ,
90
- ( HardwareCodecConfig . av1CodecId , "av1_qsv" ) ,
91
- ] ,
92
- Target = [
93
- ( HardwareCodecConfig . h264CodecId , "h264_qsv" ) ,
94
- ( HardwareCodecConfig . hvecCodecId , "hevc_qsv" ) ,
95
- ( HardwareCodecConfig . av1CodecId , "av1_qsv" ) ,
96
- ]
104
+ intelbase
105
+ } ,
106
+ {
107
+ ( TestCaseArgumentDeviceType . Intel , [ FfmpegVersionConfig . WindowsVersionGroup ] ) ,
108
+ intelbase with {
109
+ Template = """-init_hw_device d3d11va:{gpu} -hwaccel qsv -hwaccel_output_format qsv -c:v {SOURCE} -i {video_file} -noautoscale -an -sn -vf \"scale_qsv=-1:{scale}:format=nv12\" -c:v {TARGET} -preset veryfast -b:v {bitrate} -maxrate {bitrate} -f null - -benchmark""" ,
97
110
}
98
- } ,
111
+ } ,
99
112
} ;
100
113
101
114
var testCases = new List < TestCaseArgument > ( ) ;
0 commit comments