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 7th April 2020, 09:17   #21  |  Link
josemaria.alkala
Registered User
 
Join Date: Apr 2010
Posts: 16
Could you try the convolution and the filter? Those are just linux binaries that return:
Code:
$ ./modifyframe
Time       : 164.1971027851105
Num. frames: 100000
FPS        : 609.0241441767271
I would like to see how does it perform on your system.

Last edited by josemaria.alkala; 7th April 2020 at 09:21.
josemaria.alkala is offline   Reply With Quote
Old 8th April 2020, 13:26   #22  |  Link
MeteorRain
結城有紀
 
Join Date: Dec 2003
Location: NJ; OR; Shanghai
Posts: 894
I was thinking how fast can you run temporal median considering it'll be a lot slower if the radius is large.

If done in SIMD, probably I can use a sorting network but I can imagine it still runs at O(n^2).
__________________
Projects
x265 - Yuuki-Asuna-mod Download / GitHub
TS - ADTS AAC Splitter | LATM AAC Splitter | BS4K-ASS
Neo AviSynth+ filters - F3KDB | FFT3D | DFTTest | MiniDeen | Temporal Median
MeteorRain is offline   Reply With Quote
Old 8th April 2020, 20:27   #23  |  Link
josemaria.alkala
Registered User
 
Join Date: Apr 2010
Posts: 16
I manage to compare in my computer the pure C++ filter and a Nim based version.

C++ Version
I took it from here. I compiled with:
Code:
g++ -Wall -O3 -shared -fPIC -I. -o libfilter.so GaussBlur.cxx
Create a VapourSynth python filter like test_filter.vpy:
Code:
import vapoursynth as vs
core = vs.get_core()
core.std.LoadPlugin(path='./libfilter.so')
core.std.SetMaxCPU('none')
clip = core.std.BlankClip(format=vs.GRAYS, length=100000, fpsnum=24000, fpsden=1001, keep=True)
clip = core.testc.GaussBlur(clip)
clip.set_output()
and finally:
Code:
$ vspipe test_filter.vpy /dev/null
Output 100000 frames in 29.53 seconds (3386.27 fps)
Nim Version
I use custom_filter.nim which uses DrawFrame.nim.

I compile it like:
Code:
$ nim c -f --threads:on -d:release -d:danger custom_filter
And test it by doing:
Code:
$ ./custom_filter 
Time       : 9.394126653671265
Num. frames: 100000
FPS        : 10644.94909283766
Using int32.

If I use float32:
Code:
$ ./custom_filter 
Time       : 16.52139902114868
Num. frames: 100000
FPS        : 6052.756178335272
I wasn't using multithreading before while vspipe does.
josemaria.alkala is offline   Reply With Quote
Old 8th April 2020, 20:33   #24  |  Link
josemaria.alkala
Registered User
 
Join Date: Apr 2010
Posts: 16
Another test that I have done is using the Convolution filter from Nim: convolution.nim and I get:
Code:
$ ./convolution 
Time       : 5.210163354873657
Num. frames: 100000
FPS        : 19193.25617813089
Using vspipe and python script:
Code:
$ vspipe convolution.vpy /dev/null
Output 100000 frames in 26.87 seconds (3721.76 fps)
I think that vspipe is actually writting frames to /dev/null while I just request the frame and then dismiss them without further processing.
josemaria.alkala is offline   Reply With Quote
Old 8th April 2020, 20:45   #25  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by josemaria.alkala View Post
Another test that I have done is using the Convolution filter from Nim: convolution.nim and I get:
Code:
$ ./convolution 
Time       : 5.210163354873657
Num. frames: 100000
FPS        : 19193.25617813089
Using vspipe and python script:
Code:
$ vspipe convolution.vpy /dev/null
Output 100000 frames in 26.87 seconds (3721.76 fps)
I think that vspipe is actually writting frames to /dev/null while I just request the frame and then dismiss them without further processing.
Correct. Use "vspipe script.vpy ." to simply discard the output
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 8th April 2020, 21:25   #26  |  Link
josemaria.alkala
Registered User
 
