i think i need a pro in here

This forum is for questions and discussion of all the aspects of handling and cleaning up your footage with Avisynth.
Locked
User avatar
jt_x
Joined: Wed Oct 17, 2007 10:13 am
Org Profile

i think i need a pro in here

Post by jt_x » Sun Apr 19, 2009 7:04 pm

oh well... i just recently stumbled upon this nice script, which i dont seem to understand much *sigh*
i think it was done for haibane ranmei, lossy episodes i think, can someone please explain what exactly it does? what are all these last's for? and what does return do? and what is the meaning of "." in the last line? please someone, i want to understand it better...

Code: Select all

function HeavyGradient(clip clip)
{
last=clip
Repair(AA(), clip, mode=3)

fluxsmoothst(0, 7)
grainoptimizer(last, gradfun2db().ttempsmooth(), tdist=10)

prescale = last
LimitedSharpenFaster(dest_x=856, Lmode=3)
Repair(last, prescale.Spline36Resize(856,472), mode=1)

vmToon(sharpen=false, thinning=15)
awarpsharp(8,cm=1)

return last
}

function OrdinaryHR(clip clip)
{
last=clip

Repair(AA(), last, mode=3)
Overlay(last, Invert().YLevelsS(gamma=1.5, output_high=240).Invert(), mode="Darken")

prescale = last

LimitedSharpenFaster(dest_x=856, Lmode=3, strength=110, undershoot=1)
Repair(last, prescale.Spline36Resize(856,472), mode=1)

vmToon(sharpen=false, thinning=15, strength=48, threshold=4)

ttempsmooth(maxr=5)
fluxsmoothst(4, 7)

awarpsharp(5,3,cm=0)

return last
}

function PreviewFile()
{
DirectShowSource("d:\hr_previews.avi", fps=29.97, convertfps=true)
Trim(0, 448)
#AA(edge=true)
AAA()
#Overlay(last, Invert().YLevelsS(gamma=1.5, output_high=240).Invert(), mode="Darken")
Crop(0, 4, 0, -4)
Spline36Resize(856, 472)
return last
}

Trim(0,2370).HeavyGradient() ++ Trim(2371, last.framecount).OrdinaryHR() ++ PreviewFile()

User avatar
Zarxrax
Joined: Sun Apr 01, 2001 6:37 pm
Contact:
Org Profile

Re: i think i need a pro in here

Post by Zarxrax » Sun Apr 19, 2009 7:59 pm

Last is an internal variable used by avisynth to reference the last output thus far in the script. The "last" part is always just sort of implied in the code, even if it's not written.

And return tells it which clip to return as the final output. Again, it's always there, even if it's not actually written in the script.

A dot simply tells avisynth to take the clip referenced on the left side of the dot, and apply the filter listed on the right side of the dot.

The following:

Code: Select all

MPEG2Source("file.d2v")
Crop(8,0,-8,-0)
Is exactly the same as:

Code: Select all

last = MPEG2Source("file.d2v")
last = last.Crop(8,0,-8,-0)
return last
The former is just an easier way of writing the latter.

It's probably easier to understand if you have any amount of programming background, as you are simply assigning clips to a variable, and then doing something to that clip, then finally returning a clip.

You can find more in the avisynth documentation.

As for this function itself... I'm not really sure what it's doing. There's a lot of stuff going on.

User avatar
Scintilla
(for EXTREME)
Joined: Mon Mar 31, 2003 8:47 pm
Status: Quo
Location: New Jersey
Contact:
Org Profile

Re: i think i need a pro in here

Post by Scintilla » Sun Apr 19, 2009 8:00 pm

last always means whatever the result of the last (= previous) line was. Usually, this is just implied -- if you don't explicitly give a clip argument to a function that needs one, it'll take the result of the last line by default.

The "." is what's known in object-oriented programming as the dot operator. In AVISynth, it means that you're taking the result of whatever's on the left side of the dot and passing it as the clip argument to the function on the right side of the dot.
So, for example,

AVISource("C:\blah.avi").ConvertToRGB32().Trim(0,100)

is the same as:

AVISource("C:\blah.avi")
ConvertToRGB32()
Trim(0,100)


Most of the script you posted is function definitions that are used by the last line. What the last line does is:

1. Start with whatever came beforehand in the script (before all the function definitions). Presumably, you'd be copying all of this into a script of your own that actually had a video source loaded already.

2. Take only up to frame 2370 of this and apply the HeavyGradient() function, as defined earlier.

3. Take only from frame 2371 to the end of the original video and apply the OrdinaryHR() function, as defined earlier.

4. Call the PreviewFile() function, as defined earlier. For some reason, this function is hardcoded to load "D:\hr_previews.avi" as the video source, and this using DirectShowSource instead of AVISource. I'm beginning to lose faith in whoever wrote this script.

5. Use AlignedSplice() to combine the results of steps 2, 3, and 4, in that order. ("++" is a shortcut for AlignedSplice.) Return the result of this splice.

Does that help?
ImageImage
:pizza: :pizza: Image :pizza: :pizza:

User avatar
jt_x
Joined: Wed Oct 17, 2007 10:13 am
Org Profile

Re: i think i need a pro in here

Post by jt_x » Sat Apr 25, 2009 4:26 pm

Wow... i didn't expect to get an answer so fast. awesome guys + :up: to both of you. :D

User avatar
jt_x
Joined: Wed Oct 17, 2007 10:13 am
Org Profile

Re: i think i need a pro in here

Post by jt_x » Sat Apr 25, 2009 4:27 pm

and yes your explanations helped me a lot.

outlawed
Joined: Fri Jan 12, 2001 1:03 pm
Location: Lost
Org Profile

Re: i think i need a pro in here

Post by outlawed » Sun May 03, 2009 9:34 am

Looks like something someone encoding a warez release of Haibane Renmei might do. The entire point of what the script is trying to do is remove grain from the video through a variety of filters. One might do this so you would need "less bitrate for an internets release".

Grain is not necessarily a bad thing. It is often present in video because of stylistic things done by the real creators.

Locked

Return to “AviSynth Help”