View Full Version : Proposed new standard filter behavior
Guest
30th August 2002, 02:03
After seeing people change certain Decomb parameters on a regular basis, I thought that it would be a great idea to allow users to configure their own defaults! Building on dividee's excellent implementation of a plugins directory, I developed the following method for allowing the user to set his own default behaviors. I plan to release a version of Decomb shortly that supports user-definable defaults for all functions and parameters. If you prefer having post=false by default, you'll be able to have that!
AVSValue __cdecl Create_Decimate(AVSValue args,
void* user_data,
IScriptEnvironment* env)
{
char path[1024];
char buf[80], *p;
int cycle = 5;
int mode = 2;
int threshold = 0;
int threshold2 = 100;
bool debug = false;
try
{
FILE *f;
const char* plugin_dir = env->GetVar("$PluginDir$").AsString();
strcpy(path, plugin_dir);
strcat(path, "\\Decimate.def");
if ((f = fopen(path, "r")) != NULL)
{
while(fgets(buf, 80, f) != 0)
{
if (strncmp(buf, "cycle=", 6) == 0)
{
p = buf;
while(*p++ != '=');
cycle = atoi(p);
}
if (strncmp(buf, "mode=", 5) == 0)
{
p = buf;
while(*p++ != '=');
mode = atoi(p);
}
if (strncmp(buf, "threshold=", 10) == 0)
{
p = buf;
while(*p++ != '=');
threshold = atoi(p);
}
if (strncmp(buf, "threshold2=", 11) == 0)
{
p = buf;
while(*p++ != '=');
threshold2 = atoi(p);
}
if (strncmp(buf, "debug=", 6) == 0)
{
p = buf;
while(*p++ != '=');
if (*p == 't') debug = true;
else debug = false;
}
}
}
}
catch (...)
{
// plugin directory not set
// probably using an older version avisynth
}
return new Decimate(
args[0].AsClip(), // clip
args[1].AsInt(cycle), // cycle size
args[2].AsInt(mode), // mode
args[3].AsInt(threshold), // threshold
args[4].AsInt(threshold2), // threshold2
args[5].AsBool(debug), // debug
env);
}
Thanks to dividee for telling me how to get the plugin directory path.
Si
30th August 2002, 19:15
So what would be the syntax for users in the .def file be then?
You know me -it takes me light years to understand anything
new ;)
regards
Simon
Guest
30th August 2002, 19:56
Simon, even you will be able to understand it. :)
For example to make the default for postprocessing be false, you would say:
post=false
...in other words, it is exactly the same as the existing syntax, except that you put one parameter per line.
The filename will be the name of the filter with .def added, e.g., Telecide.def.
Couldn't you tell from reading the code? ;)
dividee
30th August 2002, 22:53
Nice idea, but wouldn't it be better to implement it in avisynth itself ?
Why write code for each filter when we can put it in just one place? If done properly, I think even older (and built-in) filters could benefit from it.
Guest
30th August 2002, 23:26
@dividee
If it can be implemented without a priori knowledge of filters and their parameters and will support filters with and without named parameters, I'm all for it. I would imagine, however, that it would be a low priority given all the other exciting things the Avisynth developers have on their plates.
It can't hurt to add it to my filters until it gets supported in the core.
BTW, did you see over at 100fps.com they diss Telecide() because it has ("Oh, My God") so many parameters. I started thinking... My car: speedometer, odometer, oil gauge, water gauge, brakes, clutch, gas pedal, emergency brakes, window handles, radio, comfort controls... Oh, My God! How could I ever drive it??? :)
Guest
30th August 2002, 23:27
@dividee
A second thought...
If some kind soul would like to help me get started building Avisynth, perhaps I could contribute to the core efforts.
dividee
30th August 2002, 23:55
I'm glad you're considering working on avisynth.
First step would be to install a CVS client app, if you don't have one (I recommend TortoiseCVS (http://www.tortoisecvs.org/)).
You'll need the MS Platform SDK (I don't know which parts of it is necessary; just download the whole thing if 350 MB doesn't scare you).
IIRC, there are some posts about compiling avisynth buried in the "Core Leadership" thread.
When you're set up, as I'm somewhat familiar with the sources, I'll give you my thoughts about where (and how) it could fit.
Guest
31st August 2002, 00:24
@dividee
Thank you for the guidance. Is it pretty much a necessity to upgrade from Win98SE to (say) WinXP to develop for Avisynth?
dividee
31st August 2002, 00:37
I don't know about Win98. I don't think it should be a problem. Did you encounter any ? I'm on Windows 2000.
Si
31st August 2002, 00:42
@neuron2
I can just about read my own C/C++ code - never mind someone elses :)
regards
Simon
dividee
31st August 2002, 03:25
@Simon:
Sometimes I can read someone else's code better than my own. It's not something I'm proud of, of course :p
@Neuron2:
I don't know what 'diss' means, but I've read that piece at 100fps. But I guess that's the typical reaction from a newcomer to avisynth that first encounter a filter with more than two parameters. The parameter count is quite reasonable, given the functionnality. Apparently, they didn't take the time to learn to "drive" it :)
manono
31st August 2002, 06:22
Hi dividee-
Diss in the sense neuron2 is using it means to show disrespect.
sh0dan
31st August 2002, 09:50
@neuron: Win98 is ok (developing on it myself at home) - I know you need DirectX 8.1 SDK, but I'm not sure about the Platform SDK - I installed it both at home and here, and it doesn't seem to create any problems anyway.
vcmohan
4th November 2003, 02:51
Thanks for the clarification. I earlier thought that Avisynth creates def file. Now I know the user need to create one with his defaults.
I also find interesting that my question is leading to a new Avisynth version.
Wilbert
4th November 2003, 10:42
I also find interesting that my question is leading to a new Avisynth version.
Huh? Which question, and which clarification?
Bidoche
4th November 2003, 12:45
I think you need the platform SDK, but I am not sure of that since I haven't build the full dll even once.
Side note : 3.0 will allow users to specify their defaults through its overload mechanism, you just have to define a function of the same name, same parameters (with your defaults) and it will hide the other (in scripts)
stickboy
4th November 2003, 19:45
FWIW, while 2.x doesn't allow that, it's not that hard to write user-level wrapper functions (http://www.avisynth.org/index.php?page=Wrapper) to supply default values. I think that should be good enough until 3.0 comes out.
neily
5th November 2003, 02:06
@neuron2
You are such a pessimist, me thinks. "Donald Graft has made a few of the finest filters for Virtualdub in the net" was the more significant comment than "including this complicated one".
Si
5th November 2003, 09:15
Has something gone wrong with the forum software.:confused:
Are posts going to the wrong places :confused:
Or are people having trouble with their fingers :p
regards
Simon
vcmohan
6th November 2003, 03:29
[QUOTE]Originally posted by neuron2
[B]After seeing people change certain Decomb parameters on a regular basis, I thought that it would be a great idea to allow users to configure their own defaults! const char* plugin_dir = env->GetVar("$PluginDir$").AsString();
catch (...)
{
// plugin directory not set
// probably using an older version avisynth
}
As Avisynth reads the script which may have loadplugin(""FILTER")
when the FILTER calls GetVar Plugin Directory, will it not be possible to return the directory name even if the dll is in some other directory? In c obj files the first arg of call is the name of the obj file. Is no such mechanism exist for a dll?
Guest
6th November 2003, 22:38
This thread has been resurrected by an errant post. Amazing!
Yes, it would be possible to use a more general hunt for the .def file. I used the plugin directory because it was easy and it seemed a reasonable place to store .def files.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.