Skip to content

Commit

Permalink
vs: 新增 ivtc_std
Browse files Browse the repository at this point in the history
附带修正 nlmeans
  • Loading branch information
hooke007 committed Jan 27, 2023
1 parent f145006 commit 0509dec
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 23 deletions.
29 changes: 29 additions & 0 deletions portable_config/vs/ivtc_std.vpy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### 伪25或30帧的源转24帧

import vapoursynth as vs
from vapoursynth import core

input = video_in
fps_in = container_fps

############
# 用户选项 #
############

Ivtc_core = 1
## <1|2> ivtc模式

if fps_in < 24.5 or fps_in > 32 :
raise Exception("非限定源,已临时禁用该脚本。")

if Ivtc_core == 1 :
if fps_in > 24 and fps_in < 26 :
output = core.vivtc.VDecimate(clip=input, cycle=25)
elif fps_in > 29 and fps_in < 31 :
output = core.vivtc.VDecimate(clip=input, cycle=5)
elif Ivtc_core == 2 :
cut0 = core.std.AssumeFPS(clip=input, fpsnum=fps_in * 1000, fpsden=1000)
cut1 = core.tivtc.TDecimate(clip=cut0, mode=7, rate=24 / 1.001)
output = core.std.AssumeFPS(clip=cut1, fpsnum=24000, fpsden=1001)

output.set_output()
6 changes: 3 additions & 3 deletions portable_config/vs/nlmeans_cuda.vpy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Blur_mode = 2
Frame_num = 1
Radius_sw = 2
Radius_snw = 2
Strength = 3
Strength = 3.0
GPU = 0
GPU_t = 2
## <0|1|2> 分离模式。0为不使用
Expand All @@ -42,11 +42,11 @@ elif Blur_mode == 2 :
if Blur_mode :
diff = core.std.MakeDiff(clipa=cut0, clipb=blur)
cut1 = core.nlm_cuda.NLMeans(clip=diff, d=Frame_num, a=Radius_sw, s=Radius_snw, h=Strength,
channels="AUTO", wmode=2, wref=1, rclip=None, device_id=GPU, num_streams=GPU_t)
channels="AUTO", wmode=2, wref=1.0, rclip=None, device_id=GPU, num_streams=GPU_t)
merge = core.std.MergeDiff(clipa=blur, clipb=cut1)
else :
cut1 = core.nlm_cuda.NLMeans(clip=blur, d=Frame_num, a=Radius_sw, s=Radius_snw, h=Strength,
channels="AUTO", wmode=2, wref=1, rclip=None, device_id=GPU, num_streams=GPU_t)
channels="AUTO", wmode=2, wref=1.0, rclip=None, device_id=GPU, num_streams=GPU_t)

output = core.resize.Bilinear(clip=merge if Blur_mode else cut1, format=fmt_in)

Expand Down
51 changes: 31 additions & 20 deletions portable_config/vs/nlmeans_std.vpy
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Nlm_core = 1
Frame_num = 1
Radius_sw = 2
Radius_snw = 2
Strength = 3
Strength = 3.0
GPU = 0
## 分离模式 1=RemoveGrain // 2=Convolution
## <0|1|2> 分离模式。0为不使用
## 降噪核心 1=OpenCL // 2=cpu
## 降噪帧数(整数)
## 搜索窗口半径(整数)
Expand All @@ -28,23 +28,34 @@ GPU = 0

cut0 = core.resize.Bilinear(clip=input, format=vs.YUV444P16)

if Blur_mode == 1 :
blur1 = core.rgvs.RemoveGrain(clip=cut0, mode=20)
blur2 = core.rgvs.RemoveGrain(clip=blur1, mode=20)
blur3 = core.rgvs.RemoveGrain(clip=blur2, mode=20)
if Blur_mode == 2 :
blur1 = core.std.Convolution(clip=cut0, matrix=[1, 1, 1, 1, 1, 1, 1, 1, 1])
blur2 = core.std.Convolution(clip=blur1, matrix=[1, 1, 1, 1, 1, 1, 1, 1, 1])
blur3 = core.std.Convolution(clip=blur2, matrix=[1, 1, 1, 1, 1, 1, 1, 1, 1])

diff = core.std.MakeDiff(clipa=cut0, clipb=blur3)

if Nlm_core == 1 :
cut1 = core.knlm.KNLMeansCL(clip=diff, d=Frame_num, a=Radius_sw, s=Radius_snw, h=Strength, wmode=2, device_type="GPU", device_id=GPU)
if Nlm_core == 2 :
cut1 = core.nlm_ispc.NLMeans(clip=diff, d=Frame_num, a=Radius_sw, s=Radius_snw, h=Strength, wmode=2)

merge = core.std.MergeDiff(clipa=blur3, clipb=cut1)
output = core.resize.Bilinear(clip=merge, format=fmt_in)
if Blur_mode == 0 :
blur = cut0
elif Blur_mode == 1 :
blur = core.rgvs.RemoveGrain(clip=cut0, mode=20)
blur = core.rgvs.RemoveGrain(clip=blur, mode=20)
blur = core.rgvs.RemoveGrain(clip=blur, mode=20)
elif Blur_mode == 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])
blur = core.std.Convolution(clip=blur, matrix=[1, 1, 1, 1, 1, 1, 1, 1, 1])

if Blur_mode :
diff = core.std.MakeDiff(clipa=cut0, clipb=blur)
if Nlm_core == 1 :
cut1 = core.knlm.KNLMeansCL(clip=diff, d=Frame_num, a=Radius_sw, s=Radius_snw, h=Strength,
channels="auto", wmode=2, wref=1.0, rclip=None, device_type="GPU", device_id=GPU)
elif Nlm_core == 2 :
cut1 = core.nlm_ispc.NLMeans(clip=diff, d=Frame_num, a=Radius_sw, s=Radius_snw, h=Strength,
channels="AUTO", wmode=2, wref=1.0, rclip=None)
merge = core.std.MergeDiff(clipa=blur, clipb=cut1)
else :
if Nlm_core == 1 :
cut1 = core.knlm.KNLMeansCL(clip=blur, d=Frame_num, a=Radius_sw, s=Radius_snw, h=Strength,
channels="auto", wmode=2, wref=1.0, rclip=None, device_type="GPU", device_id=GPU)
elif Nlm_core == 2 :
cut1 = core.nlm_ispc.NLMeans(clip=blur, d=Frame_num, a=Radius_sw, s=Radius_snw, h=Strength,
channels="AUTO", wmode=2, wref=1.0, rclip=None)

output = core.resize.Bilinear(clip=merge if Blur_mode else cut1, format=fmt_in)

output.set_output()

0 comments on commit 0509dec

Please sign in to comment.