lypheo / vs-placebo Goto Github PK
View Code? Open in Web Editor NEWlibplacebo-based debanding, scaling and color mapping plugin for VapourSynth
License: GNU Lesser General Public License v2.1
libplacebo-based debanding, scaling and color mapping plugin for VapourSynth
License: GNU Lesser General Public License v2.1
Not sure where the problem is.
Using the shaders from https://github.com/bloc97/Anime4K/releases and for example:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.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 source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# GLSL filter: Anime4K_Darken_VeryFast.glsl
# adjusting color space from YUV420P8 to YUV444P16 for VsGLSLFilter
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
clip = core.placebo.Shader(clip=clip, shader="C:/Users/Selur/Desktop/Anime4k/Anime4K_Darken_VeryFast.glsl", width=640, height=352)
# adjusting output color from: YUV444P16 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
that the preview works fine, vspipe --info works fine, but encoding using:
[code]vspipe "E:\Temp\encodingTempSynthSkript_2021-12-26@07_38_12_9010.vpy" - -c y4m | x264 --preset veryfast --crf 18.00 --profile high --level 4.1 --ref 3 --direct auto --b-adapt 0 --sync-lookahead 48 --qcomp 0.50 --rc-lookahead 40 --qpmax 51 --partitions i4x4,p8x8,b8x8 --no-fast-pskip --subme 5 --aq-mode 0 --vbv-maxrate 62500 --vbv-bufsize 78125 --sar 1:1 --non-deterministic --range tv --colormatrix bt470bg --demuxer y4m --input-range tv --fps 25/1 --output-depth 8 --output "E:\Temp\2021-12-26@07_38_12_9010_03.264" -
fails with: `y4m [error]: bad frame header magic`
Did I make a mistake somewhere?
Is this a known limitation?
Is this the glsl filter somewho requiring an active preview to work and can't be used during encoding?
Cu Selur
nnedi3-nns128-win8x4.zip
For example, when I use the shader source file uploaded above in mpv, it goes well. But placebo.Shader
reports compiling error like input:278: error: '' : syntax error, unexpected IDENTIFIER
. And the [278]
is below:
[276] imageStore(out_image, ivec2(gl_GlobalInvocationID) * ivec2(2, 1) + ivec2(1, 0), ret);
[277] } // hook
[278] ionID) * ivec2(2, 1) + ivec2(1, 0), ret);
[279] } // hook
[280] void _main_19_0() {
[281] hook();
[282]
[283] }
It is very strange. And this problem also appears when the shader source file is relatively large.
When I try to use any shaders with core.placebo.Shader()
, I get a green blank output in VapourSynth-Editor or when piped to mpv.
When I pipe to mpv, I get this error repeatedly printed out in the terminal:
Validation failed: !params->renderable || fmt_caps & PL_FMT_CAP_RENDERABLE (../../../../../src_packages/libplacebo/src/gpu.c:234)
for texture: ../../../../../src_packages/vs-placebo/src/shader.c:122
I've done a few checks myself:
vs-placebo
release version (1.4.4)ffmpeg
's libplacebo
works, hardware incompatibilities shouldn't be an issuelsmas
and ffms2
doesn't change the outputcore.placebo.Deband()
works, so vs-placebo
is definitely loaded correctlyadaptive-sharpen
YUV444Px
as requested before passing it off to the shader functionI'm out of ideas.
CPU: Intel Core i7-9700
RAM: 8GB
GPU: Intel UHD Graphics 630, No external GPUs
OS: Windows 11 Build 22621.1778
from vapoursynth import core
import vapoursynth as vs
video = core.lsmas.LWLibavSource(source="video.mkv")
video = core.resize.Point(clip=video, format=vs.YUV444P16)
shader = core.placebo.Shader(clip=video, shader="FSR.glsl", width=1920, height=1080)
#shader = core.placebo.Deband(clip=video, iterations=2, threshold=35)
video = core.resize.Point(clip=shader, format=vs.YUV420P8)
video.set_output()
Doesn't build anymore on haasn/libplacebo@e0297b2 because of changes.
DEPRECATION: vs placebo has a non-standard version number. pip 24.1 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of vs or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at pypa/pip#12063
pip 24.1 is next milestone release
Could you also 7zip the latest release?
My environment in Windows10:
Python 3.11 + VapourSynth R62 + VapourSynth Editor r19-mod-6.2
I'm using these lines for a Dovi clip converted to SDR:
(the clip from Dolby Vision AD Demo )
v1 = core.ffms2.Source(src,width=1920, height=1080,format=vs.YUV420P16)
v2 = core.placebo.Tonemap(clip=v1, src_csp=3, dst_csp=0)
When open Preview window of VS Editor, it got these error messages.
Error on frame 0 request:
placebo.Tonemap: Clip is missing `DolbyVisionRPU` prop for Dolby Vision mapping!
How can I do to avoid this issue?
-- Can this plugin work with ffms2 Resource loader to deal dovi file?
-- Is YUV420P16 a valid format for vs-placebo?
-- Do I need additionally import RPU file or choose vulkan device in the syntax and how to?
(I can extract RPU bin from dvhe video track but I'm not sure it useful or not for this workflow.)
I can't find more info in Readme.md, please guide me more.
All the sig_*
fields were replaced, and most of the currently used code is deprecated.
Hopefully it might be easier to reproduce similar behaviour to the plplay
defaults.
Dithering to 16-bit is not necessary and indeed broken.
Test code:
import vapoursynth as vs
core = vs.core
# source: https://github.com/jursonovicst/gradient/blob/master/test_sequences/1920x1080/gradient_1920-1080_25-50_yuv444p10_x265.mp4
src = core.ffms2.Source(r'gradient_1920-1080_25-50_yuv444p10_x265.mp4')
src = core.resize.Point(src, format=vs.YUV444P16)
# I try to do nothing for all planes
db1 = core.placebo.Deband(src, planes=1|2|4, iterations=0, grain=0, dither=False)
db2 = core.placebo.Deband(src, planes=1|2|4, iterations=0, grain=0, dither=True)
# and check the difference
df1 = core.std.Expr([db1, src], 'x y - abs').std.Binarize(1) # clean result
df2 = core.std.Expr([db2, src], 'x y - abs').std.Binarize(128) # broken
final = core.std.Interleave([src, df1, df2])
final.set_output()
Trying to run the awsmfunc.MapDolbyVision function returns shader errors. I recently built libplacebo from the latest git version and rebuilt vs-placebo to be sure but the same errors persist. Perhaps the issue is specific to M1 Mac systems?
[mvk-error] VK_ERROR_INITIALIZATION_FAILED: Shader library compile failed (Error code 3):
program_source:9:51: error: use of undeclared identifier '_16_tmp'; did you mean '_15_tmp'?
constant float _33 = is_function_constant_defined(_16_tmp) ? _16_tmp : 1.0;
^~~~~~~
_15_tmp
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/31001/Libraries/lib/clang/31001.720/include/metal/metal_types:159:78: note: expanded from macro 'is_function_constant_defined'
#define is_function_constant_defined(c) __metal_is_function_constant_defined(c)
^
program_source:6:16: note: '_15_tmp' declared here
constant float _15_tmp [[function_constant(1)]];
^
program_source:9:62: error: use of undeclared identifier '_16_tmp'; did you mean '_15_tmp'?
constant float _33 = is_function_constant_defined(_16_tmp) ? _16_tmp : 1.0;
^~~~~~~
_15_tmp
program_source:6:16: note: '_15_tmp' declared here
constant float _15_tmp [[function_constant(1)]];
^
.
[mvk-error] VK_ERROR_INVALID_SHADER_NV: Fragment shader function could not be compiled into pipeline. See previous logged error.
vk_recreate_pipelines(vk, pass, has_spec, VK_NULL_HANDLE, pipe): VK_ERROR_INVALID_SHADER_NV (../src/vulkan/gpu_pass.c:586)
vertex shader source:
[ 1] #version 450
[ 2] #extension GL_KHR_shader_subgroup_basic : enable
[ 3] #extension GL_KHR_shader_subgroup_vote : enable
[ 4] #extension GL_KHR_shader_subgroup_arithmetic : enable
[ 5] #extension GL_KHR_shader_subgroup_ballot : enable
[ 6] #extension GL_KHR_shader_subgroup_shuffle : enable
[ 7] #extension GL_KHR_shader_subgroup_clustered : enable
[ 8] #extension GL_KHR_shader_subgroup_quad : enable
[ 9] #extension GL_ARB_texture_gather : enable
[ 10] layout(constant_id=0) const float _4_const = 1;
[ 11] layout(constant_id=1) const float _8004_const = 1;
[ 12] layout(binding=0) uniform sampler2D _2_src_tex;
[ 13] layout(binding=1) uniform sampler2D _8002_src_tex;
[ 14] layout(location=0) in vec2 _7_va;
[ 15] layout(location=0) out vec2 _3_tex_coord;
[ 16] layout(location=1) in vec2 _8_va;
[ 17] layout(location=1) out vec2 _8003_tex_coord;
[ 18] layout(location=2) in vec2 _9_va;
[ 19] void main() {
[ 20] _3_tex_coord = _7_va;
[ 21] _8003_tex_coord = _8_va;
[ 22] vec2 va_pos = _9_va;
[ 23] gl_Position = vec4(va_pos, 0.0, 1.0);
[ 24] }
fragment shader source:
[ 1] #version 450
[ 2] #extension GL_KHR_shader_subgroup_basic : enable
[ 3] #extension GL_KHR_shader_subgroup_vote : enable
[ 4] #extension GL_KHR_shader_subgroup_arithmetic : enable
[ 5] #extension GL_KHR_shader_subgroup_ballot : enable
[ 6] #extension GL_KHR_shader_subgroup_shuffle : enable
[ 7] #extension GL_KHR_shader_subgroup_clustered : enable
[ 8] #extension GL_KHR_shader_subgroup_quad : enable
[ 9] #extension GL_ARB_texture_gather : enable
[ 10] layout(constant_id=0) const float _4_const = 1;
[ 11] layout(constant_id=1) const float _8004_const = 1;
[ 12] layout(binding=0) uniform sampler2D _2_src_tex;
[ 13] layout(binding=1) uniform sampler2D _8002_src_tex;
[ 14] layout(location=0) in vec2 _3_tex_coord;
[ 15] layout(location=1) in vec2 _8003_tex_coord;
[ 16] layout(location=0) out vec4 out_color;
[ 17]
[ 18] vec4 _8001_main() {
[ 19] // pl_shader_sample_direct
[ 20] vec4 color = vec4(_8004_const) * textureLod(_8002_src_tex, _8003_tex_coord, 0.0);
[ 21] return color;
[ 22] }
[ 23]
[ 24] vec4 _1_main() {
[ 25] // pl_shader_sample_direct
[ 26] vec4 color = vec4(_4_const) * textureLod(_2_src_tex, _3_tex_coord, 0.0);
[ 27] {
[ 28] vec4 tmp = _8001_main();
[ 29] color[1] = tmp[0];
[ 30] }
[ 31] return color;
[ 32] }
[ 33]
[ 34] void main() {
[ 35] out_color = _1_main();
[ 36] }
Backtrace:
# 0 1 libplacebo.278.dylib 0x000000010792e078 pl_pass_create + 1520
# 1 2 libplacebo.278.dylib 0x00000001079233d4 finalize_pass + 5936
# 2 3 libplacebo.278.dylib 0x00000001079218a0 pl_dispatch_finish + 980
# 3 4 libplacebo.278.dylib 0x000000010793b7ec _img_tex + 124
# 4 5 libplacebo.278.dylib 0x00000001079361c4 pass_read_image + 2460
# 5 6 libplacebo.278.dylib 0x000000010793421c pl_render_image + 372
# 6 7 libvs_placebo.dylib 0x00000001070f5e1c vspl_tonemap_filter + 684
# 7 8 libvs_placebo.dylib 0x00000001070f7194 VSPlaceboTMGetFrame + 2524
# 8 9 libvapoursynth.dylib 0x0000000101a85464 _ZN6VSNode16getFrameInternalEiiP14VSFrameContext + 156
# 9 10 libvapoursynth.dylib 0x0000000101a969e4 _ZN12VSThreadPool8runTasksERNSt3__16atomicIbEE + 736
# 10 11 libvapoursynth.dylib 0x0000000101a98490 ZNSt3__1L14__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEPFvP12VSThreadPoolRNS_6atomicIbEEES8_NS_17reference_wrapperISA_EEEEEEEPvSH + 48
# 11 12 libsystem_pthread.dylib 0x0000000187b8bfa8 _pthread_start + 148
# 12 13 libsystem_pthread.dylib 0x0000000187b86da0 thread_start + 8
Failed creating render pass for dispatch
Failed dispatching intermediate pass!
Failed dispatching plane merging shader, disabling FBOs!
Failed rendering image!
[mvk-error] VK_ERROR_INITIALIZATION_FAILED: Shader library compile failed (Error code 3):
program_source:15:51: error: use of undeclared identifier '_20_tmp'; did you mean '_19_tmp'?
constant float _61 = is_function_constant_defined(_20_tmp) ? _20_tmp : 1.0;
^~~~~~~
_19_tmp
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/31001/Libraries/lib/clang/31001.720/include/metal/metal_types:159:78: note: expanded from macro 'is_function_constant_defined'
#define is_function_constant_defined(c) __metal_is_function_constant_defined(c)
^
program_source:6:16: note: '_19_tmp' declared here
constant float _19_tmp [[function_constant(2)]];
^
program_source:15:62: error: use of undeclared identifier '_20_tmp'
constant float _61 = is_function_constant_defined(_20_tmp) ? _20_tmp : 1.0;
^
.
[mvk-error] VK_ERROR_INVALID_SHADER_NV: Fragment shader function could not be compiled into pipeline. See previous logged error.
vk_recreate_pipelines(vk, pass, has_spec, VK_NULL_HANDLE, pipe): VK_ERROR_INVALID_SHADER_NV (../src/vulkan/gpu_pass.c:586)
vertex shader source:
[ 1] #version 450
[ 2] #extension GL_KHR_shader_subgroup_basic : enable
[ 3] #extension GL_KHR_shader_subgroup_vote : enable
[ 4] #extension GL_KHR_shader_subgroup_arithmetic : enable
[ 5] #extension GL_KHR_shader_subgroup_ballot : enable
[ 6] #extension GL_KHR_shader_subgroup_shuffle : enable
[ 7] #extension GL_KHR_shader_subgroup_clustered : enable
[ 8] #extension GL_KHR_shader_subgroup_quad : enable
[ 9] #extension GL_ARB_texture_gather : enable
[ 10] layout(std430, push_constant) uniform PushC {
[ 11] layout(offset=0) float _7_lo;
[ 12] layout(offset=4) float _8_hi;
[ 13] layout(offset=16) vec4 _9_coeffs;
[ 14] layout(offset=32) float _b_lo;
[ 15] layout(offset=36) float _c_hi;
[ 16] layout(offset=48) vec4 _d_coeffs;
[ 17] layout(offset=64) float _f_lo;
[ 18] layout(offset=68) float _10_hi;
[ 19] layout(offset=80) vec3 _12_cmat_c;
[ 20] layout(offset=92) float _17_const;
[ 21] layout(offset=96) vec3 _28_cmat_c;
[ 22] layout(offset=108) float _5_pivots[7];
[ 23] layout(offset=144) vec4 _6_coeffs[8];
[ 24] layout(offset=272) vec4 _a_mmr[6];
[ 25] layout(offset=368) vec4 _e_mmr[6];
[ 26] layout(offset=464) mat3 _11_cmat;
[ 27] layout(offset=512) mat3 _13_lms2rgb;
[ 28] layout(offset=560) mat3 _14_mat;
[ 29] layout(offset=608) mat3 _15_mat;
[ 30] layout(offset=656) mat3 _18_mat;
[ 31] layout(offset=704) mat3 _26_mat;
[ 32] layout(offset=752) mat3 _27_cmat;
[ 33] };
[ 34] layout(constant_id=0) const float _2_const = 1;
[ 35] layout(constant_id=1) const float _3_const = 1;
[ 36] layout(constant_id=2) const float _8004_const = 1;
[ 37] layout(constant_id=3) const float _4004_const = 1;
[ 38] layout(constant_id=4) const float _c004_const = 1;
[ 39] layout(constant_id=5) const float _4_const = 1;
[ 40] layout(constant_id=6) const float _16_const = 1;
[ 41] layout(constant_id=7) const float _1c_const = 1;
[ 42] layout(constant_id=8) const float _1d_const = 1;
[ 43] layout(constant_id=9) const float _1f_const = 1;
[ 44] layout(constant_id=10) const float _20_const = 1;
[ 45] layout(constant_id=11) const float _22_const = 1;
[ 46] layout(constant_id=12) const float _23_const = 1;
[ 47] layout(constant_id=13) const float _24_const = 1;
[ 48] layout(constant_id=14) const float _25_const = 1;
[ 49] layout(constant_id=15) const float _29_const = 1;
[ 50] layout(binding=0) uniform sampler2D _8002_src_tex;
[ 51] layout(binding=1) uniform sampler2D _4002_src_tex;
[ 52] layout(binding=2) uniform sampler2D _c002_src_tex;
[ 53] layout(binding=3) uniform sampler3D _1a_weights;
[ 54] layout(location=0) in vec2 _2d_va;
[ 55] layout(location=0) out vec2 _8003_tex_coord;
[ 56] layout(location=1) in vec2 _2e_va;
[ 57] layout(location=1) out vec2 _4003_tex_coord;
[ 58] layout(location=2) in vec2 _2f_va;
[ 59] layout(location=2) out vec2 _c003_tex_coord;
[ 60] layout(location=3) in vec2 _30_va;
[ 61] void main() {
[ 62] _8003_tex_coord = _2d_va;
[ 63] _4003_tex_coord = _2e_va;
[ 64] _c003_tex_coord = _2f_va;
[ 65] vec2 va_pos = _30_va;
[ 66] gl_Position = vec4(va_pos, 0.0, 1.0);
[ 67] }
fragment shader source:
[ 1] #version 450
[ 2] #extension GL_KHR_shader_subgroup_basic : enable
[ 3] #extension GL_KHR_shader_subgroup_vote : enable
[ 4] #extension GL_KHR_shader_subgroup_arithmetic : enable
[ 5] #extension GL_KHR_shader_subgroup_ballot : enable
[ 6] #extension GL_KHR_shader_subgroup_shuffle : enable
[ 7] #extension GL_KHR_shader_subgroup_clustered : enable
[ 8] #extension GL_KHR_shader_subgroup_quad : enable
[ 9] #extension GL_ARB_texture_gather : enable
[ 10] layout(std430, push_constant) uniform PushC {
[ 11] layout(offset=0) float _7_lo;
[ 12] layout(offset=4) float _8_hi;
[ 13] layout(offset=16) vec4 _9_coeffs;
[ 14] layout(offset=32) float _b_lo;
[ 15] layout(offset=36) float _c_hi;
[ 16] layout(offset=48) vec4 _d_coeffs;
[ 17] layout(offset=64) float _f_lo;
[ 18] layout(offset=68) float _10_hi;
[ 19] layout(offset=80) vec3 _12_cmat_c;
[ 20] layout(offset=92) float _17_const;
[ 21] layout(offset=96) vec3 _28_cmat_c;
[ 22] layout(offset=108) float _5_pivots[7];
[ 23] layout(offset=144) vec4 _6_coeffs[8];
[ 24] layout(offset=272) vec4 _a_mmr[6];
[ 25] layout(offset=368) vec4 _e_mmr[6];
[ 26] layout(offset=464) mat3 _11_cmat;
[ 27] layout(offset=512) mat3 _13_lms2rgb;
[ 28] layout(offset=560) mat3 _14_mat;
[ 29] layout(offset=608) mat3 _15_mat;
[ 30] layout(offset=656) mat3 _18_mat;
[ 31] layout(offset=704) mat3 _26_mat;
[ 32] layout(offset=752) mat3 _27_cmat;
[ 33] };
[ 34] layout(constant_id=0) const float _2_const = 1;
[ 35] layout(constant_id=1) const float _3_const = 1;
[ 36] layout(constant_id=2) const float _8004_const = 1;
[ 37] layout(constant_id=3) const float _4004_const = 1;
[ 38] layout(constant_id=4) const float _c004_const = 1;
[ 39] layout(constant_id=5) const float _4_const = 1;
[ 40] layout(constant_id=6) const float _16_const = 1;
[ 41] layout(constant_id=7) const float _1c_const = 1;
[ 42] layout(constant_id=8) const float _1d_const = 1;
[ 43] layout(constant_id=9) const float _1f_const = 1;
[ 44] layout(constant_id=10) const float _20_const = 1;
[ 45] layout(constant_id=11) const float _22_const = 1;
[ 46] layout(constant_id=12) const float _23_const = 1;
[ 47] layout(constant_id=13) const float _24_const = 1;
[ 48] layout(constant_id=14) const float _25_const = 1;
[ 49] layout(constant_id=15) const float _29_const = 1;
[ 50] layout(binding=0) uniform sampler2D _8002_src_tex;
[ 51] layout(binding=1) uniform sampler2D _4002_src_tex;
[ 52] layout(binding=2) uniform sampler2D _c002_src_tex;
[ 53] layout(binding=3) uniform sampler3D _1a_weights;
[ 54] layout(location=0) in vec2 _8003_tex_coord;
[ 55] layout(location=1) in vec2 _4003_tex_coord;
[ 56] layout(location=2) in vec2 _c003_tex_coord;
[ 57] layout(location=0) out vec4 out_color;
[ 58]
[ 59] vec4 _8001_main() {
[ 60] // pl_shader_sample_direct
[ 61] vec4 color = vec4(_8004_const) * textureLod(_8002_src_tex, _8003_tex_coord, 0.0);
[ 62] return color;
[ 63] }
[ 64]
[ 65] vec4 _4001_main() {
[ 66] // pl_shader_sample_direct
[ 67] vec4 color = vec4(_4004_const) * textureLod(_4002_src_tex, _4003_tex_coord, 0.0);
[ 68] return color;
[ 69] }
[ 70]
[ 71] vec4 _c001_main() {
[ 72] // pl_shader_sample_direct
[ 73] vec4 color = vec4(_c004_const) * textureLod(_c002_src_tex, _c003_tex_coord, 0.0);
[ 74] return color;
[ 75] }
[ 76]
[ 77] #define _1b_LUT_SCALE(x) (_1c_const * (x) + _1d_const)
[ 78] #define _1e_LUT_SCALE(x) (_1f_const * (x) + _20_const)
[ 79] #define _21_LUT_SCALE(x) (_22_const * (x) + _23_const)
[ 80] #define _19_lut(pos) (textureLod(_1a_weights, vec3(
[ 81] _1b_LUT_SCALE(vec3(pos).x)
[ 82] ,_1e_LUT_SCALE(vec3(pos).y)
[ 83] ,_21_LUT_SCALE(vec3(pos).z)
[ 84] ), 0.0).xyzw)
[ 85] vec4 _1_main() {
[ 86] vec4 color = vec4(_2_const, vec2(_3_const), 1.0);
[ 87] // pass_read_image
[ 88] {
[ 89] vec4 tmp;
[ 90] tmp = _8001_main();
[ 91] color[0] = tmp[0];
[ 92] tmp = _4001_main();
[ 93] color[1] = tmp[0];
[ 94] tmp = _c001_main();
[ 95] color[2] = tmp[0];
[ 96] }
[ 97] // pl_shader_decode_color
[ 98] {
[ 99] color.rgb *= vec3(_4_const);
[100] // pl_shader_reshape
[101] {
[102] vec3 sig;
[103] vec4 coeffs;
[104] float s;
[105] sig = clamp(color.rgb, 0.0, 1.0);
[106] s = sig[0];
[107] #define test(i) bvec4(s >= _5_pivots[i])
[108] #define coef(i) _6_coeffs[i]
[109] coeffs = mix(mix(mix(coef(0), coef(1), test(0)),
[110] mix(coef(2), coef(3), test(2)),
[111] test(1)),
[112] mix(mix(coef(4), coef(5), test(4)),
[113] mix(coef(6), coef(7), test(6)),
[114] test(5)),
[115] test(3));
[116] #undef test
[117] #undef coef
[118] s = (coeffs.z * s + coeffs.y) * s + coeffs.x;
[119] color[0] = clamp(s, _7_lo, _8_hi);
[120] s = sig[1];
[121] coeffs = _9_coeffs;
[122] {
[123] const uint mmr_idx = 0u;
[124] vec4 sigX;
[125] s = coeffs.x;
[126] sigX.xyz = sig.xxy * sig.yzz;
[127] sigX.w = sigX.x * sig.z;
[128] s += dot(_a_mmr[mmr_idx + 0].xyz, sig);
[129] s += dot(_a_mmr[mmr_idx + 1], sigX);
[130] vec3 sig2 = sig * sig;
[131] vec4 sigX2 = sigX * sigX;
[132] s += dot(_a_mmr[mmr_idx + 2].xyz, sig2);
[133] s += dot(_a_mmr[mmr_idx + 3], sigX2);
[134] s += dot(_a_mmr[mmr_idx + 4].xyz, sig2 * sig);
[135] s += dot(_a_mmr[mmr_idx + 5], sigX2 * sigX);
[136] }
[137] color[1] = clamp(s, _b_lo, _c_hi);
[138] s = sig[2];
[139] coeffs = _d_coeffs;
[140] {
[141] const uint mmr_idx = 0u;
[142] vec4 sigX;
[143] s = coeffs.x;
[144] sigX.xyz = sig.xxy * sig.yzz;
[145] sigX.w = sigX.x * sig.z;
[146] s += dot(_e_mmr[mmr_idx + 0].xyz, sig);
[147] s += dot(_e_mmr[mmr_idx + 1], sigX);
[148] vec3 sig2 = sig * sig;
[149] vec4 sigX2 = sigX * sigX;
[150] s += dot(_e_mmr[mmr_idx + 2].xyz, sig2);
[151] s += dot(_e_mmr[mmr_idx + 3], sigX2);
[152] s += dot(_e_mmr[mmr_idx + 4].xyz, sig2 * sig);
[153] s += dot(_e_mmr[mmr_idx + 5], sigX2 * sigX);
[154] }
[155] color[2] = clamp(s, _f_lo, _10_hi);
[156] }
[157] color.rgb = _11_cmat * color.rgb + _12_cmat_c;
[158] color.rgb = pow(max(color.rgb, 0.0), vec3(1.0/78.84375000000000000000));
[159] color.rgb = max(color.rgb - vec3(0.83593750000000000000), 0.0)
[160] / (vec3(18.85156250000000000000) - vec3(18.68750000000000000000) * color.rgb);
[161] color.rgb = pow(color.rgb, vec3(1.0/0.15930175781250000000));
[162] color.rgb = _13_lms2rgb * color.rgb;
[163] color.rgb = pow(max(color.rgb, 0.0), vec3(0.15930175781250000000));
[164] color.rgb = (vec3(0.83593750000000000000) + vec3(18.85156250000000000000) * color.rgb)
[165] / (vec3(1.0) + vec3(18.68750000000000000000) * color.rgb);
[166] color.rgb = pow(color.rgb, vec3(78.84375000000000000000));
[167] }
[168] // pl_shader_color_map
[169] {
[170] // pl_shader_linearize
[171] color.rgb = max(color.rgb, 0.0);
[172] color.rgb = pow(color.rgb, vec3(1.0/78.84375000000000000000));
[173] color.rgb = max(color.rgb - vec3(0.83593750000000000000), 0.0)
[174] / (vec3(18.85156250000000000000) - vec3(18.68750000000000000000) * color.rgb);
[175] color.rgb = pow(color.rgb, vec3(1.0/0.15930175781250000000));
[176] color.rgb *= vec3(49.26108374384236298501);
[177] vec3 clipped = clamp(color.rgb, _16_const, _17_const);
[178] vec3 lms = _18_mat * clipped;
[179] vec3 lmspq = 0.02030000090599060058 * lms;
[180] lmspq = pow(max(lmspq, 0.0), vec3(0.15930175781250000000));
[181] lmspq = (vec3(0.83593750000000000000) + 18.85156250000000000000 * lmspq)
[182] / (vec3(1.0) + 18.68750000000000000000 * lmspq);
[183] lmspq = pow(lmspq, vec3(78.84375000000000000000));
[184] vec3 ipt = _14_mat * lmspq;
[185] vec3 idx;
[186] idx.x = _24_const * ipt.x + _25_const;
[187] idx.y = 2.0 * length(ipt.yz);
[188] idx.z = 0.15915494309189533814 * atan(ipt.z, ipt.y) + 0.5;
[189] ipt = _19_lut(idx).xyz;
[190] lmspq = _15_mat * ipt;
[191] lms = pow(max(lmspq, 0.0), vec3(1.0/78.84375000000000000000));
[192] lms = max(lms - vec3(0.83593750000000000000), 0.0)
[193] / (vec3(18.85156250000000000000) - 18.68750000000000000000 * lms);
[194] lms = pow(lms, vec3(1.0/0.15930175781250000000));
[195] lms *= 49.26108551025390625000;
[196] color.rgb = _26_mat * lms;
[197] // pl_shader_delinearize
[198] color.rgb = max(color.rgb, 0.0);
[199] color.rgb *= vec3(1.0/49.26108551025390625000);
[200] color.rgb = pow(color.rgb, vec3(0.15930175781250000000));
[201] color.rgb = (vec3(0.83593750000000000000) + vec3(18.85156250000000000000) * color.rgb)
[202] / (vec3(1.0) + vec3(18.68750000000000000000) * color.rgb);
[203] color.rgb = pow(color.rgb, vec3(78.84375000000000000000));
[204] }
[205] // pl_shader_encode_color
[206] {
[207] color.rgb = _27_cmat * color.rgb + _28_cmat_c;
[208] color.rgb *= vec3(color.a);
[209] }
[210] color *= vec4(1.0 / _29_const);
[211] vec4 _2a_orig_color = color;
[212] color = vec4(0.0, 0.0, 0.0, 1.0);
[213] color[0] = _2a_orig_color[0];
[214] color[1] = _2a_orig_color[1];
[215] color[2] = _2a_orig_color[2];
[216] return color;
[217] }
[218]
[219] void main() {
[220] out_color = _1_main();
[221] }
Backtrace:
#0 1 libplacebo.278.dylib 0x000000010792e078 pl_pass_create + 1520
# 1 2 libplacebo.278.dylib 0x00000001079233d4 finalize_pass + 5936
# 2 3 libplacebo.278.dylib 0x00000001079218a0 pl_dispatch_finish + 980
# 3 4 libplacebo.278.dylib 0x00000001079389f0 pass_output_target + 3548
# 4 5 libplacebo.278.dylib 0x000000010793423c pl_render_image + 404
# 5 6 libvs_placebo.dylib 0x00000001070f5e1c vspl_tonemap_filter + 684
# 6 7 libvs_placebo.dylib 0x00000001070f7194 VSPlaceboTMGetFrame + 2524
# 7 8 libvapoursynth.dylib 0x0000000101a85464 _ZN6VSNode16getFrameInternalEiiP14VSFrameContext + 156
# 8 9 libvapoursynth.dylib 0x0000000101a969e4 _ZN12VSThreadPool8runTasksERNSt3__16atomicIbEE + 736
# 9 10 libvapoursynth.dylib 0x0000000101a98490 ZNSt3__1L14__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEPFvP12VSThreadPoolRNS_6atomicIbEEES8_NS_17reference_wrapperISA_EEEEEEEPvSH + 48
# 10 11 libsystem_pthread.dylib 0x0000000187b8bfa8 _pthread_start + 148
# 11 12 libsystem_pthread.dylib 0x0000000187b86da0 thread_start + 8
Failed creating render pass for dispatch
Failed rendering image!
...
Failed rendering image!
Input #0, yuv4mpegpipe, from 'pipe:':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (Y3[11][12] / 0xC0B3359), yuv420p12le(progressive), 3840x2160, 23.33 fps, 23.33 tbr, 23.33 tbn
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> hevc (libx265))
x265 [info]: HEVC encoder version 3.4+31-6722fce1f
x265 [info]: build info [Mac OS X][clang 13.0.0][32 bit][noasm] 12bit
x265 [info]: using cpu capabilities: none!
x265 [warning]: halving the quality when psy-rd is enabled for 444 input. Setting cbQpOffset = 6 and crQpOffset = 6
x265 [info]: Main 4:4:4 12 profile, Level-5 (Main tier)
x265 [info]: Thread pool created using 10 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 3 / wpp(68 rows)
x265 [info]: Coding QT: max CU size, min CU size : 32 / 16
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge : dia / 57 / 0 / 2
x265 [info]: Cb/Cr QP Offset : 6 / 6
x265 [info]: Lookahead / bframes / badapt : 5 / 3 / 0
x265 [info]: b-pyramid / weightp / weightb : 1 / 0 / 0
x265 [info]: References / ref-limit cu / depth : 1 / off / off
x265 [info]: AQ: mode / str / qg-size / cu-tree : 1 / 0.0 / 32 / 1
x265 [info]: Rate Control / qCompress : CRF-0.0 / 0.60
x265 [info]: tools: rd=2 psy-rd=2.00 early-skip rskip mode=1 tmvp fast-intra
x265 [info]: tools: strong-intra-smoothing lslices=8 deblock
Output #0, matroska, to 'test.mkv':
Metadata:
encoder : Lavf60.3.100
Stream #0:0: Video: hevc, yuv444p12le(tv, progressive), 3840x2160, q=2-31, 23.33 fps, 1k tbn
Metadata:
encoder : Lavc60.3.100 libx265
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Output 219 frames in 67.35 seconds (3.25 fps)e=00:00:08.48 bitrate=9638.1kbits/s speed=0.182x
frame= 219 fps=4.3 q=7.0 Lsize= 16408kB time=00:00:09.25 bitrate=14520.1kbits/s speed=0.181x
video:16403kB audio:0kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 0.028249%
x265 [info]: frame I: 1, Avg QP:4.94 kb/s: 964.88
x265 [info]: frame P: 55, Avg QP:4.53 kb/s: 29503.19
x265 [info]: frame B: 163, Avg QP:6.67 kb/s: 9273.66
x265 [info]: consecutive B-frames: 1.8% 1.8% 0.0% 96.4%
encoded 219 frames in 51.12s (4.28 fps), 14316.20 kb/s, Avg QP:6.12`
The output video is a pure green image with hints of the EL on top. Any help would be appreciated.
There is a problem with shaders when CRLF is used for Newline instead of LF. There is no error, but the result is not what it should be.
Some shaders have "parameters" like:
#define INTENSITY_SIGMA 0.1 //Intensity window size, higher is stronger denoise, must be a positive real number
#define SPATIAL_SIGMA 1.0 //Spatial window size, higher is stronger denoise, must be a positive real number
https://github.com/bloc97/Anime4K/tree/master/glsl
Is it possible to change those parameters on the fly with placebo.Shader()? If not, would it be hard to implement?
I wrote a simple glsl shader, here is the code:
//!HOOK LUMA
//!BIND LUMA
//!DESC HZ
vec4 hook(){
return vec4(float(LUMA_texOff(vec2(0,0)))*2, 0, 0, 1);
}
It only doubles the values of luma, and works properly in my mpv player.
But when I tries to use it in vs-placebo, it does not work at all.
I have tried "FSRCNNX_x2_8-0-4-1.glsl" in vs-placebo, and it worked well.
Because it is an environment with multiple GPUs
placebo.Shader needs the ability to select a GPU
Using:
//!HOOK MAIN
//!BIND HOOKED
//!DESC Levels
// Define levels adjustment parameters
#define input_low 16.0
#define input_high 235.0
#define gamma 1.0
#define output_low 16.0
#define output_high 235.0
vec4 hook() {
vec4 color = HOOKED_texOff(0);
// Normalize input and output parameters to [0, 1] range
float input_low_norm = input_low / 255.0;
float input_high_norm = input_high / 255.0;
float output_low_norm = output_low / 255.0;
float output_high_norm = output_high / 255.0;
// Apply input low/high levels
vec3 normalized = (color.rgb - input_low_norm) / (input_high_norm - input_low_norm);
// Ensure values are within the [0, 1] range before gamma correction
normalized = clamp(normalized, 0.0, 1.0);
// Apply gamma correction using 1/gamma
vec3 gamma_corrected = pow(normalized, vec3(1.0 / gamma));
// Apply output low/high levels
vec3 adjusted_output = gamma_corrected * (output_high_norm - output_low_norm) + output_low_norm;
// Ensure values are within the [0, 1] range
color.rgb = clamp(adjusted_output, 0.0, 1.0);
return color;
}
through:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
import sys
import os
core = vs.core
# Import scripts folder
scriptPath = 'F:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# loading plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
# Import scripts
import validate
# Source: 'G:\TestClips&Co\files\test.avi'
# Current color space: YUV420P8, bit depth: 8, resolution: 640x352, frame rate: 25fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
# 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=0)
frame = clip.get_frame(0)
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip=clip, _Matrix=5)
# setting color transfer (170), if it is not set.
if validate.transferIsInvalid(clip):
clip = core.std.SetFrameProps(clip=clip, _Transfer=6)
# setting color primaries info (to 470), if it is not set.
if validate.primariesIsInvalid(clip):
clip = core.std.SetFrameProps(clip=clip, _Primaries=5)
# setting color range to TV (limited) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)
# making sure frame rate is set to 25fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# making sure the detected scan type is set (detected: progressive)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=0) # progressive
# adjusting color space from YUV420P8 to YUV444P16 for vsGLSLLevels
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/Levels.glsl") as glslf:
glsl = glslf.read()
clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
# adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
# set output frame rate to 25fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# output
clip.set_output()
I expected the filtered and the unfiltered version to be identical, which they are not.
Is there a bug in vs-placebo? Am I using it wrong? Is there a bug in my shader code?
Libplacebo has gotten a massive overhaul in many categories recently. We now have many gamut-mapping modes, improved tonemapping, scaler antiringing, etc... All of this is completely missing in the current vs-placebo build. Any kind of update to bring these features over would be great.
Hi, using shader="path to file" works fine for me, but using 'shader_s' does not.
Since my python skills aren't that high I'm not sure whether I made a mistake or this is a bug. :)
Calling:
# Imports
import vapoursynth as vs
core = vs.get_core()
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# source: 'G:\TestClips&Co\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/test.avi",cachefile="E:/Temp/avi_9dec25d3f707eb4813d42334c7f1a8d6_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Point(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# GLSL filter: adaptive-sharpen.glsl
# adjusting color space from YUV420P8 to YUV444P16 for VsGLSLFilter
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
with open("I:/Hybrid/64bit/vsfilters/GLSL/adaptive-sharpen.glsl") as glslf:
glsl = glslf.read()
glsl = glsl.replace('#define curve_height 1.0', '#define curve_height 2.0');
clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=640, height=352)
# adjusting output color from: YUV444P16 to YUV420P10 for x265Model (i420@8)
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
I get:
Failed to evaluate the script:
Python exception: Shader: Function does not take argument(s) named shader_s
Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 2242, in vapoursynth.vpy_evaluateScript
File "src\cython\vapoursynth.pyx", line 2243, in vapoursynth.vpy_evaluateScript
File "C:\Users\Selur\Desktop\test.vpy", line 23, in <module>
clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=640, height=352)
File "src\cython\vapoursynth.pyx", line 2040, in vapoursynth.Function.__call__vapoursynth.Error: Shader: Function does not take argument(s) named shader_s
according to:
placebo.Shader(clip clip, [string shader, int width, int height, int chroma_loc = 1, int matrix = 2, int trc = 1, string filter = "ewa_lanczos", float radius, float clamp, float taper, float blur, float param1, float param2, float antiring = 0.0, int lut_entries = 64, float cutoff = 0.001, bool sigmoidize = 1, bool linearize = 1, float sigmoid_center = 0.75, float sigmoid_slope = 6.5, string shader_s])
this should work, shouldn't it?
Cu Selur
Hi, I'm using placebo.Shader to run Alexkral/AviSynthAiUpscale's mpv syntax shader. As I'm a fresher to glsl shader and Alexkral is fresher to vapoursynth at all, we cannot locate the cause of the error.
It looks like we're using the same code, but I run into problems and he can run it correctly. I wonder if I can get help here, thx!
Further error description and informations at Alexkral/AviSynthAiUpscale#5
Splitting up the planes and processing them all separately gives me a pretty big speedup.
import vsutil
clip = core.ffms2.Source()
clip = vsutil.depth(clip, 16)
a = core.placebo.Deband(clip, planes=1|2|4, threshold=4, radius=16, grain=0)
b = vsutil.join([core.placebo.Deband(x, planes=1, threshold=4, radius=16, grain=0) for x in vsutil.split(clip)])
core.std.Expr([a,b], 'x y = 0 65535 ?').set_output() # green
a.set_output() # Time elapsed: 0:43.090 - 69.62245859547165593995 FPS
b.set_output() # Time elapsed: 0:26.074 - 115.05868775474569076778 FPS
Having an issue on certain files (linked a sample of one of those below) where I'm getting this error. I looked at this issue here #39 and tested the FFMS2 build as suggested as well as the latest FFMS2 5.0 from here https://github.com/FFMS/ffms2/releases/tag/5.0 and they both produce the same error (as well as LSMASH).
Sample:
https://drive.google.com/file/d/1jG5iM1durg-Likk0rpXx3zLtU4LmJ3Ar/view?usp=sharing
This same file works with dovi baker.
Note: this also fails with https://github.com/Asd-g/avslibplacebo
Thanks!
When updating vs-placebo and trying to run a script, it will return the following error:
AttributeError: No attribute with the name placebo exists. Did you mistype a plugin namespace?
Downgrading to v1.4.1 fixes this issue. I'm not at all familiar with C, and I can't find any obvious places for the regression to have taken place between 1.4.1 and 1.4.2.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.