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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 16th January 2021, 15:21   #4221  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,505
@Myrsloik
what are some of the other things I need to do to make my project the preferred C++ wrapper for VS over vsxx?
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 17th January 2021, 13:30   #4222  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,279
Quote:
Originally Posted by feisty2 View Post
@Myrsloik
what are some of the other things I need to do to make my project the preferred C++ wrapper for VS over vsxx?
Find 3 people who prefer it I guess? I don't use either so I have no opinion about which one is better...
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 17th January 2021, 16:21   #4223  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,365
We don't need no steenkin' wrappers. Imagine having a bug in your filter and having to go to feisty2 for support.
videoh is offline   Reply With Quote
Old 17th January 2021, 17:03   #4224  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,660
But it's pythonic and C++20, don't you like it?
stax76 is offline   Reply With Quote
Old 17th January 2021, 17:42   #4225  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,365
I'm sure it's wonderful and great for noobs.
videoh is offline   Reply With Quote
Old 17th January 2021, 18:59   #4226  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,864
I'm sure that its lovely Feisty, Myrsloik and VideoH are just being, well themselves really
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 17th January 2021, 19:34   #4227  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,505
Quote:
Originally Posted by videoh View Post
Imagine having a bug in your filter and having to go to feisty2 for support.
that is simply not true. the source code is publicly available and extremely easy to understand. anyone reasonably familiar with the C++ language should be able to manipulate the wrapper (adding more functionality, fixing bugs, etc.) however he or she wants with zero difficulty.
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 17th January 2021, 19:53   #4228  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,365
Where is the documentation for the wrapper?

Visual Studio solution files for building the examples?

Last edited by videoh; 17th January 2021 at 20:00.
videoh is offline   Reply With Quote
Old 17th January 2021, 20:15   #4229  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,505
Quote:
Originally Posted by videoh View Post
I'm sure it's wonderful and great for noobs.
also not true. the wrapper covers all functions provided by the C API, so anything you can do with the low level API, you can do the same with the C++ wrapper, plus the much cleaner and more concise syntax while also being less error prone. there is no performance cost (as long as you choose not to enable some dynamic features like automatic padding which are meant for fast prototyping), everything is built upon zero cost abstraction. even experienced developers should enjoy some benefits like RAII and expect less memory errors.

someone must be a masochist to prefer
Code:
auto std = vsapi->getPluginByNs("std", core);
auto args = vsapi->createMap();
vsapi->propSetNode(args, "clip", node, paAppend);
vsapi->freeNode(node);
auto ret = vsapi->invoke(std, "Transpose", args);
vsapi->freeMap(args);
node = vsapi->propGetNode(ret, "clip", 0, nullptr);
vsapi->freeMap(ret);
over

Code:
auto TransposedClip = Core["std"]["Transpose"]("clip", InputClip);
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 17th January 2021, 20:54   #4230  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,505
Quote:
Originally Posted by videoh View Post
Where is the documentation for the wrapper?

Visual Studio solution files for building the examples?
I haven't started working on documentation and I'll get started once all interface design is finalized. I have covered all functions in the C API but the filter backbone is still subject to change.

for now, you can find various examples here: https://github.com/IFeelBloated/vsFi...aster/Examples

GaussBlur - simple 3x3 convolutional filter

TemporalMedian - a temporal filter

Rec601ToRGB - an example showing how to write filters that manipulate frame properties, and output a video clip of a different format than its input

Crop - an example showing how to write filters that deal with various bitdepths, and output a video clip with a different image size

ModifyFrame - an example showing how to write filters that interact with Python scripts.

Palette - an example showing how to write filters with multiple outputs

SeparableConvolution - an example showing how to write filters that invoke external filters and itself

GaussBlurFast - an example showing how to write filters without automatic padding.

msvc is not currently supported, because it lacks many core language features of C++20 (mainly concepts). you need at least GCC 10.2 to compile the examples
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 17th January 2021, 21:47   #4231  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,365
It's undocumented and I can't build with it or debug it in my development environment. I'm such a masochist for not using it.
videoh is offline   Reply With Quote
Old 20th January 2021, 00:21   #4232  |  Link
sl1pkn07
Pajas Mentales...
 
Join Date: Dec 2004
Location: Spanishtán
Posts: 480
@videoh. is a joke?

