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

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 20th January 2019, 01:50   #4401  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Fixed, sorry.

If size specifier is wrong then gets only first four bytes (half of __int64 start, bytes 0 to 3) from stack for vsprintf start arg,
vsprintf count would come from 2nd half (4 bytes, bytes 4 to 7) of start, so count on stack would NOT be accessed at all.

EDIT: for other readers, the vsprintf mentioned stuff, think Wonkey is using something like this

Code:
    int __cdecl dprintf(char* fmt, ...) {
        char printString[2048]="WonkeyWilly: ";                         // Must be nul Termed, eg "Test: " or ""
        char *p=printString;
        for(;*p++;);
        --p;                                                            // @ null term
        va_list argp;
        va_start(argp, fmt);
        vsprintf(p, fmt, argp);
        va_end(argp);
        for(;*p++;);
        --p;                                                            // @ null term
        if(printString == p || p[-1] != '\n') {
            p[0]='\n';                                                  // append n/l if not there already
            p[1]='\0';
        }
        OutputDebugString(printString);
        return int(p-printString);                                      // strlen printString
    }
EDIT:
Quote:
Originally Posted by wonkey_monkey View Post
This is my GetAudio:

Code:
void __stdcall tracker::GetAudio(void* buffer, __int64 start, __int64 count, IScriptEnvironment* env) {
	debug("GetAudio: %d,%d", start, count);
	if (start == -0x5452414b) {
		switch (count) {
			case 0: {
				*((int*)buffer) = 0x5452414b;
			} break;
		}
	} else {
		child->GetAudio(buffer, start, count, env);
	}
}
and this is my call to GetAudio, in the constructor of another filter:

Code:
		int check = 0;
		child->GetAudio(&check, 0x5452414b, 0, env);
		debug("%d", check);
Not sure that I'm understandin' the -ve value in red [0x5452414b = 'TRAK'].
__________________
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; 20th January 2019 at 19:29.
StainlessS is offline  
Old 20th January 2019, 12:26   #4402  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
It's a magic number to flip GetAudio into providing something other than audio. Negative numbers were making it crash, so I must have copied-and-pasted mid-testing. The comparison in GetAudio should be with the positive number.

I've abandoned that idea now because of the possible caching/bounds checking issue (something is intercepting the call and aborting it because the clip doesn't have that many samples). Now I'm calling it with start=0 and passing the magic number in the buffer. I'm not sure this will work either, because it's possible the returned values for a given start/count will change, and if something is caching them then it will interfere.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline  
Old 20th January 2019, 18:55   #4403  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Avs+ Feature request:

Layer with YV24 support would be nice [think I requested this in avs Standard thread]

I would like to mod S_ExLogo() for YV24, currently only YUY2 [Layer also supports RGB32 & under avs+ RGB64].

S_ExLogo[YUY2 Only]:- https://forum.doom9.org/showthread.p...light=S_ExLogo
Code:
# Based on Dekafka (YUY2 Only)
#
#  HHHHHH         s_Exlogo, samples above and below (shown left as 'H')
# VLLLLLLV        and combines them into a horizontal bar.
# VLLLLLLV        Samples left and right and combines them into a vertical bar (show as 'V'.
# VLLLLLLV        Logo area shown as 'L'.
# VLLLLLLV        These bars may or may not be blurred, and are then resized to fit
#  HHHHHH         the logo area. The resized bars are then mixed together based
#                 on arg "Spow" and the ratio of length of Vertical bars to length
#                 of horizontal bars. Finally, the resultant de-logo'd area is
#                 Layer'ed onto the clip using the Amount arg.
#                   Clipping can be set so as to avoid eg sampling letterboxing when
#                 blurring out the logo (would normally result in nasty black
#                 block instead of a nasty logo). 
#
#  Basic usage:-
#   s_ExLogo(clip, int LogoX, int LogoY, int LogoW, Int LogoH)
S_ExLogo is a Mod of DeKafka:- http://avisynth.nl/index.php/DeKafka

