Log in

View Full Version : Avisynth+


Pages : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 [87] 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112

GMJCZP
8th November 2018, 23:46
I have a problem with ImageWriter, when using the following script, for example:

ConverttoRGB24().ImageWriter("", 5,5, "bmp").ConvertToYV12()

I get an error with the DevIL library. I am using AVS + 2728. I never had problems with the old AVS.

LigH
9th November 2018, 08:48
Which is "an error"? Maybe it tells about the reason.

pinterf
9th November 2018, 17:37
Yep.
With my test clip (854x480@30, 3775 Frames), memory usage max's out at about 1.73GB
I checked the 32 bit vdub2 process with SysInternals vmmap. It seems that we are near 2GB with this script and parameters. As the internal caches are getting filled (until the set limit) Windows suddenly cannot allocate memory. Even when I set the max cache size to the minimum of 64MB, it could not request new memory buffer from the system after a while. Either avisynth or virtualdub - whichever is unlucky - will feel deep unhappyness and crash. So I think the problem is not avisynth related.

StainlessS
9th November 2018, 22:06
So I think the problem is not avisynth related.

Thank you for looking in to this P, much appreciated.

GMJCZP
9th November 2018, 23:23
Which is "an error"? Maybe it tells about the reason.

I am using a borrowed PC because I have not had internet for several months, so I do not remember exactly how the message says, the issue is that I can not save the frame and it is something related to DevIL. I do not know if anyone can try to recreate the error using the script.

pinterf
9th November 2018, 23:27
Perhaps it wants to write to c: root which is not allowed?

StainlessS
9th November 2018, 23:32
Perhaps it wants to write to c: root which is not allowed?

Yeh[EDIT: good catch] , possibly. Maybe try,


Colorbars
ConverttoRGB24().ImageWriter(".\", 5,5, "bmp").ConvertToYV12()


".\" is current directory, and at least it works as expected here.

EDIT: With just "" here on W7x64Avs32, I got nothing, no output and no error message, perhaps reason that you could not
remember the error message :)

EDIT: "." alone did NOT work [EDIT: Same result as ""].

StainlessS
10th November 2018, 00:34
EDIT: "." alone did NOT work [EDIT: Same result as ""].

Actually, I was in sub directory of D:\ drive ("D:\NewFolder"), and "." actually wrote to the root of D:\.

