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. |
|
|
Thread Tools | Search this Thread | Display Modes |
19th February 2022, 17:18 | #1 | Link |
Formerly davidh*****
Join Date: Jan 2004
Posts: 2,496
|
shebang_mod - a modification to AviSynth to implement script pre-processing
Download: shebang_mod.zip
As mentioned here, I had an idea to add a script pre-processor to AviSynth to allow for plugins that could free up the grammar a bit, or perform other tricks, while maximising backwards compatability and not putting any new restrictions on script writers or AviSynth itself. I've managed to make it work with a short modification to scriptparser.cpp. Compiled AviSynth DLLs (based on 3.7.2 from https://github.com/AviSynth/AviSynthPlus) are in the zip file above along with an example preprocessing plugin (ScriptMonkey.dll) and a couple of example scripts, as well as the modified scriptparser.cpp and a diff file. Preprocessing is triggered by a shebang ("#!") as the first characters of the first (and any immediately following) lines of the script, followed by the name of any function which takes a string as input and returns a string (the function name can be optionally followed by comments, as below): Code:
#!revstr <- this internal AviSynth function reverses the characters of the script (including the order of lines) 21VYoTtrevnoC srabroloC Code:
#!ScriptMonkey <- this line enables the script # The ScriptMonkey plugin function allows multi-line parameters without # requiring backslashes (\) for line continuation, # comments in the middle of # multi-line parameters, and trailing commas in parameter lists. ColorBarsHD ConvertToYV12( interlaced = true, matrix = "rec709", # this trailing comma is now allowed # chromaresample = "point" # this parameter is commented out ) Last edited by wonkey_monkey; 18th March 2022 at 18:56. |
24th March 2022, 08:48 | #4 | Link |
Registered User
Join Date: Jan 2014
Posts: 2,314
|
Can you remember what is the reason for requiring backslash for line continuation? I know - compatibility and probably handling some special function calling case. Surely there were discussions about it, Avisynth is mature enough.
|
24th March 2022, 10:40 | #5 | Link |
Formerly davidh*****
Join Date: Jan 2004
Posts: 2,496
|
Nope, no idea. I did some Googling a few weeks back while I was working on this, and all I could find was an obscure case, that Gavino came up with I think, where getting rid of the backslash requirement could cause a change to the result of a script. It was something like
Code:
some_var = -5 + 5 ? clip1 : clip2 However, just to be on the safe side, my mod and filter only removes newlines while inside function parameter lists. Last edited by wonkey_monkey; 25th March 2022 at 23:24. |
19th April 2022, 05:38 | #6 | Link | ||
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
Quote:
# OK Code:
Function Fn() { return true } x=Round(123.456) (TRUE) ? Fn() : NOP # On separate line OK return MessageClip("DONE") Code:
Function Fn() { return true } x=Round(123.456) (TRUE) ? Fn() : NOP # "Script Error. 'Int' cannot be called. Give me A function!" return MessageClip("DONE") EDIT: Shifting NOP out of it, same. Code:
Function Fn() { return true } x=Round(123.456) (TRUE) ? Fn() : Fn() # "Script Error. 'Int' cannot be called. Give me A function!" return MessageClip("DONE") EDIT: Bit more of a clue, Code:
Function Fn() { return true } x=Float(123) (TRUE) ? Fn() : Fn() # "Script Error. 'float' cannot be called. Give me A function!" return MessageClip("DONE")
__________________
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 April 2022 at 06:14. |
||
20th April 2022, 01:36 | #7 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Further to above, no error,[removed () from around (TRUE) ]
Code:
Function Fn() { return true } x=Float(123) TRUE ? Fn() : Fn() # NO ERROR return MessageClip("DONE")
__________________
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 ??? |
Thread Tools | Search this Thread |
Display Modes | |
|
|