EDIT: Despite what it says on the Wiki, Dekafka supports only YUY2, RGB32, RGB64(same as Layer).
Quote:
Note this version works with any format, but there will be a RGB32 conversion. [NO THERE WILL NOT - at least not from eg YV12 or YV24]
EDIT: Only real reason for YV24 desirability, is to support ODD X coords.
__________________
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; 20th January 2019 at 19:31.
StainlessS is offline  
Old 21st January 2019, 14:29   #4404  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
Good catch, Layer is somewhat retarded at the moment. YUY2 is supported so there should be no complain why it's missing other YUV formats. Nor it does support planar RGB, what a world we live in.
Problem registered, and will be solved, well before the next lunar eclipse (but not this week), thanks for the report
pinterf is offline  
Old 21st January 2019, 14:52   #4405  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
and will be solved, well before the next lunar eclipse
Terrific [EDIT: no hurry at all] , Layer is not nearly as RAM greedy and faster than Overlay, and often a better choice if colorspace supported.
Me is a happy bunny, Thanx.

EDIT:
Quote:
faster than Overlay
S_ExLogo may not be the best DeLogo filter, but it does a fair job and 'goes like the clappers' [real fast in comparison to most delogo'ers].
__________________
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; 21st January 2019 at 15:05.
StainlessS is offline  
Old 23rd January 2019, 18:20   #4406  |  Link
BlockABoots
Registered User
 
Join Date: Dec 2012
Posts: 163
Excuses my ignorance, but what is the latest release of avisynth (or what ever it has morphed into)?

Is there a better fork to use than standard avisynth, as i used to use AvsPmod in conjunction with avisynth is there an all in one app now a days?
BlockABoots is offline  
Old 23rd January 2019, 19:23   #4407  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
BockABoots,
Here, Avisynth+ r2772, usually via pinterf sig link "My Avisynth+ repo on github", and then click Releases tab:- https://github.com/pinterf/AviSynthPlus/releases

Above (current avs+) is the only one that everybody should be using.
__________________
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; 23rd January 2019 at 22:02.
StainlessS is offline  
Old 23rd January 2019, 20:09   #4408  |  Link
BlockABoots
Registered User
 
Join Date: Dec 2012
Posts: 163
Thanks
BlockABoots is offline  
Old 24th January 2019, 00:35   #4409  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Quote:
Originally Posted by StainlessS View Post
Above (current avs+) is the only one that everybody should be using.
Please allow me to disagree...

On an old computer with low system RAM and a single core CPU AVS+ does run, but it is way slower than plain vanilla AVS 2.60 (or 2.61 Beta). The only reason to use AVS+ on such a computer is if the user needs the high bit depth and extented color space features of AVS+.

Even on a much newer Core i5 CPU with 8 GB system RAM I found that I had to turn off multithreading completely when using ffms2 as the source filter (in the default serialized mode). Speed dropped to a crawl when the prefetch value was set to 4.

So I do see a few good reasons to prefer AVS 2.60 over AVS+.


Cheers
manolito
manolito is offline  
Old 24th January 2019, 00:59   #4410  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Is it possible to have an AVSValue with an ArraySize() of 0?
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline  
Old 24th January 2019, 01:01   #4411  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by manolito View Post
Please allow me to disagree...

On an old computer with low system RAM and a single core CPU AVS+ does run, but it is way slower than plain vanilla AVS 2.60 (or 2.61 Beta).
Can you post an example script which would show that classic Avisynth uses less memory than AVS+? My expierence is that AVS+ is much more efficient using the available memory.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline  
Old 24th January 2019, 11:08   #4412  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
My expierence is that AVS+ is much more efficient using the available memory.
Mine too.

Quote:
Is it possible to have an AVSValue with an ArraySize() of 0?
Yes.

FrameSel plugin, 2nd arg is array of frame numbers,
Quote:
env->AddFunction("FrameSel", "ci*[SCmd]s[Cmd]s[Show]b[Ver]b[Reject]b[Ordered]b[Debug]b[Extract]i", Create_FrameSel, 0);,
Code:
AVSValue __cdecl Create_FrameSel(AVSValue args, void* user_data, IScriptEnvironment* env) {
PClip		_child	= args[0].AsClip();						// Source Clip, No Default
AVSValue	_Frames	= args[1];								// Frames, Array of frame numbers as filter arguments
const char *_SCmd	= args[2].AsString(NULL);				// SCmd, Frames in string, defaults to NULL
const char *_Cmd	= args[3].AsString(NULL);				// Cmd, Frames Cmd File, defaults to NULL
bool		_show	= args[4].AsBool(false);				// show, show frame numbers
bool		_ver	= args[5].AsBool(false);				// ver, show version
bool		_reject = args[6].AsBool(false);				// Reject Mode
bool		_ordered= args[7].AsBool(true);					// ordered Mode
bool		_debug  = args[8].AsBool(false);				// debug
int 		_extract = args[9].AsInt(1);					// extract

	if(_SCmd && *_SCmd == '\0')		_SCmd=NULL;				// Convert user supplied "" to NULL
	if(_Cmd  && *_Cmd  == '\0')		_Cmd=NULL;				// Convert user supplied "" to NULL

//	if(_Cmd==NULL && _SCmd==NULL && _Frames.ArraySize()==0)
//		return _child;										// No frames specified at all, return orig clip as if no filter.

	return new FrameSel(_child,_Frames,_SCmd,_Cmd,_show,_ver,_reject,_ordered,_debug,_extract,env);
}
Above, is actually switched off (commented out), but still shows that you can have ArraySize==0 when no frames specified.
__________________
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; 24th January 2019 at 11:13.
StainlessS is offline  
Old 24th January 2019, 11:58   #4413  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Oh, sorry, I meant is it possible to construct an AVSValue with an ArraySize() of zero? I tried AVSValue x = AVSValue() but it had an ArraySize() of 1.

I'm using two creator functions which both instantiate the same class - one includes an i+ in its parameter definition, the other doesn't (but does have all the other variables). I also tried passing NULL but C++ wouldn't let me compare an AVSValue with NULL.

It's very easy to work around but I always try to strive for a neat solution (even if my source code doesn't suggest it).
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline  
Old 24th January 2019, 12:27   #4414  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
For anything like that, I tend to look at Avisynth VERSION 3 header (v2.58) with baked code.