EDIT:
So far as I remember,
"D:" should be current directory on D drive,
"D:\" should be root directory on D drive,
"." should be current directory, current drive (also think ".\" should be same).

EDIT: Damn, forum keeps swallowing '\' characters.

EDIT: Also, ".." should be parent directory to current directory, think "..\" should be same.

EDIT:
Where below script in "D:\NewFolder\NewFolder"
This writes to root directory of D: (I think should be parent directory to current directory ie D:\NewFolder\)
Colorbars ConverttoRGB24().ImageWriter("..", 5,5, "bmp").ConvertToYV12()

This writes to D:\NewFolder (I think should be parent directory to current directory ie D:\NewFolder\)
Colorbars ConverttoRGB24().ImageWriter("..\", 5,5, "bmp").ConvertToYV12()

Something seems to be messed up somewhere, dont know if ImageWriter or Windows 7.

EDIT: Also "" should be interpreted same as "." and ".\", ie current directory.
Excepting for case where eg "D:\" specifies root directory of drive D, a trailing '\' just explicitly specifies that it is a directory
rather than a file, but "." and ".." already imply a directory where trailing "\" should be superfluous unless a node is appended after
the slash (ie another directory or file name node).

manolito
15th November 2018, 17:25
In one of my video conversion scripts I need to remove the station logo, for this I have been using LogoAway 4.01 by Krzysztof Wojdon for a long time. After switching to AVS+ I got random crashes using this filter, and luckily I believe I solved the issue, but it took me a long time and a lot of detective work...

My hardware and software setup first:

Core i5 3rd generation with 8GB RAM
Win7 64-bit
Avisynth+ r2728-MT 32-bit
SetMTMode.avsi from this link: http://publishwith.me/ep/pad/view/ro.rDkwcdWn4k9/latest
StaxRip v. 1.1.9.0 (last stable 32-bit version)
X264 r2935 32-bit

I use "Prefetch(4)" with this CPU (2 physical cores plus Hyperthreading). This normally runs stable. But after getting these random crashes I first made tests to find out which filter was to blame, and it was LogoAway.

It does not happen with all sources, and sometimes the crash occurs shortly after the conversion start, sometimes it happens in the middle and sometimes at the end. I get this Windows popup that X264.exe has stopped working and must be shut down.

I am quite sure that X2364 is not to blame, I tried 3 different builds of the same release without any difference. Reducing the AVS+ threads from 4 to 2 still gave me the crashes, but this time without the Windows popup. X264 just stopped working, CPU load went down to 0, no error message.

Removing the "SetMTMode.avsi" also made no difference (except slowing down encoding speed by 0.3 fps). What did fix it of course was to disable MT altogether, and forcing MT_SERIALIZED for LogoAway also worked, but speed was not any faster than without MT.

The final solution came just by trial and error, and I really do not understand why it works. If I specify MT_MULTI_INSTANCE explicitly for LogoAway either in the conversion script or in the "SetMTMode.avsi" then the crashes miraculously disappear. This is reproduceable each and every time.

How is this possible? The docs say that MT_MULTI_INSTANCE is the default MT mode which always gets used as long as no different MT mode is explicitly specified. So it should not make a difference if I specify MT_MULTI_INSTANCE in the script or not, right? But obviously it does... :devil:

Or does AVS+ treat VDub plugins differently from other filters?
:confused:

Any thoughts?

Cheers
manolito

pinterf
16th November 2018, 10:38
How is this possible? The docs say that MT_MULTI_INSTANCE is the default MT mode which always gets used as long as no different MT mode is explicitly specified. So it should not make a difference if I specify MT_MULTI_INSTANCE in the script or not, right? But obviously it does... :devil:

Or does AVS+ treat VDub plugins differently from other filters?
:confused:
Just looking at the code I see that no special MT mode is set for vdub filters, so I expect them to behave as MT_MULTI_INSTANCE. I'll check it.

pinterf
16th November 2018, 17:17
I could not reproduce, for me it works like MT_MULTI_INSTANCE. I'd need the source clip or a short fragment with that it still crashes. And a (minimized) script itself.
Maybe it's not the filter itself which fails, just when it appears in a specific sequence.
Once I had an issue when I was debugging TIVTC for weeks because it crashed x264, then it turned out that an mvtools2 function did not clear the processors's mmx state and conflicted with x264 and it was just a coincidence that tivtc seemed to be a culprit.

manolito
16th November 2018, 19:02
Thanks pinterf for looking into it...

The source file I used for my tests was a huge 2 hour HD captured TV file. Please give me some time to find a smaller source which reliably crashes...

Otherwise I did not use any elaborate filters in my script. I should probably mention that for FineSharp I use old and proven versions of RemoveGrain (original by Kassandro from 2005) and MaskTools v2.0a48. Upgrading to later versions is not an option because I need to use the same scripts under WinXP with a non-SSE2 CPU.

I will report back soon...

Cheers
manolito

wonkey_monkey
18th November 2018, 00:26
A question about expr(), if someone can answer - when the AVX/SSE optimisations are enabled, it processes four (or more) pixels at once - is that correct? Like if you were adding the values of two clips, it would load several pixels into two SSE/AVX registers and add them together in one operation?

GMJCZP
18th November 2018, 01:54
Thanks for the replies pinterf and TinMan, and sorry for responding late, but I still do not have internet.

On the AVS wiki page, when you talk about ImageWriter, give this example:

# Write frame 5 to "C: \ 000005.PNG"
ImageWriter ("", 5, 5, "png")

When putting the quotes "" I always worked with the old AVS, capturing the frame and saving it in the same place in the script, no matter where in the Hard Disk it is. When placing
".\"
It works for AVS +, so my question is why the difference between AVS and AVS+?

Note: the error message varies, which does not always appear, says:

ImageWriter: error 'Could not open file' in DevIL library writing file "000005.bmp"
DevIL version 0.

Until I got an error message with strange characters, the problem is the incompatibility of "" in ImageWriter with AVS+ , but not with AVS, why?

pinterf
18th November 2018, 09:18
A question about expr(), if someone can answer - when the AVX/SSE optimisations are enabled, it processes four (or more) pixels at once - is that correct? Like if you were adding the values of two clips, it would load several pixels into two SSE/AVX registers and add them together in one operation?

Expr handles 2x4 pixels (XMM registers) or 2x8 pixels (AVX2) at a time. Code is generated for two sets of XMM/YMM registers unless optSingleMode=true - I introduced this parameter for curiosity, if it is any faster to use only a single register set - one lane. (Looking at the generated code of a slightly more complex expression it turned out that the registers were heavily swapped to and from temporal memory variables because the code required too many physical XMM/YMM registers but we had only a limited number of them).

Note that I added AVX2 - and not AVX - code generation to Expr, though the calculations are using 32bit floats inside. Many helper asm instructions I'm using are available only from AVX2. On the other hand, old processors with AVX-only support suffer from not having real 256 bit internally, e.g. memory access would still happen in 2x128bit mode which is sometimes slower than using 2x128bit memory load manually which can use different ports in parallel. At least for my old AVX-only i7 that was the case.

See optSSE2, optAVX2 and optSingleMode in http://avisynth.nl/index.php/Expr

EDIT:
In Avisynth+ frame alignment is 64 bytes since I added AVX2 codegen to Expr to allow the two-lane (2x256 bit YMM register) operation for 32 bit float-type inputs - and as a side effect allows painless AVX512 usage for present and future filters. Why 64 bytes? For float-type pixel input in order to use 2xYMM registers we have to read and write 512bits = 64 bytes at a time, which requires 64 byte line padding.

Later when one-lane mode (optSingleMode=true option) was put in the codegen core, it became possible to have all calculations in two-lane (2x256bit = 2x8 float pixels) mode, except the last chunk of a line which could be done either for 8 pixels (one 256 bit YMM register, like in optSingleMode=true) or 2x8 pixels (2x256bit YMM registers), depending on the source clip width. Using such an adaptive treating of the last pixels it would no longer require 64 byte alignment and line padding, because the old 32 bytes padding would have been enough, anyway I left the 64 bytes frame aligment in general thinking of the plenty future filters using AVX512.

pinterf
18th November 2018, 12:18
On the AVS wiki page, when you talk about ImageWriter, give this example:

# Write frame 5 to "C: \ 000005.PNG"
ImageWriter ("", 5, 5, "png")

... so my question is why the difference between AVS and AVS+?

Until I got an error message with strange characters, the problem is the incompatibility of "" in ImageWriter with AVS+ , but not with AVS, why?
Yep, avs+ worked like wiki says, but that part of wiki is wrong. "c:\" is the default value of "file" parameter if it is not provided. When file parameter is given and it's empty string it should get the current directory.

Probably when it was rewritten for avs+ from the classic avs source, they missed that special case.

EDIT: fixed the example on wiki

And yes, it should work (and now the git dev version works) like classic avisynth does.

manolito
18th November 2018, 20:34
I will report back soon...

Finding a shorter source which still revealed the issue was unsuccessful. On two long source files I did get the crashes during the first 10 minutes into the clip, but cutting out the first 15 minutes did not bring any results. With the cut-out sources the conversions went without problems. So the source files themselves are not to blame.

Specifying MT_MULTI_INSTANCE explicitly for the LogoAway filter again seemed to make the crashes disappear first, but on a very long source file with a length of more than 2 and a half hours the crashes did return towards the end of the clip.

My conclusion is that the LogoAway filter needs MT_SERIALZED to work reliably. Sorry for the false alarm... :o


Cheers
manolito

pinterf
19th November 2018, 09:04
O.K. then. By seeing the source code it could be established whether it behaves well in MT environment or not but I suppose we don't have it.

StainlessS
19th November 2018, 12:36
but I suppose we don't have it

I found this, dont know if he has the original source (from the VirtualDub2 thread).

by b2kguga,
I´m giving a try building a new version of LogoAway. So far, the rebuild is doing well. I´m doing it in assembly and debugging it also with my own assembler. One of the things i´m having difficulties to understand is that inside my ConfigDialog it have a call to the toggle function of Vdub.


https://forum.doom9.org/showthread.php?p=1777801#post1777801

EDIT: b2kguga last activity April 2017, so maybe a bum steer.

GMJCZP
22nd November 2018, 01:47
Yep, avs+ worked like wiki says, but that part of wiki is wrong. "c:\" is the default value of "file" parameter if it is not provided. When file parameter is given and it's empty string it should get the current directory.

Probably when it was rewritten for avs+ from the classic avs source, they missed that special case.

EDIT: fixed the example on wiki

And yes, it should work (and now the git dev version works) like classic avisynth does.

Thanks pinterf.
What you say means that the next version of avs+ will admit "" as it does the classic avs?

pinterf
22nd November 2018, 08:45
Thanks pinterf.
What you say means that the next version of avs+ will admit "" as it does the classic avs?
Yes, in next release.

Reel.Deel
7th December 2018, 03:26
I found something really cool from the AviSynth+ nekopanda fork. It is a function to output the flow of filter processing as a graph. See following pictures:

QTGMC(): https://i.imgur.com/JMWKKaO.png

SMDegrain(): https://i.imgur.com/56xKzxl.png

https://github.com/nekopanda/AviSynthPlus/blob/Neo/avs_core/core/FilterGraph.cpp

Any possibility of this filter being incorporated into Avs+? There are other features in this fork as well:
https://github.com/nekopanda/AviSynthPlus/wiki/Avisynth-Neo
https://github.com/nekopanda/AviSynthPlus/wiki/Language-New-Features

pinterf
7th December 2018, 07:43
Yep, I know it, I was just looking into it yesterday. Good and brave modifications, Avisynth++. Also fixed some MT problems with runtime filters which I did't understand two years ago when I tried to fix it, and since then it was forgotten.
EDIT: Yesterday I was already trying to integrate the older ScriptClip related fixes. But in general the source code of the core (caching, video frame storage and allocations, frame properties (!), threading) became so much different and reworked that now it is not easy - or maybe impossible - to simply cherry-pick only one or two features. I have to mention though that as seen on QTGMC or TemporalDegrain when using CPU-only method it consumes more memory and is a bit slower than the current Avisynth+ version (x64, Win10, i7-7770). But it's the question of time when it's getting solved.

pinterf
13th December 2018, 13:12
Doc updated for Overlay (http://avisynth.nl/index.php/Overlay), VarExists (http://avisynth.nl/index.php/Internal_functions#VarExists), BuildPixelType (http://avisynth.nl/index.php/Internal_functions#BuildPixelType), and ColorSpaceNameToPixelType (http://avisynth.nl/index.php/Internal_functions#ColorSpaceNameToPixelType)

wonkey_monkey
14th December 2018, 01:35
This is probably a silly idea and probably not worth implementing even if it isn't, but is there any way for a plugin to set global AviSynths variable that can be used in the script? I'm thinking of those parameters were numbers just won't cut it, so they have to be specified as strings - like specifying a matrix for RGB->YUV conversion.

That seems really clunky, though, so I was wondering if there was a way to do something like this:

foo(clip, quality=FOO_BILINEAR)
foo(clip, quality=FOO_BICUBIC)

with FOO_BILINEAR and FOO_BICUBIC being declared somehow a bit like enums in C++ (having values of 0, 1, etc)? I'm guessing you could do it with an accompanying .avsi script, but can a DLL plugin arrange something like that by itself? By doing something with env in its Init thingy? (I still don't really know how plugins work despite the many I've written...)

FranceBB
14th December 2018, 04:47
Hi Ferenc.
I personally use Avisynth+ x86 32bit (both on my x64 and on my legacy x86 32bit systems) and I rely on that due to filters compatibility/consistency.
Whenever I have to allocate more than 4GB of RAM, I use MP_Pipeline (https://forum.doom9.org/showthread.php?t=163281), but it's not that fast and it doesn't support audio.
Anyway, do you think it can be modified to support audio, improved and included inside Avisynth+ x86 32bit?
Having a better and updated version of MP_Pipeline that also supports audio would be great, especially nowadays 'cause high bit depth and high resolutions require a lot of RAM.
I know that you have many things to do before even considering this one, but it's just a hint, whenever you have time. ^^

Thank you in advance and sorry if it's not 100% related to the Avisynth+ development (you are doing a great job by the way). ^_^

StainlessS
14th December 2018, 10:15
David,
Some Stuff (SetVar and SetGlobalVar pretty much the same usage):-

http://avisynth.nl/index.php/Filter_SDK/Cplusplus_API#SetGlobalVar
http://avisynth.nl/index.php/Filter_SDK/Cplusplus_API#SaveString
https://forum.doom9.org/showthread.php?p=1572321#post1572321
https://forum.doom9.org/showthread.php?p=1843591&highlight=setVar#post1843591


If setting some kind of var (Local or Global) from within eg GetFrame, then suggest that in Constructor, check for existence of the var, and if does not exist, create it with dummy value (using env->SaveString for the variable name, so you know for sure that the name already exists when in GetFrame), also, if eg var type is string and with a known max possible size, then create dummy max size string for it and also SaveString.
In GetFrame, can then assume that var name already exists (and saved with SaveString), and so can just set value in already allocated and saved buffer.

EDIT: If using preallocated buffer, then just write to that buffer, dont SetVar, assuming that you kept address of SaveString buffer,
otherwise get the used buffer via GetVar, and extract the pointer to the buffer from the AVSValue and write to that buffer.
SaveString

virtual char* SaveString(const char* s, int length = -1);

This function copies its argument to a safe "permanent" location and returns a pointer to the new location. Each ScriptEnvironment instance has a buffer set aside for storing strings, which is expanded as needed. The strings are not deleted until the ScriptEnvironment instance goes away (when the script file is closed, usually). This is usually all the permanence that is needed, since all related filter instances will already be gone by then. The returned pointer is not const-qualified, and you're welcome to write to it, as long as you don't stray beyond the bounds of the string.


If just setting with string literals, can just save var name via SaveString,and set var with address of string literal (dont need saving),
string literals are at constant address and read only.

Saving Strings, related to SetVar;
https://forum.doom9.org/showthread.php?p=1633936#post1633936

EDIT:
ApparentFPS constructor

ApparentFPS::ApparentFPS(PClip _child,double _DupeThresh,double _FrameRate,int _Samples,double _ChromaWeight,
const char*_Prefix,bool _Show,bool _Verbose,bool _Debug,
int _Mode,int _Matrix,int _BlkW,int _BlkH,int _oLapX,int _oLapY,
IScriptEnvironment* env) :
GenericVideoFilter(_child),DupeThresh(_DupeThresh),FrameRate(_FrameRate),Samples(_Samples),
ChromaWeight(_ChromaWeight),Prefix(_Prefix),Show(_Show),Verbose(_Verbose),Debug(_Debug),
Mode(_Mode),Matrix(_Matrix),BlkW(_BlkW),BlkH(_BlkH),oLapX(_oLapX),oLapY(_oLapY) {
# ifdef AVISYNTH_PLUGIN_25
if(vi.IsPlanar() && vi.pixel_type != 0xA0000008) {
// Here Planar but NOT YV12, If v2.5 Plugin Does NOT support ANY v2.6+ ColorSpaces
env->ThrowError("ApparentFPS: ColorSpace unsupported in ApparentFPS v2.5\n");
}
# endif
num_frames = vi.num_frames;
Dif = 0.0;
AppFPS = 0.0;
MaxAppFPS = 0.0;
MaxBelowDupeDif = 0.0;
MinAboveDupeDif = 255.0;
Unique = 0;
Valid = 0;
UniqMax = 0;
LftSpan = 0;
RgtSpan = 0;
Prev_n = -666;
int i;
for(i=5;--i>=0;) VarNames[i][0]='\0';
if(*Prefix != '\0') {
char *names[5]={"ApparentFPS","MaxApparentFPS","MaxBelowDupeDif","MinAboveDupeDif","CurrentDif"};
int pfixlen=int(strlen(Prefix));
if(pfixlen>128) pfixlen=128;
for(i=5;--i>=0;) {
char * p = VarNames[i];
memcpy(p,Prefix,pfixlen);
char *d=p+pfixlen;
const char *np=names[i];
for(;*d++=*np++;); // strcat variable name part
AVSValue var = GetVar(env,p);
env->SetVar(var.Defined() ? p : env->SaveString(p),(i==3)?255.0:0.0); // Make sure name exists, init with dummy value
}
}
}



GetFrame

PVideoFrame __stdcall ApparentFPS::GetFrame(int n, IScriptEnvironment* env) {

...


if(*Prefix != '\0') {
env->SetVar(VarNames[0],AppFPS);
env->SetVar(VarNames[1],MaxAppFPS);
env->SetVar(VarNames[2],MaxBelowDupeDif);
env->SetVar(VarNames[3],MinAboveDupeDif);
env->SetVar(VarNames[4],Dif);
}

...
}


EDIT: Take NOTE that GetVar() [by Gavino] is in the 3rd link.

EDIT: Again here:

AVSValue __cdecl GetVar(IScriptEnvironment* env, const char* name) {
try {return env->GetVar(name);} catch (IScriptEnvironment::NotFound) {} return AVSValue();}


If you have any probs, post again. [EDIT: Perhaps ask a mod to move your post and this one to new thread]

EDIT:
Also AtExit function, maybe to release buffers if you allocate them for strings yourself.
http://avisynth.nl/index.php/Filter_SDK/Non-clip_sample
EDIT: Not sure, think you can forget AtExit above, I seem to remember that it is called AFTER plugins are destroyed, so may not work.
EDIT: Think maybe above wrong, plugins do still exist, its the filter graph that is already destroyed (otherwise there would be no point in the AtExit function if plugins already gone, basically dont count on any avisynth structures existing during call from AtExit).


EDIT:
Return constants rather than variables, simple really.

#include <windows.h>

#ifdef AVISYNTH_PLUGIN_25
#include "avisynth25.h"
#else
#include "avisynth.h"
#endif

AVSValue __cdecl Foo_Bilinear(AVSValue args, void* user_data, IScriptEnvironment* env) {
return "12345678"; // Constant address read only, no need to SaveString
}

AVSValue __cdecl Foo_BiCubic(AVSValue args, void* user_data, IScriptEnvironment* env) {
return "87654321";
}

AVSValue __cdecl Foo_PI(AVSValue args, void* user_data, IScriptEnvironment* env) {
return 3.1415926f;
}

AVSValue __cdecl Foo_Life(AVSValue args, void* user_data, IScriptEnvironment* env) {
return 42;
}

#ifdef AVISYNTH_PLUGIN_25
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) {
#else
const AVS_Linkage *AVS_linkage = 0;
extern "C" __declspec(dllexport) const char* __stdcall
AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) {
AVS_linkage = vectors;
#endif
env->AddFunction("FOO_BILINEAR", "", Foo_Bilinear, 0);
env->AddFunction("FOO_BICUBIC", "", Foo_BiCubic, 0);
env->AddFunction("FOO_PI", "", "", Foo_PI, 0);
env->AddFunction("FOO_Life", "", Foo_Life, 0);
return "`DHorman Presets' DHorman plugin";
}

wonkey_monkey
14th December 2018, 19:37
Thanks Stainless. I think env->SetGlobalVar does what I want. Whether it's a good idea or not... well, I don't know if it will suit everyone, but I like what I can do with it and I will probably use it in filters in the future, with suitable variable names that are extermely unlikely to clash with anyone's scripts.

Another thought I had, and again it's probably a bit too odd an idea to implement, is that it'd be great if plugins could provide their own short help text. Instead of having to keep looking things up, there could be an "Explain" or "Help" function that you could call with a filter name, and it would give (thrown as an exception, perhaps) a list of its known parameters, and maybe some brief text for each one. I see that AvisynthPluginInit3 expects you to return a string, but don't know of any way to call that string up in a script.

StainlessS
14th December 2018, 20:13
extermely unlikely to clash with anyone's scripts.
That is not the reason for SaveString, its because Avisynth memory pool is not the same as your memory pool, and so you have to hand over control
of the string for freeing via Avisynth, and leaving Avisynth in charge of it and responsible for the freeing of the memory block. (otherwise memory leaks).
[Above incase you meant that you were not gonna bother with SaveString].

I have never seen the string returned by AvisynthPluginInit2/3 used by anything (with possible exception of AvsEdit, not sure if it used it, and perhaps AvsPMod does too). [EDIT: At least one plugin (dont remember which) returns 0 where it should return that string, so a program trying to access it as a string might cause a system exception/access violation]

I guess that some kind of simple (even script) function could be knocked up to show doc text on video clip,
would need (how I see it) an RT_Stats DBase with eg string name of function, and string name of a txt file on hard drive.
Look for name of function in DBase, if not found then error.
Else read in associated string filename from DB, and read text from doc file, and RT_Subtlte as in the RT_Stats subtitle demo in the avs folder of RT_Stats.

So would use something like return Man("amp").

Demo From RT_Stats using RT_Subtitle (In the AVS directory).

RT_SCROLLDEMO.avs (will open fileselector, you choose an avi file, and then a text file and it will display that text upon the avi).

avi = RT_FSelOpen("Please select an AVI file",Filt="*.AVI|*.AVI")
Assert(avi.IsString,"RT_FSelOpen: Error="+String(avi))
AVISource(AVI)
txt = RT_FSelOpen("And now select a Text file",Filt="*.txt|*.txt")
Assert(txt.IsString,"RT_FSelOpen: Error="+String(txt))
Txt=RT_ReadTxtFromFile(txt)
Lines=RT_TxtQueryLines(Txt)
# config
DELAY=100
ALIGN=1 # As Numeric KeyPad
SCROLL=0 # 0 = Upwards : 1 = Downwards : 2 = Right to Left : 3 = Left to right : 4 = Karaoke
#
ORG=Last
Last=(SCROLL==4)? ORG.Blankclip(height=80) : Last
CMD_0 = """RT_Subtitle("%s",Txt,align=ALIGN,y=height+DELAY-current_frame,expx=true,expy=true)"""
CMD_1 = """RT_Subtitle("%s",Txt,align=ALIGN,y=-(Lines*20+DELAY) + current_frame,expx=true,expy=true)"""
CMD_2 = """RT_Subtitle("%s",Txt,align=ALIGN,x=width+DELAY-current_frame,expx=true,vcent=true)"""
CMD_3 = """RT_Subtitle("%s",Txt,align=ALIGN,x=-(width+DELAY)+current_frame,expx=true,vcent=true)"""
CMD_4 = """RT_Subtitle("%s",Txt,align=ALIGN,y=height+DELAY-current_frame,expx=true,expy=true)"""
CMD_5 = """RT_Subtitle("BAD SCROLL COMMAND (0->4)")"""
CMD = (SCROLL<0 || SCROLL>4) ? CMD_5 : Select(Scroll,CMD_0,CMD_1,CMD_2,CMD_3,CMD_4)
ScriptClip(CMD)
Return (SCROLL==4)? StackVertical(ORG,Last) : Last


EDIT: I guess that you could even eg open notepad and feed it the doc text file.
Doc files could actually be stored as string in a DB, but strings are of fixed max size and so might have to allocate eg 64KB (in DB) each, even for tiny doc files.

EDIT: Even script functions could be stored in DBase, and an Eval/GScript would implant them in current script.
EDIT: For the man thing, could even have a DBase of DBase Names, where each sub DBase record might hold eg an argument name as string, and min value, max value, and some short (eg 1KB) description of the arg. (perhaps more)

EDIT: Each DBase, also has 10 user string attributes (Max 1024 len) for whatever you wish, and 1024 Int or Float user attributes, again for whatever
you want, perhaps link to website download or whatever [for StringUserAttrib(0)], and version number for Float UserAttrib(0).

goorawin
15th December 2018, 00:30
Hi Ferenc.
I personally use Avisynth+ x86 32bit (both on my x64 and on my legacy x86 32bit systems) and I rely on that due to filters compatibility/consistency.
Whenever I have to allocate more than 4GB of RAM, I use MP_Pipeline (https://forum.doom9.org/showthread.php?t=163281), but it's not that fast and it doesn't support audio.
Anyway, do you think it can be modified to support audio, improved and included inside Avisynth+ x86 32bit?
Having a better and updated version of MP_Pipeline that also supports audio would be great, especially nowadays 'cause high bit depth and high resolutions require a lot of RAM.
I know that you have many things to do before even considering this one, but it's just a hint, whenever you have time. ^^

Thank you in advance and sorry if it's not 100% related to the Avisynth+ development (you are doing a great job by the way). ^_^

You can add audio to pipeline by adding it outside the pipeline script, so why would you bother including it within the script?

manolito
16th December 2018, 12:17
After using AVS+ for a few months on my Core i5 (two physical cores plus hyperthreading) I decided to revert back to AviSynth 2.61 Alpha.

I don't have any use for high bit depth and all the new fancy color spaces. I also cannot use the 64-bit version because I absolutely need to use some 32-bit plugins. All I wanted was a speed boost by using MT modes for my AVS plugins, but I was quite disappointed.

My main sources are captured HD files in the HEVC format. My source filters are DSS2Mod and ffms2 (I do not like LSMASH, and I cannot use DGDecNV). And for both source filters the decoding speed is unacceptable with these HEVC sources.

With DSS2Mod the speed tends to be OK at the start, but after a while the speed drops to a snail's pace. With ffms2 it is even worse, speed is about one tenth compared to disabling MT.

With AVS+ the solution is to disable MT, but why would I want to do this? Under AviSynth 2.61 Alpha I get even better speed.


Cheers
manolito

ChaosKing
16th December 2018, 12:31
Maybe the bottleneck is the hdd (cache is full)? How huge are the files?

You can combine 64bit with 32bit filters (and speed up things) with MP_Pipeline: https://forum.doom9.org/showthread.php?t=163281

FranceBB
16th December 2018, 12:43
You can add audio to pipeline by adding it outside the pipeline script, so why would you bother including it within the script?

I could, but if there's a framerate conversion in-between my filter-chain, it would be out of sync.

wonkey_monkey
16th December 2018, 14:48
Bug? When calling extracttoy on a Y8 clip, AviSynth+ complains that there are no chroma channels.

Edit: also minor cosmetic issue: colorbars with pixel_types YV12 and YV24 do not line up exactly. I'm guessing because the bars have to align with chroma subsampling in the YV12 case, but (if someone was so inclined) I would suggest YV24 should be forced to do the same for consistency (with 4:2:0 and 4:1:1 as well), even though it isn't subsampled.

pinterf
16th December 2018, 16:37
Bug? When calling extracttoy on a Y8 clip, AviSynth+ complains that there are no chroma channels.

It was fixed on git but not released yet.

Groucho2004
18th December 2018, 13:55
It was fixed on git but not released yet.Any chance you'd put a new release under our trees before the holidays?

pinterf
18th December 2018, 14:38
Any chance you'd put a new release under our trees before the holidays?
Probably yes.

Groucho2004
18th December 2018, 16:29
Probably yes.Cool, thanks.

Dogway
18th December 2018, 17:17
Try dfttest(sigma=2, lsb=true) with MT mode 2 and check if it fails. It might be dfttestMC problem.

I have some issues with your build (actually all builds but your explcitly since is the most up to date).
I get "illegal instruction" message. Using:
Setfiltermtmode("dfttest", 2)
or with/without Prefetch(4), in avs+ x64, so far the only plugin that doesn't work (well wishing SoundOut and ClipClop as well). I'm using libfftw3f-3.dll from fftw338-x64-AVX2 though.

pinterf
18th December 2018, 18:27
O.K., it's been a long time since I released any update here, no big things included, only a new build. A sort of a maintenance release.

Download Avisynth+ r2768-MT (https://github.com/pinterf/AviSynthPlus/releases/tag/r2768-MT)

The files-only section also contains an x86 build for SSE-only processors.

This release features an interesting language extension: inline assignments, contributed by a new fellow developer addewyd.

Enjoy.

# Avisynth+ r2768 (20181218)
https://forum.doom9.org/showthread.php?t=168856

- New: Expr: allow input clips to have more planes than an implicitely specified output format
Expr(aYV12Clip, "x 255.0 /", format="Y32") # target is Y only which needs only Y plane from YV12 -> no error
- New: Expr: Y-plane-only clip(s) can be used as source planes when a non-subsampled (rgb or 444) output format implicitely specified
Expr(Y, "x", "x 2.0 /", "x 3.0 /", format="RGBPS") # r, g and b expression uses Y plane
Expr(Grey_r, Grey_g, Grey_b, "x", "y 2.0 /", "z 3.0 /", format="RGBPS") # r, g and b expression uses Y plane
- Fix: ConvertToYUY2() error message for non-8 bit sources.
- Fix: Y32 source to 32 bit 420,422,444 (introduced in the zero-chroma-center transition project)
- Fix: ShowY, ShowU, ShowV crash for YUV (non-YUVA) sources
- Speedup: ConvertToY12/16... for RGB or YUY2 sources where 4:4:4 or YV16 intermediate clip was used internally
(~1.5-2x speed, was a regression in Avs+, use intermediate cache again)
- Fix: Allow ExtractY on greyscale clips
- ImageReader/ImageSource: use cache before FreezeFrame when result is a multiframe clip (fast again, regression since an early AVS+ version)
- Resizers: don't use crop at special edge cases to avoid inconsistent results across different parameters/color spaces
- Fix: Histogram 'classic': rare incomplete histogram shown in multithreading environment
- Fix: ImageReader and ImageWriter: if path is "" then it works from/to the current directory.
- GeneralConvolution: Allow 7x7 and 9x9 matrices (was: 3x3 and 5x5)
- GeneralConvolution: All 8-32 bit formats (was: RGB32 only): YUY2 is converted to/from YV16, RGB24/32/48/64 are treated as planar RGB internally
Since 32 bit float input is now possible, matrix elements and bias parameter now is of float type.
For 8-16 bit clips the matrix is converted to integer before use.
- GeneralConvolution: Allow chroma subsampled formats to have their luma _or_ chroma processed. E.g. set chroma=false for a YV12 input.
- GeneralConvolution: new parameters: boolean luma (true), boolean chroma(true), boolean alpha(true)
Default: process all planes. For RGB: luma and chroma parameters are ignored.
Unprocessed planes are copied. Using alpha=false makes RGB32 processing faster, usually A channel is not needed.
- GeneralConvolution: MT friendly parameter parsing
- New: UTF8 filename support in AviSource, AVIFileSource, WAVSource, OpenDMLSource and SegmentedAVISource
All functions above have a new bool utf8 parameter. Default value is false.
- Experimental: new syntax element (by addewyd): assignment operator ":=" which returns the assigned value itself.
(Assignment within an expression)
Examples:
w := h := 256

b := blankclip(width=w * 2, height = h * 3, length=40, pixel_type="yv12")
bm = blankclip(width=w, height = w).letterbox(2,0,2,0, color=$ff)
b

for(j = 0, 1, 1) {
for(i = 0, 1, 1) {
e = 0 + i * 16 + j * 16 * 4
ce = string(e)
c = bm.subtitle("Y = 0x" + hex(e) + " " + ce)
eval("c" + string(i) + string(j) + " := c")
b := b.overlay(c, x = i * w, y = j * h)
}
}

cx = c00.trim(0, 9) + c01.trim(0, 9) + c10.trim(0, 9) + c11.trim(0, 9)

b := overlay(cx, x = 0, y = w * 2)

/* defined NEW_AVSVALUE at build */
array = [99, 101, "303", cnt := 4]

for(j = 0, cnt - 1, 1) {
b := subtitle(string(array[ind := j]), x = 100, y=(j+1) * 20)
}

g := b.tstfunc(kf := "first", ks := "second")

g := subtitle((s := 4) > 0 ? t := "left" : t := "right", y = 100)
g := subtitle(string(s) + " " + t + " " + ks, y = 150)

eval("""h := g.subtitle("G", x=200, y = 20)""")

h.subtitle("H " + string(ind), x = 300, y = 20)


function tstfunc(c, d, e) {
if (f := 1 < 2) {
c.subtitle(string(f) + e, y = 50)
} else {
c.subtitle(d, y = 50)
}
}

FranceBB
18th December 2018, 20:19
Thank you very much indeed for the Christmas present! :D

magiblot
18th December 2018, 20:24
# Avisynth+ r2768 (20181218)
https://forum.doom9.org/showthread.php?t=168856

- New: Expr: allow input clips to have more planes than an implicitely specified output format
Expr(aYV12Clip, "x 255.0 /", format="Y32") # target is Y only which needs only Y plane from YV12 -> no error
- New: Expr: Y-plane-only clip(s) can be used as source planes when a non-subsampled (rgb or 444) output format implicitely specified
Expr(Y, "x", "x 2.0 /", "x 3.0 /", format="RGBPS") # r, g and b expression uses Y plane
Expr(Grey_r, Grey_g, Grey_b, "x", "y 2.0 /", "z 3.0 /", format="RGBPS") # r, g and b expression uses Y plane
- Fix: ConvertToYUY2() error message for non-8 bit sources.
- Fix: Y32 source to 32 bit 420,422,444 (introduced in the zero-chroma-center transition project)
- Speedup: ConvertToY12/16... for RGB or YUY2 sources where 4:4:4 or YV16 intermediate clip was used internally
(~1.5-2x speed, was a regression in Avs+, use intermediate cache again)
- ImageReader/ImageSource: use cache before FreezeFrame when result is a multiframe clip (fast again, regression since an early AVS+ version)


:thanks: :goodpost: :D

pinterf
18th December 2018, 21:02
Thank you for the precious (my precious :) - just have finished re-reading the lotr books) bug reports and the patience and the thanks giving.

wonkey_monkey
18th December 2018, 22:20
Thanks for all the work you do!

StainlessS
19th December 2018, 00:29
+1 on that. Yes, thank you my perfectly precious Pinterf. :)
I just watched all three Hobbits
(standard versions only, not sure if there are extended versions,
I only got extended in LOTR, me loves the Faceless & Accursed one [always brings to mind TheFluff for some reason]).

Sparktank
19th December 2018, 02:44
And just like that, it started to snow.
The who's in whoville started to sing!

Thanks for the update!

LigH
19th December 2018, 09:00
Are you a Whovian?

Sparktank
19th December 2018, 09:24
Are you a Whovian?

I LOVE Doctor Who!
Still need to catch up to current season and then check out the older series before the 2005 revamp.

Back on topic, loving all these updates.
It's even nicer seeing older plugins get updated for AVS+.

With all this, I can delay learning python language for VS a bit longer. :p

pinterf
20th December 2018, 14:37
New build, Expr fixes. I hope.

Download Avisynth+ r2772-MT (https://github.com/pinterf/AviSynthPlus/releases/tag/r2772-MT)


20181220 r2772
--------------
- Fix: Expr: possible Expr x64 crash under specific memory circumstances
- Fix: Expr: safer code for internal variables "Store and pop from stack" (see: Internal variables at http://avisynth.nl/index.php/Expr)

In the x64 stack frame generation, address calculation was truncated to 32 bits when AVX2 registers were to be saved. Caused C0000005 Access Violation.

The second fix is a precaution, (generating code for the A^ syntax for 'store and pop' operation of internal variables), did not caused any troubles yet, I fixed it anyway.

Dogway
23rd December 2018, 12:04
Does someone know if there's an alternative to SoundOut() for avs+ x64? It's a basic tool I use very oftenly (currently) to do edits/filtering to audio without having to create intermediary WAV files. I tried BatchEncoder and similar and they don't work fine.