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. |
16th June 2008, 18:36 | #1 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
(Bug) Run-time functions can produce wrong results
I have discovered a subtle and potentially nasty bug in the operation of the run-time (aka conditional) environment. Under certain circumstances, a run-time function can produce the wrong result because it is looking at the wrong frame of its input clip.
Specifically, if:
As you can see, a combination of factors need to be present. However, the bug is potentially nasty because when it bites, you get no error or any indication that something has gone wrong; the script runs apparently OK but produces erroneous results. And it can appear or disappear depending on statements in a completely different part of the script. Here's an example reduced to its simplest form: Code:
# 100 frames black + 100 white, to give predictable luma BlankClip(100, pixel_type="YV12")+BlankClip(100, pixel_type="YV12", color=color_white) FrameEvaluate("#anything you like, even nothing") # ... <- arbitrary filters can appear here... Trim(50, 149) # ... <- ... and again here ScriptClip(""" a1 = AverageLuma() # OK a2 = AverageLuma() # gives wrong value Subtitle("a1="+string(a1)+" a2="+string(a2)) # shows a1 != a2 """) Code:
ScriptClip(""" f1 = current_frame a1 = AverageLuma() f2 = current_frame # now wrong, = f1+50 Subtitle("f1="+string(f1)+" f2="+string(f2)) """)
(If some aspects of this seem strangely familiar, you may have seen the recent thread about problems using run-time functions inside user-defined functions. Thinking further about that problem led me to deduce the existence of this bug, which I was then able to reproduce.) |
|
|