PDA

View Full Version : DupHQ


MOmonster
10th August 2005, 23:46
I had some free time this day and used it to create a new function for avisynth. I donīt like the name so much, but it tells what the function is doing. It duplicates the frames of static scenes with better quality.
At this point the function is only for testing, not for using. It has only two parameter, that says the function how strong the difference between two frames has to be to detect it as motion. Defaults are 1 & 6, higher values can cause jerkiness and to low values has no effect. Maybe you have some ideas for tweakings. :)
Of course this function is only useful for sources with many static scenes, especially anime.

DupHq(savev=1.2, maxv=6.5)


Function DupHQ(clip input, clip "analyse", float "savev", float "maxv", bool "chroma", float "forward", float "motionbreak")
{
###### PREPARATION ######
global testclip = analyse.isclip() ? analyse : input
global output = input
global save = default(savev,1.0)
global max = default(maxv,6.0)
global f = default(forward,1.3)
global p = (max-save)/default(motionbreak,6.0)/max
global full = default(chroma,false)

###### VAR.. ######
global t3d3 = 100.0
global t3d2 = 100.0
global t3d1 = 100.0
global t3d0 = 100.0
global temp = 100.0
global t3db = 100.0

###### Conditional Function Chain, evaluated from bottom to top (!) ######
d99=scriptclip(input, "(t3d0*f < t3d1) && (t3db*f < t3d1) && (t3d0 < save ||
\ ((t3d0 < (t3d1-max)*p+save) && (t3d0 < max) && (t3db < max/2))) ? ((t3db2*f < t3d0) &&
\ (t3db*f < t3d0) ? output.duplicateframe(0).duplicateframe(0) : output.duplicateframe(0)) :
\ ((t3d1 < t3d0) && (t3d2 < t3d0*f) && ((t3d1 < save) ||
\ ((t3d1 < (t3d0-max)*p+save) && (t3d1 < max))) ? ((t3d2 < save) && (t3d3 < t3d1*f) &&
\ (t3d2 < t3d1) ? output.trim(2,0) : output.trim(1,0)) : output)")

d4=FrameEvaluate(d99, "global t3d3 = full == false ? YDifferenceToNext(testclip.trim(2,0)) :
\ YDifferenceToNext(testclip.trim(2,0))*3/5 + VDifferenceToNext(testclip.trim(2,0))/5 +
\ UDifferenceToNext(testclip.trim(2,0))/5
global temp = t3d0")
d3=FrameEvaluate(d4, "global t3d2 = t3d3
global t3db = temp")
d2=FrameEvaluate(d3, "global t3d1 = t3d2
global t3db2 = t3db")
d1=FrameEvaluate(d2, "global t3d0 = t3d1")
return(d1)
}
:cool:
This pictures are from fieldblended bobbed sources, but they are representative for what the function does.
source1
http://www.uploadhouse.com/images/932590661source1.jpg (http://www.uploadhouse.com/)
result1
http://www.uploadhouse.com/images/276522544result1.jpg (http://www.uploadhouse.com/)
source2
http://www.uploadhouse.com/images/209321639source2.jpg (http://www.uploadhouse.com/)
result2
http://www.uploadhouse.com/images/143675730result2.jpg (http://www.uploadhouse.com/)

neuron2
10th August 2005, 23:55
DupHQ() might be a good name.

MOmonster
11th August 2005, 00:11
@neuron2
Hmm, sounds really nice :thanks:

@all
There is a fatal bug in the code. If you set the savem to high the motion donīt get only jerky, the motion also jumps. Cruel :scared:
Itīs late, Iīll fix it tomorrow or friday.

Edit: Bug is fixed, but to make this function useful, I have to implement a motion adaptive variable savem parameter.

MOmonster
12th August 2005, 01:31
@neuron2
I changed the name of the function, but to be a representative name there has to be done some work.

@all
I updated the function. Itīs not any longer just proof of concept. The spatial analyse is removed temporally (unfilter isnīt necessary anymore).
It has a maximum value that is used in scenes with high motion and a save value that is used for low motion and static scenes. The function is really fast, but will become slower in the future :angry:
What it exatly do I will explain, if I have a little bit more time :p

MOmonster
15th August 2005, 23:54
@all
I updated the function ones more. I think now it is ready to use. It offers a chroma option and the option for a separate analyse clip like I did it for Crestore. Also there are two other new parameters to tweak the function.
Sorry, but I will write a eplaination for the function, if I have some more time. ;)