Code:
class AVSValue {
public:

  AVSValue() { type = 'v'; }
  AVSValue(IClip* c) { type = 'c'; clip = c; if (c) c->AddRef(); }
  AVSValue(const PClip& c) { type = 'c'; clip = c.GetPointerWithAddRef(); }
  AVSValue(bool b) { type = 'b'; boolean = b; }
  AVSValue(int i) { type = 'i'; integer = i; }
//  AVSValue(__int64 l) { type = 'l'; longlong = l; }
  AVSValue(float f) { type = 'f'; floating_pt = f; }
  AVSValue(double f) { type = 'f'; floating_pt = float(f); }
  AVSValue(const char* s) { type = 's'; string = s; }
  AVSValue(const AVSValue* a, int size) { type = 'a'; array = a; array_size = size; }
  AVSValue(const AVSValue& v) { Assign(&v, true); }

  ~AVSValue() { if (IsClip() && clip) clip->Release(); }
  AVSValue& operator=(const AVSValue& v) { Assign(&v, false); return *this; }

  // Note that we transparently allow 'int' to be treated as 'float'.
  // There are no int<->bool conversions, though.

  bool Defined() const { return type != 'v'; }
  bool IsClip() const { return type == 'c'; }
  bool IsBool() const { return type == 'b'; }
  bool IsInt() const { return type == 'i'; }
//  bool IsLong() const { return (type == 'l'|| type == 'i'); }
  bool IsFloat() const { return type == 'f' || type == 'i'; }
  bool IsString() const { return type == 's'; }
  bool IsArray() const { return type == 'a'; }

