Log in

View Full Version : avisynth+ color presets ?


poisondeathray
30th March 2018, 05:37
Does avs+ have color presets? The "layman" version, not the hex code ? like "color_white"
http://avisynth.nl/index.php/Color_presets

For example

blankclip(color=color_white)


It seems to work in avisynth classic. But it returns "I don't know what 'color_white' means." in avs+

Or did I mess up my avs+ config ? (The hex works ok)

hello_hello
30th March 2018, 08:41
Aren't the colour presets courtesy of "colors_rgb.avsi" in the Avisynth plugins directory? I assume it'd work for Avisynth+, but maybe the Avisynth+ installer doesn't include it.

Groucho2004
30th March 2018, 09:11
For example

blankclip(color=color_white)


It seems to work in avisynth classic. But it returns "I don't know what 'color_white' means." in avs+
Some info about this here (https://forum.doom9.org/showthread.php?p=1714618#post1714618).

poisondeathray
30th March 2018, 15:54
Thanks guys

I tried placing a copy of "colors_rgb.avsi" into the appropriate directory before and it didn't work. (Other plugins and avsi's autoload ok)

Can you suggest another simple workarounds ? (It's not the end of the world, it's just nice to have this function)

StainlessS
30th March 2018, 20:24
PDR, tried a few things and this works ok


blankclip
#RED=Color_red # FAIL
x=RT_VarExist("Color_red") # Somehow forces it to work OK after this line
RT_Subtitle("%s",String(x)) # Shows "True"
RED=Color_Red # NOTE, Is same color as prev FAIL
RT_Subtitle("RED=\a2$%06X",RED,Align=2) # Shows $FF0000
LIME=Color_Lime # NOTE, Not same color as prev
RT_Subtitle("LIME=\a4$%06X",LIME,Align=5) # Shows $00FF00
return Last


EDIT: You will probably prefer this fix (simple access to global vars 'True')

blankclip
T=True # Access Global var TRUE
RT_Subtitle("%s",String(T)) # Shows "True" # EDIT: Actually this that makes it work
RED=Color_Red # NOTE, Is same color as prev FAIL
RT_Subtitle("RED=\a2$%06X",RED,Align=2) # Shows $FF0000
LIME=Color_Lime # NOTE, Not same color as prev
RT_Subtitle("LIME=\a4$%06X",LIME,Align=5) # Shows $00FF00
return Last


EDIT: Actually commenting out above "RT_Subtitle("%s",String(T)) # Shows "True" and it fails, it seems that RT_VarExist or RT_Subtitle that makes it work.


blankclip
#RED=Color_red # FAIL
T=RT_VarExist("Color_red") # Somehow forces it to work OK after this line
#RT_Subtitle("%s",String(T)) # Shows "True"
RED=Color_Red # NOTE, Is same color as prev FAIL
RT_Subtitle("RED=\a2$%06X",RED,Align=2) # Shows $FF0000
LIME=Color_Lime # NOTE, Not same color as prev
RT_Subtitle("LIME=\a4$%06X",LIME,Align=5) # Shows $00FF00
return Last


EDIT: Even this works

blankclip
#RED=Color_red # FAIL
T=RT_VarExist("True") # Somehow forces it to work OK after this line
#RT_Subtitle("%s",T) # Shows "True"
RED=Color_Red # NOTE, Is same color as prev FAIL
RT_Subtitle("RED=\a2$%06X",RED,Align=2) # Shows $FF0000
LIME=Color_Lime # NOTE, Not same color as prev
RT_Subtitle("LIME=\a4$%06X",LIME,Align=5) # Shows $00FF00
return Last


EDIT: So it looks like *** ANY *** access to global vars table via a plugin makes it work, but via script alone does not work.

EDIT: This is RT_VarExist()

AVSValue __cdecl RT_VarExist(AVSValue args, void* user_data, IScriptEnvironment* env) {
try {
env->GetVar(args[0].AsString());
} catch (IScriptEnvironment::NotFound)
{return false;}
return true;
}


EDIT: Above, env->GetVar() first searches Locals vars table and if fails then searches Global vars Table.

StainlessS
30th March 2018, 22:27
PDR, Further to above, find here a temp dll with source + VS 2008 project files (but not avs+ headers, EDIT: Get the latest available)

AvsGlobFix (x86, and x64[x64 untested])[~13KB]:- http://www.mediafire.com/file/2j26qpkdhdp2kts/AvsGlobFix+_dll_1.00_20180330.7z
(requires VS 2008 runtimes)

