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 > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 3rd July 2019, 14:40   #4781  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 1,293
Quote:
Originally Posted by pinterf View Post
3.) What's wrong with the second "this"?
it can't has "universal Expr" https://forum.doom9.org/showthread.p...44#post1873444
__________________
My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 3rd July 2019, 14:46   #4782  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,248
Quote:
you'll probably find more glitches.
Hope not but you never can tell.
Getting there step by step, looking quite good.
Looks like S_ExLogo may support all colorspaces that layer supports. [wonder if we have to support YAxx at some point (internally, dont think exists externally, <maybe just strip alpha>)]

Thanks muchly for all of the nice new Layer() stuff, we is gettin' there.
__________________
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; 3rd July 2019 at 14:52.
StainlessS is online now   Reply With Quote
Old 3rd July 2019, 15:00   #4783  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,255
Quote:
Originally Posted by real.finder View Post
Universal (lut or Expr) expressions make us lazy. I have already put thousands of hacks into the lut and Expr expression syntax.
But sometimes we have to use "IF float ELSE ".

32 bit float expressions can be tricky, using a generic expression would be sub-optimal for lower bit depths.

Anyway, this one seems to work properly for me (I'm using different y and u/v expression) for both 16 and 32 bits:

In smaskmerge:
mt_lutxyz(src,overlay,mask,\
"x range_max z - * y z * + range_max /",\
uexpr="x range_max range_min - z - * y z * + range_max range_min - /",\
vexpr="x range_max range_min - z - * y z * + range_max range_min - /",\
y=y,u=u,v=v)

I'd rather use Expr for high bit depth (speed)
pinterf is offline   Reply With Quote
Old 3rd July 2019, 15:50   #4784  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 1,293
Quote:
Originally Posted by pinterf View Post
Universal (lut or Expr) expressions make us lazy. I have already put thousands of hacks into the lut and Expr expression syntax.
But sometimes we have to use "IF float ELSE ".

32 bit float expressions can be tricky, using a generic expression would be sub-optimal for lower bit depths.

Anyway, this one seems to work properly for me (I'm using different y and u/v expression) for both 16 and 32 bits:

In smaskmerge:
mt_lutxyz(src,overlay,mask,\
"x range_max z - * y z * + range_max /",\
uexpr="x range_max range_min - z - * y z * + range_max range_min - /",\
vexpr="x range_max range_min - z - * y z * + range_max range_min - /",\
y=y,u=u,v=v)

I'd rather use Expr for high bit depth (speed)
I am with you here, but sometimes these lazy friendly things help even for none lazy people in testing purpose

I will use "IF float ELSE" only if the lazy method slower
__________________
My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 3rd July 2019, 16:21   #4785  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,255
Quote:
Originally Posted by real.finder View Post
I am with you here, but sometimes these lazy friendly things help even for none lazy people in testing purpose

I will use "IF float ELSE" only if the lazy method slower
Passing a differently assembled expression can affect performance and sometimes worth doing it.

Unlike the lut family, Expr can use constant folding internally when it pre-scans an expression. The expression e.g. range_max - range_min (RPN: "range_max range_min -") is a constant expression known before JIT compilation is done, so it'll be replaced with a single constant. (Other optimizations exist in Expr preprocessor such as eliminating "*1" and "+0", replacing "x power 2" with a much faster x*x, etc...)

Since lutxyz is not using JIT (Just In Time) compilation, the subtraction is done as a separate step. In lut versions where the lookup table is precalculated (e.g. lutxyz in 8 bits) this does not affect performance much because the actual expression evaluation is done once during filter creation (unless it's working in a runtime evaluated function, because the size of this lut is 256*256*256 = 16777216 which takes significant time if expression is complex).
pinterf is offline   Reply With Quote
Old 3rd July 2019, 16:55   #4786  |  Link
GillesH
Registered User
 
Join Date: Dec 2013
Location: France
Posts: 60
RunTime Functions

Quick test with the latest AVS+ r2895.
With a active RunTime Function in MT Mode, I no longer have the error message reported to the first post of this topic.
https://forum.doom9.org/showthread.php?t=176502
But, total freezing of the script with active MT (Prefetch).

RunTime Functions works, always, normally WITHOUT MT.
GillesH is offline   Reply With Quote
Old 5th July 2019, 00:59   #4787  |  Link
LouieChuckyMerry
Registered User
 
LouieChuckyMerry's Avatar
 
Join Date: Feb 2014
Posts: 322
Hello. I'm attempting to graduate from AviSynth+ x86 to AviSynth+ x64 but I'm encountering difficulty. With Win 7 x64 and MeGUI, my standard script:

Code:
SOURCE INFORMATION HERE
SetFilterMTMode("Default_MT_Mode",2)
SMDegrain(TR=X,ThSAD=XXX,RefineMotion=True,Plane=0,Chroma=False,n16=True,n16_Out=True)
FastLineDarkenMod4()
ConvertToDoubleWidth()
F3KDB(Y=100,Cb=100,Cr=100,GrainY=0,GrainC=0,Input_Mode=2,Output_Mode=2)
ConvertFromDoubleWidth()
PreFetch(X)
runs fine with MeGUI x86-AviSynth+ x86. When I try to run the same script with MeGUI x64-AviSynth+ x64, I can index, load, and start the script without a problem, but receive the error message "H.264 (MPEG-4 AVC) encoder has stopped working" within a few seconds of starting it. However, if I hash-out the "F3KDB" lines thusly:

Code:
SOURCE INFORMATION HERE
SetFilterMTMode("Default_MT_Mode",2)
SMDegrain(TR=X,ThSAD=XXX,RefineMotion=True,Plane=0,Chroma=False,n16=True,n16_Out=True)
FastLineDarkenMod4()
# ConvertToDoubleWidth()
# F3KDB(Y=100,Cb=100,Cr=100,GrainY=0,GrainC=0,Input_Mode=2,Output_Mode=2)
# ConvertFromDoubleWidth()
PreFetch(X)
the script runs without a problem. I've the minimum plugins necessary for x86 and x64: Dither(_64bit).dll, F3KDB(_64bit).dll, FastLineDarkenMTMod1_44.avsi, MaskTools2_2_18_0MTDualSignatureMod_pinterf(_64bit).dll, MVTools2_7_41_0MTMod_pinterf(_64bit).dll, and SMDegrainMod_rf_3.1.2.101s.dll.

I realize this possibly (probably) isn't an AviSynth+ issue but I couldn't come up with a better place to post a question given the number of geniuses frequenting this thread. Thanks for any redirection or help .

Last edited by LouieChuckyMerry; 5th July 2019 at 01:06. Reason: Information; Information...
LouieChuckyMerry is offline   Reply With Quote
Old 5th July 2019, 01:06   #4788  |  Link
Natty
Noob
 
Join Date: Mar 2017
Posts: 219
try adding input and output depth parameters in f3kdb
Natty is offline   Reply With Quote
Old 5th July 2019, 01:58   #4789  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,084
Don't try to use MeGUI to debug anything. Pass the script to AVSMeter or FFmpeg (or mpv) or x264 itself and see what error gets thrown there. Because I can almost guarantee you it's because you're using the new AviSynth+ high bit depth-compatible build of f3kdb and yet still using the input_mode and output_mode parameters, which were removed (technically also the DoubleWidth conversions, but that's mostly because they're irrelevant now, not because they'd actually cause an error).
qyot27 is offline   Reply With Quote
Old 5th July 2019, 13:26   #4790  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 674
Quote:
Originally Posted by qyot27 View Post
Because I can almost guarantee you it's because you're using the new AviSynth+ high bit depth-compatible build of f3kdb and yet still using the input_mode and output_mode parameters, which were removed (technically also the DoubleWidth conversions, but that's mostly because they're irrelevant now, not because they'd actually cause an error).
This is exactly the reason why I expressed my reluctance in removing 16bit stacked and interleaved in f3kdb here https://forum.doom9.org/showthread.php?t=176553&page=2

And this is just a script that calls f3kdb directly.
Think about how many other plugins/filters are there, who requires f3kdb as a dependency and who call it using those parameters!
__________________
Broadcast Encoder
Avisynth memes: 1 - 2 - 3
Videotek - Audacity XP
FranceBB is offline   Reply With Quote
Old 5th July 2019, 16:54   #4791  |  Link
Groucho2004
Cantankerous Fossil
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,470
Quote:
Originally Posted by pinterf View Post
Meanwhile a question that emerged over another topic, since I wasn't able to compile a C plugin with Visual C++ which was recognized as a C plugin in both Avisynth+ and classic Avisynth 2.6

The code inside the different Avisynth versions is trying to identify a DLL as a C plugin by searching the following entries:

AVS+ x64:
avisynth_c_plugin_init
_avisynth_c_plugin_init@4

AVS+ Win32
_avisynth_c_plugin_init@4
avisynth_c_plugin_init@4

AVS 2.6 Win32
avisynth_c_plugin_init@4
avisynth_c_plugin_init

Visual C++ supports:
_avisynth_c_plugin_init@4
avisynth_c_plugin_init (through .def file)

The common solution would be using avisynth_c_plugin_init@4 that works for both Avs+ and Avs 2.6.
Unfortunately this kind of semi-decorated name is not supported in VC++ (at least I was not able to do it)

The other choice: the non-decorated avisynth_c_plugin_init is not recognized by Avisynth+.
Why don't you just enumerate all plugin export functions and look for "avisynth_c_plugin_init"? That works for all C-plugins (32 & 64 bit). That way you can also identify all C++ plugs and determine if a plugin is 32 or 64 bit. If you're interested I can put together (and comment ) the code bits from AVSMeter that you need.
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 5th July 2019 at 16:59.
Groucho2004 is offline   Reply With Quote
Old 5th July 2019, 18:44   #4792  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,255
Isn't it slow?
pinterf is offline   Reply With Quote
Old 5th July 2019, 18:57   #4793  |  Link
Groucho2004
Cantankerous Fossil
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,470
Quote:
Originally Posted by pinterf View Post
Isn't it slow?
No. I think the current method is slow, just count the number of times you run "GetProcAddress(plugin.Library, "....") on each plugin.
Almost all plugins just have one export so the enumeration is going to be fast. Also, within the same call to "MapAndLoad()" you get the bitness info.
Have a look, the relevant function in AVSMeter is "CAvisynthInfo::GetPluginType" in "AvisynthInfo.h". As I mentioned, I can strip the stuff you don't need and put some comments.
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 5th July 2019 at 19:03.
Groucho2004 is offline   Reply With Quote
Old 5th July 2019, 21:55   #4794  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,255
Sounds interesting. I don't want (= there are other things in my queue) to touch that section right now, but yes, your idea can work.
pinterf is offline   Reply With Quote
Old 7th July 2019, 03:32   #4795  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 1,293
Quote:
Originally Posted by pinterf View Post

In smaskmerge:
mt_lutxyz(src,overlay,mask,\
"x range_max z - * y z * + range_max /",\
uexpr="x range_max range_min - z - * y z * + range_max range_min - /",\
vexpr="x range_max range_min - z - * y z * + range_max range_min - /",\
y=y,u=u,v=v)
I did some test with https://pastebin.com/ade3wBBV (has pmaskmerge and fixed smaskmerge by shifting)

Code:
blankclip(length=48,width=720,height=480, color=$00000,pixel_type="YV12")
expr("sx frameno + 32 % 16 < range_half range_max ?","sx frameno 2 / + 16 % 8 < range_half sx 15 / - range_half ?","sx frameno 2 / + 16 % 8 < range_half sx 8 / - range_half ?")
o=last
setbits=32
ConvertBits(setbits) # 32bit float vs 8-16bit integer

video=last
video2=video.trim(20,0)

	x1=string(20)
	x2=string(600)
	y1=string(50)
	y2=string(340)
msk=o.expr("sx "+x1+" >= sx "+x2+" <= & sy "+y1+" >= sy "+y2+" <= & & range_max range_min ?", "range_half", "range_half").trim(0,-1).FreezeFrame(0, FrameCount(last)-1, 0)
msk=msk.ConvertBits(setbits) # 32bit float vs 8-16bit integer
##########################

pmaskmerge(video, video2, msk,3,3,3, true).StackVertical(smaskmerge(video, video2, msk,3,3,3, true).Subtitle("smaskmerge"))

ConvertBits(8)
pmaskmerge don't do it, and even if the fixed smaskmerge has many workarounds it's not much slower than pmaskmerge (I think it's because pmaskmerge has additional multiplication in expr)
__________________
My Avisynth Stuff

Last edited by real.finder; 7th July 2019 at 04:00.
real.finder is offline   Reply With Quote
Old 7th July 2019, 12:42   #4796  |  Link
Groucho2004
Cantankerous Fossil
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,470
Quote:
Originally Posted by pinterf View Post
Sounds interesting. I don't want (= there are other things in my queue) to touch that section right now, but yes, your idea can work.
For your reference, below is the latest "GetPluginType()". Every plugin I have thrown at it is correctly detected.
Code:
BOOL GetPluginType(std::string sPlugin)
{
 BOOL PROCESS_64 = (sizeof(void*) == 8) ? TRUE : FALSE;
 BOOL bIs64BitDLL = FALSE;

 //The MapAndLoad function maps an image and preloads data from the mapped file.
 LOADED_IMAGE li;
 BOOL bLoaded = MapAndLoad((LPSTR)sPlugin.c_str(), NULL, &li, TRUE, TRUE);

 if (!bLoaded)
 {
  //error handling, check GetLastError() why the DLL could not be loaded
  return FALSE;
 }

 if (li.FileHeader->FileHeader.Machine != IMAGE_FILE_MACHINE_I386) //check the PE header for bitness
 {
  bIs64BitDLL = TRUE; //it's a 64 bit DLL
  if (!PROCESS_64) //if running a 32 bit process, throw error and return
  {
   //"Trying to load 64 bit DLL in 32 bit Avisynth"
   UnMapAndLoad(&li);
   return FALSE;
  }
 }
 else //it's a 32 bit DLL
 {
  if (PROCESS_64) //if running a 64 bit process, throw error and return
  {
   //"Trying to load 32 bit DLL in 64 bit Avisynth"
   UnMapAndLoad(&li);
   return FALSE;
  }
 }

 DWORD expVA = li.FileHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
 if (expVA == 0)
 {
  //error handling -> "Cannot retrieve PE header data"
  UnMapAndLoad(&li);
  return FALSE;
 }

 PIMAGE_EXPORT_DIRECTORY pExp = (PIMAGE_EXPORT_DIRECTORY)ImageRvaToVa(li.FileHeader, li.MappedAddress, expVA, NULL);
 if (pExp == 0)
 {
  //error handling -> "Cannot retrieve PE header data", check GetLastError()
  UnMapAndLoad(&li);
  return FALSE;
 }

 DWORD rvaNames = pExp->AddressOfNames;
 DWORD *prvaNames = (DWORD*)ImageRvaToVa(li.FileHeader, li.MappedAddress, rvaNames, NULL);
 if (prvaNames == 0)
 {
  //error handling -> "Cannot retrieve PE header data", check GetLastError()
  UnMapAndLoad(&li);
  return FALSE;
 }


 //enumerate DLL exports 
 DWORD dwName = 0;
 std::string sPluginType = "";
 for (dwName = 0; dwName < pExp->NumberOfNames; ++dwName)
 {
  DWORD rvaName = prvaNames[dwName];
  std::string sExportFunc((char *)ImageRvaToVa(li.FileHeader, li.MappedAddress, rvaName, NULL));
  std::transform(sExportFunc.begin(), sExportFunc.end(), sExportFunc.begin(), ::tolower); //convert to lower case for comparison

  if (sExportFunc.find("avisynthplugininit3") != string::npos) //CPP 2.6, 32 or 64 bit
  {
   sPluginType = "AVSCPP26";
   break;
  }

  if (sExportFunc.find("avisynthplugininit2") != string::npos) //CPP 2.5, 32 or 64 bit
  {
   sPluginType = "AVSCPP25";
   break;
  }

  if ((sExportFunc.find("avisynthplugininit") != string::npos) && !bIs64BitDLL) //CPP 2.0 (these are 32 bit only)
   sPluginType = "AVSCPP20"; //don't break here, keep looping

  if ((sExportFunc.find("avisynth_c_plugin_init@4") != string::npos) && !bIs64BitDLL) //32 bit C 2.5
  {
   sPluginType = "AVSC25";
   break;
  }

  if ((sExportFunc.find("avisynth_c_plugin_init") != string::npos) && bIs64BitDLL) //64 bit C 2.5
  {
   sPluginType = "AVSC25";
   break;
  }

  if ((sExportFunc == "avisynth_c_plugin_init") && !bIs64BitDLL) //C 2.0 (these are 32 bit only)
   sPluginType = "AVSC20"; //don't break here, keep looping
 }

 UnMapAndLoad(&li);

 return TRUE;
}
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 7th July 2019 at 18:37.
Groucho2004 is offline   Reply With Quote
Old 7th July 2019, 21:13   #4797  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,835
converttorgb32 from a 32-bit (float) YUV source results in black, if one of the following matrices is used:

pc.601
pc.709
average

The other matrices and other bit-depths seem to be okay.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 8th July 2019, 05:28   #4798  |  Link
LouieChuckyMerry
Registered User
 
LouieChuckyMerry's Avatar
 
Join Date: Feb 2014
Posts: 322
Natty, qyot27, and FranceBB: Thank you for leading me to a solution; updating my F3KDB.dll fixed the problem .
LouieChuckyMerry is offline   Reply With Quote
Old 8th July 2019, 12:07   #4799  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,255
Quote:
Originally Posted by wonkey_monkey View Post
converttorgb32 from a 32-bit (float) YUV source results in black, if one of the following matrices is used:

pc.601
pc.709
average

The other matrices and other bit-depths seem to be okay.
Thank you for the report.
New test build Avisynth+ r2900
https://drive.google.com/open?id=14D...3LX9jCssDt3VeF
Changes since last test build:
Code:
- Fix: ConvertToRGB from 32bit float YUV w/ full scale matrixes (pc.601, pc.709, average)
- Fix: FlipHorizontal RGB48/64 artifacts
- Enhanced: a bit quicker FlipHorizontal
- Fix: RGB64 Blur leftmost column artifact
pinterf is offline   Reply With Quote
Old 8th July 2019, 15:35   #4800  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,248
Ooooo lovely, thanx P.
__________________
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 online now   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 11:45.


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