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 7th June 2020, 16:37   #1  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Can someone look over this and tell me if I'm doing something wrong/inadvisable?

https://pastebin.com/w5h1ksny

This is some code for a basic caching filter I wrote to speed up a random access filter.

I'm currently using it as part of a complex script, and for some reason it seems to be causing a crash (I also can't rule out the child filter yet, but removing the call to this filter also stops the crash).

And by "crash" I mean the host program, either VirtualDub, AvsMeter64, or my own, just disappears completely without so much as an exception.

I'm calling it with:

Code:
FrameCache(0, 40, true)
which should cause it to preload and cache frames 0-40 of the passed clip. This should only need about 128mb of RAM (I've got 24Gb of it to play with).

One odd thing I've noticed is that, for some reason, during the caching filter's constructor the passed ("child", I still think that's poor terminology though!) clip's GetFrame is called three times in a row for frame 0, without ever returning to the calling point (line 33 in the file). It only gets called once for all the other frames.

Usually it crashes after the first or second GetFrame for frame 0 of the child clip, but it's one of those weird ones where adding more debugging output lines seems to stop the crash happening.

Edit: running AvsMeter64, because it crashes memory usage peaks at about 1.5Gb, so it doesn't seem to be a memory problem.

Anyone got any clues? Is what I'm doing liable to be an abuse of PVideoFrame?
__________________
My AviSynth filters / I'm the Doctor

Last edited by wonkey_monkey; 7th June 2020 at 16:47.
wonkey_monkey is offline   Reply With Quote
Old 7th June 2020, 17:03   #2  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
there are FrameCache in warpsharp, so it's better to change the function name
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 7th June 2020, 17:34   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Wonkey, I dont see any real probs, but
Code:
//#ssS    if (start < 0 || end < 0 || end < start) env->ThrowError("FrameCache: bad start/end value(s)");   // Original line
	if (start < 0 || end < start || end >= num_frames) env->ThrowError("FrameCache: bad start/end value(s)");
Code:
AVSValue __cdecl Create_FrameCache(AVSValue args, void* user_data, IScriptEnvironment* env) {
	return new FrameCache(
		args[0].AsClip(),
		args[1].AsInt(0),
		args[2].AsInt(0),
		args[3].AsBool(),         //sss # No default
		env
	);
}
EDIT: Maybe add
Code:
FrameCache::FrameCache(PClip _child, int _start, int _end, bool _immediate, IScriptEnvironment* env) : GenericVideoFilter(_child), start(_start), end(_end), immediate(_immediate), cache(NULL) {
EDIT: You could also output debug stuff to narrow down where problem resides.
Code:
int __cdecl dprintf(char* fmt, ...) {
char printString[2048]="Wonkey_Test: ";         // This must be nul termed eg "Hello: ", at very least char printString[2048]="".
    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
}
Code:
dprintf("We got to position %d so far",position);
EDIT: Above dprintf() may require below to avoid M$ compiler warning [before M$ headers inclusion].
Code:
    #define _CRT_SECURE_NO_WARNINGS
__________________
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; 7th June 2020 at 18:21.
StainlessS is offline   Reply With Quote
Old 7th June 2020, 21:45   #4  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Quote:
EDIT: You could also output debug stuff to narrow down where problem resides.
Well that's part of the problem. The crash seems to happen, usually, in the middle of some compiled machine code from an otherwise very stable plugin, so it's hard to work out what's going wrong. It's one of those weird ones where it seems to be caused by a specific combination of filters.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:31.


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