  PClip AsClip() const { _ASSERTE(IsClip()); return IsClip()?clip:0; }
  bool AsBool() const { _ASSERTE(IsBool()); return boolean; }
  int AsInt() const { _ASSERTE(IsInt()); return integer; }
//  int AsLong() const { _ASSERTE(IsLong()); return longlong; }
  const char* AsString() const { _ASSERTE(IsString()); return IsString()?string:0; }
  double AsFloat() const { _ASSERTE(IsFloat()); return IsInt()?integer:floating_pt; }

  bool AsBool(bool def) const { _ASSERTE(IsBool()||!Defined()); return IsBool() ? boolean : def; }
  int AsInt(int def) const { _ASSERTE(IsInt()||!Defined()); return IsInt() ? integer : def; }
  double AsFloat(double def) const { _ASSERTE(IsFloat()||!Defined()); return IsInt() ? integer : type=='f' ? floating_pt : def; }
  const char* AsString(const char* def) const { _ASSERTE(IsString()||!Defined()); return IsString() ? string : def; }

  int ArraySize() const { _ASSERTE(IsArray()); return IsArray()?array_size:1; }

  const AVSValue& operator[](int index) const {
    _ASSERTE(IsArray() && index>=0 && index<array_size);
    return (IsArray() && index>=0 && index<array_size) ? array[index] : *this;
  }

private:

  short type;  // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong
  short array_size;
  union {
    IClip* clip;
    bool boolean;
    int integer;
    float floating_pt;
    const char* string;
    const AVSValue* array;
//    __int64 longlong;
  };

  void Assign(const AVSValue* src, bool init) {
    if (src->IsClip() && src->clip)
      src->clip->AddRef();
    if (!init && IsClip() && clip)
      clip->Release();
    // make sure this copies the whole struct!
    ((__int32*)this)[0] = ((__int32*)src)[0];
    ((__int32*)this)[1] = ((__int32*)src)[1];
  }
};
Looks like you need to give an array size.
Code:
AVSValue(const AVSValue* a, int size) { type = 'a'; array = a; array_size = size; }

int ArraySize() const { _ASSERTE(IsArray()); return IsArray()?array_size:1; }
EDIT: does this not work ?
Code:
AVSValue a[0];
Nope, error C2466: cannot allocate an array of constant size 0

EDIT: Some existing code that works,
Code:
    AVSValue std1[STD_SIZE]    =    {child,0,0,0,0,0,0,false};
    AVSValue xtra1[XTRA_SIZE];
    xtra1[XTRA_RGBIX]          =    matrix;
    std1[STD_FRAME]            =    n;

    AVSValue std2[STD_SIZE]    =    {child2,0,0,0,0,0,0,false};
    AVSValue xtra2[XTRA_SIZE];
    xtra2[XTRA_RGBIX]          =    matrix;
    std2[STD_FRAME]            =    n2;

    MYLO mylo;

    RT_MYstats_Lo(RTHIST_F,AVSValue(std1,STD_SIZE),AVSValue(xtra1,XTRA_SIZE),mylo,myName,env,hist1);
    RT_MYstats_Lo(RTHIST_F,AVSValue(std2,STD_SIZE),AVSValue(xtra2,XTRA_SIZE),mylo,myName,env,hist2);
__________________
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; 24th January 2019 at 13:43.
StainlessS is offline  
Old 24th January 2019, 13:10   #4415  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Oh, I guess I can just use IsArray() instead then, thanks for the help. Returning 1 confused me into thinking it was being treated as an array.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline  
Old 24th January 2019, 23:29   #4416  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
It's just occured to me that the "child" clip in the GenericVideoFilter constructor shouldn't really be called "child", should it? It should be "parent".

Not suggesting it should be changed, of course, just making an observation!
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline  
Old 25th January 2019, 06:52   #4417  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Quote:
Originally Posted by pinterf View Post
The files-only section also contains an x86 build for SSE-only processors.
Thanks for still supporting folks with non-SSE2 CPUs...

Just found out that DirectShowSource.dll from the Non-SSE2 folder seems to be broken. It sure does not work without SSE2. Using the older DirectShowSource.dll from the qyot27 build avisynth _r2741-g0cb91abf-20180803 fixes it.


