forked from hooke007/MPV_lazy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
k7sfunc.py
2491 lines (2139 loc) · 95.8 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.1.22"
__all__ = [
"FMT_CHANGE", "FMT_CTRL", "FPS_CHANGE", "FPS_CTRL",
"ACNET_STD", "CUGAN_NV", "ESRGAN_DML", "ESRGAN_NV", "EDI_US_STD", "WAIFU_DML", "WAIFU_NV",
"MVT_LQ", "MVT_STD", "MVT_POT", "MVT_MQ", "RIFE_STD", "RIFE_NV", "RIFE_NV_ORT", "SVP_LQ", "SVP_STD", "SVP_HQ", "SVP_PRO",
"BILA_NV", "BM3D_NV", "CCD_STD", "DFTT_STD", "DFTT_NV", "FFT3D_STD", "NLM_STD", "NLM_NV",
"COLOR_P3W_FIX", "CSC_RB", "DEBAND_STD", "DEINT_LQ", "DEINT_STD", "DEINT_EX", "EDI_AA_STD", "EDI_AA_NV", "IVTC_STD", "STAB_STD", "STAB_HQ", "UAI_DML", "UAI_NV_TRT",
]
import os
import typing
import math
import vapoursynth as vs
from vapoursynth import core
##################################################
## 初始设置
##################################################
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
dfttest2 = None
nnedi3_resample = None
QTGMCv2 = None
vsmlrt = None
##################################################
## 格式转换 # 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 fps_in <= 0.0 :
raise vs.Error(f"模块 {func_name} 的子参数 fps_in 的值无效")
if 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 * 1000, fpsden=1000)
fin = _ChangeFPS(clip=src, fpsnum=fps_out * 1000, fpsden=1000)
output = core.std.AssumeFPS(clip=fin, fpsnum=fps_out * 1000, fpsden=1000)
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 fps_in <= 0.0 :
raise vs.Error(f"模块 {func_name} 的子参数 fps_in 的值无效")
if fps_out is not None :
if 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 的值无效")
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
##################################################
## Real-CUGAN放大
##################################################
def CUGAN_NV(
input : vs.VideoNode,
lt_hd : bool = False,
nr_lv : typing.Literal[-1, 0, 3] = -1,
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 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 的值无效")
global vsmlrt
if vsmlrt is None :
import vsmlrt
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 = input.resize.Bilinear(format=vs.RGBH, matrix_in_s="709")
cut2 = vsmlrt.CUGAN(clip=cut1, noise=nr_lv, scale=2, 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
##################################################
## Real-ESRGAN放大
##################################################
def ESRGAN_DML(
input : vs.VideoNode,
lt_hd : bool = False,
model : typing.Literal[0, 2, 5005, 5006, 5007] = 5005,
scale : typing.Literal[1, 2, 3, 4] = 2,
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] :
raise vs.Error(f"模块 {func_name} 的子参数 model 的值无效")
if scale not in [1, 2, 3, 4] :
raise vs.Error(f"模块 {func_name} 的子参数 scale 的值无效")
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 的值无效")
global vsmlrt
if vsmlrt is None :
import vsmlrt
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 = input.resize.Bilinear(format=vs.RGBS, matrix_in_s="709")
cut2 = vsmlrt.RealESRGANv2(clip=cut1, scale=scale, 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] = 5005,
scale : typing.Literal[1, 2, 3, 4] = 2,
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] :
raise vs.Error(f"模块 {func_name} 的子参数 model 的值无效")
if scale not in [1, 2, 3, 4] :
raise vs.Error(f"模块 {func_name} 的子参数 scale 的值无效")
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 的值无效")
global vsmlrt
if vsmlrt is None :
import vsmlrt
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 = input.resize.Bilinear(format=vs.RGBH, matrix_in_s="709")
cut2 = vsmlrt.RealESRGANv2(clip=cut1, scale=scale, 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
##################################################
## 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 的值无效")
global nnedi3_resample
if nnedi3_resample is None :
import nnedi3_resample
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
##################################################
## Waifu2x放大
##################################################
def WAIFU_DML(
input : vs.VideoNode,
lt_hd : bool = False,
model : typing.Literal[3, 5, 6] = 3,
nr_lv : typing.Literal[-1, 0, 1, 2, 3] = 1,
scale : typing.Literal[1, 2, 3, 4] = 2,
gpu : typing.Literal[0, 1, 2] = 0,
gpu_t : int = 2,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "WAIFU_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 [3, 5, 6] :
raise vs.Error(f"模块 {func_name} 的子参数 model 的值无效")
if nr_lv not in [-1, 0, 1, 2, 3] :
raise vs.Error(f"模块 {func_name} 的子参数 nr_lv 的值无效")
if scale not in [1, 2, 3, 4] :
raise vs.Error(f"模块 {func_name} 的子参数 scale 的值无效")
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 的值无效")
global vsmlrt
if vsmlrt is None :
import vsmlrt
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 = input.resize.Bilinear(format=vs.RGBS, matrix_in_s="709")
cut2 = vsmlrt.Waifu2x(clip=cut1, noise=nr_lv, scale=scale, 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
##################################################
## Waifu2x放大
##################################################
def WAIFU_NV(
input : vs.VideoNode,
lt_hd : bool = False,
model : typing.Literal[3, 5, 6] = 3,
nr_lv : typing.Literal[-1, 0, 1, 2, 3] = 1,
scale : typing.Literal[1, 2, 3, 4] = 2,
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 = "WAIFU_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 [3, 5, 6] :
raise vs.Error(f"模块 {func_name} 的子参数 model 的值无效")
if nr_lv not in [-1, 0, 1, 2, 3] :
raise vs.Error(f"模块 {func_name} 的子参数 nr_lv 的值无效")
if scale not in [1, 2, 3, 4] :
raise vs.Error(f"模块 {func_name} 的子参数 scale 的值无效")
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 的值无效")
global vsmlrt
if vsmlrt is None :
import vsmlrt
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 = input.resize.Bilinear(format=vs.RGBH, matrix_in_s="709")
cut2 = vsmlrt.Waifu2x(clip=cut1, noise=nr_lv, scale=scale, 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
##################################################
## MVtools补帧
##################################################
def MVT_LQ(
input : vs.VideoNode,
fps_in : float = 23.976,
fps_out : float = 59.940,
recal : bool = True,
block : bool = True,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "MVT_LQ"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if fps_in <= 0.0 :
raise vs.Error(f"模块 {func_name} 的子参数 fps_in 的值无效")
if fps_out <= 0.0 or fps_out <= fps_in :
raise vs.Error(f"模块 {func_name} 的子参数 fps_out 的值无效")
if not isinstance(recal, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 recal 的值无效")
if not isinstance(block, bool) :
raise vs.Error(f"模块 {func_name} 的子参数 block 的值无效")
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
w_in, h_in = input.width, input.height
blk_size = 32
w_tmp = math.ceil(w_in / blk_size) * blk_size - w_in
h_tmp = math.ceil(h_in / blk_size) * blk_size - h_in
cut0 = core.std.AddBorders(clip=input, right=w_tmp, bottom=h_tmp)
cut1 = core.std.AssumeFPS(clip=cut0, fpsnum=int(fps_in * 1000), fpsden=1000)
cut_s = core.mv.Super(clip=cut1, pel=1, sharp=0)
cut_b = core.mv.Analyse(super=cut_s, blksize=blk_size, search=2, isb=True)
cut_f = core.mv.Analyse(super=cut_s, blksize=blk_size, search=2)
if recal :
cut_b = core.mv.Recalculate(super=cut_s, vectors=cut_b, thsad=200, blksize=blk_size / 2, search=2, searchparam=1)
cut_f = core.mv.Recalculate(super=cut_s, vectors=cut_f, thsad=200, blksize=blk_size / 2, search=2, searchparam=1)
else :
cut_b, cut_f = cut_b, cut_f
if block :
fin = core.mv.BlockFPS(clip=cut1, super=cut_s, mvbw=cut_b, mvfw=cut_f, num=fps_out * 1000, den=1000)
else :
fin = core.mv.FlowFPS(clip=cut1, super=cut_s, mvbw=cut_b, mvfw=cut_f, num=fps_out * 1000, den=1000, mask=1)
output = core.std.Crop(clip=fin, right=w_tmp, bottom=h_tmp)
return output
##################################################
## MOD https://gist.github.com/KCCat/1b3a7b7f085a066af3719859f88ded02
## MVtools补帧
##################################################
def MVT_STD(
input : vs.VideoNode,
fps_in : float = 23.976,
fps_out : float = 60.0,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "MVT_STD"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if fps_in <= 0.0 :
raise vs.Error(f"模块 {func_name} 的子参数 fps_in 的值无效")
if 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 _ffps(fps) :
rfps = int('%.0f' % fps)
if ( abs(fps - (rfps/1.001)) < abs(fps - (rfps/1.000)) ) :
vfps, vden = rfps*1000, 1001
else :
vfps, vden = rfps*1000, 1000
return vfps, vden
vfps, vden = _ffps(fps_in)
cut1 = core.std.AssumeFPS(input, fpsnum=int(vfps), fpsden=vden)
cut_s = core.mv.Super(clip=cut1, sharp=1, rfilter=4)
if vs_api >=4 :
cut_b = core.mv.Analyse(super=cut_s, blksize=64, searchparam=0, pelsearch=3, isb=True, lambda_=0, lsad=10000, overlapv=16, badrange=0, search_coarse=4)
cut_f = core.mv.Analyse(super=cut_s, blksize=64, searchparam=0, pelsearch=3, lambda_=0, lsad=10000, overlapv=16, badrange=0, search_coarse=4)
else :
cut_b = core.mv.Analyse(super=cut_s, blksize=64, searchparam=0, pelsearch=3, isb=True, _lambda=0, lsad=10000, overlapv=16, badrange=0, search_coarse=4)
cut_f = core.mv.Analyse(super=cut_s, blksize=64, searchparam=0, pelsearch=3, _lambda=0, lsad=10000, overlapv=16, badrange=0, search_coarse=4)
output = core.mv.BlockFPS(clip=cut1, super=cut_s, mvbw=cut_b, mvfw=cut_f, num=fps_out * 1000, den=vden, mode=2, thscd1=970, thscd2=255, blend=False)
return output
##################################################
## MVtools补帧
##################################################
def MVT_POT(
input : vs.VideoNode,
fps_in : float = 23.976,
fps_out : float = 59.940,
vs_t : int = vs_thd_dft,
) -> vs.VideoNode :
func_name = "MVT_POT"
if not isinstance(input, vs.VideoNode) :
raise vs.Error(f"模块 {func_name} 的子参数 input 的值无效")
if fps_in <= 0.0 :
raise vs.Error(f"模块 {func_name} 的子参数 fps_in 的值无效")
if 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
max_flow_width = 1280
max_flow_height = 720
th_block_diff = 8*8*7
th_flow_diff = 8*8*7
th_block_changed = 14
th_flow_changed = 14
blocksize = 2**4
target_num = int(fps_out * 1e6)
target_den = int(1e6)
source_num = int(fps_in * 1e6)
source_den = int(1e6)
clip = core.std.AssumeFPS(input, fpsnum=source_num, fpsden=source_den)
sup = core.mv.Super(clip, pel=2, hpad=blocksize, vpad=blocksize)
bv = core.mv.Analyse(sup, blksize=blocksize, isb=True , chroma=True, search=3, searchparam=2)
fv = core.mv.Analyse(sup, blksize=blocksize, isb=False, chroma=True, search=3, searchparam=2)
use_block = clip.width > max_flow_width or clip.height > max_flow_height
if use_block :
output = core.mv.BlockFPS(clip, sup, bv, fv, num=target_num, den=target_den, mode=3, thscd1=th_block_diff, thscd2=th_block_changed)
else :
output = core.mv.FlowFPS(clip, sup, bv, fv, num=target_num, den=target_den, mask=0, thscd1=th_flow_diff, thscd2=th_flow_changed)
return output
##################################################
## MOD xvs (b24d5594206635f7373838acb80643d2ab141222)
## MVtools补帧
##################################################
def MVT_MQ(
input : vs.VideoNode,
fps_in : float = 23.976,
fps_out : float = 59.940,