> I can't build with it or debug it in my development environment.

maybe is your problem(?)
__________________
[AUR] Vapoursynth Stuff
[AUR] Avisynth Stuff
sl1pkn07 is offline   Reply With Quote
Old 20th January 2021, 03:05   #4233  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,365
Because Visual Studio on Windows has such a tiny usage. I'm the only one that would be stupid enough to have such an environment.

Hey, he called me a masochist for not using his stuff. How about you mind your own business? Or how about you ask him to create some documentation, for God's sake?

The only joke here is the never-DG guys continually twisting themselves into pretzels. Pitiful.

Last edited by videoh; 20th January 2021 at 03:14.
videoh is offline   Reply With Quote
Old 20th January 2021, 07:48   #4234  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,505
it's nobody's problem, msvc is well known to be slow on supporting new C++ features (it's also not the worst tho, apple clang is far worse than msvc in terms of C++20 support). things will get there eventually. the main problem with msvc currently is that it does not provide complete support for concepts, a major C++20 feature that the wrapper relies on heavily.

and the masochist thing is not personal, using the low level API not only requires more work to do the same thing, it is also very error prone in certain cases, especially when dealing with reference counted objects. you won't believe how easy and how likely it is to forget calling that "free" function marked in red in the following code block
Code:
auto std = vsapi->getPluginByNs("std", core);
auto args = vsapi->createMap();
vsapi->propSetNode(args, "clip", node, paAppend);
vsapi->freeNode(node); // manually releasing resource acquired in a foreign scope, highly error prone.
auto ret = vsapi->invoke(std, "Transpose", args);
vsapi->freeMap(args);
node = vsapi->propGetNode(ret, "clip", 0, nullptr);
vsapi->freeMap(ret);
and bang! there you have a memory leak. and that's what I meant by "masochist", to rely on the not always so consciously stable human willpower to deal with all that when you have the option to let a language facility do it automatically for you.
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 20th January 2021, 12:45   #4235  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,365
Quote:
Originally Posted by feisty2 View Post
when you have the option to let a language facility do it automatically for you
I don't have that option, and I can't wait for eventually.

And do yourself a favor and write some documentation. Examples are not enough.
videoh is offline   Reply With Quote
Old 22nd January 2021, 06:28   #4236  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,563
Quote:
Originally Posted by feisty2 View Post
it's nobody's problem, msvc is well known to be slow on supporting new C++ features (it's also not the worst tho, apple clang is far worse than msvc in terms of C++20 support). things will get there eventually. the main problem with msvc currently is that it does not provide complete support for concepts, a major C++20 feature that the wrapper relies on heavily.
You have to be kidding me, right? This is a bleeding edge GCC 10 feature. You need an Ubuntu line less than six months old to be able to use that, no 20.04 or LTS for you. There's still no RHEL/CentOS that has gcc10. You literally have to reinstall your entire OS to be able to build this, or have a dev environment just for it.

You're intentionally cutting your userbase off in order to experiment with bleeding edge features, which is fine in the abstract, but marks the project as unsuitable for anyone else.
foxyshadis is offline   Reply With Quote
Old 22nd January 2021, 11:22   #4237  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,505
the latest version of all 3 mainstream compilers (GCC, Clang, MSVC) have supported many C++20 features, both GCC and Clang have implemented full support for concepts, and MSVC has partial support for it. I can imagine that MSVC should be able to catch up in the following months and my project should work with all mainstream compilers by the time I finish writing the documentation. CentOS is dead so not supporting it is no big deal, regardless of that, GCC is capable of bootstrapping, just download the source code of the latest version and build it with whatever version you already have, you certainly don't need to reinstall your OS to run the latest version of GCC. what's the point really to use Linux if you can't even compile GCC from scratch...

concepts is a must-have in order to design a flexible interface in C++, it is by far the only facility to express type-level equivariance in C++, take the following polymorphic function f() for example:
Code:
auto f(auto&& x) {
    if constexpr (requires { { x.g() }->Iterable; })
        if constexpr (requires { { *x.g().begin() }->SubtypeOf<VideoInfo>; })
            return std::vector<VideoNode>{};
        else if constexpr (requires { { *x.g().begin() }->SubtypeOf<AudioInfo>; })
            return std::vector<AudioNode>{};
        else
            static_assert(AlwaysFalse<decltype(x)>, "Type Error!");
    else if constexpr (requires { { x.g() }->SubtypeOf<VideoInfo>; })
        return VideoNode{};
    else if constexpr (requires { { x.g() }->SubtypeOf<AudioInfo>; })
        return AudioNode{};
    else
        static_assert(AlwaysFalse<decltype(x)>, "Type Error!");
}
the "if constexpr (requires { ... })" construct defines an equivariant map from the return type of x.g() to the return type of f(), and therefore extends polymorphism to the type level for f(). As a result, the user defined function x.g() no longer needs to be constrained by an invariant interface. the user is allowed to define g() however he/she likes at the type level, whatever works the best for his/her particular use case, and the framework function f() always self-adapts to whatever the user wants.

you simply cannot write such f() without concepts. you can try mimicking it using SFINAE in older versions of C++ and I guarantee that your code will be an unreadable and unmaintainable mess in no time. therefore concepts is absolutely essential if you agree that the user's freewill matters.

edit: simple proof that shows f() is indeed equivariant at the type level for types that it can handle.
let F() denote f() at the type level, [] denote a type operator that transforms any type T to std::vector<T>.

we have that:
F([VideoInfo]) = [VideoNode]
[F(VideoInfo)] = [VideoNode]
F([AudioInfo]) = [AudioNode]
[F(AudioInfo)] = [AudioNode]

therefore F() satisfies F(G∙T) = G∙F(T), where G = [], T = VideoInfo, AudioInfo.
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated

Last edited by feisty2; 22nd January 2021 at 13:47.
feisty2 is offline   Reply With Quote
Old 22nd January 2021, 20:09   #4238  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 180
Not that is important, but tried to subclass videonode, if for example could use custom attributes like clip.rgb, clip.isError etc:
Code:
class My_videonode(vs.VideoNode):
    def __init__(self, clip, *args, **kwargs):
        super(My_videonode, self).__init__(*args,**kwargs)

my_videonode = My_videonode(clip1)
got error, vapoursynth.Error: Class cannot be instantiated directly,
from here:
https://github.com/vapoursynth/vapou...synth.pyx#L954

is it possible, or is it stupid idea, it could be done differently sure, or forget it?
_Al_ is offline   Reply With Quote
Old 22nd January 2021, 20:13   #4239  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,505
use VaporMagik, it allows you to do dangerous things to native extensions, not just VideoNode, you can even modify the behavior of built-in types like list or int
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 22nd January 2021, 21:41   #4240  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 180
thank you,
I think I saw it before, really advanced script for me, thinking what it would be good for :-) . I tried to butcher it a bit and came up with this, which works. So I might use it. Interesting. I realized also I could also use collections.namedtuple lib, not sure how I would implement it yet. But your VaporMagik seams to be fun:
Code:
import ctypes
import builtins

class PyObject(ctypes.Structure):
    pass

PyObject._fields_ = [
    ('ob_refcnt', ctypes.c_ssize_t),
    ('ob_type', ctypes.POINTER(PyObject)),
]

class NativeMappingProxy(PyObject):
    _fields_ = [('UnderlyingDictionary', ctypes.POINTER(PyObject))]

def Dereference(Pointer):
    ObjectHolder = []
    ctypes.pythonapi.PyList_Append(ctypes.py_object(ObjectHolder), Pointer)
    return ObjectHolder[0]
    
def ExposeAttributeDictionary(Type):
    AttributeMaps = Type.__dict__
    TransparentAttributeMaps = NativeMappingProxy.from_address(id(AttributeMaps))
    return Dereference(TransparentAttributeMaps.UnderlyingDictionary)

def SetTypeAttribute(Type, Name, Attribute):
    AttributeDictionary = ExposeAttributeDictionary(Type)
    AttributeDictionary[Name] = Attribute
    ctypes.pythonapi.PyType_Modified(ctypes.py_object(Type))

@property
def rgb(self):
    return self.resize.Bicubic(format=vs.RGB24)

SetTypeAttribute(vs.VideoNode, 'rgb', rgb)


clip = core.avisource.AVISource(file.avi)
print(clip)
print(clip.rgb)

Last edited by _Al_; 22nd January 2021 at 21:45.
_Al_ is offline   Reply With Quote
Reply

Tags
speed, vaporware, vapoursynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:22.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.