Cheers
manolito
manolito is offline  
Old 25th January 2019, 07:09   #4418  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Quote:
Originally Posted by Groucho2004 View Post
Can you post an example script which would show that classic Avisynth uses less memory than AVS+? My expierence is that AVS+ is much more efficient using the available memory.
Not on my ancient WinXP machine...

Specs:



I tested it again using a short HD clip and converted it to DVD. I used two scripts, the first one is very basic, the second one uses jm_fps (frame rate interpolation) and is much slower. These are the scripts:

Easy.avs:
Quote:
Video = DSS2("I:\test.webm", fps = 30, preroll = 15, lavs = "l0", lavd = "l0")
Audio = DirectShowSource("I:\test.webm", video=false)

Video = Video.ConvertToYV12()
Video = Video.Spline36Resize(720,576)
Video = Video.ChangeFPS(25)

AudioDub(Video, Audio)

Hard.avs:
Quote:
Video = DSS2("I:\test.webm", fps = 30, preroll = 15, lavs = "l0", lavd = "l0")
Audio = DirectShowSource("I:\test.webm", video=false)

Video = Video.ConvertToYV12()
Video = Video.Spline36Resize(720,576)
Video = Video.jm_fps(25)

AudioDub(Video, Audio)

And these are the AVSMeter results for plain vanilla AVS 2.61 Alpha and for the current AVS+ version:








bilder hochladen free


For me this is enough reason to not use AVS+ on this computer. It is slow enough as it is, but slowing it down even more without any additional benefit does not make sense to me.


Cheers
manolito

Last edited by manolito; 25th January 2019 at 07:13.
manolito is offline  
Old 25th January 2019, 07:50   #4419  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,419
Quote:
Originally Posted by manolito View Post
Just found out that DirectShowSource.dll from the Non-SSE2 folder seems to be broken. It sure does not work without SSE2. Using the older DirectShowSource.dll from the qyot27 build avisynth _r2741-g0cb91abf-20180803 fixes it.
DirectShowSource.dll is the only plugin in the main source tree that actually requires linking in an external library - the baseclasses from the Windows 7 SDK. Said baseclasses library doesn't set a processor architecture, so on newer MSVC it just defaults to SSE2 unless overridden manually.

Being a system library, I'm pretty sure I always make sure to compile that piece using /ARCH:IA32 (i.e., none at all) for 32-bit.
qyot27 is offline  
Old 25th January 2019, 11:45   #4420  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by manolito View Post
Not on my ancient WinXP machine...
I used basically the same script as your "hard.avs" with a 720p clip and here are the results with my i5:
Code:
AviSynth 2.61, build:May 17 2016 [16:06:18] VC2008Exp

FPS (min | max | average):      18.57 | 198864 | 46.70
Process memory usage (max):     592 MiB
Thread count:                   13
CPU usage (average):            24.9%
Code:
AviSynth+ 0.1 (r2772, MT, i386)

FPS (min | max | average):      18.64 | 137675 | 46.88
Process memory usage (max):     142 MiB
Thread count:                   20
CPU usage (average):            24.6%
Edit: I just remembered that Avisynth (classic, not sure about AVS+) sets "SetMemoryMax()" according to the available memory:
Code:
    MEMORYSTATUS memstatus;
    GlobalMemoryStatus(&memstatus);
    // Minimum 16MB
    // else physical memory/4
    // Maximum 0.5GB
    if (memstatus.dwAvailPhys    > 64*1024*1024)
      memory_max = (__int64)memstatus.dwAvailPhys >> 2;
    else
      memory_max = 16*1024*1024;

    if (memory_max <= 0 || memory_max > 512*1024*1024) // More than 0.5GB
      memory_max = 512*1024*1024;
In your case this is probably 128 MiB. That would explain the rather moderate memory usage of Avisynth 2.6.1 in your test.
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 25th January 2019 at 13:02.
Groucho2004 is offline  
Closed Thread

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 15:28.


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