Join Date: Apr 2010
Posts: 16
It is not showing faster in my computer:
Code:
$ vspipe convolution.vpy .
Output 100000 frames in 26.94 seconds (3712.54 fps)
$ vspipe test_filter.vpy .
Output 100000 frames in 29.58 seconds (3380.22 fps)
josemaria.alkala is offline   Reply With Quote
Old 8th April 2020, 23:41   #27  |  Link
MeteorRain
結城有紀
 
Join Date: Dec 2003
Location: NJ; OR; Shanghai
Posts: 894
v = core.std.BlankClip(format=vs.GRAY8, length=10000, fpsnum=24000, fpsden=1001, keep=True)
v = core.neo_tmedian.TemporalMedian(v, radius=3)
v.set_output()

Output 10000 frames in 6.10 seconds (1638.35 fps)

radius=10

Output 10000 frames in 18.55 seconds (539.06 fps)

That uses the same algorithms as F2's, std::nth_element.

EDIT:

* On radius=2

C code:
Output 10000 frames in 5.83 seconds (1714.24 fps)

AVX2 code:
Output 10000 frames in 0.41 seconds (24321.61 fps)

* On radius=3

C code:
Output 10000 frames in 6.10 seconds (1638.35 fps)

AVX2 code:
Output 10000 frames in 0.52 seconds (19154.49 fps)

* On radius=4

C code:
Output 10000 frames in 9.45 seconds (1057.94 fps)

AVX2 code:
Output 10000 frames in 0.64 seconds (15681.07 fps)
__________________
Projects
x265 - Yuuki-Asuna-mod Download / GitHub
TS - ADTS AAC Splitter | LATM AAC Splitter | BS4K-ASS
Neo AviSynth+ filters - F3KDB | FFT3D | DFTTest | MiniDeen | Temporal Median

Last edited by MeteorRain; 9th April 2020 at 01:47.
MeteorRain is offline   Reply With Quote
Old 11th April 2020, 14:19   #28  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
update:
new functionality: Buffer, a writable matrix similar to a Plane, you may access the buffer as a plane to enable automatic padding when're done writing it, useful to filters that generate intermediate representations of the input clip.

revamped: the argument extracting process now has a prettier syntax, and looks more pythonic.

to get the argument for a parameter:
Code:
param = Arguments["param"];
to get the argument for an optional parameter:
Code:
if (Arguments["param"].Exists())
    param = Arguments["param"];
to get the argument for a parameter array:
Code:
for (auto x : Range{ param_arr.size() })
    if (Arguments["param"][x].Exists())
        param_arr[x] = Arguments["param"][x];
or
Code:
for (auto x : Range{ Arguments["param"].Size() })
    param_arr[x] = Arguments["param"][x];

Last edited by feisty2; 11th April 2020 at 14:26.
feisty2 is offline   Reply With Quote
Old 11th April 2020, 21:06   #29  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
update:
revamped: even prettier syntax for parameter arrays

you may also fetch each element for a parameter array with range-for syntax
Code:
for (auto x : Arguments["param"])
    param_arr.push_back(x);
revamped: you no longer have to specify the "Name + ..." caption in your error messages, this is now automatically appended via reflection.
Code:
// this is now deprecated
Console.RaiseError(Name + ": some error message"s);

//do this instead
Console.RaiseError("some error message");

Last edited by feisty2; 11th April 2020 at 21:57.
feisty2 is offline   Reply With Quote
Old 11th April 2020, 21:43   #30  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
I'm thinking of adding support for frame properties, but very few filters seem to utilize these and I can't find an example filter to test if my implementations are correct.
feisty2 is offline   Reply With Quote
Old 11th April 2020, 22:12   #31  |  Link
MeteorRain
結城有紀
 
