View Single Post
Old 20th June 2008, 23:43   #13  |  Link
gzarkadas
Registered User
 
gzarkadas's Avatar
 
Join Date: Sep 2005
Location: 100011110010001000001 10000011111111000001
Posts: 221
@Gavino,

The problem I see in making current_frame global is a performance one. This would mean that env->GetVar would have to make in each frame request a full scan of the local vartable table (since by design it would fail) and then a scan of the typically larger global vartable to get the value.

This is a small overhead but is added up at each frame. And the fact is that most Avisynth users do not make such advanced use of runtime scripts; thus any performance penalty, albeit small should be optional and not the norm.

In addition, for all the possible uses of a global current_frame there are alternative solutions. For example:
  • Instead of calling runtime functions inside a function, you can pass their result as argument.
  • Instead of calling ScriptClip("f()") you can pass in a multiline string. In fact, I find this to be most of the time better style because the documentation of what f() does is at the point of use.
  • If the problem is to make functions utilising runtime scripts that can be callable as normal functions, you can use the simple technique of putting a suffix at your key-script-variables (with text substitution). See my FrameFilter and FrameFilterReader filters for a working example (code quick-link here).

Thus, to sum up, the change is possible, but offers optional functionality. In exchange it requires an additional possibly small (but I don't know exactly how much; IanB is in better position to answer this ) runtime cost to be beared by all Avisynth runtime filters' users. It has to be weighted whether it should be implemented.

After all, for all those that do need this functionality, there is now your plugin available .
__________________
AVSLib, a free extension library for Avisynth. Current version: 1.1.0 (beta), 14/05/2007.
[ Home page | Download page ]
gzarkadas is offline   Reply With Quote