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. |
|
|
Thread Tools | Search this Thread | Display Modes |
8th October 2020, 11:44 | #61 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
new functionality: full integration of C++ exceptions. with exceptions, you no longer have to manually handle any of the following errors:
a) failing to invoke an external plugin (plugin does not exist) b) failing to invoke an external filter c) failing to invoke a python function d) failing to invoke SelfInvoker ... and possibly many more. SelfInvoker is now allowed to throw exceptions so the earlier restriction requiring SelfInvoker to always be successfully evaluated has been removed. Any of these errors will transparently pass through your filters and propagate to a root caller like Create() which automatically handles any error. To you, it would be like the error does not exist so you NEVER have to worry about errors. It's now one step closer to python scripts. Initialize() has been replaced by normal constructors because with exceptions, it is no longer required to return a value to introspect if the filter has been successfully constructed. |
16th November 2020, 15:07 | #62 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
I have nearly finished rewriting this whole thing for API v4, and I'd like to do a survey
does any one of you, including anyone that uses the vaporsynth API in external applications, use the following functions? Code:
createCore/freeCore (implemented) addMessageHandler/removeMessageHandler (implemented) getFrameAsync (implemented) createFunc (implemented) queryCompletedFrame (deprecated) releaseFrameEarly (deprecated) Last edited by feisty2; 16th January 2021 at 11:58. |
16th November 2020, 15:11 | #63 | Link | |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
|
Quote:
addMessageHandler/removeMessageHandler - vspipe/vsedit/just about all consumers of vsscript will be using it getFrameAsync - vspipe/vsedit/just about all applications retrieving frames queryCompletedFrame - deprecated and 0 known uses in the wild releaseFrameEarly - 0 known uses
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
17th November 2020, 18:14 | #64 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
I have implemented the wrapper for createFunc() in the form of Core.Mount(), but I'm not sure if the implementation is correct because this function is rarely used and certain cython functions relating to it seem "fishy". you're welcome to examine the code of Core.Mount or play with it if you're familiar with createFunc().
Core.Mount() could be used to mount any callable entity (function, function pointer, lambda expression, or any type that overloads operator()) compatible with any of the following signatures: Code:
auto() auto(auto Arguments) auto(auto Arguments, auto Core) // the return value may be of any type supported by VSMap, or an iterable container of any type supported by VSMap, or void Code:
// C++ code, inside getFrame() auto f = [](auto args) { auto msg = static_cast<std::string>(args["msg"]); vsapi->logMessage(VSMessageType::mtWarning, msg.data()); throw RuntimeError{ "hello world" }; }; ProcessedFrame["test"] = Core.Mount(f); #Python script clip = core.test.Test(clip) clip.get_frame(0).props['test'](msg = 'aaaaa') # prints 'aaaaa', then prints 'hello world' in the error message. a) the cython function Func.__call__ does not seem to handle the return value of the mounted function properly, the return value seems to be discarded in the process. b) the type deduction required by Core.Mount() is so complex that it actually crashes GCC10 if you specify a non-void function to it (internal compiler error: in cp_get_fndecl_from_callee, at cp/cvt.c:1000). I'll see if this problem has been fixed in GCC11 and file a bug report if not. |
18th November 2020, 15:14 | #65 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
I updated my toolchain and the compiler bug mentioned above has been fixed in GCC trunk. I did some quick tests and Core.Mount() properly mounts any supported function-like entity, with a void or non-void return value. Any mounted function can be properly invoked in C++ programs, however you still cannot call non-void mounted functions in python and that's something only @Myrsloik can fix. The corresponding cython code has been broken since 2014 and still hasn't been fixed.
|
18th November 2020, 16:32 | #66 | 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 |
|
18th November 2020, 17:00 | #67 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
well, I don't really have a problem with this thing being partially broken since it's rarely used anyways...
I simply wanna do some tests to verify if my implementation is correct. I'll just move on to the next function in line if there's no plan to fix this any time soon |
24th November 2020, 11:40 | #68 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
I have implemented getFrameAsync() as Node::ExpectFrame(). This is yet another function that I'm not 100% sure if I have implemented correctly since I don't have a standalone VS application like vsedit to test it. Based on my quick (and evil) test which invokes this thing inside a filter's constructor, it seems to work properly. After reading the internal code of getFrame()/getFrameAsync(), I realized it's actually a lot simpler than I originally thought. I don't need to mess with threads and locks, getFrameAsync() already renders the frame in a new thread and I simply need to return a future and fulfill the promise inside the callback.
a call to Node::ExpectFrame() instantly starts rendering the requested frame in a new thread and returns a future that lets you retrieve the frame some time later when needed. Code:
auto f = Clip.ExpectFrame(n); // instantly start rendering frame n in a new thread ... // do something else while waiting for the rendering completes auto frame = f.get(); // now retrieve frame n, if the rendering hasn't finished yet, block the current thread until the frame is available and retrieved. |
31st December 2020, 15:19 | #69 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
I have finally implemented support for custom message loggers by year 2021
the mutex thing really got me good... you may send a message to all registered loggers by calling Core.DebugPrint/Print/Alert/CriticalAlert/Abort(Message), or send a message to a particular logger x by calling x.DebugPrint/Print/Alert/CriticalAlert/Abort(Message) Core.TetherLogger() tethers a logger function to VS and returns a corresponding logger object. the logger function may be any callable entity compatible with any of the following signatures: Code:
auto(auto Message) auto(auto MessageType, auto Message) "MessageType" may be of type auto/MessageTypes/VSMessageType/int, auto assumes MessageTypes "Message" may be of type auto/const char*/std::string_view, std::string or anything constructible from const char*, auto assumes std::string_view Last edited by feisty2; 31st December 2020 at 15:36. |
16th January 2021, 23:22 | #73 | Link |
Registered User
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 321
|
Ran them three times and seemed consistent.
Code:
Old GaussBlur: Output 100000 frames in 27.22 seconds (3674.02 fps) Old GaussBlurFast: Output 100000 frames in 5.92 seconds (16891.87 fps) New GaussBlur: Output 100000 frames in 31.10 seconds (3215.69 fps) New GaussBlurFast: Output 100000 frames in 5.90 seconds (16959.92 fps) |
17th January 2021, 06:57 | #74 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
it just occurred to me that I actually changed the default padding function to "reflect" in the current version, it's a bit slower but better preserves the structure of the image, and thus GaussBlur also got a bit slower. however GaussBlurFast was not affected by such change and it is indeed now a bit faster, that's enough to prove that the optimizations do work as expected :-)
Last edited by feisty2; 17th January 2021 at 07:00. |
20th January 2021, 06:50 | #77 | Link | |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
Quote:
|
|
|
|