Join Date: Dec 2003
Location: NJ; OR; Shanghai
Posts: 894
Interlaced content? There should be some IVTC/deinterlace filters that check tff/bff.
__________________
Projects
x265 - Yuuki-Asuna-mod Download / GitHub
TS - ADTS AAC Splitter | LATM AAC Splitter | BS4K-ASS
Neo AviSynth+ filters - F3KDB | FFT3D | DFTTest | MiniDeen | Temporal Median
MeteorRain is offline   Reply With Quote
Old 12th April 2020, 21:44   #32  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
update:
bug fixes: apparently in rare cases stride / sizeof(PixelType) != width, fixed.

new functionality: ability to manipulate frame properties, you could read the properties attached to the source frame similarly to how you fetch arguments for parameters, except that you may have to manually cast the property back to its original type.

to get the "_Matrix" property:
Code:
auto matrix = static_cast<int>(srcFrame["_Matrix"]);
to get a property array:
Code:
auto prop_arr = std::vector<PropType>{};
for (auto x : srcFrame["_Prop"])
    prop_arr.push_back(x);
assigning properties to the output frame is also easy!

to assign a property:
Code:
dstFrame["_Prop"] = prop_value;
to assign a property array:
Code:
for (auto x : prop_arr)
    dstFrame["_Prop"] += x;
to erase a property:
Code:
dstFrame["_Prop"].Erase();
there're 3 assigning operators, operator= corresponds to paReplace, operator+= corresponds to paAppend and operator|= corresponds to paTouch.

the semantics of "someFrame[x]" is dependent on the type of x
if x is an integer, someFrame[x] is the x-th channel of the frame.
if x is a string (of type char*, const char*, std::string, std::string_view), someFrame[x] is the property x attached to the frame.

Last edited by feisty2; 12th April 2020 at 21:52.
feisty2 is offline   Reply With Quote
Old 14th April 2020, 19:46   #33  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
update:
revamped: dropped support for multiple outputs, I've never seen a single filter that uses this feature and my implementation was incorrect anyways.

revamped: eliminated all indirect addressing
Code:
// no more the following
InputClip.Info->Width
InputFrame.Format->PlaneCount
InputClip.Info->Format->BitsPerSample

// now you have direct access to all these items
InputClip.Width
InputFrame.PlaneCount
InputClip.BitsPerSample
note that for clips with mutable format, format members are filled with garbage data at clip level

new example: Crop, this example shows you how to write filters that modify the measures of the input (e.g. frame size) and filters that adapt to inputs with arbitrary bitdepths.

new example: Rec601ToRGB, this example converts a YUV444 clip to RGB using the Rec601 matrix, it shows you how to write filters that modify the format of the input (e.g. YUV->RGB) and how to manipulate frame properties.

I think this thing is almost feature complete now.
feisty2 is offline   Reply With Quote
Old 17th April 2020, 12:13   #34  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
update:
new functionality: ability to call external filters before the actual filtering (DrawFrame()) begins, you may define a Preprocess() function to do things that happen before DrawFrame() is invoked. you don't need to define an empty Preprocess() if there's no preprocessing required, the wrapper will automatically detect if your filter has the Preprocess() member via hasattr reflection, if Preprocess() exists, it will be invoked. Likewise, you don't need to define DrawFrame() and its relevant functions or attributes if the filter itself does not do any filtering (something like nnedi3_rpow2), in such case, you should pass the output clip to Console with Console.Receive(), see Transpose for a concrete example.

new functionality: calling external filters.

the syntax to invoke external filters is as follows:
Code:
Core["namespace"]["filter name"]("param1", argument1, "param2", argument2, ...);
the call returns a video clip, the same as what you expect in vpy scripts. you may pass any iterable container as the argument to array parameters, the wrapper will examine if the argument is a scalar or a container via reflection (thru hasattr(argument, begin)) and take care of everything.

it is now no longer possible to apply some trivial patches and compile vsFilterScript with GCC9.3, the hasattr reflection is implemented by core language features of C++20 (concepts and constraints).
feisty2 is offline   Reply With Quote
Old 18th April 2020, 11:07   #35  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
update:
bug fixes: fixed a bug where std::string and std::string_view were assumed to be containers when forwarded as arguments.

revamped: if you allocate a temporary plane with Buffer, each row is now guaranteed to have a 32-byte alignment.

