Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
28th March 2021, 09:53 | #4261 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
@Myrsloik
is it safe to delete the user data passed to registerFunction() in Create() like the following? Code:
auto RegisterFunction(auto&& Signature, auto&& Function) { using FunctionType = std::decay_t<decltype(Function)>; auto FunctionHandle = new auto{ std::forward<decltype(Function)>(Function) }; auto Create = [](auto in, auto out, auto FunctionHandle, auto core, auto...) { auto& RegisteredFunction = *reinterpret_cast<FunctionType*>(FunctionHandle); Console{ out }.Receive(RegisteredFunction(ArgumentList{ in }, CoreProxy{ core })); delete &RegisteredFunction; }; ::vsapi->registerFunction(DeduceName(Signature), ExtractParamList(Signature), Create, FunctionHandle, ::PluginHandle); } RegisterFunction("f(x: int[])", [](auto args, auto Core) { for (auto y : args["x"]) Core.Print(static_cast<int>(y)); return 42; }); |
28th March 2021, 11:50 | #4262 | Link |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
|
No. Filter creation can be multithreaded too (mostly happens when you create and destroy filters in a getframe function).
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
28th March 2021, 12:17 | #4263 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
then who deletes the user data? I searched thru avisynth_compat.cpp and didn't find where the WrappedFunction object gets deleted
|
28th March 2021, 12:29 | #4264 | Link | |
unsigned int
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
|
Quote:
Things I noticed: - You're leaking the args VSMap. You should free it after you call invoke. - getPluginById can return NULL if the plugin you want is not loaded. fmtconv is not included with VapourSynth. You could use the built-in resizer (com.vapoursynth.resize), then you don't really have to check what getPluginById returns.
__________________
Buy me a "coffee" and/or hire me to write code! |
|
28th March 2021, 12:41 | #4265 | Link | |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
|
Quote:
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
28th March 2021, 12:44 | #4266 | Link |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
|
R53-RC1
Code:
updated visual studio 2019 runtime version updated to python 3.9 for windows fixed length calculation in y4m header (djatom) added long path support to vspipe (stax76) fixed crash in text filter with small resolution clips (jackoneill) fixed calling wrapped functions through python (IFeelBloated)
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
28th March 2021, 13:48 | #4267 | Link |
Where's my loot?
Join Date: May 2019
Posts: 63
|
Thanks for the new release!
With the portable version combined with python 3.9.2 embedded I get Code:
Failed to initialize VapourSynth environment Previously I had R52 with 3.8.8 working just fine (portable+embedded). I copied over the fresh files and I get this. The installed version works fine with the installer version of python 3.9.2... What did I do wrong? Any suggestions? I'm on Win10 20H2 x64. Both python and vs are 64-bit variants. Last edited by l00t; 28th March 2021 at 13:50. |
28th March 2021, 13:58 | #4269 | Link | |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
|
Quote:
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
28th March 2021, 15:28 | #4271 | Link | |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
Quote:
I guess I could tie the lifetime of user data to a static variable like the following Code:
struct GlobalRecyler { using RecordType = std::tuple<auto(*)(void*)->void, void*>; std::vector<RecordType> Records = {}; GlobalRecyler() = default; GlobalRecyler(const GlobalRecyler&) = delete; GlobalRecyler(GlobalRecyler&&) = delete; auto& operator=(const GlobalRecyler&) = delete; auto& operator=(GlobalRecyler&&) = delete; auto Collect(auto Garbage) { using GarbageType = std::decay_t<decltype(*Garbage)>; Records.push_back({ [](auto PointerToGarbage) { delete reinterpret_cast<GarbageType*>(PointerToGarbage); }, Garbage }); } ~GlobalRecyler() { for (auto [Recyler, Garbage] : Records) Recyler(Garbage); } }; auto RegisterFunction(auto&& Signature, auto&& Function) { using FunctionType = std::decay_t<decltype(Function)>; static auto Evil = GlobalRecyler{}; auto FunctionHandle = new auto{ std::forward<decltype(Function)>(Function) }; auto Create = [](auto in, auto out, auto FunctionHandle, auto core, auto...) { auto& RegisteredFunction = *reinterpret_cast<FunctionType*>(FunctionHandle); Console{ out }.Receive(RegisteredFunction(ArgumentList{ in }, CoreProxy{ core })); }; Evil.Collect(FunctionHandle); ::vsapi->registerFunction(DeduceName(Signature), ExtractParamList(Signature), Create, FunctionHandle, ::PluginHandle); } |
|
31st March 2021, 10:09 | #4272 | Link | |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
|
Quote:
You have to ask yourself if you're writing a wrapper to create new good plugins or if it's only a programming exercise to sexually please yourself using naughty code. The correct pattern is for the plugin itself to have an internal filter initialization counter or properly free everything on library unload. That pointer is useless if you have any idea what you're doing when writing code.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
31st March 2021, 14:57 | #4273 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
well I'm not doing it just because I can, I'm doing it because I think there is indeed a valid use case. I've excluded quite a few rarely used or deprecated things or things that are not meant to be used by plugin developers from the C API (setMessageHandler, queryCompletedFrame, releaseFrameEarly, arFrameReady, nfIsCache, nfMakeLinear, cmCompat and all Compat formats, also all "map" stuff is invisible to the user). I would have excluded the use of this pointer too if I didn't already find a use case for it.
a while ago @lansing requested an example of a bridge plugin to load Vdubfilters, while I never had the time to finish the example he/she asked for, I did take a quick glance over how it's done in avisynth. there's this configuration object (fdl) representing the state of a virtualdub filter that you must pass to a filter instance, I suppose the skeleton of the bridge plugin would be something like Code:
struct VirtualDubProxy { VirtualDubProxy(auto Arguments, auto& Configurations, auto Core) { auto& [ReferenceCounter, VirtualDubFunctionHandles, _] = Configurations; ... } static auto SpecifySignature(auto& Configurations) { auto& [_, __, RawSignature] = Configurations; ... return ... // converts RawSignature to VS signature format } .... }; for (auto& x : VirtualDubPlugin.ListFunctions()) PluginAPI::RegisterFilter<VirtualDubProxy>(x.ZipConfigurations()); |
10th April 2021, 14:50 | #4274 | Link |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
|
R53-RC2
Code:
r53: updated visual studio 2019 runtime version updated to python 3.9 for windows added scale argument to text filters (AkarinVS) fixed length calculation in y4m header (djatom) added long path support to vspipe (stax76) fixed crash in text filter with small resolution clips (jackoneill) fixed calling wrapped functions through python (IFeelBloated)
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
10th April 2021, 16:20 | #4275 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
I tested portable with Python 3.9.4, it works fine.
Long path support might not be useful currently because original/vanilla x265 builds don't support long path, most builds are modded, mods from DJATOM, Patman and MeteorRain have a vs reader included, Lighs builds are based on synth readers from DJATOM and MeteorRain, links are here: https://github.com/staxrip/staxrip/wiki/x265
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
21st April 2021, 17:59 | #4277 | Link |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
|
R53 is released!
Code:
updated visual studio 2019 runtime version updated to python 3.9 for windows added scale argument to text filters (AkarinVS) fixed length calculation in y4m header (djatom) added long path support to vspipe (stax76) fixed crash in text filter with small resolution clips (jackoneill) fixed calling wrapped functions through python (IFeelBloated)
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
23rd April 2021, 08:05 | #4279 | Link |
Registered User
Join Date: Jul 2003
Location: India
Posts: 890
|
It is a great convenience that vapousynth input script allows arrays. I am however curious whether an array of arrays for example filt:int[[],[],[],...]: opt; can be used in the code of plugin. If its possible how to get input number of arrays and number of elements in each array.
|
23rd April 2021, 09:21 | #4280 | Link | |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
|
Quote:
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
Tags |
speed, vaporware, vapoursynth |
Thread Tools | Search this Thread |
Display Modes | |
|
|