AkarinVS / vapoursynth-plugin

My experimental VapourSynth plugin: (1) an enhanced LLVM-based std.Expr (aka lexpr), Select, PropExpr, Text and Tmpl. (2) DLISR. (3) DLVFX (4) CAMBI.
GNU Lesser General Public License v3.0
37 stars 8 forks source link

akarin.DLVFX => invalid pitch argument #20

Closed Selur closed 1 year ago

Selur commented 1 year ago

Using:

# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading G:\TestClips&Co\files\test.avi using LWLibavSource
clip = core.lsmas.LWLibavSource(source="G:/TestClips&Co/files/test.avi", format="YUV420P8", stream_index=0, cache=0, prefer_hw=2)
# Setting color matrix to 470bg.
clip = core.std.SetFrameProps(clip, _Matrix=5)
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0)
# Resizing using 10 - bicubic spline
clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1920, h=1056, interlaced=False, interlacedd=False) # resolution 1024x560

# load akarin plugin
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/Akarin/akarin.dll")
import os

clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
# add akarin-folder to PATH (folder includes akarin.dll and all dlls from nvidia_video_effects_sdk_installer_ada)
os.environ["PATH"] += os.pathsep +  'i:/Hybrid/64bit/vsfilters/Support/Akarin'
clip = core.akarin.DLVFX(clip, op=0, strength=0.5,model_dir='i:/Hybrid/64bit/vsfilters/Support/Akarin/models')

# Output
clip.set_output()

works fine, but using: (using another source)

# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/libimwri.dll")
# source: 'C:/Users/Selur/Desktop/36D15hum.png'
# current color space: RGB24, bit depth: 8, resolution: 1620x1080, fps: 25, color matrix: 709, yuv luminance scale: limited, scanorder: progressive
# Loading C:\Users\Selur\Desktop\36D15hum.png using vsImageReader
clip = core.imwri.Read(["C:/Users/Selur/Desktop/36D15hum.png"])
clip = core.std.Loop(clip=clip, times=100)
# Input color space is assumed to be RGB24
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=1)
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0)

# load akarin plugin
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/Akarin/akarin.dll")
import os
# convert to RGBS
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, range_s="limited")
# add akarin-folder to PATH (folder includes akarin.dll and all dlls from nvidia_video_effects_sdk_installer_ada)
os.environ["PATH"] += os.pathsep +  'i:/Hybrid/64bit/vsfilters/Support/Akarin'
clip = core.akarin.DLVFX(clip, op=0, strength=0.5,model_dir='i:/Hybrid/64bit/vsfilters/Support/Akarin/models')

# Output
clip.set_output()

fails with:

MODEL_DIR = i:/Hybrid/64bit/vsfilters/Support/Akarin/models
failed VFX call NvVFX_SetImage(d->vfx, NVVFX_INPUT_IMAGE, &d->srcGpuImg): ffffff90 (invalid pitch argument)

I tried, sticking with RGB24, resizing to mod16, but neither of them helped.

Is this a bug, or am I missing something? here's the image I use as source: 36D15hum

AkarinVS commented 1 year ago

Have you tried to pad the input so that its width/height are multiples of 32?

Selur commented 1 year ago

Yes, resizing to 1632x1088 beforehand:

# load akarin plugin
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/Akarin/akarin.dll")
import os
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS)
clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1632, h=1088, interlaced=False, interlacedd=False) # resolution 1632x1088 for mod 32
# add akarin-folder to PATH (folder includes akarin.dll and all dlls from nvidia_video_effects_sdk_installer_ada)
os.environ["PATH"] += os.pathsep +  'i:/Hybrid/64bit/vsfilters/Support/Akarin'
clip = core.akarin.DLVFX(clip, op=0, strength=0.5,model_dir='i:/Hybrid/64bit/vsfilters/Support/Akarin/models')

also results in:

MODEL_DIR = i:/Hybrid/64bit/vsfilters/Support/Akarin/models
failed VFX call NvVFX_SetImage(d->vfx, NVVFX_INPUT_IMAGE, &d->srcGpuImg): ffffff90 (invalid pitch argument)
AkarinVS commented 1 year ago

According to the NV docs, https://docs.nvidia.com/deeplearning/maxine/pdf/vfx-sdk-programming-guide.pdf, page 8. The Artifact reduction filter only supports input resolution in [90p, 1080p], so in this case, perhaps h=1088 is too large.

Please try padding (i.e. std.AddBorders) the input to make height/width multiples of 32, not resize (as it's hard to keep aspect ratio.) satisfy the requirement in the next message.

AkarinVS commented 1 year ago

The requirements for input for the artifact reduction effect:

Special thanks to @WolframRhodium for figuring this out.

Selur commented 1 year ago

Thanks! Staying inside these restrictions seems to work fine.

Selur commented 1 year ago

btw. op=0: artefact reduction. int strength controls the strength (only 0 or 1 allowed). seems wrong. At least here, values between 0 and 1 work fine.

AkarinVS commented 1 year ago

as internally the value is passed as an integer to the underlying effect, passing a value between 0 and 1 will be equivalent to passing 0.

The docs specifies that the effect only has two modes 0 and 1, please refer to the docs for details.

Selur commented 1 year ago

Ah okay. thanks for clearing that up. :)