Log in

View Full Version : Problem with a function


Soshen
12th July 2006, 18:38
Hello i'm newbie of function but i need a little help for find a way to do a function like that:

for example

if i made a line like that Function Test(Clip Clp,Float"TypeSmooth")
and i can insert in "typesmooth" values like "Hard" or "Soft"


and i want that: if i write "Hard", the function will use Deen("a3d",4,9,1,9) , if i write "Soft" use MipSmooth(preset = "AnimeHQ")

the concept are use deen or Mipsmooth with particular values

i try with that code but dont work

TypeSmooth = Default(TypeSmth,hard)

dSoft = Default(params, Chr(34)+"MipSmooth"+Chr(34)+"(preset = "Chr(34)+"AnimeHQ"+Chr(34)+")")
dHard = Default(params, Chr(34)+"Deen"+Chr(34)+"("Chr(34)+"a3d"+Chr(34)+", 4, 9, 1, 9)")
params = (TypeSmth=="Hard") ? dHard : dSoft
params = (TypeSmth=="soft") ? dSoft : dhard

foxyshadis
12th July 2006, 20:12
It looks like it's too complicated from what you describe, and you didn't include everything. And you'll probably need some more work to understand the basics of the scripting. But it looks like what you might want:


function Test(clip clp, string "TypeSmooth", clip "params") {
TypeSmooth = default(TypeSmooth,"hard")
dSoft = Defined(params) ? params : MipSmooth(preset="AnimeHQ")
dHard = Defined(params) ? params : Deen("a3d",4,9,1,9)
filtered = (TypeSmooth == "hard") ? dHard : dSoft
return filtered
}

With this, you would call it as Test(params=FrFun7()) to pass in your own filtered version.

If you're looking to pass a function in to be used partway through, well, that's generally not a great idea, but it can be done with eval:


dSoft = Default(params, """ MipSmooth(preset="AnimeHQ") """)
#...
filtered = (TypeSmooth == "hard") ? eval(dSoft) : eval(dHard)

Note the tripe-double-quotes.

Some advice: Watch your variable names (you're mixing typesmooth and typesmth up), watch your syntax (you're missing a couple of + in your strings), and watch your types (you can't pass a string in a float type, which you defined TypeSmooth as).

Soshen
12th July 2006, 23:20
The output say me "invalid argument for function MipSmooth
if i try to use your script...

foxyshadis
12th July 2006, 23:48
Sorry, I forgot to put the clip in there:

function Test(clip clp, string "TypeSmooth", clip "params") {
TypeSmooth = default(TypeSmooth,"hard")
clp
dSoft = Defined(params) ? params : MipSmooth(preset="AnimeHQ")
dHard = Defined(params) ? params : Deen("a3d",4,9,1,9)
filtered = (TypeSmooth == "hard") ? dHard : dSoft
return filtered
}

Soshen
12th July 2006, 23:58
If i try to add a second variable of my function and add first the return the command
Final = Debug ? filtered : Border

it work..

but if the variables are more i need the way to work are

RT = Debug ? filtered : Border
RZ = Debug ? XXX : YYY

Final = Debug ? RT : RZ
Rerutn (Final)

?


And...

i Try to force the color convrsion in Yv12
with a code like
Clp = Clp.isYV12() ? Clp : Clp.ConvertToYV12()
but when try to import the avs in other script like a filter it thell me that still want imput YV12

there are other way to fix it?

Soshen
13th July 2006, 00:38
Sorry, I forgot to put the clip in there:

function Test(clip clp, string "TypeSmooth", clip "params") {
TypeSmooth = default(TypeSmooth,"hard")
clp
dSoft = Defined(params) ? params : MipSmooth(preset="AnimeHQ")
dHard = Defined(params) ? params : Deen("a3d",4,9,1,9)
filtered = (TypeSmooth == "hard") ? dHard : dSoft
return filtered
}


but with your code if a write Import("C:\Test.avs")
and
Test(TypeSmooth="Hard") the function use the Deen filter
and
if i use
Test(TypeSmooth="Soft") the function use MipSmooth
?

cose i try to unload the filter deen.dll and use "Hard" and i work good ^^'

Soshen
14th July 2006, 13:03
If i've understood good your function set the variable only for Hard command, any for Soft...

foxyshadis
14th July 2006, 13:45
I tried to avoid too much complexity, but you could go further:

filtered = (TypeSmooth == "hard") ? dHard :
\ (TypeSmooth == "soft") ? dSoft :
\ (TypeSmooth == "green") ? Blankclip(last,color=$800000) :
\ Blur(1) # default

I don't know why it would still work when deen was removed, though if it's in the avisynth plugins folder you don't need a LoadPlugin() to use it. (try moving the dll.)

Soshen
18th July 2006, 15:08
yeah seam work good thanks