Also available via SendSpace (for about 30 days) below this post, in my sig.

Source, excluding headers and resource files.

#include <windows.h>

#include "Version.h"
#include "Avisynth.h"

AVSValue __cdecl AvsGlobFix(AVSValue args, void* user_data, IScriptEnvironment* env) {
try {env->GetVar("True");} catch (IScriptEnvironment::NotFound){}
return true;
}

const AVS_Linkage *AVS_linkage = 0;
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) {
AVS_linkage = vectors;
env->AddFunction("AvsGlobFix", "",AvsGlobFix, 0);
return "`AvsGlobaFix' AvsGlobaFix plugin"; // EDIT: In red should NOT be there, but no effect so OK.
}


The only docs supplied, ColorGlobals_Test.avs # EDIT: Below uses RT_Stats for subtitles only, Can comment out those lines

#RED=Color_Red # Will Fail as Colors_rgb.avsi Globals dont work proper in avs+.
AvsGlobFix # Fix Global vars, will work OK now.
blankclip
RED=Color_Red # NOTE, Is same color as prev FAIL
RT_Subtitle("RED=\a2$%06X",RED,Align=2) # Shows $FF0000 [EDIT: $FF0000 In Red ie \a2 switch text Red]
LIME=Color_Lime # NOTE, Not same color as prev
RT_Subtitle("LIME=\a4$%06X",LIME,Align=5) # Shows $00FF00 [EDIT: $00FF00 In Green ie \a4 switch text Green]
return Last

# Note, Creating AvsGlobFix.avsi containing "AvsGlobFix()" command, dont work either.
[EDIT: Not work if put in Plugins dir, I imagine that it would work though if Import()'ed from somewhere via main script,
but then Importing color_rgb.avsi also works.
But AvsGlobFix would also fix any other non color Globals too.]

raffriff42
31st March 2018, 07:59
Could never get the hang of auto-loading. I have a "master" script called _global.avsi that gets included at the top of every script. It loads a few essential plugins, imports colors_rgb.avsi, sets max memory, and does a couple of other things:global pathBase = "E:\Programs\Avisynth_Plugins\"

### return true if running in Avisynth+, false otherwise
function IsAvsPlus()
{
sVer = LCase(VersionString)
return (FindStr(sVer, "avisynth+") > 0)
\ || (FindStr(sVer, "avisynthplus") > 0)
}

IsAvsPlus()
\ ? Eval("""
if (GetProcessInfo()==64)
{
## AVS+, 64-bit
global Is64 = true
SetMemoryMax(2048)

LoadPlugin(pathBase + "ffms-2.17\ffms2-2.23.1-msvc\x64\ffms2.dll")
LoadPlugin(pathBase + "LSMASH_Source\AviSynth-r929\x64\LSMASHSource.dll")
LoadPlugin(pathBase + "MaskTools2\pinterf\v2,2,13\x64\masktools2.dll")
LoadPlugin(pathBase + "MVTools2\v2,7,20,22\x64\mvtools2.dll")
}
else
{
## AVS+, 32-bit
global Is64 = false
SetMemoryMax(512)

LoadPlugin(pathBase + "ffms-2.17\ffms2-2.23.1-msvc\x86\ffms2.dll")
LoadPlugin(pathBase + "LSMASH_Source\AviSynth\LSMASHSource.dll")
LoadPlugin(pathBase + "MaskTools2\pinterf\v2,2,13\x86\masktools2.dll")
LoadPlugin(pathBase + "MVTools2\v2,7,20,22\x86\mvtools2.dll")
}

## AVS+, 32/64
Import(pathBase + "_misc\Utils-r41.avsi")
""",
\ "Eval: AvsPlus=true")
\ : Eval("""
## AVS classic, 32-bit
global Is64 = false
SetMemoryMax(512)

LoadPlugin(pathBase + "ffms-2.17\ffms2-2.23.1-msvc\x86\ffms2.dll")
LoadPlugin(pathBase + "LSMASH_Source\AviSynth\LSMASHSource.dll")
LoadPlugin(pathBase + "MaskTools2\pinterf\v2,2,13\x86\masktools2.dll")
LoadPlugin(pathBase + "MVTools2\v2,7,20,22\x86\mvtools2.dll")
""",
\ "Eval: AvsPlus=false")

## all versions:
Import(pathBase + "_misc\colors_rgb.avsi")
Import(pathBase + "_misc\FFMS2.avsi")

(Is64)
\ ? LoadPlugin(pathBase + "Nnedi3\0,94,48\x64\Release_W7\nnedi3.dll")
\ : LoadPlugin(pathBase + "Nnedi3\0,94,48\x86\Release_W7\nnedi3.dll")