revamped: you can now alter the padding policy of a plane at runtime
Code:
frame[c].PaddingPolicy = new_policy;
new functionality: PeekFrameFormat(), useful to deal with clips with mutable format. you may use this function to determine the bitdepth of a frame before calling GetFrame<PixelType>() which relies on the bitdepth information.
feisty2 is offline   Reply With Quote
Old 18th April 2020, 17:50   #36  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
This looks very interesting. It should make it easier to port Avisynth filters to VapourSynth; which I still haven't looked into!
MysteryX is offline   Reply With Quote
Old 18th April 2020, 20:22   #37  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
Quote:
Originally Posted by MysteryX View Post
This looks very interesting. It should make it easier to port Avisynth filters to VapourSynth; which I still haven't looked into!
this thing relies heavily on c++20 features and currently, the only known compiler that has implemented all required features is the yet unreleased GCC10. you have to first compile master branch GCC then you get to play with vsFilterScript

Last edited by feisty2; 19th April 2020 at 10:23.
feisty2 is offline   Reply With Quote
Old 19th April 2020, 01:10   #38  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Quote:
Originally Posted by feisty2 View Post
this thing replies heavily on c++20 features and currently, the only known compiler that has implemented all required features is the yet unreleased GCC10. you have to first compile master branch GCC then you get to play with vsFilterScript
Surely Visual Studio 2025 will support it
MysteryX is offline   Reply With Quote
Old 19th April 2020, 10:15   #39  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by feisty2 View Post
this thing replies heavily
Too many 'p' s

Quote:
Originally Posted by feisty2 View Post
yet unreleased GCC10.
I dont as yet use Linux very much, but a couple of days back I think Cinnamon Mint [EDIT: 19.3 Tricia] installed GCC10 as update.

Just saying.

EDIT: some stuff extracted from /var/log/dpkg.log
Code:
2020-04-11 22:14:35 startup archives unpack
2020-04-11 22:14:44 install gcc-10-base:amd64 <none> 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:44 status half-installed gcc-10-base:amd64 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:44 status unpacked gcc-10-base:amd64 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:44 status unpacked gcc-10-base:amd64 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:44 install gcc-10-base:i386 <none> 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:44 status half-installed gcc-10-base:i386 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:44 status unpacked gcc-10-base:i386 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:44 status unpacked gcc-10-base:i386 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:45 startup packages configure
2020-04-11 22:14:45 configure gcc-10-base:amd64 10-20200405-0ubuntu1~18.04 <none>
2020-04-11 22:14:45 status unpacked gcc-10-base:amd64 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:45 status half-configured gcc-10-base:amd64 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:45 status installed gcc-10-base:amd64 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:45 configure gcc-10-base:i386 10-20200405-0ubuntu1~18.04 <none>
2020-04-11 22:14:45 status unpacked gcc-10-base:i386 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:45 status half-configured gcc-10-base:i386 10-20200405-0ubuntu1~18.04
2020-04-11 22:14:45 status installed gcc-10-base:i386 10-20200405-0ubuntu1~18.04
EDIT: I forced a 'Refresh' for the updates to appear in Update Manager.
__________________
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 ???

Last edited by StainlessS; 19th April 2020 at 11:19.
StainlessS is offline   Reply With Quote
Old 19th April 2020, 11:17   #40  |  Link
MeteorRain
結城有紀
 
Join Date: Dec 2003
Location: NJ; OR; Shanghai
Posts: 894
SssS: Yes that's the 20200405 snapshot of GCC 10 that's still in development. I don't know why a distribution would put a software still in development on users' computer.

Clang 10 however, has just released. But that doesn't support all the features I believe.
__________________
Projects
x265 - Yuuki-Asuna-mod Download / GitHub
TS - ADTS AAC Splitter | LATM AAC Splitter | BS4K-ASS
Neo AviSynth+ filters - F3KDB | FFT3D | DFTTest | MiniDeen | Temporal Median
MeteorRain is offline   Reply With Quote
Reply

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 12:40.


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