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/)
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/)