Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
#1 | Link |
|
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,394
|
Conditional Filtering Problem
Here an example from Avisynth docs,
Advanced Conditional Filtering Part II Code:
global sep="."
global combedthreshold=25
Function IsMoving() {
global b = (diff < 1.0) ? false : true
}
Function CombingInfo(clip c) {
file = "interlace.log"
global clip = c
c = WriteFile(c, file, "a", "sep", "b")
c = FrameEvaluate(c, "global a = IsCombed(clip, combedthreshold)")
c = FrameEvaluate(c, "IsMoving")
c = FrameEvaluate(c, "global diff = 0.50*YDifferenceFromPrevious(clip) + 0.25*UDifferenceFromPrevious(clip) + 0.25*VDifferenceFromPrevious(clip)")
return c
}
v=Avisource("F.AVI")
CombingInfo(v)
And here, the example following which is supposed to just get rid of the globals (EDIT: diff, a, and b). Code:
global sep="."
global combedthreshold=25
Function IsMoving(float diff) {
return (diff >= 1.0)
}
Function CombingInfo(clip c) {
file = "interlace.log"
c = WriteFile(c, file, "a", "sep", "b")
c = FrameEvaluate(c,"
diff = 0.50*YDifferenceFromPrevious() + 0.25*UDifferenceFromPrevious() + 0.25*VDifferenceFromPrevious()
b = IsMoving(diff)
a = IsCombed(combedthreshold)
")
return c
}
v=Avisource("F.AVI")
CombingInfo(v)
Code:
I don't know what "a" means.I don't know what "b" means false.false false.false false.false false.false false.false false.false false.false false.false false.false false.false false.false false.true Question is, is there a way to eradicate the "I dont know" line (EDIT: & why is it there?). What I'm trying to do is experimental, something like this:- Code:
Function ChooseClip(float df) {
return df>0.5?7:df>0.25?6:df>0.125?5:df>0.0625?4:df>0.03125?3:df>0.015625?2:df>0.0078125?1:0
}
Function MakeClopCmd(clip c,string File) {
c = WriteFile(c, File, "Ix", """ "," """, "current_frame", append=false)
c = FrameEvaluate(c,"
df=YDifferenceFromPrevious()
Ix=ChooseClip(df)
")
return c
}
v=Avisource("F.AVI")
MakeClopCmd(v,"Clop.txt")
Thanx in advance.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 19th January 2012 at 23:21. |
|
|
|
|
|
#2 | Link |
|
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,442
|
Firstly I must apologise, as it was me who added the second example.
![]() I see now that it's not quite right. It should be: Code:
...
Function CombingInfo(clip c) {
file = "interlace.log"
c = FrameEvaluate(c,"
diff = 0.50*YDifferenceFromPrevious() + 0.25*UDifferenceFromPrevious() + 0.25*VDifferenceFromPrevious()
b = IsMoving(diff)
a = IsCombed(combedthreshold)
")
c = WriteFile(c, file, "a", "sep", "b")
return c
}
...
As it was, the values of a and b were not defined on the first frame (and on later frames wrongly referred to the previous frame). That's because the YDifferenceFromPrevious() requests a frame from WriteFile before the variables have been assigned a value. The first example works OK because there the input to YDifferenceFromPrevious (etc) is the global clip, and a frame is not requested from WriteFile until all the variables have been assigned. So your function should work if you move the WriteFile call to be after FrameEvaluate(). |
|
|
|
|
|
#3 | Link |
|
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,394
|
Thankyou Gavino, I hoped that this thread might attract your attention.
I guess I should have realized the reason and tried moving line order, but the conditional stuff always gets me a little confused as to order of evaluation, its very complicated stuff eh! Thanks again, what would we all do without you.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
|
|
|
|
|
#4 | Link | |
|
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,442
|
Quote:
And as shodan (original author of the conditional/run-time filters) said: I've corrected the example now, by the way - thanks for finding the error! |
|
|
|
|
|
|
#5 | Link |
|
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,394
|
The experimental stuff mentioned above does not really work too well, YDifferenceFromPrevious
does not give a good measure of 'blockiness' (although not so bad in a small range). I am more concerned with finding a way of using the conditionals to choose a frame from a choice of multiple clips than with deblocking as such, BUT, would anyone know of any plug that provides some kind of runtime quantitative measure of blockiness of a frame? EDIT: I'll be surprised if anybody does.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 20th January 2012 at 19:08. |
|
|
|
![]() |
| Tags |
| conditional |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|