__END__

## Long list of LoadPlugin & Import statements follows, ready to be copied & pasted into my scripts;
## also contains URLs, function signatures, general notes, etc
## ("#include ..." lines are recognized as links by my text editor, TextPad)

##########################################
## (A) ##
##########################################
## AdaptiveMedian
LoadPlugin(pathBase + "VCMohan\AdaptiveMedian\AdaptiveMedian.dll")
#@ AdaptiveMedian (clip, int "sf", int "f", int "maxgrid", bool "yy", bool "uu", bool "vv")
## sf, ef - start frame, end frame
## maxgrid - Maximum size to which grid can be increased (range 3..9; default 5)
## yy, uu, vv - whether to process Y, U & V planes

## ADDCODE by jmac (VITC-like time code)
# http://forum.doom9.org/showthread.php?p=1690894#post1690894
#include "E:\Programs\Avisynth_Plugins\plugins-NOT\jmac-addcode\addcode readme.txt"
#include "E:\Programs\Avisynth_Plugins\plugins-NOT\jmac-addcode\addcode-demo.avs"
LoadPlugin(pathBase + "jmac-addcode\addcode.dll")

## AddGrain (addnoise) (x64)
# http://avisynth.org.ru/docs/english/externalfilters/addgrain.htm
# http://forum.doom9.org/showthread.php?t=111849
# http://avisynth.nl/index.php/AddGrain
#include "E:\Programs\Avisynth_Plugins\plugins-NOT\trbarry\AddGrainC\AddGrainC_loadx64.avsi"
Import(pathBase + "trbarry\AddGrainC\AddGrainC_loadx64.avsi")
#@ AddGrain(float "var", float "hcorr", float "vcorr", float "uvar", int "seed", bool "constant")
#@ AddGrainC(float "var", float "uvar", float "hcorr", float "vcorr", int "seed", bool "constant")

...etc

poisondeathray
31st March 2018, 15:52
# Note, Creating AvsGlobFix.avsi containing "AvsGlobFix()" command, dont work either.
[EDIT: Not work if put in Plugins dir, I imagine that it would work though if Import()'ed from somewhere via main script,
but then Importing color_rgb.avsi also works.
But AvsGlobFix would also fix any other non color Globals too.]


AvsGlobFix works, and import(color_rgb.avsi) from the main script unexpectedly works too. It doesn't quite make sense to me why the latter would work

For me, the simplest is probably import() , but if I had other globals then maybe AvsGlobFix

I'll try to digest RR42's approach later

Thanks guys

GMJCZP
31st March 2018, 16:37
Guys, where is the AvsGlobFix file placed in order for it to work? Does this avoid using Import() for color_rgb.avsi?

poisondeathray
31st March 2018, 16:58
Guys, where is the AvsGlobFix file placed in order for it to work? Does this avoid using Import() for color_rgb.avsi?

The .dll autoloads for me (plugins directory)

But you have to preface each script with AvsGlobFix

GMJCZP
31st March 2018, 17:15
Thank you for the answer, but the last thing you say I do not understand it well about pefrace each script, sorry for my ignorance.

poisondeathray
31st March 2018, 17:21
Thank you for the answer, but the last thing you say I do not understand it well about pefrace each script, sorry for my ignorance.

Include the line in the script

AvsGlobFix
blankclip(color=color_white)

GMJCZP
31st March 2018, 17:25
Thanks poisondeathray.

Hopefully this will be resolved natively soon.

pinterf
3rd April 2018, 12:58
Indeed, strange, the avsi file itself is loaded and must be syntax checked, because when I put an intentional syntax error in it, avs+ will notice. I suspect the variables are cleaned after the autoloading phase.
Added to my todo list.
EDIT: fixed on github.

Shirtfull
20th May 2018, 16:50
Indeed, strange, the avsi file itself is loaded and must be syntax checked, because when I put an intentional syntax error in it, avs+ will notice. I suspect the variables are cleaned after the autoloading phase.
Added to my todo list.
EDIT: fixed on github.

R2664,MT,i386 returns "I don't know what 'color_white' means." .
added AvsGlobFix and now works

Script

BlankClip(length=999, width=720, height=576, pixel_type="yv12", fps=25.0, fps_denominator=1, audio_rate=44100, channels=1, sample_type="16bit", color=color_Thistle)

pinterf
20th May 2018, 17:06
Fixed on git but not released, 2664 does not contain the fix yet.