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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 19th February 2022, 17:18   #1  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,492
shebang_mod - a modification to AviSynth to implement script pre-processing

Download: shebang_mod.zip
  • Now based on Avisynth+ 3.7.2

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
As a more useful example, the included ScriptMonkey plugin reformats scripts so you no longer need to use backslashes to continue lines (within function parameter lists only), and allows inter-parameter # comments and trailing commas, so function parameters can be quickly and easily commented out:

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
)
I put it together pretty quickly so if anyone wants to look at the source code and see if I've made any mistakes I'd appreciate it.
__________________
My AviSynth filters / I'm the Doctor

Last edited by wonkey_monkey; 18th March 2022 at 18:56.
wonkey_monkey is offline   Reply With Quote
Old 19th February 2022, 18:06   #2  |  Link
Ceppo
Registered User
 
Join Date: Feb 2016
Location: Nonsense land
Posts: 339
I kinda like the idea. Thanks a lot. I will make some tests when I'm free.
Ceppo is offline   Reply With Quote
Old 18th March 2022, 18:55   #3  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,492
Updated from Avisynth+ 3.7.2.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 24th March 2022, 08:48   #4  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
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.
pinterf is offline   Reply With Quote
Old 24th March 2022, 10:40   #5  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,492
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
Currently, some_var would equal 5 and clip1 would become implicit last. If lines auto-continued, some_var would be equal to clip2.

However, just to be on the safe side, my mod and filter only removes newlines while inside function parameter lists.
__________________
My AviSynth filters / I'm the Doctor

Last edited by wonkey_monkey; 25th March 2022 at 23:24.
wonkey_monkey is offline   Reply With Quote
Old 19th April 2022, 05:38   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by pinterf View Post
Can you remember what is the reason for requiring backslash for line continuation?
Quote:
Originally Posted by wonkey_monkey View Post
all I could find was an obscure case, that Gavino came up with
Not sure if this is same pre recent Avs+,

# OK
Code:
Function Fn() { return true }

x=Round(123.456)
(TRUE) ? Fn() : NOP     # On separate line OK

return MessageClip("DONE")
Not OK
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")
I sometimes like to pack a few things on a single line, so as to be easy to comment/uncomment the lot, during debug.

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: Maybe I'm doin' something silly, its 05:45 and I aint been to bed yet. [maybe to do with the new function objects or whatever they are ???]

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")
Looks maybe something like "123.0(TRUE)" , some kind of Parser bug.
__________________
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.
StainlessS is offline   Reply With Quote
Old 20th April 2022, 01:36   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
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 ???
StainlessS is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:03.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.