-
Notifications
You must be signed in to change notification settings - Fork 156
/
k7sfunc.py
3256 lines (2810 loc) · 131 KB
/
k7sfunc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##################################################
### 文档: https://github.com/hooke007/MPV_lazy/wiki/3_K7sfunc
##################################################
__version__ = "0.6.1"
__all__ = [
"FMT_CHANGE", "FMT_CTRL", "FPS_CHANGE", "FPS_CTRL",
"ACNET_STD", "ARTCNN_NV", "CUGAN_NV", "EDI_US_STD", "ESRGAN_DML", "ESRGAN_NV", "NGU_HQ", "WAIFU_DML", "WAIFU_NV",
"MVT_LQ", "MVT_STD", "MVT_POT", "MVT_MQ", "RIFE_STD", "RIFE_NV", "SVP_LQ", "SVP_STD", "SVP_HQ", "SVP_PRO",
"BILA_NV", "BM3D_NV", "CCD_STD", "DFTT_STD", "DFTT_NV", "DPIR_NR_NV", "FFT3D_STD", "NLM_STD", "NLM_NV",
"COLOR_P3W_FIX", "CSC_RB", "DEBAND_STD", "DEINT_LQ", "DEINT_STD", "DEINT_EX", "DPIR_DBLK_NV", "EDI_AA_STD", "EDI_AA_NV", "IVTC_STD", "STAB_STD", "STAB_HQ", "UAI_DML", "UAI_NV_TRT", "UVR_MAD",
]
##################################################
## https://github.com/python/cpython/blob/v3.11.8/Lib/distutils/version.py
##################################################
import re
class Version:
def __init__ (self, vstring=None):
if vstring:
self.parse(vstring)
def __repr__ (self):
return "%s ('%s')" % (self.__class__.__name__, str(self))
def __eq__(self, other):
c = self._cmp(other)
if c is NotImplemented:
return c
return c == 0
def __lt__(self, other):
c = self._cmp(other)
if c is NotImplemented:
return c
return c < 0
def __le__(self, other):
c = self._cmp(other)
if c is NotImplemented:
return c
return c <= 0
def __gt__(self, other):
c = self._cmp(other)
if c is NotImplemented:
return c
return c > 0
def __ge__(self, other):
c = self._cmp(other)
if c is NotImplemented:
return c
return c >= 0
class StrictVersion (Version):
version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$',
re.VERBOSE | re.ASCII)
def parse (self, vstring):
match = self.version_re.match(vstring)
if not match:
raise ValueError("invalid version number '%s'" % vstring)
(major, minor, patch, prerelease, prerelease_num) = \
match.group(1, 2, 4, 5, 6)
if patch:
self.version = tuple(map(int, [major, minor, patch]))
else:
self.version = tuple(map(int, [major, minor])) + (0,)
if prerelease:
self.prerelease = (prerelease[0], int(prerelease_num))
else:
self.prerelease = None
def __str__ (self):
if self.version[2] == 0:
vstring = '.'.join(map(str, self.version[0:2]))
else:
vstring = '.'.join(map(str, self.version))
if self.prerelease:
vstring = vstring + self.prerelease[0] + str(self.prerelease[1])
return vstring
def _cmp (self, other):
if isinstance(other, str):
other = StrictVersion(other)
elif not isinstance(other, StrictVersion):
return NotImplemented
if self.version != other.version:
if self.version < other.version:
return -1
else:
return 1
if (not self.prerelease and not other.prerelease):
return 0
elif (self.prerelease and not other.prerelease):
return -1
elif (not self.prerelease and other.prerelease):
return 1
elif (self.prerelease and other.prerelease):
if self.prerelease == other.prerelease:
return 0
elif self.prerelease < other.prerelease:
return -1
else:
return 1
else:
assert False, "never get here"
class LooseVersion (Version):
component_re = re.compile(r'(\d+ | [a-z]+ | \.)', re.VERBOSE)
def __init__ (self, vstring=None):
if vstring:
self.parse(vstring)
def parse (self, vstring):
self.vstring = vstring
components = [x for x in self.component_re.split(vstring)
if x and x != '.']
for i, obj in enumerate(components):
try:
components[i] = int(obj)
except ValueError:
pass
self.version = components
def __str__ (self):
return self.vstring
def __repr__ (self):
return "LooseVersion ('%s')" % str(self)
def _cmp (self, other):
if isinstance(other, str):
other = LooseVersion(other)
elif not isinstance(other, LooseVersion):
return NotImplemented
if self.version == other.version:
return 0
if self.version < other.version:
return -1
if self.version > other.version:
return 1
##################################################
## 初始设置
##################################################
import os
import vapoursynth as vs
vs_thd_init = os.cpu_count()
if vs_thd_init > 8 and vs_thd_init <= 16 :
vs_thd_dft = 8
elif vs_thd_init > 16 :
if vs_thd_init <= 32 :
vs_thd_dft = vs_thd_init // 2
if vs_thd_dft % 2 != 0 :
vs_thd_dft = vs_thd_dft - 1
else :
vs_thd_dft = 16
else :
vs_thd_dft = vs_thd_init
vs_api = vs.__api_version__.api_major
if vs_api < 4 :
raise ImportError("帧服务器 VapourSynth 的版本号过低,至少 R57")
core = vs.core
dfttest2 = None
nnedi3_resample = None
qtgmc = None
vsmlrt = None
import typing
import math
import fractions
##################################################
## 格式转换 # TODO
##################################################
def FMT_CHANGE(
input : vs.VideoNode,
fmtc : bool = False, # TODO
algo : typing.Literal[1, 2, 3, 4] = 1,
param_a : float = 0.0,
param_b : float = 0.0,
w_out : int = 0,
h_out : int = 0,
fmt_pix : typing.Literal[-1, 0, 1, 2, 3] = -1,
dither : typing.Literal[0, 1, 2, 3] = 0,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "FMT_CHANGE"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if not isinstance(fmtc, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 fmtc 的值无效")
if algo not in [1, 2, 3, 4] :
raise vs.Error(f"模块 {func_name} 的子参数 algo 的值无效")
if not isinstance(param_a, (int, float)) or not isinstance(param_b, (int, float)) :
raise vs.Error(f"模块 {func_name} 的子参数 param_a 或 param_b 的值无效")
if not isinstance(w_out, int) or not isinstance(h_out, int) :
raise vs.Error(f"模块 {func_name} 的子参数 w_out 或 h_out 的值无效")
if isinstance(w_out, int) and isinstance(h_out, int) :
if w_out < 0 or h_out < 0 :
raise vs.Error(f"模块 {func_name} 的子参数 w_out 或 h_out 的值无效")
if fmt_pix not in [-1, 0, 1, 2, 3] :
raise vs.Error(f"模块 {func_name} 的子参数 fmt_pix 的值无效")
if dither not in [0, 1, 2, 3] :
raise vs.Error(f"模块 {func_name} 的子参数 dither 的值无效")
if not isinstance(vs_t, int) or vs_t > vs_thd_init :
raise vs.Error(f"模块 {func_name} 的子参数 vs_t 的值无效")
core.num_threads = vs_t
fmt_in = input.format.id
algo_val = ["Bilinear", "Bicubic", "Lanczos", "Spline36"][algo - 1]
resizer = getattr(core.resize, algo_val)
if fmt_pix > 0 :
fmt_pix_val = [vs.YUV420P8, vs.YUV420P10, vs.YUV444P16][fmt_pix - 1]
fmt_out = fmt_pix_val
elif fmt_pix == 0 :
fmt_out = fmt_in
if fmt_in not in [vs.YUV420P8, vs.YUV420P10] :
fmt_out = vs.YUV420P10
dither_val = ["none", "ordered", "random", "error_diffusion"][dither]
output = resizer(clip=input, width=w_out if w_out else None, height=h_out if h_out else None, filter_param_a=param_a, filter_param_b=param_b, format=fmt_pix_val if fmt_pix >= 0 else None, dither_type=dither_val)
return output
##################################################
## 限制输出的格式与高度
##################################################
def FMT_CTRL(
input : vs.VideoNode,
h_max : int = 0,
h_ret : bool = False,
spl_b : float = 1/3, # TODO 替换为 FMT_CHANGE
spl_c : float = 1/3,
fmt_pix : typing.Literal[0, 1, 2, 3] = 0,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "FMT_CTRL"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if not isinstance(h_max, int) or h_max < 0 :
raise vs.Error(f"模块 {func_name} 的子参数 h_max 的值无效")
if not isinstance(h_ret, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 h_ret 的值无效")
if not isinstance(spl_b, (int, float)) :
raise vs.Error(f"模块 {func_name} 的子参数 spl_b 的值无效")
if not isinstance(spl_c, (int, float)) :
raise vs.Error(f"模块 {func_name} 的子参数 spl_c 的值无效")
if fmt_pix not in [0, 1, 2, 3] :
raise vs.Error(f"模块 {func_name} 的子参数 fmt_pix 的值无效")
if not isinstance(vs_t, int) or vs_t > vs_thd_init :
raise vs.Error(f"模块 {func_name} 的子参数 vs_t 的值无效")
core.num_threads = vs_t
fmt_src = input.format
fmt_in = fmt_src.id
spl_b, spl_c = float(spl_b), float(spl_c)
w_in, h_in = input.width, input.height
# https://github.com/mpv-player/mpv/blob/master/video/filter/vf_vapoursynth.c
fmt_mpv = [vs.YUV420P8, vs.YUV420P10, vs.YUV422P8, vs.YUV422P10, vs.YUV410P8, vs.YUV411P8, vs.YUV440P8, vs.YUV444P8, vs.YUV444P10]
fmt_pass = [vs.YUV420P8, vs.YUV420P10, vs.YUV444P16]
fmt_safe = [vs.YUV444P8, vs.YUV444P10, vs.YUV444P16]
if fmt_pix :
fmt_pix_val = fmt_pass[fmt_pix - 1]
fmt_out = fmt_pix_val
if fmt_out == fmt_in :
clip = input
else :
if (fmt_out not in fmt_safe) and (fmt_in in fmt_safe) :
if not (w_in % 2 == 0) :
w_in = w_in - 1
if not (h_in % 2 == 0) :
h_in = h_in - 1
clip = core.resize.Bicubic(clip=input, width=w_in, height=h_in, filter_param_a=spl_b, filter_param_b=spl_c, format=fmt_out)
else :
clip = core.resize.Bilinear(clip=input, format=fmt_out)
else :
if fmt_in not in fmt_mpv :
fmt_out = vs.YUV420P10
if (fmt_out not in fmt_safe) and (fmt_in in fmt_safe) :
if not (w_in % 2 == 0) :
w_in = w_in - 1
if not (h_in % 2 == 0) :
h_in = h_in - 1
clip = core.resize.Bicubic(clip=input, width=w_in, height=h_in, filter_param_a=spl_b, filter_param_b=spl_c, format=fmt_out)
else :
clip = core.resize.Bilinear(clip=input, format=fmt_out)
else :
fmt_out = fmt_in
clip = input
if h_max :
if h_in > h_max :
if h_ret :
raise Exception("源高度超过限制的范围,已临时中止。")
else :
w_ds = w_in * (h_max / h_in)
h_ds = h_max
if fmt_src.subsampling_w or fmt_src.subsampling_h :
if not (w_ds % 2 == 0) :
w_ds = math.floor(w_ds / 2) * 2
if not (h_ds % 2 == 0) :
h_ds = math.floor(h_ds / 2) * 2
if not h_max and not fmt_pix :
output = clip
elif h_max and not fmt_pix :
if h_max >= h_in :
output = clip
else :
output = core.resize.Bicubic(clip=clip, width=w_ds, height=h_ds, filter_param_a=spl_b, filter_param_b=spl_c)
elif not h_max and fmt_pix :
if fmt_pix_val == fmt_out :
output = clip
else :
output = core.resize.Bilinear(clip=clip, format=fmt_pix_val)
else :
if h_max >= h_in :
if fmt_pix_val == fmt_out :
output = clip
else :
output = core.resize.Bilinear(clip=clip, format=fmt_pix_val)
else :
if fmt_pix_val == fmt_out :
output = core.resize.Bicubic(clip=clip, width=w_ds, height=h_ds, filter_param_a=spl_b, filter_param_b=spl_c)
else :
output = core.resize.Bicubic(clip=clip, width=w_ds, height=h_ds, filter_param_a=spl_b, filter_param_b=spl_c)
return output
##################################################
## PORT adjust (a3af7cb57cb37747b0667346375536e65b1fed17)
## 均衡器 # helper
##################################################
def EQ(
input : vs.VideoNode,
hue : typing.Optional[float] = None,
sat : typing.Optional[float] = None,
bright : typing.Optional[float] = None,
cont : typing.Optional[float] = None,
coring : bool = True,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
core.num_threads = vs_t
fmt_src = input.format
fmt_cf_in = fmt_src.color_family
fmt_bit_in = fmt_src.bits_per_sample
if hue is not None or sat is not None :
hue = 0.0 if hue is None else hue
sat = 1.0 if sat is None else sat
hue = hue * math.pi / 180.0
hue_sin = math.sin(hue)
hue_cos = math.cos(hue)
gray = 128 << (fmt_bit_in - 8)
chroma_min = 0
chroma_max = (2 ** fmt_bit_in) - 1
if coring:
chroma_min = 16 << (fmt_bit_in - 8)
chroma_max = 240 << (fmt_bit_in - 8)
expr_u = "x {} - {} * y {} - {} * + {} + {} max {} min".format(gray, hue_cos * sat, gray, hue_sin * sat, gray, chroma_min, chroma_max)
expr_v = "y {} - {} * x {} - {} * - {} + {} max {} min".format(gray, hue_cos * sat, gray, hue_sin * sat, gray, chroma_min, chroma_max)
src_u = input.std.ShufflePlanes(planes=1, colorfamily=vs.GRAY)
src_v = input.std.ShufflePlanes(planes=2, colorfamily=vs.GRAY)
dst_u = core.std.Expr(clips=[src_u, src_v], expr=expr_u)
dst_v = core.std.Expr(clips=[src_u, src_v], expr=expr_v)
output = core.std.ShufflePlanes(clips=[input, dst_u, dst_v], planes=[0, 0, 0], colorfamily=fmt_cf_in)
if bright is not None or cont is not None :
bright = 0.0 if bright is None else bright
cont = 1.0 if cont is None else cont
luma_lut = []
luma_min = 0
luma_max = (2 ** fmt_bit_in) - 1
if coring :
luma_min = 16 << (fmt_bit_in - 8)
luma_max = 235 << (fmt_bit_in - 8)
for i in range(2 ** fmt_bit_in) :
val = int((i - luma_min) * cont + bright + luma_min + 0.5)
luma_lut.append(min(max(val, luma_min), luma_max))
output = input.std.Lut(planes=0, lut=luma_lut)
return output
##################################################
## 提取高频层 # helper
##################################################
def LAYER_HIGH(
input : vs.VideoNode,
blur_m : typing.Literal[0, 1, 2] = 2,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
core.num_threads = vs_t
fmt_in = input.format.id
if fmt_in == vs.YUV444P16 :
cut0 = input
else :
cut0 = core.resize.Bilinear(clip=input, format=vs.YUV444P16)
if blur_m == 0 :
output_blur = cut0
output_diff = None
elif blur_m == 1 :
blur = core.rgvs.RemoveGrain(clip=cut0, mode=20)
blur = core.rgvs.RemoveGrain(clip=blur, mode=20)
output_blur = core.rgvs.RemoveGrain(clip=blur, mode=20)
elif blur_m == 2 :
blur = core.std.Convolution(clip=cut0, matrix=[1, 1, 1, 1, 1, 1, 1, 1, 1])
blur = core.std.Convolution(clip=blur, matrix=[1, 1, 1, 1, 1, 1, 1, 1, 1])
output_blur = core.std.Convolution(clip=blur, matrix=[1, 1, 1, 1, 1, 1, 1, 1, 1])
if blur_m :
output_diff = core.std.MakeDiff(clipa=cut0, clipb=blur)
return output_blur, output_diff
##################################################
## 提取线条 # helper
##################################################
def LINE_MASK(
input : vs.VideoNode,
cpu : bool = True,
gpu : typing.Literal[-1, 0, 1, 2] = -1,
plane : typing.List[int] = [0],
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
core.num_threads = vs_t
if cpu : # r13+
output = core.tcanny.TCanny(clip=input, sigma=1.5, t_h=8.0, t_l=1.0, mode=0, op=1, planes=plane)
else : # r12
output = core.tcanny.TCannyCL(clip=input, sigma=1.5, t_h=8.0, t_l=1.0, mode=0, op=1, device=gpu, planes=plane)
return output
##################################################
## 分离平面 # helper
##################################################
def PLANE_EXTR(
input : vs.VideoNode,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
core.num_threads = vs_t
''' obs
output = []
for plane in range(input.format.num_planes) :
clips = core.std.ShufflePlanes(clips=input, planes=plane, colorfamily=vs.GRAY)
output.append(clips)
'''
output = core.std.SplitPlanes(clip=input)
return output
##################################################
## 动态范围修正 # helper
##################################################
def RANGE_CHANGE(
input : vs.VideoNode,
l2f : bool = True,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
core.num_threads = vs_t
fmt_in = input.format.id
cut0 = input
if fmt_in in [vs.YUV420P8, vs.YUV422P8, vs.YUV410P8, vs.YUV411P8, vs.YUV440P8, vs.YUV444P8] :
lv_val_pre = 0
elif fmt_in in [vs.YUV420P10, vs.YUV422P10, vs.YUV444P10] :
lv_val_pre = 1
elif fmt_in in [vs.YUV420P16, vs.YUV422P16, vs.YUV444P16] :
lv_val_pre = 2
else :
cut0 = core.resize.Bilinear(format=vs.YUV444P16)
lv_val_pre = 2
lv_val1 = [16, 64, 4096][lv_val_pre]
lv_val2 = [235, 940, 60160][lv_val_pre]
lv_val2_alt = [240, 960, 61440][lv_val_pre]
lv_val3 = 0
lv_val4 = [255, 1023, 65535][lv_val_pre]
if l2f :
cut1 = core.std.Levels(clip=cut0, min_in=lv_val1, max_in=lv_val2, min_out=lv_val3, max_out=lv_val4, planes=0)
output = core.std.Levels(clip=cut1, min_in=lv_val1, max_in=lv_val2_alt, min_out=lv_val3, max_out=lv_val4, planes=[1,2])
else :
cut1 = core.std.Levels(clip=cut0, min_in=lv_val3, max_in=lv_val4, min_out=lv_val1, max_out=lv_val2, planes=0)
output = core.std.Levels(clip=cut1, min_in=lv_val3, max_in=lv_val4, min_out=lv_val1, max_out=lv_val2_alt, planes=[1,2])
return output
##################################################
## MOD HAvsFunc (e1fcce2b4645ed4acde9192606d00bcac1b5c9e5)
## 变更源帧率
##################################################
def FPS_CHANGE(
input : vs.VideoNode,
fps_in : float = 24.0,
fps_out : float = 60.0,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "FPS_CHANGE"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if not isinstance(fps_in, (int, float)) or fps_in <= 0.0 :
raise vs.Error(f"模块 {func_name} 的子参数 fps_in 的值无效")
if not isinstance(fps_out, (int, float)) or fps_out <= 0.0 or fps_out == fps_in :
raise vs.Error(f"模块 {func_name} 的子参数 fps_out 的值无效")
if not isinstance(vs_t, int) or vs_t > vs_thd_init :
raise vs.Error(f"模块 {func_name} 的子参数 vs_t 的值无效")
core.num_threads = vs_t
def _ChangeFPS(clip: vs.VideoNode, fpsnum: int, fpsden: int = 1) -> vs.VideoNode :
factor = (fpsnum / fpsden) * (clip.fps_den / clip.fps_num)
def _frame_adjuster(n: int) -> vs.VideoNode :
real_n = math.floor(n / factor)
one_frame_clip = clip[real_n] * (len(clip) + 100)
return one_frame_clip
attribute_clip = clip.std.BlankClip(length=math.floor(len(clip) * factor), fpsnum=fpsnum, fpsden=fpsden)
return attribute_clip.std.FrameEval(eval=_frame_adjuster)
src = core.std.AssumeFPS(clip=input, fpsnum=fps_in * 1e6, fpsden=1e6)
fin = _ChangeFPS(clip=src, fpsnum=fps_out * 1e6, fpsden=1e6)
output = core.std.AssumeFPS(clip=fin, fpsnum=fps_out * 1e6, fpsden=1e6)
return output
##################################################
## 限制源帧率
##################################################
def FPS_CTRL(
input : vs.VideoNode,
fps_in : float = 23.976,
fps_max : float = 32.0,
fps_out : typing.Optional[str] = None,
fps_ret : bool = False,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "FPS_CTRL"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if not isinstance(fps_in, (int, float)) or fps_in <= 0.0 :
raise vs.Error(f"模块 {func_name} 的子参数 fps_in 的值无效")
if fps_out is not None :
if not isinstance(fps_out, (int, float)) or fps_out <= 0.0 :
raise vs.Error(f"模块 {func_name} 的子参数 fps_out 的值无效")
if not isinstance(fps_ret, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 fps_ret 的值无效")
if not isinstance(vs_t, int) or vs_t > vs_thd_init :
raise vs.Error(f"模块 {func_name} 的子参数 vs_t 的值无效")
core.num_threads = vs_t
if fps_in > fps_max :
if fps_ret :
raise Exception("源帧率超过限制的范围,已临时中止。")
else :
output = FPS_CHANGE(input=input, fps_in=fps_in, fps_out=fps_out if fps_out else fps_max)
else :
output = input
return output
##################################################
## ACNet放大
##################################################
def ACNET_STD(
input : vs.VideoNode,
nr : typing.Literal[0, 1] = 1,
nr_lv : typing.Literal[1, 2, 3] = 1,
gpu : typing.Literal[0, 1, 2] = 0,
gpu_m : typing.Literal[1, 2] = 1,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "ACNET_STD"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if nr not in [0, 1] :
raise vs.Error(f"模块 {func_name} 的子参数 nr 的值无效")
if nr_lv not in [1, 2, 3] :
raise vs.Error(f"模块 {func_name} 的子参数 nr_lv 的值无效")
if gpu not in [0, 1, 2] :
raise vs.Error(f"模块 {func_name} 的子参数 gpu 的值无效")
if gpu_m not in [1, 2] :
raise vs.Error(f"模块 {func_name} 的子参数 gpu_m 的值无效")
if not isinstance(vs_t, int) or vs_t > vs_thd_init :
raise vs.Error(f"模块 {func_name} 的子参数 vs_t 的值无效")
if not hasattr(core, "anime4kcpp") :
raise ModuleNotFoundError(f"模块 {func_name} 依赖错误:缺失插件,检查项目 anime4kcpp")
core.num_threads = vs_t
fmt_in = input.format.id
if fmt_in == vs.YUV444P16 :
cut0 = input
else :
cut0 = core.resize.Bilinear(clip=input, format=vs.YUV444P16)
cut1 = core.anime4kcpp.Anime4KCPP(src=cut0, zoomFactor=2, ACNet=1, GPUMode=1, GPGPUModel="opencl" if gpu_m==1 else "cuda", HDN=nr, HDNLevel=nr_lv, platformID=gpu, deviceID=gpu)
output = core.resize.Bilinear(clip=cut1, format=fmt_in)
return output
##################################################
## ArtCNN放大
##################################################
def ARTCNN_NV(
input : vs.VideoNode,
lt_hd : bool = False,
model : typing.Literal[6, 7, 8] = 8,
gpu : typing.Literal[0, 1, 2] = 0,
gpu_t : int = 2,
st_eng : bool = False,
ws_size : int = 0,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "ARTCNN_NV"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if not isinstance(lt_hd, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 lt_hd 的值无效")
if model not in [6, 7, 8] :
raise vs.Error(f"模块 {func_name} 的子参数 model 的值无效")
if gpu not in [0, 1, 2] :
raise vs.Error(f"模块 {func_name} 的子参数 gpu 的值无效")
if not isinstance(gpu_t, int) or gpu_t <= 0 :
raise vs.Error(f"模块 {func_name} 的子参数 gpu_t 的值无效")
if not isinstance(st_eng, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 st_eng 的值无效")
if not isinstance(ws_size, int) or ws_size < 0 :
raise vs.Error(f"模块 {func_name} 的子参数 ws_size 的值无效")
if not isinstance(vs_t, int) or vs_t > vs_thd_init :
raise vs.Error(f"模块 {func_name} 的子参数 vs_t 的值无效")
if not hasattr(core, "trt") :
raise ModuleNotFoundError(f"模块 {func_name} 依赖错误:缺失插件,检查项目 trt")
plg_dir = os.path.dirname(core.trt.Version()["path"]).decode()
mdl_fname = ["ArtCNN_R16F96", "ArtCNN_R8F64", "ArtCNN_R8F64_DS"][[6, 7, 8].index(model)]
mdl_pth = plg_dir + "/models/ArtCNN/" + mdl_fname + ".onnx"
if not os.path.exists(mdl_pth) :
raise vs.Error(f"模块 {func_name} 所请求的模型缺失")
global vsmlrt
if vsmlrt is None :
try :
import vsmlrt
except ImportError :
raise ImportError(f"模块 {func_name} 依赖错误:缺失脚本 vsmlrt")
if LooseVersion(vsmlrt.__version__) < LooseVersion("3.21.13") :
raise ImportError(f"模块 {func_name} 依赖错误:缺失脚本 vsmlrt 的版本号过低,至少 3.21.13")
core.num_threads = vs_t
w_in, h_in = input.width, input.height
size_in = w_in * h_in
colorlv = getattr(input.get_frame(0).props, "_ColorRange", 0)
fmt_in = input.format.id
if (not lt_hd and (size_in > 1280 * 720)) or (size_in > 2048 * 1080) :
raise Exception("源分辨率超过限制的范围,已临时中止。")
if not st_eng and (((w_in > 2048) or (h_in > 1080)) or ((w_in < 64) or (h_in < 64))) :
raise Exception("源分辨率不属于动态引擎支持的范围,已临时中止。")
cut0 = core.resize.Bilinear(clip=input, format=vs.YUV444PH)
cut0_y = core.std.ShufflePlanes(clips=cut0, planes=0, colorfamily=vs.GRAY)
cut1_y = vsmlrt.ArtCNN(clip=cut0_y, model=model, backend=vsmlrt.BackendV2.TRT(
num_streams=gpu_t, force_fp16=True, output_format=1,
workspace=None if ws_size < 128 else (ws_size if st_eng else ws_size * 2),
use_cuda_graph=True, use_cublas=False, use_cudnn=False,
static_shape=st_eng, min_shapes=[0, 0] if st_eng else [64, 64],
opt_shapes=None if st_eng else ([1920, 1080] if lt_hd else [1280, 720]), max_shapes=None if st_eng else ([2048, 1080] if lt_hd else [1280, 720]),
device_id=gpu, short_path=True))
cut1_uv = core.resize.Bilinear(clip=cut0, width=cut1_y.width, height=cut1_y.height)
cut2 = core.std.ShufflePlanes(clips=[cut1_y, cut1_uv], planes=[0, 1, 2], colorfamily=vs.YUV)
output = core.resize.Bilinear(clip=cut2, format=fmt_in)
return output
##################################################
## Real-CUGAN放大
##################################################
def CUGAN_NV(
input : vs.VideoNode,
lt_hd : bool = False,
nr_lv : typing.Literal[-1, 0, 3] = -1,
sharp_lv : float = 1.0,
gpu : typing.Literal[0, 1, 2] = 0,
gpu_t : int = 2,
st_eng : bool = False,
ws_size : int = 0,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "CUGAN_NV"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if not isinstance(lt_hd, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 lt_hd 的值无效")
if nr_lv not in [-1, 0, 3] :
raise vs.Error(f"模块 {func_name} 的子参数 nr_lv 的值无效")
if not isinstance(sharp_lv, (int, float)) or sharp_lv < 0.0 or sharp_lv > 2.0 :
raise vs.Error(f"模块 {func_name} 的子参数 sharp_lv 的值无效")
if gpu not in [0, 1, 2] :
raise vs.Error(f"模块 {func_name} 的子参数 gpu 的值无效")
if not isinstance(gpu_t, int) or gpu_t <= 0 :
raise vs.Error(f"模块 {func_name} 的子参数 gpu_t 的值无效")
if not isinstance(st_eng, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 st_eng 的值无效")
if not isinstance(ws_size, int) or ws_size < 0 :
raise vs.Error(f"模块 {func_name} 的子参数 ws_size 的值无效")
if not isinstance(vs_t, int) or vs_t > vs_thd_init :
raise vs.Error(f"模块 {func_name} 的子参数 vs_t 的值无效")
if not hasattr(core, "trt") :
raise ModuleNotFoundError(f"模块 {func_name} 依赖错误:缺失插件,检查项目 trt")
plg_dir = os.path.dirname(core.trt.Version()["path"]).decode()
mdl_fname = ["pro-no-denoise3x-up2x", "pro-conservative-up2x", "pro-denoise3x-up2x"][[-1, 0, 3].index(nr_lv)]
mdl_pth = plg_dir + "/models/cugan/" + mdl_fname + ".onnx"
if not os.path.exists(mdl_pth) :
raise vs.Error(f"模块 {func_name} 所请求的模型缺失")
global vsmlrt
if vsmlrt is None :
try :
import vsmlrt
except ImportError :
raise ImportError(f"模块 {func_name} 依赖错误:缺失脚本 vsmlrt")
if LooseVersion(vsmlrt.__version__) < LooseVersion("3.18.1") :
raise ImportError(f"模块 {func_name} 依赖错误:缺失脚本 vsmlrt 版本号过低,至少 3.18.1")
core.num_threads = vs_t
w_in, h_in = input.width, input.height
size_in = w_in * h_in
colorlv = getattr(input.get_frame(0).props, "_ColorRange", 0)
fmt_in = input.format.id
if (not lt_hd and (size_in > 1280 * 720)) or (size_in > 2048 * 1080) :
raise Exception("源分辨率超过限制的范围,已临时中止。")
if not st_eng and (((w_in > 2048) or (h_in > 1080)) or ((w_in < 64) or (h_in < 64))) :
raise Exception("源分辨率不属于动态引擎支持的范围,已临时中止。")
cut1 = core.resize.Bilinear(clip=input, format=vs.RGBH, matrix_in_s="709")
cut2 = vsmlrt.CUGAN(clip=cut1, noise=nr_lv, scale=2, alpha=sharp_lv, version=2, backend=vsmlrt.BackendV2.TRT(
num_streams=gpu_t, force_fp16=True, output_format=1,
workspace=None if ws_size < 128 else (ws_size if st_eng else ws_size * 2),
use_cuda_graph=True, use_cublas=False, use_cudnn=False,
static_shape=st_eng, min_shapes=[0, 0] if st_eng else [64, 64],
opt_shapes=None if st_eng else ([1920, 1080] if lt_hd else [1280, 720]), max_shapes=None if st_eng else ([2048, 1080] if lt_hd else [1280, 720]),
device_id=gpu, short_path=True))
output = core.resize.Bilinear(clip=cut2, format=fmt_in, matrix_s="709", range=1 if colorlv==0 else None)
return output
##################################################
## NNEDI3放大
##################################################
def EDI_US_STD(
input : vs.VideoNode,
ext_proc : bool = True,
nsize : typing.Literal[0, 4] = 4,
nns : typing.Literal[2, 3, 4] = 3,
cpu : bool = True,
gpu : typing.Literal[-1, 0, 1, 2] = -1,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "EDI_US_STD"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if not isinstance(ext_proc, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 ext_proc 的值无效")
if nsize not in [0, 4] :
raise vs.Error(f"模块 {func_name} 的子参数 nsize 的值无效")
if nns not in [2, 3, 4] :
raise vs.Error(f"模块 {func_name} 的子参数 nns 的值无效")
if not isinstance(cpu, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 cpu 的值无效")
if gpu not in [-1, 0, 1, 2] :
raise vs.Error(f"模块 {func_name} 的子参数 gpu 的值无效")
if not isinstance(vs_t, int) or vs_t > vs_thd_init :
raise vs.Error(f"模块 {func_name} 的子参数 vs_t 的值无效")
if not hasattr(core, "fmtc") :
raise ModuleNotFoundError(f"模块 {func_name} 依赖错误:缺失插件,检查项目 fmtc")
if cpu :
if not hasattr(core, "znedi3") :
raise ModuleNotFoundError(f"模块 {func_name} 依赖错误:缺失插件,检查项目 znedi3")
else :
if not hasattr(core, "nnedi3cl") :
raise ModuleNotFoundError(f"模块 {func_name} 依赖错误:缺失插件,检查项目 nnedi3cl")
global nnedi3_resample
if nnedi3_resample is None :
try :
import nnedi3_resample
except ImportError :
raise ImportError(f"模块 {func_name} 依赖错误:缺失脚本 nnedi3_resample")
if LooseVersion(nnedi3_resample.__version__) < LooseVersion("2") :
raise ImportError(f"模块 {func_name} 依赖错误:缺失脚本 nnedi3_resample 的版本号过低,至少 2")
core.num_threads = vs_t
if ext_proc :
fmt_in = input.format.id
if fmt_in in [vs.YUV410P8, vs.YUV420P8, vs.YUV420P10] :
clip = core.resize.Bilinear(clip=input, format=vs.YUV420P16)
elif fmt_in in [vs.YUV411P8, vs.YUV422P8, vs.YUV422P10] :
clip = core.resize.Bilinear(clip=input, format=vs.YUV422P16)
elif fmt_in == vs.YUV444P16 :
clip = input
else :
clip = core.resize.Bilinear(clip=input, format=vs.YUV444P16)
else :
clip = input
output = nnedi3_resample.nnedi3_resample(input=clip, target_width=input.width * 2, target_height=input.height * 2,
nsize=nsize, nns=nns, qual=1, etype=0, pscrn=2, mode="znedi3" if cpu else "nnedi3cl", device=gpu)
if ext_proc :
output = core.resize.Bilinear(clip=output, format=fmt_in)
return output
##################################################
## Real-ESRGAN放大
##################################################
def ESRGAN_DML(
input : vs.VideoNode,
lt_hd : bool = False,
model : typing.Literal[0, 2, 5005, 5006, 5007, 5008, 5009, 5010] = 5005,
gpu : typing.Literal[0, 1, 2] = 0,
gpu_t : int = 2,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "ESRGAN_DML"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if not isinstance(lt_hd, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 lt_hd 的值无效")
if model not in [0, 2, 5005, 5006, 5007, 5008, 5009, 5010] :
raise vs.Error(f"模块 {func_name} 的子参数 model 的值无效")
if gpu not in [0, 1, 2] :
raise vs.Error(f"模块 {func_name} 的子参数 gpu 的值无效")
if not isinstance(gpu_t, int) or gpu_t <= 0 :
raise vs.Error(f"模块 {func_name} 的子参数 gpu_t 的值无效")
if not isinstance(vs_t, int) or vs_t > vs_thd_init :
raise vs.Error(f"模块 {func_name} 的子参数 vs_t 的值无效")
if not hasattr(core, "ort") :
raise ModuleNotFoundError(f"模块 {func_name} 依赖错误:缺失插件,检查项目 ort")
plg_dir = os.path.dirname(core.ort.Version()["path"]).decode()
mdl_fname = ["RealESRGANv2-animevideo-xsx2", "realesr-animevideov3", "animejanaiV2L1", "animejanaiV2L2", "animejanaiV2L3", "animejanaiV3-HD-L1", "animejanaiV3-HD-L2", "animejanaiV3-HD-L3"][[0, 2, 5005, 5006, 5007, 5008, 5009, 5010].index(model)]
mdl_pth = plg_dir + "/models/RealESRGANv2/" + mdl_fname + ".onnx"
if not os.path.exists(mdl_pth) :
raise vs.Error(f"模块 {func_name} 所请求的模型缺失")
global vsmlrt
if vsmlrt is None :
try :
import vsmlrt
except ImportError :
raise ImportError(f"模块 {func_name} 依赖错误:缺失脚本 vsmlrt")
if LooseVersion(vsmlrt.__version__) < LooseVersion("3.15.47") :
raise ImportError(f"模块 {func_name} 依赖错误:缺失脚本 vsmlrt 的版本号过低,至少 3.15.47")
core.num_threads = vs_t
w_in, h_in = input.width, input.height
size_in = w_in * h_in
colorlv = getattr(input.get_frame(0).props, "_ColorRange", 0)
fmt_in = input.format.id
if (not lt_hd and (size_in > 1280 * 720)) or (size_in > 2048 * 1080) :
raise Exception("源分辨率超过限制的范围,已临时中止。")
cut1 = core.resize.Bilinear(clip=input, format=vs.RGBS, matrix_in_s="709")
cut2 = vsmlrt.RealESRGANv2(clip=cut1, scale=4 if model==2 else 2, model=model, backend=vsmlrt.BackendV2.ORT_DML(
device_id=gpu, num_streams=gpu_t, fp16=True))
output = core.resize.Bilinear(clip=cut2, format=fmt_in, matrix_s="709", range=1 if colorlv==0 else None)
return output
##################################################
## Real-ESRGAN放大
##################################################
def ESRGAN_NV(
input : vs.VideoNode,
lt_hd : bool = False,
model : typing.Literal[0, 2, 5005, 5006, 5007, 5008, 5009, 5010] = 5005,
gpu : typing.Literal[0, 1, 2] = 0,
gpu_t : int = 2,
st_eng : bool = False,
ws_size : int = 0,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "ESRGAN_NV"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if not isinstance(lt_hd, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 lt_hd 的值无效")
if model not in [0, 2, 5005, 5006, 5007, 5008, 5009, 5010] :
raise vs.Error(f"模块 {func_name} 的子参数 model 的值无效")
if gpu not in [0, 1, 2] :
raise vs.Error(f"模块 {func_name} 的子参数 gpu 的值无效")
if not isinstance(gpu_t, int) or gpu_t <= 0 :
raise vs.Error(f"模块 {func_name} 的子参数 gpu_t 的值无效")
if not isinstance(st_eng, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 st_eng 的值无效")
if not isinstance(ws_size, int) or ws_size < 0 :
raise vs.Error(f"模块 {func_name} 的子参数 ws_size 的值无效")
if not isinstance(vs_t, int) or vs_t > vs_thd_init :
raise vs.Error(f"模块 {func_name} 的子参数 vs_t 的值无效")
if not hasattr(core, "trt") :
raise ModuleNotFoundError(f"模块 {func_name} 依赖错误:缺失插件,检查项目 trt")
plg_dir = os.path.dirname(core.trt.Version()["path"]).decode()
mdl_fname = ["RealESRGANv2-animevideo-xsx2", "realesr-animevideov3", "animejanaiV2L1", "animejanaiV2L2", "animejanaiV2L3", "animejanaiV3-HD-L1", "animejanaiV3-HD-L2", "animejanaiV3-HD-L3"][[0, 2, 5005, 5006, 5007, 5008, 5009, 5010].index(model)]
mdl_pth = plg_dir + "/models/RealESRGANv2/" + mdl_fname + ".onnx"
if not os.path.exists(mdl_pth) :
raise vs.Error(f"模块 {func_name} 所请求的模型缺失")
global vsmlrt
if vsmlrt is None :
try :
import vsmlrt
except ImportError :
raise ImportError(f"模块 {func_name} 依赖错误:缺失脚本 vsmlrt")
if LooseVersion(vsmlrt.__version__) < LooseVersion("3.18.23") :
raise ImportError(f"模块 {func_name} 依赖错误:缺失脚本 vsmlrt 的版本号过低,至少 3.18.23")
core.num_threads = vs_t
w_in, h_in = input.width, input.height
size_in = w_in * h_in
colorlv = getattr(input.get_frame(0).props, "_ColorRange", 0)
fmt_in = input.format.id
if (not lt_hd and (size_in > 1280 * 720)) or (size_in > 2048 * 1080) :
raise Exception("源分辨率超过限制的范围,已临时中止。")
if not st_eng and (((w_in > 2048) or (h_in > 1080)) or ((w_in < 64) or (h_in < 64))) :
raise Exception("源分辨率不属于动态引擎支持的范围,已临时中止。")
cut1 = core.resize.Bilinear(clip=input, format=vs.RGBH, matrix_in_s="709")
cut2 = vsmlrt.RealESRGANv2(clip=cut1, scale=4 if model==2 else 2, model=model, backend=vsmlrt.BackendV2.TRT(
num_streams=gpu_t, force_fp16=True, output_format=1,
workspace=None if ws_size < 128 else (ws_size if st_eng else ws_size * 2),
use_cuda_graph=True, use_cublas=False, use_cudnn=False,
static_shape=st_eng, min_shapes=[0, 0] if st_eng else [64, 64],
opt_shapes=None if st_eng else ([1920, 1080] if lt_hd else [1280, 720]), max_shapes=None if st_eng else ([2048, 1080] if lt_hd else [1280, 720]),
device_id=gpu, short_path=True))
output = core.resize.Bilinear(clip=cut2, format=fmt_in, matrix_s="709", range=1 if colorlv==0 else None)
return output
##################################################
## NGU放大
##################################################
def NGU_HQ(
input : vs.VideoNode,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "NGU_HQ"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if not isinstance(vs_t, int) or vs_t > vs_thd_init :
raise vs.Error(f"模块 {func_name} 的子参数 vs_t 的值无效")
if not hasattr(core, "madvr") :
raise ModuleNotFoundError(f"模块 {func_name} 依赖错误:缺失插件,检查项目 madvr")