View Full Version : AviSynth+ thread Vol.2
pinterf
7th June 2020, 10:55
Who wants to play with the avisynth test 7 version and AvsPmod.
This eliminates the window error message on startup.
Exchange the included library.zip with the one in the lib folder. 32bit only.
Removed. The problem is deeper
Edit: test7 seems to have a problem releasing the IScriptEnvironment
For some reason AvsPMod requests ScriptEnvironment with version=3 (avs 2.5), this test7 version takes it seriously and provides you a 2.5 compatible avs_script_environment, which has _no_ avs_delete_scriptenvironment. So using a non-existant interface function will crash.
Groucho2004
7th June 2020, 11:23
this test7 version takes it seriously and provides you a 2.5 compatible avs_script_environment, which has _no_ avs_delete_scriptenvironment. So using a non-existant interface function will crash.There may be a safer method to release the IScriptEnvironment (https://forum.doom9.org/showthread.php?p=1631151#post1631151) (unless already implemented in AVSPmod) which is much better than the horrible "delete env".
pinterf
7th June 2020, 11:29
There may be a safer method to release the IScriptEnvironment (https://forum.doom9.org/showthread.php?p=1631151#post1631151) (unless already implemented in AVSPmod) which is much better than the horrible "delete env".
AVSPMod is using C interface, anyway this test7 was really a try-what-happens test for the premiere-plugin issue which accidentally shed light on this version=3 request inconsistency.
pinterf
7th June 2020, 11:46
But if the script has video and audio (or audio alone) it causes Premiere to crash. Tested with both external audio files and the built-in ColorBars function.
Thanks, the changes for the this test7 incorporated only video and I now found where your audio crashed.
Groucho2004
7th June 2020, 12:22
AVSPMod is using C interfaceAh, I see.
vcmohan
7th June 2020, 12:46
I am modifying a plugin to execute under avsynth+ 3.5 version using the avisynth.h header version 8-h. I was able to run many scripts under avisynth.dll 2xxx build. I installed x64 version of the dll using Groucho's universal installer. Now I always get an error message AVi import filter error ( unknown 80040154 ) with vdub. Even a simple script version() without trying to load any plugins gives this error. Should I go to 3.6 dll? What might have gone wrong on my system?
pinterf
7th June 2020, 13:11
The universal installer does not install the necessary redistributables, probably you need to install az up to date version?
vcmohan
7th June 2020, 13:20
The universal installer does not install the necessary redistributables, probably you need to install az up to date version?
Thanks. If you think I am not bothering you, can you name which distributables I need and the link for getting them. I am compiling with my 2013 vc++.
I have one more problem. Can I set MT mode from inside plugin as if an older version (pre 8) is detected, I disable multi thread but for later keep multi thread?
pinterf
7th June 2020, 13:31
The proper way of setting mt mode is returning the relevant constant (MT_SERIALIZED, MT_MULTI_INSTANCE, MT_NICE_FILTER) by using set cache hints.
You can do it adaptively: in this example the mt mode is enabled or not depending on a parameter value got from filter creation.
https://github.com/pinterf/mvtools/blob/mvtools-pfmod/Sources/MVAnalyse.h#L134
You can test the V8-ness of the filter like I did here in mvtools. A variable holds the test result found on filter creation.
https://github.com/pinterf/mvtools/commit/6537322da866392d82cce226160a3bfbb318a8f8
Groucho2004
7th June 2020, 13:33
Thanks. If you think I am not bothering you, can you name which distributables I need and the link for getting them. I am compiling with my 2013 vc++.I highly recommend the All-In-One installer from here (https://github.com/abbodi1406/vcredist/releases) which covers everything from 2003 - 2019. It's frequently updated and does not install any crap such as useless installer duplicates.
pinterf
7th June 2020, 13:34
Thanks. If you think I am not bothering you, can you name which distributables I need and the link for getting them. I am compiling with my 2013 vc++.
https://visualstudio.microsoft.com/downloads/
Other Tools and Frameworks
Microsoft Visual C++ Redistributable for Visual Studio 2019
But you don't have to link for them, just use the platform toolset which your VS2013 provides.
These 2019 redistributables are needed to run Avisynth+. Independently from your plugin.
vcmohan
7th June 2020, 14:42
https://visualstudio.microsoft.com/downloads/
Other Tools and Frameworks
Microsoft Visual C++ Redistributable for Visual Studio 2019
But you don't have to link for them, just use the platform toolset which your VS2013 provides.
These 2019 redistributables are needed to run Avisynth+. Independently from your plugin.
Many thanks. It worked. I down loaded for x64 . Do I need to install X86 version also? I have requested in my previous post regarding disabling or enabling MT from within plugin. Can you clear my doubts? I can code it, but need to communicate to Avisynth by setting a flag?
Thanks again for help.
pinterf
7th June 2020, 14:55
Test build 8 - work in progress
Avisynth+ v3.6.1 test build 8 (20200607) (https://drive.google.com/file/d/1a5VlaM3ZVjq9KwBk5piamswc_sV5bY_j/view?usp=sharing)
This time with GeneralConvolution fixes
And with the former fixes for XP and Cpp2.5 regressions but after a bit of a code cleanup. I hope nothing got worse.
pinterf
7th June 2020, 14:58
Many thanks. It worked. I down loaded for x64 . Do I need to install X86 version also?
If you are using 32 bit Avisynth+ (and probably other plugins which need it) for your tests then yes.
I have requested in my previous post regarding disabling or enabling MT from within plugin. Can you clear my doubts? I can code it, but need to communicate to Avisynth by setting a flag?
Thanks again for help.
You have probably missed my answer regarding setting mt mode.
real.finder
7th June 2020, 16:13
vcmohan, you mean internal MT? or setting the avs+ MT mode for the function?
btw, it will be nice if there are way for plugin to know what prefetch threads is used so it automaticly changes it internal MT settings to avoid using many threads if prefetch is equal or more than cores numbers
StainlessS
7th June 2020, 16:25
I still have trouble downloading anything from Pinterf Google drive [using FireFox, maybe self inflicted, I use Privazer Privacy thing, which disables some cookies and stuff],
I have success using Opera browser, but usually have to click Download button on first error message, then 2nd try usually works.
https://i.postimg.cc/BP6JkMZM/Untitled-00.jpg (https://postimg.cc/BP6JkMZM)
EDIT: Regarding Privazer, I dont use it under Cinnamon Mint, but still have probs using Firefox [sometimes works, sometimes dont].
EDIT: I'm wondering if problem related to 7z compression method of "LZMA2:12m BCJ, Solid +" [shown in 7z Properties, maybe G-Drive has problem reading/checking it]
DJATOM
7th June 2020, 16:40
btw, it will be nice if there are way for plugin to know what prefetch threads is used so it automaticly changes it internal MT settings to avoid using many threads if prefetch is equal or more than cores numbers
That's kinda difficult to do with current "Prefetch" design. "The filter" usually called at the end of script, so one possible workaround to pre-parse script and search for prefetch string, then on instantiation expose it's value for plugins that called before prefetch. With current design we can only adjust threads usage at "getframe" event, not on filter instantiation.
StainlessS
7th June 2020, 16:43
Beware, I'm pretty sure that there was recently a Pinterf post saying that you can now use multiple Prefetch calls in script [avs+ Neo, 3.6.x, maybe 3.5.x].
real.finder
7th June 2020, 17:34
That's kinda difficult to do with current "Prefetch" design. "The filter" usually called at the end of script, so one possible workaround to pre-parse script and search for prefetch string, then on instantiation expose it's value for plugins that called before prefetch. With current design we can only adjust threads usage at "getframe" event, not on filter instantiation.
edit: maybe adding new function called setthreads and unlike Prefetch, it need to be called in start of script (before any External filter)
addition to that, maybe Prefetch need some updates, like adding threads=0 which mean auto (like old avs mt) and make it default
StainlessS
7th June 2020, 17:52
maybe adding new function called setthreads and unlike Prefetch, it need to be called in start of script (before any External filter)
As previously noted, can be several Prefetch() calls in script,
however, if setthreads() called prior to each Prefetch call, then
would (I think) work.
NOW_PREFETCH_THREADS=x
SetThreads(NOW_PREFETCH_THREADS)
...
Prefetch(NOW_PREFETCH_THREADS)
...
NOW_PREFETCH_THREADS=y
SetThreads(NOW_PREFETCH_THREADS)
...
Prefetch(NOW_PREFETCH_THREADS)
...
NOW_PREFETCH_THREADS=z
SetThreads(NOW_PREFETCH_THREADS)
...
Prefetch(NOW_PREFETCH_THREADS)
return last
Instead of SetThreads(), could maybe just
Global GLB_NOW_PREFETCH_THREADS=x
and test if global variable exists inside filter constructor.
EDIT:
How much memory is required for all those 24 threads? Mvtools working area can be quite memory hungry for example, multiply it by 24 (filters are mostly MT_MULTI_INSTANCE mode) + UHD source. What is avsmeter telling? If it is near 4GB then use SetMemoryMax with e.g. 8000 or use a value which is probably above the memory need by a safe margin.
All you can do is experimenting and share your findings
1.) You can have now multiple Prefetchers (new in 3.6)
2.) At the moment, forget "frames" parameter
3.) Try another cache mode (new in 3.6) default is 0.
- SetCacheMode(0) or SetCacheMode(CACHE_FAST_START) start up time and size balanced mode
SetCacheMode(1) or SetCacheMode(CACHE_OPTIMAL_SIZE) slow start up but optimal speed and cache size
Latter can do wonders especially at really low memory environment
gispos
7th June 2020, 20:29
I still have trouble downloading anything from Pinterf Google drive [using FireFox, maybe self inflicted, I use Privazer Privacy thing, which disables some cookies and stuff],
I have success using Opera browser, but usually have to click Download button on first error message, then 2nd try usually works.
https://i.postimg.cc/BP6JkMZM/Untitled-00.jpg (https://postimg.cc/BP6JkMZM)
EDIT: Regarding Privazer, I dont use it under Cinnamon Mint, but still have probs using Firefox [sometimes works, sometimes dont].
EDIT: I'm wondering if problem related to 7z compression method of "LZMA2:12m BCJ, Solid +" [shown in 7z Properties, maybe G-Drive has problem reading/checking it]
I recommend Sandboxie (https://www.sandboxie.com/), then you don't need a private session in firefox.
I personally only go online in a sandbox.
wonkey_monkey
7th June 2020, 21:02
I've got a bug which is driving me mental, but during my investigations I've found some behaviour I can't explain and would like to know the explanation for (just to satisfy my curiosity more than anything else, but also because it's been obfuscating my search for the other bug).
I'm using this simple plugin to follow various filter events (construction, GetFrame, etc): https://pastebin.com/szEzD7hP
Here's my script:
colorbars.trim(0,3)
avs_debug("inner")
converttoyv12
avs_debug("outer")
And here's the output (with indentation by me):
[38152] avs_debug (inner): creator
[38152] avs_debug (inner): constructor
[38152] avs_debug (outer): creator
[38152] avs_debug (outer): constructor
[38152] avs_debug (outer): GetFrame in (0)
[38152] avs_debug (inner): GetFrame in (0)
[38152] avs_debug (inner): GetFrame out (0)
[38152] avs_debug (inner): GetFrame in (0)
[38152] avs_debug (inner): GetFrame out (0)
[38152] avs_debug (inner): GetFrame in (0)
[38152] avs_debug (inner): GetFrame out (0)
[38152] avs_debug (outer): GetFrame out (0)
[38152] avs_debug (outer): GetFrame in (1)
[38152] avs_debug (inner): GetFrame in (1)
[38152] avs_debug (inner): GetFrame out (1)
[38152] avs_debug (outer): GetFrame out (1)
[38152] avs_debug (outer): GetFrame in (2)
[38152] avs_debug (inner): GetFrame in (2)
[38152] avs_debug (inner): GetFrame out (2)
[38152] avs_debug (outer): GetFrame out (2)
[38152] avs_debug (outer): GetFrame in (3)
[38152] avs_debug (inner): GetFrame in (3)
[38152] avs_debug (inner): GetFrame out (3)
[38152] avs_debug (outer): GetFrame out (3)
[38152] avs_debug (outer): destructor
[38152] avs_debug (inner): destructor
What I'm trying to work out is why the "inner" GetFrame for frame 0 is being called (by converttoyv12) three times (additional two calls highlighted in red), whereas for every other frame it only gets called once.
This does not happen if you use converttoyv24 or converttoy8.
Investigation with VirtualDub2 shows that it always happens to the first frame to get read, even if that's not frame 0.
StainlessS
7th June 2020, 21:11
VD2 will call GetFrame(0) when load clip, and again if start to Play. [often produces double 0 entry for any metrics]
EDIT: Media players usually do not do this, as they start playing immediately.
wonkey_monkey
7th June 2020, 21:26
I used AvsMeter and my own program to avoid that (in any case it would have triggered additional calls on the "outer" avs_debug call). The extra "inner" calls don't occur when using converttoyv24 or converttoy8.
Groucho2004
7th June 2020, 21:58
I used AvsMeter and my own program to avoid that (in any case it would have triggered additional calls on the "outer" avs_debug call). The extra "inner" calls don't occur when using converttoyv24 or converttoy8.
For such purposes you should use avsr. It just creates the script environment and starts reading frames.
AVSMeter creates a script environment, reads frames for 5 seconds to determine the correct frame interval for measurements and then destroys the environment. After that, it creates a new script environment for the main processing.
If you use the switch "-o" however, it behaves pretty much the same as avsr.
Groucho2004
7th June 2020, 22:00
VD2 will call GetFrame(0) when load clip, and again if start to Play.Depending on the script and filters used, this GetFrame(0) will load a bunch of frames into the cache.
wonkey_monkey
7th June 2020, 22:12
I always use -o. I also used my own program which only reads frames when required. In any case, the calling program can only trigger the outer call, and it's the inner call which is repeated.
Plus there's the fact that this issue doesn't occur with converttoyv24 or converttoy8. Maybe it has something to do with chroma subsampling, though I can't imagine what.
StainlessS
7th June 2020, 22:43
I sometimes call GetFrame(0) in constructor to calc equivalent to GetPlaneWidthSubsampling/height (or whatever they are called), because they dont exist under v2.58 avs.
pinterf
8th June 2020, 08:55
I've got a bug which is driving me mental, but during my investigations I've found some behaviour I can't explain and would like to know the explanation for (just to satisfy my curiosity more than anything else, but also because it's been obfuscating my search for the other bug).
I'm using this simple plugin to follow various filter events (construction, GetFrame, etc): https://pastebin.com/szEzD7hP
Here's my script:
colorbars.trim(0,3)
avs_debug("inner")
converttoyv12
avs_debug("outer")
And here's the output (with indentation by me):
[38152] avs_debug (outer): GetFrame in (0)
[38152] avs_debug (inner): GetFrame in (0)
[38152] avs_debug (inner): GetFrame out (0)
[38152] avs_debug (inner): GetFrame in (0)
[38152] avs_debug (inner): GetFrame out (0)
[38152] avs_debug (inner): GetFrame in (0)
[38152] avs_debug (inner): GetFrame out (0)
[38152] avs_debug (outer): GetFrame out (0)
What I'm trying to work out is why the "inner" GetFrame for frame 0 is being called (by converttoyv12) three times (additional two calls highlighted in red), whereas for every other frame it only gets called once.
This does not happen if you use converttoyv24 or converttoy8.
ConvertToYV12 seems to be a single filter but only from outside.
Since the origin is RGB, the following internal invokes are happening
- ConvertTo444
- Separating U and V chroma
- Invoke the appropriate resizers for U and V (subpixel accuracy if needed)
- Put together the luma and the resized U and V
Maybe the cache for the first frame is not created/ready and those internal subfilters are requesting the frame multiple times.
gispos
8th June 2020, 17:01
...but I never did like sandboxie...
Why?
I've been using it for over 10 years, I think. There are only two programs on my PC that I have spent money on. Sandboxie is one of them.
Now even the full version is free.
There is only one problem, not all programs run in sandboxie.
There are also the Sandbox from Comodo, so far all programs that I have installed worked there, but there are a number of disadvantages, only one sandbox and only in the partition in which Windows is located, mostly C: \
gispos
8th June 2020, 19:20
I use Comodo Internet Security thingy, and switch off Anti-Virus, HIPS, Auto Containment, VirusScope, for most of the
time, only have FireWall on permanent, every now and then do VirusScan.
No probs really, if so then would just restore from backups, dont need any Auto Containment, Sandbox whotsits.
I guess its just whatever 'Blows your skirts up', 'Floats your boat', 'Butters your bread', 'Smokes your kipper', or whatever.
I also only use the firewall from Comodo, everything else is off.
I also use various VM's and have backups for my most important partitions, but I could never do without a sandbox.
This is not a 'block on the leg' that is like the air to breathe. :D
I think now we have loaded the thread enough with useless stuff. Sorry. :)
gispos
8th June 2020, 20:54
With test8 I get errors at QTGMC.
QTGMC(Preset="fast", Sharpness=1.0, InputType=0, FPSDivisor=2, ShowSettings=False)
Script error: expected `)'
((null), line 1, column 4)
(D:\Tools\AviSynth\plugins64+\QTGMC\SMDegrain.avs, line 879)
(D:\Tools\AviSynth\plugins64+\QTGMC\QTGMC.avsi, line 208)
(Datei neu, line 8)
Anyone else?
real.finder
8th June 2020, 23:30
With test8 I get errors at QTGMC.
QTGMC(Preset="fast", Sharpness=1.0, InputType=0, FPSDivisor=2, ShowSettings=False)
Script error: expected `)'
((null), line 1, column 4)
(D:\Tools\AviSynth\plugins64+\QTGMC\SMDegrain.avs, line 879)
(D:\Tools\AviSynth\plugins64+\QTGMC\QTGMC.avsi, line 208)
(Datei neu, line 8)
Anyone else?
you are not UpToDate in scripts case
I did many changes months ago, all shared functions moved to Zs_RF_Shared.avsi so QTGMC no longer need SMDegrain
also there were changes in pre avs+ 3.6 that break things in AvsPlusVersionNumber which I fix weeks ago using StainlessS code since the pre avs+ 3.6 test builds
manolito
9th June 2020, 01:24
With test8 I get errors at QTGMC.
Anyone else?
Just when you thought that Microsoft was the undisputed champion of Version Hell and DLL Hell... :devil:
stax76
9th June 2020, 01:27
10 year old script (MCTemporalDenoise) depends on script depends on script... :(, wasted time to make the dependency detection work and then gave up making it work with a hack...
ravewulf
9th June 2020, 03:15
Test build 8 - work in progress
Avisynth+ v3.6.1 test build 8 (20200607) (https://drive.google.com/file/d/1a5VlaM3ZVjq9KwBk5piamswc_sV5bY_j/view?usp=sharing)
This time with GeneralConvolution fixes
And with the former fixes for XP and Cpp2.5 regressions but after a bit of a code cleanup. I hope nothing got worse.
Confirmed that the older Premiere plugin (1.95) now works without crashing. As that test case is resolved, I'll use the 1.96 version going forward.
pinterf
9th June 2020, 08:49
Confirmed that the older Premiere plugin (1.95) now works without crashing. As that test case is resolved, I'll use the 1.96 version going forward.
Thank you for the test
vcmohan
9th June 2020, 13:40
The proper way of setting mt mode is returning the relevant constant (MT_SERIALIZED, MT_MULTI_INSTANCE, MT_NICE_FILTER) by using set cache hints.
You can do it adaptively: in this example the mt mode is enabled or not depending on a parameter value got from filter creation.
https://github.com/pinterf/mvtools/blob/mvtools-pfmod/Sources/MVAnalyse.h#L134
Many thanks once again. This way I can disable MT in pre v8 version. But I am not too happy about it. In pre v8 version I could get memory allocated with env2. Now thats lost. So I am relying on getting a newvideoFrame. However this does not work in case of 2D FFT as both width and height of frame need a padding, plus it needs to be in float. Is there a way in pre v8 to get optional size newvideoframe? In that case I can still have multi threading in place.
ravewulf
9th June 2020, 15:36
Many thanks once again. This way I can disable MT in pre v8 version. But I am not too happy about it. In pre v8 version I could get memory allocated with env2. Now thats lost. So I am relying on getting a newvideoFrame. However this does not work in case of 2D FFT as both width and height of frame need a padding, plus it needs to be in float. Is there a way in pre v8 to get optional size newvideoframe? In that case I can still have multi threading in place.
I'm probably misunderstanding the situation, so for my own clarification - isn't internal multithreading within a plugin discouraged in favor of AviSynth handling multithreading via multiple frames being processed in parallel?
#2: Parallel execution
AviSynth-MT and VapourSynth both support multithreading, and it is being implemented in AviSynth+ too. All of them require the same things from your plugin. Here is a list of what you as a plugin author can do to support execution on multiple threads. If you are the author of any AviSynth plugin, please update your filter according to these rules if needed. Doing so will make sure your plugin can execute seamlessly when multithreaded. Furthermore, following these rules will not only guarantee correct execution in multihtreaded environments, it will also provide optimal mulithreaded performance.
Unless you have the slowest filter in the world, don't start threads in your plugin
...
In general, do not slice up your frame and start multiple threads on your own. Threading has its own performance overhead, and it is only worth doing it manually if your filter takes a lot of time to execute. And even if your filter is extremely slow (like fft3dfilter), you should try to optimize its single-threaded performance (by using SIMD instructions or choosing a more efficient algorithm) rather then manually threading it. Optimize for single-threaded performance, and as long as you follow the other rules below, you will get automatic and correct multithreading from AviSynth.
...
Excerpts from http://avisynth.nl/index.php/Avisynthplus/Developers
I'm not sure if this adds clarification or was already known?
real.finder
9th June 2020, 16:19
I'm probably misunderstanding the situation, so for my own clarification - isn't internal multithreading within a plugin discouraged in favor of AviSynth handling multithreading via multiple frames being processed in parallel?
Excerpts from http://avisynth.nl/index.php/Avisynthplus/Developers
I'm not sure if this adds clarification or was already known?
Regardless that, internal multithreading still has advantage in RAM usage, that why there should some way for plugin to know what prefetch threads is used as I said https://forum.doom9.org/showthread.php?p=1914966#post1914966
and also here https://forum.doom9.org/showthread.php?p=1907473#post1907473 and https://forum.doom9.org/showthread.php?p=1776920#post1776920
so both should be life together
anyway seems vcmohan mean setting the avs+ MT mode not plugin internal multithreading
StainlessS
9th June 2020, 16:38
optional size newvideoframe?
If you change size of vi.width / vi.height in constructor, NewVideoFrame will return new sized frame.
A Trim filter, or decimation filter where output length is known, would change vi.num_frames in constructor.
Can also change colorspace in same way but I dont know the particulars for that.
[EDIT: Must in this case get original vi from child clip to ascertain source clip properties, ie child->GetVideoInfo]
Probably also need crop off padding from result of your padded filter, within the filter creator function, and return the cropped result to caller.
From Ben's Docs [not quite the same]
A filter that changes the frame size :- http://avisynth.nl/index.php/Filter_SDK/Ben_docs#A_filter_that_changes_the_frame_size
EDIT: When you change the properties of VideoInfo in constructor, you change properties of the returned clip. [and so have to return a NewVideoFrame result,
not env->MakeWritable result, (EDIT: unless no change to frame properties eg trim filter, only frame count changed)].
EDIT:
Or I guess you could have a temp_vi in your class, and copy class vi into it, and then change that for temp NewVideoFrame, then call
PVideoFrame pad = env->NewVideoFrame(temp_vi)
and at end convert/copy/blit pad frame (excluding padding) into result NewVideoFrame (created with original vi), and would not need crop off padding in creator function.
Hope at least some of that makes sense.
pinterf
9th June 2020, 18:08
Prefetch has a default value, which is number of Physical CPUs + 1.
AVSValue Prefetcher::Create(AVSValue args, void*, IScriptEnvironment* env)
{
InternalEnvironment *envi = static_cast<InternalEnvironment*>(env);
PClip child = args[0].AsClip();
int PrefetchThreads = args[1].AsInt((int)envi->GetEnvProperty(AEP_PHYSICAL_CPUS)+1);
int PrefetchFrames = args[2].AsInt(PrefetchThreads * 2);
if (PrefetchThreads > 0 && PrefetchFrames > 0)
{
return new Prefetcher(child, PrefetchThreads, PrefetchFrames, env);
}
else
return child;
}
pinterf
9th June 2020, 18:15
Many thanks once again. This way I can disable MT in pre v8 version. But I am not too happy about it. In pre v8 version I could get memory allocated with env2. Now thats lost. So I am relying on getting a newvideoFrame. However this does not work in case of 2D FFT as both width and height of frame need a padding, plus it needs to be in float. Is there a way in pre v8 to get optional size newvideoframe? In that case I can still have multi threading in place.
Not lost, memory pool allocation is now part of IScriptEnvironment.
VideoFrame buffers (frame pointers and pitches) are 64 byte aligned in AviSynth+. I don't know what you mean under optimal size, but as said, adjusting vi.width and vi.height (and all other VideoInfo properties) in filter creation will determine the frame size and format your next NewVideoFrame will allocate.
ravewulf
9th June 2020, 19:27
Regardless that, internal multithreading still has advantage in RAM usage, that why there should some way for plugin to know what prefetch threads is used as I said https://forum.doom9.org/showthread.php?p=1914966#post1914966
and also here https://forum.doom9.org/showthread.php?p=1907473#post1907473 and https://forum.doom9.org/showthread.php?p=1776920#post1776920
so both should be life together
anyway seems vcmohan mean setting the avs+ MT mode not plugin internal multithreading
Thanks for the clarification!
DJATOM
9th June 2020, 19:54
internal multithreading still has advantage in RAM usage
Yet it's slower on complex scripts + encoding (judging from eedi3/nnedi3), so I think internal mt should be off by default. The only useful case with internal threading is when we preview stuff in avspmod or another host, since usually there is no need in computation of 24 frames (my case) when tweaking filter.
vcmohan
10th June 2020, 06:11
Not lost, memory pool allocation is now part of IScriptEnvironment.
VideoFrame buffers (frame pointers and pitches) are 64 byte aligned in AviSynth+. I don't know what you mean under optimal size, but as said, adjusting vi.width and vi.height (and all other VideoInfo properties) in filter creation will determine the frame size and format your next NewVideoFrame will allocate.
Thanks. but sorry I could not understand fully. My goal is to code so that in either version MT is fully maintained. I am internally using disposable buffers of size larger than input video frame. My output will still remain the same VideoFrame size. So if I change vi.width and vi.height then my output frame size changes, which I do not want to happen (as per my understanding).
Or can I code like
float * buf;
Iscriptenvironment2 * env2 = (Iscriptenvironment2 *) env;
if(v8) { buf =(float *)env->Allocate(.....);}
else{ buf = (float*)env2->Allocate(....);}
I thought this will not work as env2 is broken and this was the reason why I am modifying the code..
pinterf
10th June 2020, 08:08
Or can I code like
float * buf;
Iscriptenvironment2 * env2 = (Iscriptenvironment2 *) env;
if(v8) { buf =(float *)env->Allocate(.....);}
else{ buf = (float*)env2->Allocate(....);}
I thought this will not work as env2 is broken and this was the reason why I am modifying the code..
I see. Then do env->Allocate if V8 and use _aligned_malloc for the rest.
Like asd-g did when updated chikuzen's plugins:
https://github.com/Asd-g/TMM2/commit/d79fd18b54843d9b831e37e97c131627134cc161#diff-44bf449871c471dc8dee9a12b896c307
Look, how the old allocate was split adaptively. He is using _mm_alloc/_mm_free which allocates on (at least) 16 byte aligned memory area. If you need more strict allocation, use _aligned_alloc/aligned_free and specify your alignment requirement.
vcmohan
10th June 2020, 12:51
If _mm_alloc is available then why is env->Allocate introduced? Or as I think _mm_alloc is a system call. If so if done for each frame, it will slow down and MT may be a waste. Am I correct?
DJATOM
10th June 2020, 13:12
https://github.com/AviSynth/AviSynthPlus/blob/9a813c1bdfec9d35252ca489e01ea059a6323783/avs_core/core/BufferPool.cpp#L105
Looks like BufferPool::Allocate does some job to don't allocate new buffers if possible, so it should be faster if you use allocation per getframe (if buffer allocation is pooled, it will not be freed but marked as reusable, see BufferPool::Free). i didn't dig too deep, but assume it's freed at destruction or on cache adjustment.
Selur
10th June 2020, 17:48
Does anyone have a newer Planartools build which works with Avisynth 3.6.x, tried with https://github.com/chikuzen/PlanarTools/releases/download/0.3.0/PlanarTools-0.3.0.zip but that fails. (thought all my filter worked fine and then a YUV2 interlaced source came around ;))
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.