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 Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th August 2020, 23:21   #181  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,904
Thanks to you both! I'm gonna try it out and see whether it does what it's supposed to do with my source which definitely would have benefited from an hardware time base correction (but the tape is on another site 500 km away and it's not exactly the time to... uh... travel... you know...).
FranceBB is offline   Reply With Quote
Old 15th August 2020, 20:16   #182  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,666
Quote:
Originally Posted by StainlessS View Post
EDIT: Maybe Reel.Deel has any missing plugins.
Those are all of jmac's plugins. He also lost the source code to all of them .
Reel.Deel is offline   Reply With Quote
Old 15th August 2020, 20:29   #183  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Yep, Sendspace only keeps them for 30 days after latest download. [ what a silly billy ]

RD, did you update this on Wiki: http://avisynth.nl/index.php/Filter_SDK/Env_SaveString

Thats a pretty awful example of env->SaveString() use, eg
Code:
Filter SDK/Env SaveString

env->SaveString is given to allow users to pass strings to AVSValue, and ensure that they are being deallocated on unload.

An Example: 
     fnpluginnew = new char[string_len];
     
     strcpy(fnpluginnew, fnplugin.AsString());
     strcat(fnpluginnew, " ");
     strcat(fnpluginnew, name);
     
     env->SetGlobalVar("$PluginFunctions$", AVSValue(env->SaveString(fnpluginnew, string_len)));
     
     // Since fnpluginnew has now been saved it can safely be deleted.
     
     delete[] fnpluginnew;
What newbie is gonna know what "$PluginFunctions$" is, and if thats not bad enough, looks like it will squash your current plugin functions list to me.

I think previous example was taken from one of my posts in dev forum, way better [but I'm probably biased a bit].
I'll find it if you want.

EDIT: Here:- https://forum.doom9.org/showthread.p...36#post1633936

Quote:
Originally Posted by StainlessS View Post
Here how to return strings:-

Code:
    char * strlit="AnyOldName";
    int len=strlen(strlit);
    char * s=new char[len+1];
    if(s==NULL)
        env->ThrowError("Cannot Allocate string mem");
    strcpy(s,strlit);                               // dup
    char *e=s+len;                                  // point at nul

//  make safe copy of string (freed on Avisynth closure)
    AVSValue ret =  env->SaveString(s,e-s);         // e-s is text len only (excl nul) {SaveString uses memcpy)
//  AVSValue ret =  env->SaveString(s);             // alternative, Avisynth uses strlen to ascertain length
//  AVSValue ret =  env->SaveString(s,-1);          // alternative, Avisynth uses strlen to ascertain length
    delete [] s;                                    // delete our temp s buffer
    return ret;                                     // return Saved Str as AVSValue

//  return strlit;                                  // Alternative to MOST of above code char* converted to AVSValue.
//  return "AnyOldName";                            // Alternative to ALL of above code char* converted to AVSValue.
// String literals are read only and at constant address and so need not be saved.
above untested
EDIT: Dont use the one in red above (Its a bit naughty).
EDIT:
Avisynth and your plugin both have their own heap memory [new/malloc] and when you return a string allocated on your plugin heap,
you MUST hand over a string copy to avisynth, you must make a copy on avisynth heap (using avisynth's env->SaveString()) and give it the copy,
this gives avisynth full control over the string memory and also the responsibility to delete the memory when avisynth closes down.
After you make a string copy for avisynth, you can then delete/free your temp string memory buffer.
It is not necessary to use SaveString() on a string literal, "String literals are read only and at constant address and so need not be saved".

Set a Global var named MyGlobalString="Some GlobalVar Text" (actually does not need to use SaveString as "Some GlobalVar Text" is a String Literal).
Code:
env->SetGlobalVar("MyGlobalString", AVSValue(env->SaveString("Some GlobalVar Text")));   // Set Global [SaveString will use strlen() to establish length of string]
...
env->SetVar("MyLocalString", AVSValue(env->SaveString("Some LocalVar Text")));           // Set Local [SaveString will use strlen() to establish length of string]
Also NOTE above, if MyGlobalString and MyLocalString variable name strings above were NOT string literals and located in some dynamic memory buffer, you would
similarly have to use env->SaveString() to make copies of them, and give the copies as the names to SetGlobalVar() and SetVar() functions.


Set Global variable MyPi=3.1415926 [again, below MyPiName is a pointer to "MyPi" string literal (text wrapped in double quotes) and does not need env->SaveString, is just for illustration purposes]
Code:
char *MyPiName = "MyPi";
float pi=3.1415926f;
env->SetGlobalVar(env->SaveString(MyPiName), AVSValue(pi));
...
env->SetGlobalVar(env->SaveString(MyPiName), pi);   // Implicit type conversion of float pi to an AVSValue
__________________
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; 16th August 2020 at 15:28.
StainlessS is offline   Reply With Quote
Reply

Tags
tbc

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 17:03.


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