├── Logo.avsi
├── ExTools.avsi
├── GradePack.avsi
├── MasksPack.avsi
├── yugefunc.avsi
├── .github
├── FUNDING.yml
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── ResizersPack.avsi
├── EX mods
├── LSFplus.avsi
├── DeblockPack.avsi
├── FillMissing.avsi
├── GradFun3plus.avsi
├── MCaWarpSharp4.avsi
├── FastLineDarkenPlus.avsi
├── SimilarityMetrics.avsi
├── SwipeSubs.avsi
├── SantiagMod.avsi
├── DeStripe.avsi
├── MultiSWAR_V2-Beta9.avsi
└── FrameRateConverterEX.avsi
├── MIX mods
├── LSFplus.avsi
├── QTGMC+.avsi
├── Spresso.avsi
├── LSharpAAF.avsi
├── GradFun3plus.avsi
├── SharpenersPack.avsi
└── ChromaReconstructorMod.avsi
├── SMDegrain
├── SMDegrain.avsi
├── show.v4.4.0d.png
├── README.md
└── avisynth.css
├── TransformsPack - Main.avsi
├── TransformsPack - Models.avsi
├── .gitattributes
├── Tools
├── AvsPmod
│ ├── Bookmarks to Typed Text.py
│ ├── FreezeFrameFor.py
│ ├── FreezeFrame.py
│ ├── Bookmarks to ClipClop.py
│ └── SceneStats_SC to bookmarks (WIP).py
├── RgTools Guides
│ └── README.md
└── Notepad3
│ ├── DogwayChalk.ini
│ └── DogwayGraphite.ini
├── README.md
├── Stabilization Tools Pack.avsi
├── FilmGrain+.avsi
└── ScenesPack.avsi
/Logo.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/Logo.avsi
--------------------------------------------------------------------------------
/ExTools.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/ExTools.avsi
--------------------------------------------------------------------------------
/GradePack.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/GradePack.avsi
--------------------------------------------------------------------------------
/MasksPack.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/MasksPack.avsi
--------------------------------------------------------------------------------
/yugefunc.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/yugefunc.avsi
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: Dogway
2 | ko_fi: dogway
3 | custom: https://paypal.me/UozaStudio
--------------------------------------------------------------------------------
/ResizersPack.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/ResizersPack.avsi
--------------------------------------------------------------------------------
/EX mods/LSFplus.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/EX mods/LSFplus.avsi
--------------------------------------------------------------------------------
/MIX mods/LSFplus.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/MIX mods/LSFplus.avsi
--------------------------------------------------------------------------------
/MIX mods/QTGMC+.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/MIX mods/QTGMC+.avsi
--------------------------------------------------------------------------------
/MIX mods/Spresso.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/MIX mods/Spresso.avsi
--------------------------------------------------------------------------------
/EX mods/DeblockPack.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/EX mods/DeblockPack.avsi
--------------------------------------------------------------------------------
/EX mods/FillMissing.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/EX mods/FillMissing.avsi
--------------------------------------------------------------------------------
/MIX mods/LSharpAAF.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/MIX mods/LSharpAAF.avsi
--------------------------------------------------------------------------------
/SMDegrain/SMDegrain.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/SMDegrain/SMDegrain.avsi
--------------------------------------------------------------------------------
/EX mods/GradFun3plus.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/EX mods/GradFun3plus.avsi
--------------------------------------------------------------------------------
/EX mods/MCaWarpSharp4.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/EX mods/MCaWarpSharp4.avsi
--------------------------------------------------------------------------------
/MIX mods/GradFun3plus.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/MIX mods/GradFun3plus.avsi
--------------------------------------------------------------------------------
/SMDegrain/show.v4.4.0d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/SMDegrain/show.v4.4.0d.png
--------------------------------------------------------------------------------
/TransformsPack - Main.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/TransformsPack - Main.avsi
--------------------------------------------------------------------------------
/MIX mods/SharpenersPack.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/MIX mods/SharpenersPack.avsi
--------------------------------------------------------------------------------
/TransformsPack - Models.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/TransformsPack - Models.avsi
--------------------------------------------------------------------------------
/EX mods/FastLineDarkenPlus.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/EX mods/FastLineDarkenPlus.avsi
--------------------------------------------------------------------------------
/EX mods/SimilarityMetrics.avsi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/HEAD/EX mods/SimilarityMetrics.avsi
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Windows style line endings
2 | *.txt text eol=crlf
3 | *.avs text eol=crlf
4 | *.avsi text eol=crlf
5 |
6 | *.html linguist-detectable=false
7 | *.css linguist-detectable=false
8 | *.md linguist-detectable=false
9 | *.py linguist-detectable=false
10 |
--------------------------------------------------------------------------------
/Tools/AvsPmod/Bookmarks to Typed Text.py:
--------------------------------------------------------------------------------
1 | # Macro for AvsPmod
2 | # Just types the bookmarks numbers in your script
3 | # for reusing with DeleteFrame(), ReplaceFramesSimple(), etc
4 |
5 | bookmarks = avsp.GetBookmarkList()
6 | bookmarks.sort()
7 | avsp.InsertText("%s, \n" % bookmarks, )
--------------------------------------------------------------------------------
/Tools/AvsPmod/FreezeFrameFor.py:
--------------------------------------------------------------------------------
1 | # python macro for avsp
2 | # replaces current frame with next's.
3 |
4 | current = avsp.GetFrameNumber()
5 | margin = 1
6 | next = current + margin
7 | avsp.InsertText('freezeframe(%i,%i,%i)\n' % (current, next, next))
8 | avsp.ShowVideoFrame(forceRefresh=True)
--------------------------------------------------------------------------------
/Tools/AvsPmod/FreezeFrame.py:
--------------------------------------------------------------------------------
1 | # python macro for avsp
2 | # replaces current frame with previous.
3 |
4 | current = avsp.GetFrameNumber()
5 | margin = 1
6 | previous = current - margin
7 | avsp.InsertText('freezeframe(%i,%i,%i)\n' % (previous, current, previous))
8 | avsp.ShowVideoFrame(forceRefresh=True)
--------------------------------------------------------------------------------
/SMDegrain/README.md:
--------------------------------------------------------------------------------
1 | # SMDegrain Mod
2 |
3 |
4 | [SMDegrain v4.7.0d Documentation](https://raw.githack.com/Dogway/Avisynth-Scripts/master/SMDegrain/SMDegrain.html)
5 |
6 | ------
7 |
8 | [Doom9.org Discussion Thread](https://forum.doom9.org/showthread.php?t=182881)
9 |
10 | ------
11 |
12 | 
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 'Feature request'
3 | about: 'Suggest an idea for this project'
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/Tools/AvsPmod/Bookmarks to ClipClop.py:
--------------------------------------------------------------------------------
1 | # Macro for AvsPmod
2 | # Adds r1(n,n); for every bookmark
3 |
4 | bookmarks = avsp.GetBookmarkList()
5 | bookmarks.sort()
6 | avsp.InsertText("\n\n")
7 | bkNum = len(bookmarks)
8 | def trim(first,last,n):
9 | return "r1(%d,%d)%s" % (first+1, last-1, n)
10 | if bkNum > 1:
11 | # avsp.InsertText(trim(0-1,bookmarks[0],"; "))
12 | for i in range(0,bkNum-1):
13 | if (i % 2 != 0):
14 | avsp.InsertText(trim(bookmarks[i],bookmarks[i+1],"; "))
15 | # avsp.InsertText(trim(bookmarks[-1],avsp.GetVideoFramecount(),""))
16 | elif bkNum == 1:
17 | avsp.InsertText(trim(bookmarks[0],avsp.GetVideoFramecount(),""))
18 | else:
19 | avsp.MsgBox("Must set at least one bookmark")
--------------------------------------------------------------------------------
/Tools/AvsPmod/SceneStats_SC to bookmarks (WIP).py:
--------------------------------------------------------------------------------
1 | # SceneStats_SC to bookmarks
2 | import os
3 | avsname = avsp.SaveScript()
4 | exe = r'C:\AVSMeter3090\AVSMeter64.exe'
5 |
6 | if avsname and exe:
7 | logfilename = avsname + '.log'
8 | SC_call = 'SceneStats("Range",path="%s")' % (logfilename)
9 | os.system('%s %s %s %s --stats %s -o nul' % (exe, avsname, logfilename))
10 |
11 | logfile = open(logfilename)
12 | logs = logfile.readlines()
13 | logfile.close()
14 | bookmarks = []
15 | for logline in logs:
16 | log = logline.split(' ')
17 | if log[2] == 'type:I':
18 | bmpoint = int(log[0].lstrip('in:'))
19 | bookmarks.append(bmpoint)
20 | avsp.SetBookmark(bookmarks)
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 'Bug report'
3 | about: 'Create a report to help us improve'
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | What command was used? Describe all steps needed to reproduce the problem.
15 |
16 | **Expected behavior**
17 | A clear and concise description of what you expected to happen.
18 |
19 | **Files**
20 | If applicable, add input and output CSV and other files needed to investigate and to reproduce the problem.
21 |
22 | **System:**
23 | - OS: [e.g. Windows 10]
24 | - Version [e.g. AVS+ v3.7.3 r3667 x64]
25 |
26 | **Additional context**
27 | Add any other context about the problem here.
28 |
--------------------------------------------------------------------------------
/EX mods/SwipeSubs.avsi:
--------------------------------------------------------------------------------
1 | # SwipeSubs 2.3 by Dogway (11/02/2023)
2 | #
3 | # Display the subtitles from left to right
4 | #
5 |
6 | # start: Frame for subs start
7 | # end: Frame for subs end
8 | # fadeLenght: Range of frames to perform the fade
9 | # h: Whether you want local fade or absolute resolution fade (mask)
10 | # shadow: shadowed subs or not.
11 | # color: set the color, format is: $TTRRGGBB
12 | function ShowText(clip c, int "start", int "end", int "fadeLenght", string "text", string "font", int "x", int "y", bool "h", int "size", int "color", bool "shadow", bool "anim") {
13 |
14 | start = Default( start, 0 )
15 | end = Default( end, 100 )
16 | fadeLenght = Default( fadeLenght, 100 )
17 | text = Default( text, "hola" )
18 | font = Default( font, "Verdana" )
19 | x = Default( x, 15 )
20 | y = Default( y, 15 )
21 | h = Default( h, false )
22 | size = Default( size, 14 )
23 | color = Default( color, $00FFFFFF )
24 | shadow = Default( shadow, true )
25 | anim = Default( anim, true )
26 |
27 | anim ? \
28 | animate(c, start,start+fadeLenght,"ShowTextInter", text, font, x, y, start+end, size, color, h, 0.0, shadow, text, font, x, y, start+end, size, color, h, 2.0, shadow) : \
29 | ShowTextInter(c, text, font, x, y, start+end, size, color, h, 0.0, shadow) }
30 |
31 |
32 |
33 | # Helper function for ShowText()
34 |
35 | function ShowTextInter(clip c, string text, string font, int x, int y, int end, int size, int color, bool h, float anim, bool shadow) {
36 |
37 | x = Default( x, 15 )
38 | y = Default( y, 15 )
39 | anim = Default( anim, 0.0 )
40 | text = Default( text, "hola" )
41 | fs = propNumElements (c,"_ColorRange") > 0 ? \
42 | propGetInt (c,"_ColorRange") == 0 : isRGB(c)
43 |
44 |
45 | msk = h ? ex_lutspa( c, mode = "relative", expr = "x range_size *", UV=128) : \
46 | ex_lutspa( c, mode = "relative", expr = "x "+string(anim)+" y - < range_max range_min ?", UV=128 )
47 | msk = msk.ex_boxblur(1,mode="weighted")
48 |
49 | #LineSeparation=0
50 | #subs=subtitle(c,text,font="Verdana",lsp=LineSeparation,size=size,text_color=$ffffff,align=7,x=x,y=y,last_frame=end)
51 | shadow ? \
52 | SubtitleEx( c,text,x=x+2,y=y+2,firstframe=0, lastframe=end,font=font,effects="bsss,f(30,30)", size = size, textcolor = $20000000, halocolor = $60000000) : nop()
53 | SubtitleEx(shadow?last:c,text,x=x,y=y, firstframe=0, lastframe=end,font=font,effects="b,f(30,30)" , size = size, textcolor = color , halocolor = $FF000000)
54 |
55 | ex_merge(c,last,msk) }
56 |
--------------------------------------------------------------------------------
/SMDegrain/avisynth.css:
--------------------------------------------------------------------------------
1 | body { font-family: verdana, arial, helvetica, sans-serif; color: #000000;
2 | font-size: 12px; background-color: #C8D4D8; text-align: Left;
3 | line-height: 150%;
4 | padding: 0px;
5 | margin: 6px;}
6 |
7 | h1 { font-family: verdana, arial, helvetica, sans-serif; font-size: 26px;
8 | line-height: 150%; color: #000000;
9 | padding: 0px 0px 0px 8px
10 | margin-left: 0px; margin-right: 0px; margin-top: 12px; margin-bottom: 12px;}
11 |
12 | h2 { font-family: verdana, arial, helvetica, sans-serif; font-size: 22px;
13 | line-height: 150%; color: #000000;
14 | background-color: #90A0C0;
15 | padding: 0px 0px 0px 8px;
16 | margin-left: 0px; margin-right: 0px; margin-top: 12px; margin-bottom: 12px;
17 | border: #8080D0; border-style: solid;
18 | border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
19 |
20 | h3 { font-family: verdana, arial, helvetica, sans-serif; font-size: 18px;
21 | line-height: 150%; color: #000000;
22 | padding: 0px 0px 0px 8px;
23 | margin-left: 0px; margin-right: 0px; margin-top: 12px; margin-bottom: 12px;
24 | border: #8080D0; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
25 |
26 | h4 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;
27 | font-style: normal; font-weight: bold; text-decoration: underline}
28 |
29 | a { color: #005090; text-decoration: none; font-family: verdana, arial, helvetica, sans-serif }
30 | a:link { color: #005090}
31 | a:visited { color: #005090}
32 | a:hover { background-color: #FF6060; color: #005090}
33 |
34 | table { font-size: 12px; margin-left: 0px; margin-top: 12px; margin-bottom: 12px;
35 | line-height: 150% }
36 |
37 | pre { font-size: 12px; font-family: Courier, mono;
38 | margin-top: 10px; margin-bottom: 10px;
39 | background-color: #D0D0C0;
40 | padding-left: 12px; padding-top: 12px; padding-right: 12px; padding-bottom: 12px;
41 | border: #908030; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
42 |
43 | code { font-family: Courier, mono; font-size: 12px; letter-spacing: 1px; color: #660033}
44 | var { font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: normal; font-size: 12px;
45 | font-style: italic; letter-spacing: 1px; color: #660033}
46 | tt { font-family: Courier, mono; font-size: 12px}
47 | em { font-family: Courier, mono; font-weight: normal; color: #FFFFFF; font-style: normal}
48 | strong { font-family: Courier, mono; font-weight: bold; color: #FFFF66; font-style: normal}
49 | cite { border: 1px #3030A0 dotted; padding-left: 4px; padding-right: 4px; padding-top: 2px; padding-bottom: 2px}
50 | kbd { color: #808000; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: normal; font-size: 10px; font-style: normal}
--------------------------------------------------------------------------------
/EX mods/SantiagMod.avsi:
--------------------------------------------------------------------------------
1 | ###
2 | ### SantiagMod (19-04-2010)
3 | ### Simple antialiasing
4 | ###
5 | ### Original by cretindesalpes (Santiag: https://forum.doom9.org/showthread.php?p=1393006)
6 | ### Mod by Archimedes (SantiagMod: https://forum.doom9.org/showthread.php?p=1419815)
7 | ### Dogway mod: Removed GScript call (GScript builtin in AVS+)
8 | ### Added 'gpuid' arg for EEDI3CL and NNEDI3CL
9 | ### Speed optimizations
10 | ###
11 | ###
12 | ### Requires either of:
13 | ###
14 | ### EEDI3 (http://avisynth.nl/index.php/Eedi3)
15 | ### EEDI3CL (http://avisynth.nl/index.php/EEDI3CL)
16 | ### NNEDI2 (http://avisynth.nl/index.php/Nnedi2)
17 | ### NNEDI3 (http://avisynth.nl/index.php/Nnedi3)
18 | ### NNEDI3CL (http://avisynth.nl/index.php/NNEDI3CL)
19 | ###
20 | ###
21 | ### Archimedes quote:
22 | ### "I've changed the posted function santiag a little bit.
23 | ###
24 | ### Santiag has now three parameters: type, strh and strv. Type means the antialiasing type.
25 | ### Possible values are "EEDI3", "NNEDI2" and "NNEDI3". 'strh' is the strength for the horizontal
26 | ### anti aliasing and 'strv' is the strength for the vertical anti aliasing. Default values are:
27 | ### type="nnedi3", strh=1 and strv=1.
28 | ###
29 | ### Contrary to the first posted function, santiag(strh=0, strv=0) now means no anti aliasing.
30 | ### I've also corected the center shift. With NNEDI3 as type, the center shift now works correct
31 | ### for all possible input clips (YV12, YUY2 and RGB24)."
32 |
33 |
34 | function SantiagMod(clip input, int "strh", int "strv", string "type", int "UV", int "threads", int "cores", int "gpuid") {
35 |
36 | input
37 | bi = BitsPerComponent()
38 | rgb = isRGB()
39 | fch = is444() || rgb
40 | fs = propNumElements("_ColorRange") > 0 ? \
41 | propGetInt ("_ColorRange") == 0 : rgb
42 |
43 | strh = Default(strh, 1)
44 | strv = Default(strv, strh)
45 | type = Default(type, "NNEDI3")
46 | UV = Default(UV, fch ? 3 : 1)
47 | gpu = Default(gpuid, 0)
48 | th = Default(threads, 8) # Only for gpu=-1 ("cpu" nnedi3)
49 | co = Default(cores, 4) # Only for gpu=-1 ("cpu" nnedi3)
50 |
51 | UV3 = UV!=3 && !isY()
52 | UV3 ? ExtractY() : last
53 | bi>8 ? ConvertBits(8, dither=-1, fulls=fs, fulld=fs) : last
54 |
55 | strh > 0 ? Santiag_helper(type, strh, bi, fs, th, co, gpu) : last
56 | TurnLeft()
57 | strv > 0 ? Santiag_helper(type, strv, bi, fs, th, co, gpu) : last
58 | TurnRight()
59 |
60 | bi>8 ? ConvertBits(bi, fulls=fs, fulld=fs) : last
61 | UV3 ? CombinePlanes(last, input, planes=rgb ? "RGB" : "YUV", pixel_type=PixelType(input)) : last
62 | }
63 |
64 |
65 | function Santiag_helper(clip input, string type, int strength, int bi, bool fulls, int threads, int cores, int gpu) {
66 |
67 | input
68 | w = Width()
69 | h = Height()
70 | cpu = gpu < 0
71 |
72 | if (type == "EEDI3") {
73 | cpu ? EEDI3 (0, dh=True, threads=0) : \
74 | EEDI3CL(0, dh=True, device=gpu)
75 | for (i = 2, strength, 1) {
76 | cpu ? EEDI3 ((i + 1) % 2, dh=False, threads=0) : \
77 | EEDI3CL((i + 1) % 2, dh=False, device=gpu)
78 | }
79 | }
80 | else if (type == "NNEDI2") {
81 | NNEDI2(dh=True, field=0)
82 | for (i = 2, strength, 1) {
83 | NNEDI2(dh=False, field=(i + 1) % 2)
84 | }
85 | }
86 | else {
87 | cpu ? NNEDI3 (0, qual=2, dh=True, threads=cores, prefetch=(threads+cores)/2, range=fulls?1:2) : \
88 | NNEDI3CL(0, qual=2, dh=True, device=gpu)
89 | for (i = 2, strength, 1) {
90 | cpu ? NNEDI3 ((i + 1) % 2, qual=2, dh=False, threads=cores, prefetch=(threads+cores)/2, range=fulls?1:2) : \
91 | NNEDI3CL((i + 1) % 2, qual=2, dh=False, device=gpu)
92 | } }
93 |
94 | Spline36Resize(w, h, 0, 0.5, w, h * 2)
95 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AviSynth+ Scripts
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | Collection of filters for AviSynth+ 3.7.3 and above. Improved modern syntax allows much greater performance and HBD support (High Bit Depths).
24 |
25 | Since all filters are mostly self-contained and script-based you get the benefit of cross compatibility with other OSes like Linux or MacOS, specially with EX mods versions for minimal plugin dependencies. If you need an EX mod port open a ticket in the issue tracker.
26 | The only non-replaceable plugins required are [NNEDI3](https://github.com/jpsdr/NNEDI3/issues/10/NNEDI3CL) and MVTools, so [check](https://forum.doom9.org/showthread.php?t=182032) beforehand those are compiled for your OS.
27 |
28 | For a full description of each filter check the main forum thread at [Doom9](https://forum.doom9.org/showthread.php?t=182881).
29 |
30 | [](https://www.paypal.com/donate?hosted_button_id=QQSJSY7EJ9YBE)
31 |
32 | ------
33 |
34 | ## License Terms
35 |
36 | This GitHub repository is licensed under the GNU General Public License v3.0 (GPL3) license except noted otherwise below or within each script file.
37 |
38 | **ExTools**: ex_expand(), ex_inpand(), ex_deflate(), ex_inflate() and some ex_median() and ex_repair() modes have been adapted and ported from RGTools under [MIT license](https://github.com/pinterf/RgTools/blob/master/LICENSE). A few ex_median() modes are also ported from DeGrainMedian under [GPL2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt) and now promoted to [GPL3](https://www.gnu.org/licenses/gpl-3.0.txt) by its license terms.
39 |
40 | **ex_repair()** from RGTools (MIT):
41 |
42 | * median - repair(4)
43 | * medianc - repair(14)
44 | * undot - repair(1)
45 | * undot2 - repair(2)
46 | * undot3 - repair(3)
47 | * undot4 - repair(4)
48 | * undot4c - repair(14)
49 | * edgeSP - repair(16)
50 | * edgeS - repair(17)
51 | * edgeW - repair(18)
52 | * cartoon - repair(22)
53 | * cartoonc - repair(19)
54 | * temp0 - TemporalRepair mode=0
55 | * temp1 - TemporalRepair mode=1
56 | * temp2 - TemporalRepair mode=2
57 | * temp3 - TemporalRepair mode=3
58 | * temp4 - TemporalRepair mode=4
59 |
60 | **ex_median()** from RGTools (MIT):
61 | * median - removegrain(4)
62 | * undot - removegrain(1)
63 | * undot2 - removegrain(2)
64 | * undot3 - removegrain(3)
65 | * undot4 - removegrain(4)
66 | * edgeS - removegrain(17)
67 | * edgeW - removegrain(18)
68 | * edgeC - removegrain(26)
69 | * edgeCL - removegrain(27)
70 | * cartoon - removegrain(22)
71 | * vertical - VerticalCleaner mode=1
72 | * verticalS - VerticalCleaner mode=2
73 |
74 | **ex_median()** from DeGrainMedian (GPL3):
75 | * DMG0 - DeGrainMedian(mode=0)
76 | * DMG1 - DeGrainMedian(mode=1)
77 | * DMG2 - DeGrainMedian(mode=2)
78 | * DMG3 - DeGrainMedian(mode=3)
79 | * DMG4 - DeGrainMedian(mode=4)
80 | * DMG5 - DeGrainMedian(mode=5)
81 |
82 | **ExTools**: some **ex_edge()** modes are modified ports under [GPL2](https://github.com/pinterf/masktools/blob/16bit/LICENSE) and [Apache](https://github.com/groucho86/G41Fun/blob/master/LICENSE) licenses.
83 |
84 | **ex_edge()** from masktools2 (GPL2):
85 | * prewitt
86 | * hprewitt
87 | * sobel
88 | * roberts
89 | * laplace
90 | * cartoon
91 | * min/max
92 |
93 | **ex_edge()** from G41fun.py (Apache):
94 | * scharr
95 | * frei-chen
96 | * robinson
97 | * kayyali
98 | * FDoG
99 | * TEdge
100 | * kirsch
101 |
--------------------------------------------------------------------------------
/Tools/RgTools Guides/README.md:
--------------------------------------------------------------------------------
1 | ## REMOVEGRAIN:
2 |
3 | This is the original removegrain() guide I wrote back in 2011 and that made the rounds later on.
4 | Additionally I attach a similar guide for Repair() I made recently.
5 |
6 | ```
7 | removegrain(11) # luma & chroma
8 | removegrain(11,0) # only luma
9 | removegrain(0,11) # only chroma
10 | removegrain(0,11,0) # only U plane
11 | ```
12 |
13 | * -1 : ``bypass`` (output=0) faster than mode=0 (copy)
14 | *
15 | * 0 : ``copy``
16 | *
17 | * 1 : ``medianblur``. Same as Undot, but faster. (single dots) [Default]
18 | * 2 : ``medianblur``. Round up to the second closest minimum luma value in a 3x3 window matrix, if this second lowest value is lower than X pixel value, then leave unchanged. (1x2 spots)
19 | * 3 : ``medianblur``. Sames as mode 2 but rounded up to third minimum value (but artifact risky). (3pixel-clusters)
20 | * 4 : ``medianblur``. Sames as mode 2 but rounded up to fourth minimum value (but artifact risky). (up to 2x2-pixel-clusters)
21 | *
22 | * 5 : ``medianblur``. Edge sensitive. Only line pairs are used. Strong edge protection.
23 | * 6 : ``medianblur``. Edge sensitive. Only line pairs are used. Fairly edge protection.
24 | * 7 : ``medianblur``. Edge sensitive. Only line pairs are used. Mild edge protection.
25 | * 8 : ``medianblur``. Edge sensitive. Only line pairs are used. Faint edge protection.
26 | * 9 : ``medianblur``. Edge sensitive. Only line pairs are used. Barely edge protection. Practically a spatial variant of trbarry's ST Median filter.
27 | *
28 | * 10 : ``sharpening``. Minimal sharpening. Replaces center pixel by its nearest neighbour. "Very poor denoise sharpener"
29 | *
30 | * 11 : ``blur``. 3x3 kernel convolution blur. Better than its counterpart internal Blur(1) (and faster)
31 | * 12 : ``blur``. Same as 11 but fastest and only <= 1% less precise (still better than Blur(1))
32 | *
33 | * 13 : ``Smart bob`` (for interlaced content). Interpolates the top field. Similar to Trbarry's weird bob (Tomsmocomp).
34 | * 14 : ``Smart bob`` (for interlaced content). Interpolates the bottom field. Similar to Trbarry's weird bob (Tomsmocomp).
35 | * 15 : ``Smart bob`` (for interlaced content). Same as mode 13 but more quality and slightly slower.
36 | * 16 : ``Smart bob`` (for interlaced content). Same as mode 14 but more quality and slightly slower.
37 | *
38 | * 17 : ``medianblur``. Same as mode 4 but better edge protection (similar to near artifact free mode 2). Probably best mode of all.
39 | * 18 : ``medianblur``. Same as mode 9 but better edge protection (Same as what mode 17 was to mode 4, but in this case to mode 9, and far less denoising than mode 17)
40 | *
41 | * 19 : ``blur``. Average of its 8 neighbours.
42 | * 20 : ``blur``. Uniform average of its 8 neighbours. Better than 19 but slower. Very similar to blur(1.58) but faster.
43 | *
44 | * 21 : ``medianblur``. Clipping is done with respect to averages of neighbours. Best for cartoons.
45 | * 22 : ``medianblur``. Same as mode 21 but much faster (fastest mode of all)
46 | *
47 | * 23 : ``Dehalo``. Fixes small (as one pixel wide) haloes.
48 | * 24 : ``Dehalo``. Same as 23 but considerably more conservative and slightly slower. Preferred.
49 | *
50 | * 25 : ``sharpening``. Minimal sharpening.
51 | *
52 | * 26 : ``medianblur``. Based off mode 17, but preserves corners, but not thin lines.
53 | * 27 : ``medianblur``. Same as mode 26 but preserves thin lines.
54 |
55 |
56 | Recommended modes: 12,20 (Gaussian Blur), 17,22 (Median Blur), 22,27 (Smart Medians)
57 |
58 |
59 | ------
60 |
61 |
62 | ## REPAIR:
63 |
64 | These modes are similar to the RemoveGrain modes but requires two clips, as it includes the center pixel of the reference clip for min/max calculation.
65 |
66 | * -1 : Bypass - input plane is trashed thus faster than mode 1
67 | *
68 | * 0 : Copy - input plane is left intact
69 | *
70 | * 1 : Clips the source pixel with the Nth minimum and maximum found on the 3×3-pixel square from the reference clip.
71 | * 2 : Clips the source pixel with the Nth minimum and maximum found on the 3×3-pixel square from the reference clip. [Default]
72 | * 3 : Clips the source pixel with the Nth minimum and maximum found on the 3×3-pixel square from the reference clip.
73 | * 4 : Clips the source pixel with the Nth minimum and maximum found on the 3×3-pixel square from the reference clip.
74 | *
75 | * 5 : Line-sensitive clipping giving the minimal change.
76 | *
77 | * 6 : Line-sensitive clipping, intermediate.
78 | * 7 : Line-sensitive clipping, intermediate.
79 | * 8 : Line-sensitive clipping, intermediate.
80 | *
81 | * 9 : Line-sensitive clipping on a line where the neighbor pixels are the closest.
82 | * 10 : Replaces the target pixel with the closest pixel from the 3×3-pixel reference square.
83 | *
84 | * 11 : Same as modes 1–4 but uses ``min(Nth_min, c)`` and ``max(Nth_max, c)`` for the clipping, where c is the value of the center pixel of the reference clip.
85 | * 12 : Same as modes 1–4 but uses ``min(Nth_min, c)`` and ``max(Nth_max, c)`` for the clipping, where c is the value of the center pixel of the reference clip.
86 | * 13 : Same as modes 1–4 but uses ``min(Nth_min, c)`` and ``max(Nth_max, c)`` for the clipping, where c is the value of the center pixel of the reference clip.
87 | * 14 : Same as modes 1–4 but uses ``min(Nth_min, c)`` and ``max(Nth_max, c)`` for the clipping, where c is the value of the center pixel of the reference clip.
88 | *
89 | * 15 : Clips the source pixels using a clipping pair from the RemoveGrain modes 5 and 6.
90 | * 16 : Clips the source pixels using a clipping pair from the RemoveGrain modes 5 and 6.
91 | *
92 | * 17 : Clips the source pixels using a clipping pair from the RemoveGrain modes 17 and 18.
93 | * 18 : Clips the source pixels using a clipping pair from the RemoveGrain modes 17 and 18.
94 | *
95 | * 19 :
96 | * 20 :
97 | * 21 :
98 | * 22 :
99 | * 23 :
100 | * 24 :
101 | * 25 : not available
102 | * 26 : Clips the source pixels using a clipping pair from the RemoveGrain mode 26.
103 | * 27 : Clips the source pixels using a clipping pair from the RemoveGrain mode 27.
104 | * 28 : Clips the source pixels using a clipping pair from the RemoveGrain mode 28.
105 |
106 |
--------------------------------------------------------------------------------
/MIX mods/ChromaReconstructorMod.avsi:
--------------------------------------------------------------------------------
1 | # ChromaReconstructor v4.1 HBD mod: restore 420/422 to (almost) native 444
2 | # by feisty2
3 | #
4 | # just convert 420/422 to 444 with any regular resampling filter, bicubic, spline, kind of stuff
5 | # and apply this filter, chroma planes will be reconstructed to 444 with high frequencies from luma (luma serves as the weighting reference to NLMeans both chroma planes)
6 | #
7 | # An old but fast alternative is:
8 | # ConverttoYUV444(chromaresample="spline36")
9 | # aWarpSharp2(thresh=128, blur=2, type=0, depth=16, chroma=6) # Luma guided chroma warp
10 | #
11 | #
12 | # v3.0 major update, new parameter "hipass" allows you to manipulate the strength of the high frequency extraction, a new less aggressive (and a lot slower) method could be enabled when luma is not stable enough (set "wild" to False)
13 | # v3.1 HBD mod and faster "faster" mod by Dogway
14 | # v3.2 Rebasing (some copy-pasta bugfixes)
15 | # v3.3 Rename gauss() function to avoid name conflict. Some tweaks to kernel settings
16 | # v3.4 Reenable mode=1 for horizontally stretched chroma. "_faster", add center shift to nnedi3 and tweak taps
17 | # v3.5 Pass 'gpuid' argument and allow CPU processing with gpuid=-1
18 | # v4.0 Update with nnedi3wrap (passed gpuid argument). Fix 'device_type' arg assignments
19 | #
20 | #
21 | # Example:
22 | # ConvertToYUV444()
23 | # ChromaReconstructor()
24 | #
25 | #
26 | function ChromaReconstructor(clip src, int "radius", float "str", int "hipass", int "mode", bool "wild", int "gpuid") {
27 |
28 | w = src.width()
29 | h = src.height()
30 | bdpth = string(src.BitsPerComponent())
31 | p_type = PixelType(src)
32 |
33 | radius = Default(radius, 32)
34 | str = Default(str, 6.4)
35 | gpuid = Default(gpuid, 0)
36 | hipass = Default(hipass, 6)
37 | mode = Default(mode, 0) # set to mode=1 for only horizontally stretched chroma
38 | wild = Default(wild, true)
39 | cpu = gpuid < 0 ? "cpu" : "gpu"
40 | gpuCL = max(0, gpuid)
41 |
42 | Assert (is444(src), "ChromaReconstructor: Input should be full chroma sampled (444)")
43 |
44 | ref = wild ? src.ExtractY() : src.ExtractY().KNLMeansCL(0, radius, 0, pow(1.464968620512209618455732713658, str), device_type=cpu, device_id=gpuCL, dwref=1)
45 | srcU = src.ExtractU()
46 | srcV = src.ExtractV()
47 | src8 = CombinePlanes(ref, srcU, srcV, planes="YUV", pixel_type=p_type)
48 | up4x = src8.nnedi3wrap(4, nns=4, qual=2, etype=1, nsize=0, gpuid=gpuid)
49 | Luma = up4x.ExtractY()
50 | U = up4x.ExtractU()
51 | V = up4x.ExtractV()
52 | Unew = wild ? KNLMeansCL(U, 0, radius, 0, str, wref=0, rclip=Luma, device_type=cpu, device_id=gpuCL) : interpolation(Luma, U, 2, str, device_id=gpuCL)
53 | Unew = wild ? Unew : interpolation(Luma, Unew, 4, str, device_id=gpuCL)
54 | Unew = wild ? Unew : interpolation(Luma, Unew, 8, str, device_id=gpuCL)
55 | Unew = wild ? Unew : interpolation(Luma, Unew, 16, str, device_id=gpuCL)
56 | Unew = wild ? Unew : interpolation(Luma, Unew, 32, str, device_id=gpuCL)
57 | Unew = Unew.Spline64Resize(w, h, src_left=-1.25, src_top=-1.25)
58 | Vnew = wild ? KNLMeansCL(V, 0, radius, 0, str, wref=0, rclip=Luma, device_type=cpu, device_id=gpuCL) : interpolation(Luma, V, 2, str, device_id=gpuCL)
59 | Vnew = wild ? Vnew : interpolation(Luma, Vnew, 4, str, device_id=gpuCL)
60 | Vnew = wild ? Vnew : interpolation(Luma, Vnew, 8, str, device_id=gpuCL)
61 | Vnew = wild ? Vnew : interpolation(Luma, Vnew, 16, str, device_id=gpuCL)
62 | Vnew = wild ? Vnew : interpolation(Luma, Vnew, 32, str, device_id=gpuCL)
63 | Vnew = Vnew.Spline64Resize(w, h, src_left=-1.25, src_top=-1.25)
64 | UHi = (mode == 1) ? ex_makeadddiff(Unew, gauss_h(Unew, hipass), srcU) : ex_makeadddiff(Unew, gauss_b(Unew, hipass), srcU)
65 | VHi = (mode == 1) ? ex_makeadddiff(Vnew, gauss_h(Vnew, hipass), srcV) : ex_makeadddiff(Vnew, gauss_b(Vnew, hipass), srcV)
66 | return CombinePlanes(src.ExtractY(), UHi, VHi, planes="YUV")
67 | }
68 |
69 |
70 | function interpolation(clip luma, clip "chroma", int "radius", float "str", int "gpuid")
71 | {
72 | exp_c0 = 1.060417282747435920994529352433
73 | exp_c1 = pow(1.070339301855046091743224243341, 32)
74 | weight = pow(exp_c0, radius) / exp_c1
75 | ref = Expr(chroma, luma, Format("y dup x - {weight} * -"))
76 | return KNLMeansCL(chroma, 0, radius, 0, str, wref=0, rclip=ref, device_type=gpuid < 0 ? "cpu" : "gpu", device_id=gpuid)
77 | }
78 |
79 |
80 | function gauss_b(clip src, int "p")
81 | {
82 | p = Default(p, 30)
83 | w = src.width()
84 | h = src.height()
85 | upsmp = GaussResize(src, w * 2, h * 2, P=100)
86 | return GaussResize(upsmp, w, h, P=p)
87 | }
88 |
89 |
90 | function gauss_h(clip src, int "p")
91 | {
92 | p = Default(p, 30)
93 | w = src.width()
94 | h = src.height()
95 | upsmp = GaussResize(src, w * 2, h, P=100)
96 | return GaussResize(upsmp, w, h, P=p)
97 | }
98 |
99 |
100 | # This one works directly with any subsampled chroma format type as input
101 | #
102 | # Example:
103 | # 420_Source
104 | # ChromaReconstructor_faster() # 444_Output
105 | #
106 | # but I recommend you to use ConvertFormat() to account for chroma placement and chroma shift
107 | # ConvertFormat(fmt_in="420",fmt_out="444",cs_out="",UVrecon=true)
108 |
109 | function ChromaReconstructor_faster(clip src, int "radius", float "str", int "gpuid") {
110 |
111 | w = src.width()
112 | h = src.height()
113 | bi = BitsPerComponent(src)
114 | fs = propNumElements (src,"_ColorRange") > 0 ? \
115 | propGetInt (src,"_ColorRange") == 0 : false
116 |
117 | radius = Default(radius, 12)
118 | str = Default(str, 9.0)
119 | gpuid = Default(gpuid, 0)
120 | cpu = gpuid < 0 ? "cpu" : "gpu"
121 | gpuCL = max(0, gpuid)
122 |
123 | Y = ExtractY(src)
124 | Uor = ExtractU(src)
125 | Vor = ExtractV(src)
126 |
127 | ref = Y.KNLMeansCL (0, radius, 0, pow(1.464968620512209618455732713658, str), wref=1, device_type=cpu, device_id=gpuCL)
128 | Luma = ref.ConvertBits(8,dither=-1,fulls=fs).nnedi3wrap(2, nns=1, qual=1, etype=1, nsize=0, cshift="spline16" ,gpuid=gpuid).ConvertBits(bi,fulls=fs)
129 | Uu = Uor.ConvertBits(8,dither=-1,fulls=fs).nnedi3wrap(2, nns=1, qual=1, etype=1, nsize=0, fwidth=w*2, fheight=h*2, cshift="blackman6",gpuid=gpuid).ConvertBits(bi,fulls=fs)
130 | Vu = Vor.ConvertBits(8,dither=-1,fulls=fs).nnedi3wrap(2, nns=1, qual=1, etype=1, nsize=0, fwidth=w*2, fheight=h*2, cshift="blackman6",gpuid=gpuid).ConvertBits(bi,fulls=fs)
131 | Unew = Uu.KNLMeansCL (0, radius, 0, str, wref=0, rclip=Luma, device_type=cpu, device_id=gpuCL).BicubicResize(w, h, b=0.0, c=0.5)
132 | Vnew = Vu.KNLMeansCL (0, radius, 0, str, wref=0, rclip=Luma, device_type=cpu, device_id=gpuCL).BicubicResize(w, h, b=0.0, c=0.5)
133 | U = ex_makeadddiff(Unew, Removegrain(Unew, 20), Uu.BicubicResize(w, h, b=0.0, c=0.5)) # Adding the sharpened result
134 | V = ex_makeadddiff(Vnew, Removegrain(Vnew, 20), Vu.BicubicResize(w, h, b=0.0, c=0.5)) # Adding the sharpened result
135 | return CombinePlanes(Y, U, V, planes="YUV")
136 | }
--------------------------------------------------------------------------------
/EX mods/DeStripe.avsi:
--------------------------------------------------------------------------------
1 | ##
2 | ## DeStripeX() by *.mp4 guy (14-06-2010)
3 | ##
4 | ## Port to ExTools by Dogway (29-08-2021)
5 | ##
6 | ## Easy-to-use "low frequency" stripes/bands removal filter
7 | ## https://forum.doom9.org/showthread.php?p=1408276
8 | ##
9 | ## "thr is strength, rad is "how big are the (whatevers)" offset is "how far apart are they" rad goes from 1 to 4, offset from 1 to 4, thr from 1 to bignumber"
10 | ##
11 | ## Function Definition:
12 | ## (
13 | ## clip,
14 | ## int "rad"=1 (1 to 4 by 1),
15 | ## int "offset"=1 (1 to 4 by 1),
16 | ## int "thr"=255 (1 to 255 by 1),
17 | ## )
18 | ##
19 |
20 | function DeStripeH(Clip C, int "rad", int "offset", int "thr", int "UV") {
21 |
22 | rgb = isRGB(C)
23 | bi = BitsPerComponent(C)
24 | fs = propNumElements (C,"_ColorRange") > 0 ? \
25 | propGetInt (C,"_ColorRange") == 0 : rgb
26 |
27 | rad = Default(rad, 2)
28 | offset = Default(offset, 0)
29 | UV = Default(UV, rgb ? 3 : 1)
30 | thr_ = Default(thr, 255)
31 | thr = ex_bs( thr_, 8, bi, fulls=fs, flt=true)
32 | sthr = ex_bs(sqrt(thr_), 8, bi, fulls=fs, flt=true)
33 |
34 |
35 | Blurred = Rad == 1 ? C.ex_boxblur(0,1,"mean",UV=uv) : C
36 | Blurred = Rad == 2 ? offset == 0 ? C.ex_boxblur(0,2,"mean",UV=uv) : \
37 | C.ex_luts(mode="avg",pixels=" 0 -2 0 0 0 2 ", UV=uv) : Blurred
38 | Blurred = Rad == 3 ? offset == 0 ? C.ex_boxblur(0,3,"mean",UV=uv) : \
39 | offset == 1 ? C.ex_luts(mode="avg",pixels=" 0 -3 0 -2 0 0 0 2 0 3 ", UV=uv) : \
40 | C.ex_luts(mode="avg",pixels=" 0 -3 0 0 0 3 ", UV=uv) : Blurred
41 | Blurred = Rad == 4 ? offset == 0 ? C.ex_boxblur(0,4,"mean",UV=uv) : \
42 | offset == 1 ? C.ex_luts(mode="avg",pixels="0 -4 0 -3 0 -2 0 0 0 2 0 3 0 4", UV=uv) : \
43 | offset == 2 ? C.ex_luts(mode="avg",pixels="0 -4 0 -3 0 0 0 3 0 4", UV=uv) : \
44 | C.ex_luts(mode="avg",pixels="0 -4 0 0 0 4", UV=uv) : Blurred
45 |
46 | Diff = ex_makediff(C, Blurred, UV=uv, fulls=fs)
47 | expr = Format(" x y - dup dup abs 1 + dup swap2 * swap {thr} 1 >= {sthr} {thr} ? + / - range_half +")
48 |
49 | MedianDiff = Rad == 1 ? ex_luts(Diff, mode="med", pixels = ex_shape(1, mode="vertical"), expr = expr, UV=uv, fulls=fs) : Diff
50 | MedianDiff = Rad == 2 ? offset == 0 ? ex_luts(Diff, mode="med", pixels = ex_shape(2, mode="vertical"), expr = expr, UV=uv, fulls=fs) : \
51 | ex_luts(Diff, mode="med", pixels = " 0 -2 0 0 0 2 ", expr = expr, UV=uv, fulls=fs) : MedianDiff
52 | MedianDiff = Rad == 3 ? offset == 0 ? ex_luts(Diff, mode="med", pixels = ex_shape(3, mode="vertical"), expr = expr, UV=uv, fulls=fs) : \
53 | offset == 1 ? ex_luts(Diff, mode="med", pixels = " 0 -3 0 -2 0 0 0 2 0 3 ", expr = expr, UV=uv, fulls=fs) : \
54 | ex_luts(Diff, mode="med", pixels = " 0 -3 0 0 0 3 ", expr = expr, UV=uv, fulls=fs) : MedianDiff
55 | MedianDiff = Rad == 4 ? offset == 0 ? ex_luts(Diff, mode="med", pixels = ex_shape(4, mode="vertical"), expr = expr, UV=uv, fulls=fs) : \
56 | offset == 1 ? ex_luts(Diff, mode="med", pixels = "0 -4 0 -3 0 -2 0 0 0 2 0 3 0 4", expr = expr, UV=uv, fulls=fs) : \
57 | offset == 2 ? ex_luts(Diff, mode="med", pixels = "0 -4 0 -3 0 0 0 3 0 4", expr = expr, UV=uv, fulls=fs) : \
58 | ex_luts(Diff, mode="med", pixels = "0 -4 0 0 0 4", expr = expr, UV=uv, fulls=fs) : MedianDiff
59 |
60 | ex_makeadddiff(Diff, MedianDiff, Blurred, UV=uv).propCopy(C) }
61 |
62 |
63 |
64 | function DeStripeV(Clip C, int "rad", int "offset", int "thr", int "UV") {
65 |
66 | rgb = isRGB(C)
67 | bi = BitsPerComponent(C)
68 | fs = propNumElements (C,"_ColorRange") > 0 ? \
69 | propGetInt (C,"_ColorRange") == 0 : rgb
70 |
71 | rad = Default(rad, 2)
72 | offset = Default(offset, 0)
73 | UV = Default(UV, rgb ? 3 : 1)
74 | thr_ = Default(thr, 255)
75 | thr = ex_bs( thr_, 8, bi, fulls=fs, flt=true)
76 | sthr = ex_bs(sqrt(thr_), 8, bi, fulls=fs, flt=true)
77 |
78 |
79 | Blurred = Rad == 1 ? C.ex_boxblur(1,0,"mean",UV=uv) : C
80 | Blurred = Rad == 2 ? offset == 0 ? C.ex_boxblur(2,0,"mean",UV=uv) : \
81 | C.ex_luts(mode="avg",pixels=" -2 0 0 0 2 0 ", UV=uv) : Blurred
82 | Blurred = Rad == 3 ? offset == 0 ? C.ex_boxblur(3,0,"mean",UV=uv) : \
83 | offset == 1 ? C.ex_luts(mode="avg",pixels=" -3 0 -2 0 0 0 2 0 3 0 ", UV=uv) : \
84 | C.ex_luts(mode="avg",pixels=" -3 0 0 0 3 0 ", UV=uv) : Blurred
85 | Blurred = Rad == 4 ? offset == 0 ? C.ex_boxblur(4,0,"mean",UV=uv) : \
86 | offset == 1 ? C.ex_luts(mode="avg",pixels="-4 0 -3 0 -2 0 0 0 2 0 3 0 4 0", UV=uv) : \
87 | offset == 2 ? C.ex_luts(mode="avg",pixels="-4 0 -3 0 0 0 3 0 4 0", UV=uv) : \
88 | C.ex_luts(mode="avg",pixels="-4 0 0 0 4 0", UV=uv) : Blurred
89 |
90 | Diff = ex_makediff(C, Blurred, UV=uv, fulls=fs)
91 | expr = Format(" x y - dup dup abs 1 + dup swap2 * swap {thr} 1 >= {sthr} {thr} ? + / - range_half +")
92 |
93 | MedianDiff = Rad == 1 ? ex_luts(Diff, mode="med", pixels = ex_shape(1, mode="horizontal"), expr = expr, UV=uv, fulls=fs) : Diff
94 | MedianDiff = Rad == 2 ? offset == 0 ? ex_luts(Diff, mode="med", pixels = ex_shape(2, mode="horizontal"), expr = expr, UV=uv, fulls=fs) : \
95 | ex_luts(Diff, mode="med", pixels = " -2 0 0 0 2 0 ", expr = expr, UV=uv, fulls=fs) : MedianDiff
96 | MedianDiff = Rad == 3 ? offset == 0 ? ex_luts(Diff, mode="med", pixels = ex_shape(3, mode="horizontal"), expr = expr, UV=uv, fulls=fs) : \
97 | offset == 1 ? ex_luts(Diff, mode="med", pixels = " -3 0 -2 0 0 0 2 0 3 0 ", expr = expr, UV=uv, fulls=fs) : \
98 | ex_luts(Diff, mode="med", pixels = " -3 0 0 0 3 0 ", expr = expr, UV=uv, fulls=fs) : MedianDiff
99 | MedianDiff = Rad == 4 ? offset == 0 ? ex_luts(Diff, mode="med", pixels = ex_shape(4, mode="horizontal"), expr = expr, UV=uv, fulls=fs) : \
100 | offset == 1 ? ex_luts(Diff, mode="med", pixels = "-4 0 -3 0 -2 0 0 0 2 0 3 0 4 0", expr = expr, UV=uv, fulls=fs) : \
101 | offset == 2 ? ex_luts(Diff, mode="med", pixels = "-4 0 -3 0 0 0 3 0 4 0", expr = expr, UV=uv, fulls=fs) : \
102 | ex_luts(Diff, mode="med", pixels = "-4 0 0 0 4 0", expr = expr, UV=uv, fulls=fs) : MedianDiff
103 |
104 | ex_makeadddiff(Diff, MedianDiff, Blurred, UV=uv).propCopy(C) }
105 |
--------------------------------------------------------------------------------
/EX mods/MultiSWAR_V2-Beta9.avsi:
--------------------------------------------------------------------------------
1 | # MultiSWAR - Multi Step Warping And Resizing - V2 Beta 9
2 | #
3 | #
4 | # by *.mp4 guy (07-02-2007)- https://forum.doom9.org/showthread.php?t=112526
5 | #
6 | # It is designed to reduce the blurring and aliasing associated with linear resizing,
7 | # without introducing additional artifacts or being too slow for practical use.
8 | #
9 | #
10 | # Beta 4: adapted for masktools2 and awarpsharp2 (Dogway) (13-05-2011)
11 | # Beta 5: adapted for ExTools and sanitized (Dogway) (06-09-2021)
12 | # Beta 6: optimizations and fix for HBD (Dogway) (18-10-2021)
13 | # Beta 7: Porting to SharpenersPack functions (Dogway) (12-11-2021)
14 | # Beta 8: Read fulls from source (Dogway) (11-12-2021)
15 | # Beta 9: Rebasing, cleanup and fixes (Dogway) (05-03-2022)
16 | #
17 | #
18 | # Dependencies:
19 | # ExTools
20 | # ResizersPack
21 | # SharpenersPack
22 | # SPresso
23 | # vsTbilateral (https://avisynth.nl/index.php/VsTBilateral)
24 | # MedianBlur2 (https://avisynth.nl/index.php/MedianBlur2)
25 | # WarpSharp (https://avisynth.nl/index.php/WarpSharp)
26 | # aWarpSharp2 (https://avisynth.nl/index.php/AWarpSharp2)
27 | #
28 | # DestX/DestY: Default 2x input resolution. Sets the output resolution
29 | # (yes its really obvious)
30 | #
31 | #
32 | # StepRatio: Determines how many iterations of resizing wil be
33 | # needed to reach your destination resolution, the Default is 4.
34 | # Higher values are slower but should remove more aliasing.
35 | # High values may result in more artifacts. The usable range is
36 | # 1 to around 16.
37 | #
38 | #
39 | # Smoothing: When Smoothing is enabled (Which it is not by
40 | # Default) a light noise reduction filter is used to help avoid
41 | # sharpening artifacts from the source image, this is most
42 | # usefull for animated content.
43 | #
44 | #
45 | # Sthresh: Sets the strength of the smoother, Default value is 1
46 | # useful range is 0 to ~8.
47 | #
48 | #
49 | # Sharpen: Sets the amount of sharpening aplied by the main
50 | # sharpening functions, usable values are 10 to 65
51 | # depending upon your source, the Default is 40
52 | # higher values run the risk of aliasing and banding.
53 | #
54 | #
55 | # Sharpen2: Sets the amount of additional sharpening to be aplied
56 | # to the video, used to make faint details more prominent
57 | # usable values are 0.33 to 1 depending upon the source.
58 | # The Default value is 1 which doesn't usually cause any
59 | # problems, both this and sharpen are also affected by
60 | # the masking parameters, higher values run the risk of
61 | # excessive noise and banding.
62 | #
63 | #
64 | # Warping: The strength parameter for Warper. The Default of 4
65 | # should work the best on film, 8 is a good value for animated
66 | # material. if you are getting aliasing you can raise this value
67 | # to get rid of it. The acceptable range is 0 to 64. Unless
68 | # chromawarp is specified separately this parameter has a maximum
69 | # value of 10.
70 | #
71 | #
72 | # chromawarp: Default warping*25. Chroma warping, usefull range 100-255.
73 | #
74 | #
75 | # SSm: Default 2. Sets the supersampling used during mask creation,
76 | # don't change it.
77 | #
78 | #
79 | # bmrad Default 7. Sets the radius used to detect details during mask
80 | # creation, higher values are slower, but probably better, the
81 | # Default is adequate in almost all situations.
82 | #
83 | #
84 | # thr: Default 0.65. Sets the threshold for detail detection, worth
85 | # experimenting with, higher values makes more things detected as
86 | # details, higher values may cause oversharpening.
87 | #
88 | #
89 | # dthr Default 245. Sets how strongly the mask protects against
90 | # oversharpening, higher values give more protection, 0 gives
91 | # none. does not need to be set in quotes anymore.
92 | #
93 | #
94 | # dbias: Default 25. Determines how detailed areas are treated, higher
95 | # values cause them to be treated more like lines, lower values
96 | # (down to 0) cause them to be treated more like texture. does
97 | # not need to be set in quotes anymore.
98 | #
99 | #
100 | # lthr: Default 25. The same as dthr, but used to protect lines from being
101 | # oversharpened, oversharpening causes aliasing.
102 | #
103 | #
104 | # lbias: Default 225. The same as dbias, but used on lines, higher values
105 | # cause less overall sharpening of lines and detail that
106 | # would otherwise be treated as lines.
107 | #
108 | #
109 | # hthr/hbias: The same parameters as d/llthr and d/lbias, used in the
110 | # creation of the halo prevention mask, higher values
111 | # offer more protection, Defaults are hthr=48, hbias=-48
112 | #
113 | #
114 | # srad: Default 1. Sets the radius of the sharpening used on
115 | # detailed areas.
116 | #
117 | # mmrad: Default 4. Sets the radius used in creating the median mask
118 | #
119 | #
120 | # agmrad: Default 1. sets the radius used in creating the halo mask, higher
121 | # values give more protection against halos, but will cause bluring.
122 | #
123 | #
124 | # reducehalos: Default true. enables halo protection, will not reduce halos
125 | # in the source, only those added by multiswar.
126 | #
127 | #
128 | #
129 | #
130 | #Misc parameters:
131 | #DestX
132 | #Desty
133 | #Stepratio
134 | #warping
135 | #chromawarp
136 | #SSm
137 | #sthresh
138 | #Sharpen
139 | #Sharpen2
140 | #thr
141 | #
142 | #Masking parameters:
143 | #dthr
144 | #lthr
145 | #hthr
146 | #dbias
147 | #hbias
148 | #lbias
149 | #
150 | #Radius parameters:
151 | #Srad
152 | #bmrad
153 | #mrad
154 | #agmrad
155 |
156 | function MultiSWAR(clip Clp, int "DestX", int "DestY" ,int "StepRatio", int "warping", int "chromawarp", float "ssm", int "sthresh", int "Sharpen", float"Sharpen2", \
157 | float "thr", int "dthr", int "lthr", int "hthr", int "dbias", int "lbias", int "hbias", int "srad", int "bmrad", int "mmrad", int "agmrad", bool "reducehalos", bool "smoothing") {
158 |
159 | rgb = isRGB(Clp)
160 | fs = propNumElements(Clp,"_ColorRange") > 0 ? \
161 | propGetInt (Clp,"_ColorRange") == 0 : rgb
162 |
163 | OX = nmod(Clp.Width (),16,16)
164 | OY = nmod(Clp.Height(),16,16)
165 | bi = BitsPerComponent(Clp)
166 |
167 | DestX = Default(DestX, OX*2)
168 | Desty = Default(Desty, OY*2)
169 | Stepratio = Default(Stepratio, 4)
170 | warping = Default(warping, 4)
171 | chromawarp = Default(chromawarp, warping*25)
172 | SSm = Default(SSm, 2)
173 | sthresh = Default(sthresh, 1)
174 | Sharp = Default(Sharpen, 40)
175 | Sharp2 = Default(Sharpen2, 0.5)
176 | thr = Default(thr, 0.65)
177 |
178 | dthr = Default(dthr, 1024)
179 | lthr = Default(lthr, 25)
180 | hthr = Default(hthr, 48)
181 | dbias = Default(dbias, 100)
182 | hbias = Default(hbias, -48)
183 | lbias = Default(lbias, 225)
184 |
185 | Srad = Default(srad, 1)
186 | bmrad = Default(bmrad, 7)
187 | mmrad = Default(mmrad, 4)
188 | agmrad = Default(agmrad, 1)
189 |
190 | reducehalos= Default(reducehalos, true)
191 | smoothing = Default(smoothing, false)
192 |
193 | OXs = OX+nmod(OX/StepRatio,4)
194 | OYs = OY+nmod(OY/StepRatio,4)
195 |
196 | clp.blackmanresize(OXs,OYs,taps=5)
197 |
198 | #Smooth = Clp.Bilinearresize(OX+round(OX/StepRatio/4)*4,OY+round(OY/StepRatio/4)*4)
199 |
200 | o = !is420() ? ConvertToYUV420() : last
201 | s01 = o.aWarpSharp2(Depth=round(warping*0.5), Blur=1, chroma=2,thresh=128)
202 | s02 = o.warpsharp(chromawarp, chromawarp)
203 | s = s01.mergechroma(s02, 1)
204 | ss = s.blackmanresize(nmod(OX*SSm),nmod(OY*SSm),taps=6)
205 | s
206 | #smoothing ? s.ex_repair(ex_median("edges"),mode="edgeW") : last
207 | smoothing ? s.ex_repair(SPresso(s,3,sthresh*7,18),mode="edgeW") : last
208 | #smoothing ? s.dctfun4b(sthresh, sthresh) : last
209 |
210 |
211 | detail = o.ex_unsharp(str=sharp2/(1.489*pow(srad,-1.112)+0.51), Fc=max(OXs,OYs)*0.8, th=0, UV=1) # Parametrized to original variableblur's unsharp
212 | MedianSharp = o.XSharpenPlus(strength=sharp,threshold=255)
213 | MedianSharp = MedianSharp.SPresso(3,sthresh*7,18).ex_repair(o,mode="edgeW")
214 | #lsharp = s.LimitedSharpenfaster(Smode=Smode, soft=8, strength=sharpen, overshoot=Esharp, SS_X=1.25, SS_Y=1.25, lmode=1)
215 |
216 | dbias = ex_bs(dbias, 8, bi, fulls=fs)
217 | lbias = ex_bs(lbias, 8, bi, fulls=fs)
218 | hbias = ex_bs(hbias, 8, bi, fulls=fs)
219 |
220 | diff1 = ss.vsTBilateral(diameterY=bmrad, diameterU=3, diameterV=3, sdevY=thr, sdevU=thr, sdevV=thr)
221 | mask1 = ex_lutxy(ss, diff1, Format("y x - abs {dthr} * {dbias} +"), UV=1).bicubicresize(OXs, OYs,-0.5,0.25)
222 |
223 | diff2 = mmrad == 1 ? ss.ex_median("median") : \
224 | mmrad == 2 ? ss.ex_median("median5") : \
225 | mmrad == 3 ? ss.ex_median("median7") : \
226 | ss.medianblur(radiusy=mmrad, radiusu=-256, radiusv=-256)
227 |
228 | mask2 = ex_lutxy(ss, diff2, Format("y x - abs {lthr} * {lbias} +"), UV=1).bicubicresize(OXs, OYs,-0.5,0.25)
229 |
230 | # Difference of Blurs (DoB x DoG)
231 | Ablur = s.ex_boxblur(agmrad, mode="mean")
232 | Gblur = s.ex_boxblur(agmrad*2,mode="weighted")
233 | mask3 = ex_lutxy(Ablur, Gblur, Format("y x - abs {hthr} * {hbias} +"), UV=1)
234 |
235 |
236 | s = last
237 | lines = ex_merge(MedianSharp, s, mask2)
238 | detail_and_lines = ex_merge(detail, lines, mask1)
239 | reducehalos ? ex_merge(detail_and_lines, s, mask3) : last
240 |
241 | (width() >= destx) ? blackmanresize(destx,desty,taps=5) : \
242 | MultiSWAR(destx=destx, desty=desty, stepratio=stepratio, warping=warping, chromawarp=chromawarp, ssm=ssm, sthresh=sthresh, sharpen=sharp, sharpen2=sharp2, \
243 | thr=thr, dthr=dthr, lthr=lthr, hthr=hthr, dbias=dbias, lbias=lbias, hbias=hbias, srad=srad, bmrad=bmrad, mmrad=mmrad, agmrad=agmrad, reducehalos=reducehalos, smoothing=smoothing)
244 | }
--------------------------------------------------------------------------------
/Stabilization Tools Pack.avsi:
--------------------------------------------------------------------------------
1 | ### #
2 | ### EXPERIMENTAL: Largely outdated. Use at your own discretion #
3 | ### #
4 | ### 2.1 by Dogway (16-09-2015) #
5 | ### mod 2.533 by A.SONY (29-11-2020) #
6 | ### Stabilization Tools Pack 3.6 by Dogway (17-07-2023) #
7 | ### #
8 | ### https://forum.doom9.org/showthread.php?t=182881 #
9 | ### #
10 | ### #
11 | ### Functions: #
12 | ### FilmGateFix #
13 | ### FillBorder #
14 | ### FindBlackBorders #
15 | ### StabPlus #
16 | ### #
17 | ################################################################
18 | ###
19 | ###
20 | ### Set of tools to work with common stabilization issues, mainly from telecine process.
21 | ### For aggressive handheld camera shaking I still recommend vdub's Deshaker.
22 | ###
23 | ### Required: AviSynth+ 3.7.3+
24 | ### ExTools
25 | ###
26 | ###
27 | ##########################################################
28 | ###
29 | ### FilmGateFix()
30 | ###
31 | ### Function to fix frames ( by means of FreezeFrame() ) with film gate issues after a scene change.
32 | ### This is aimed at animation, for live footage frame interpolation should be desired.
33 | ###
34 | ### Rationale:
35 | ### Film Gate is about non-linear vertical stretching, thus we compare
36 | ### current and next frames in two blocks, a 1/5 block of top and bottom.
37 | ### The difference in both should be very high for film gate artifacts
38 | ### between the 2nd and 3rd frame after a Scene Change (also 1st and 2nd are compared).
39 | ### We mask this through a Scene Detection filter, motion masks, etc.
40 | ###
41 | ### EXPERIMENTAL:
42 | ### It still grabs too many false-positives, and leaves many positives-positives undone
43 | ### a better approach would be to automatically bookmark every scene change and manually freezeframe them
44 | ###
45 | ###
46 | ### Dependencies:
47 | ###
48 | ### Required:
49 | ### ------------
50 | ###
51 | ### MVTools (v2.7.45 or higher) (https://avisynth.nl/index.php/MVTools)
52 | ### MaskTools2 (v2.2.30 or higher) (https://avisynth.nl/index.php/MaskTools2)
53 | ### Average (v0.95 or higher) (https://avisynth.nl/index.php/Average)
54 | ### ResizersPack
55 | ###
56 | ####################################
57 |
58 | function FilmGateFix(clip c, float "thr", int "window", int "thSCD1", int "thSCD2", bool "debug") {
59 |
60 | thr = Default(thr, 1.2) # Main tweak setting, use debug and tweak according 2nd frame after Scene Change
61 | window = Default(window, 5) # Enlarges/reduces detection area, "height()/window"
62 | thSCD1 = Default(thSCD1,500) # Increase to reduce number of scenes detected
63 | thSCD2 = Default(thSCD2,145) # Increase to reduce number of scenes detected
64 | Debug = Default(Debug,false) # Check what frames will be fixed and the difference value of frames for tweaking "thr"
65 | thr2 = 5.0 # central part of frame must change less than this to consider static scene to fix.
66 |
67 | c
68 | w=width()
69 | h=height()
70 |
71 | # Change to SceneStats()
72 | # Codeblock for Scene Change detection and Motion Mask
73 | kind = 0
74 | gam = 1.2 # Could probably be exposed
75 | mvthr = 30 # Threshold, heavily dependent on gamma value above
76 | super = MSuper (pel=1, sharp=0,vpad=0,hpad=0)
77 | b1v = MAnalyse(super,isb=true, blksize=16,overlap=8,search=0)
78 | f1v = MAnalyse(super,isb=false, blksize=16,overlap=8,search=0)
79 | SADbv1 = MMask (b1v,kind=kind,gamma=gam,thSCD1=thSCD1,thSCD2=thSCD2)
80 | SADfv1 = MMask (f1v,kind=kind,gamma=gam,thSCD1=thSCD1,thSCD2=thSCD2)
81 |
82 | SceneChange = MSCDetection (f1v,thSCD1=thSCD1,thSCD2=thSCD2)
83 | mvmask = Merge(SADbv1,SADfv1)
84 |
85 |
86 | # Film Gate happens commonly between 2nd and 3rd frame after SC
87 | # 1st frame is commonly garbage
88 | add = round(w/(window*1.0))
89 | T = crop(0,0,0,nmod(-h+add,8),true)
90 | B = crop(0,nmod(h-add,8),0,0, true)
91 |
92 | L = crop(0,0,nmod(-w+add,8),0,true)
93 | R = crop(nmod(w-add,8),0,0,0, true)
94 |
95 | CTB = crop(0,nmod(add,8),0,-((add)/8)*8,true)
96 | CLR = crop(nmod(add*1.5,8),0,-nmod(add*1.5,8),0,true)
97 |
98 | SC2 = ex_logic(SceneChange,selectevery(SceneChange,1,-1),"max",UV=3)
99 |
100 | d = Trim(2,0)
101 |
102 | # Here, if after SC top area changes more than "thr" compared to bottom area
103 | # then apply one FreezeFrame() for first SC frame, and another FreezeFrame() for the 2nd one,
104 | # they (1st and 2nd) compute individually. There is a motionmask on top to rule out false positives.
105 | ScriptClip( function[c,d,T,B,L,R,c,SC2,CTB,CLR,mvmask,thr,thr2,mvthr] () {
106 |
107 | curf = current_frame
108 | YPlaneMax(SC2)>254 && \
109 | (abs(YDifferenceToNext(T)-YDifferenceToNext(B))>thr && abs(YDifferenceToNext(CTB))thr && abs(YDifferenceToNext(CLR))"+string(thr)+
127 | \ " && abs(YDifferenceToNext(CTB))<"+string(thr2)+") || (abs(YDifferenceToNext(L)-YDifferenceToNext(R))>"+
128 | \ string(thr)+" && abs(YDifferenceToNext(CLR))<"+string(thr2)+") ? "+
129 | \ "(YplaneMax(SC2)>254?(LumaDifference(c,d)<3.7?ex_lut(c,"+Chr(34)+"255"+Chr(34)+",UV=128):(YDifferenceToNext()<8.0?ex_lut(c,"+Chr(34)+"255"+Chr(34)+",UV=128):ex_lut(c,"+Chr(34)+"0"+Chr(34)+
130 | \ ",UV=128))):ex_lut(c,"+Chr(34)+"0"+Chr(34)+",UV=128)):ex_lut(c,"+Chr(34)+"0"+Chr(34)+",UV=128)):ex_lut(c,"+Chr(34)+"0"+
131 | \ Chr(34)+",UV=128)",args="T,B,L,R,c,CTB,CLR,SC2,mvmask,d=Trim(2,0)"))
132 | \ crop(0,0,-nmod(w/1.1,2),0,true).Subtitle("Frame to Freeze",align=9,size=40)""") : last }
133 |
134 |
135 |
136 |
137 |
138 | ####################################
139 | ###
140 | ### FillBorder()
141 | ###
142 | ###
143 | ### Function to fill dark (use threshold) borders, in the vein of old FillMargins() function.
144 | ### But instead of mirroring or other approaches like resizing, this function fills/interpolates
145 | ### missing data from surrounding pixels.
146 | ### Useful to use as a clean pass after StabPlus() and crop(x1,y1,x2,y2)
147 | ### for the remaining thin black borders (up to 3px)
148 | ###
149 | ### For borders of 4px and more you can enable FixFalPos, there you supply a clip
150 | ### without black borders (ie. before StabPlus() ). It automatically replaces the offended frames.
151 | ### Some thick black borders aren't "0" black at all, they show garbage and the 3+1 pixel border
152 | ### may not average to 0, so a "thr2" setting is added as threshold, default 7 should be enough.
153 | ###
154 | ### Below you can still use the the FindBlackBorders() function for manual handling of thick black borders.
155 | ### Use ClipClop() for the StabPlus() results according to the statistics file of FindBlackBorders()
156 | ###
157 | ###
158 | ### EXPERIMENTAL:
159 | ### Some thick black borders aren't value 0 at all, sometimes they average to 16, so one would
160 | ### need to set thr2 to >16 which will basically bypass the Stab'ed clip in a lot of dark scenes.
161 | ### So probably you might still want to use this for only <4px borders and FindBlackBorders() to
162 | ### manually find the most offending borders and problematic areas.
163 | ###
164 | ###
165 | ### Dependencies:
166 | ###
167 | ### AVSInpaint (v1.3 or higher) (https://avisynth.nl/index.php/AvsInpaint)
168 | ### ResizersPack
169 | ###
170 | ####################################
171 |
172 | function FillBorder(clip c, int "thr", int "pad", bool "blur", bool "debug", clip "FixFalPos", clip "FillBordersc", int "thr2", bool "mirror", float "PAR", bool "subsample", bool "maskonly") {
173 |
174 | isy = isy(c)
175 | bi = BitsPerComponent(c)
176 |
177 | thr = Default(thr, 1) # Threshold, pixel values below this will be considered borders
178 | pad = Default(pad, 0) # Pixels, you can expand the replacement area adding more pixels
179 | # (to deal with dirty borders) (use "1" to deal with 1px b/w chroma, due to the chroma subsampling nature of video)
180 | mirror = Default(mirror, false)
181 | blur = Default(blur, false) # Blurs the masking for the replacement area. Currently not supported for InpaintLogo()
182 | debug = Default(debug,false) # Show the borders that are going to be filled
183 | FalPos = Defined(FixFalPos) # If you supply a reference clip borders with 4 or more
184 | # average thr2 pixels will be replaced with the clip's frame
185 | thr2 = Default(thr2, 7) # Threshold for FalPos, FalPos frames sometimes have garbage borders so you need to increase threshold
186 | mskonly = Default(maskonly, false) # Show the border mask
187 | subsampl = Default(subsample,false)
188 | # FillBordersc, replacement clip, even for 1 or 2 pixel borders
189 |
190 | !isy ? c.ExtractY() : c
191 |
192 | yclip=last
193 | w = width()
194 | h = height()
195 |
196 | # 4px or greater
197 | L4=FalPos ? crop(0,0,-w+4,0,true) : nop()
198 | R4=FalPos ? crop(w-4,0,0 ,0,true) : nop()
199 | T4=FalPos ? crop(0,0,0,-h+4,true) : nop()
200 | B4=FalPos ? crop(0,h-4,0 ,0,true) : nop()
201 |
202 | c
203 | Fill = ScriptClip( function[yclip,c,w,h,isy,thr,thr2,L4,R4,T4,B4,pad,blur,debug,FalPos,FixFalPos,mirror,subsampl,PAR,mskonly,FillBordersc] () {
204 |
205 | yclip
206 | pad = blur ? pad+2 : pad
207 | x1o=0 x2o=0
208 | y1o=0 y2o=0
209 |
210 | for (li=1, 3, 1) {
211 | if (AverageLuma(crop(li-1,0,-w+li,0,true))>thr) {
212 | x1o= li-1
213 | li=3
214 | }
215 | }
216 |
217 | for (ri=1, 3, 1) {
218 | if (AverageLuma(crop(w-ri,0,-ri+1,0,true))>thr) {
219 | x2o= ri-1
220 | ri=3
221 | }
222 | }
223 |
224 | for (ti=1, 3, 1) {
225 | if (AverageLuma(crop(0,ti-1,0,-h+ti,true))>thr) {
226 | y1o= ti-1
227 | ti=3
228 | }
229 | }
230 |
231 | for (bi=1, 3, 1) {
232 | if (AverageLuma(crop(0,h-bi,0 ,-bi+1,true))>thr) {
233 | y2o= bi-1
234 | bi=3
235 | }
236 | }
237 |
238 | x1=x1o+pad
239 | x2=x2o+pad
240 | y1=y1o+pad
241 | y2=y2o+pad
242 |
243 |
244 | FalPos = !mskonly && FalPos ? ((x1o > 2 || x2o > 2 || y1o > 2 || y2o > 2 )
245 | \ ? ((AverageLuma(L4) < thr2) || (AverageLuma(R4) < thr2) || (AverageLuma(T4) < thr2) || (AverageLuma(B4) < thr2))
246 | \ : false) : false
247 |
248 |
249 | cropnpad = (x1+y1+x2+y2>0)
250 | ter = !FalPos && cropnpad
251 |
252 | x1inp=cropnpad && subsampl ? nmod(x1o,2) : x1
253 | x2inp=cropnpad && subsampl ? nmod(x2o,2) : x2
254 | y1inp=cropnpad && subsampl ? nmod(y1o,2) : y1
255 | y2inp=cropnpad && subsampl ? nmod(y2o,2) : y2
256 |
257 |
258 | PaCl = mskonly ? nop() : mirror && !ter ? c.crop(x1inp,y1inp,-x2inp,-y2inp,true).PadBorders(x1inp,y1inp,x2inp,y2inp,"Mirror") : c
259 | # change this to BoxMask
260 | msk = LetterBox(BlankClip(last,1,pixel_type="Y8",color_yuv=$ffffff),y1,y2,x1,x2,color_yuv=$000000)
261 | msk = !mirror ? msk.ex_lut("x range_half > range_max x ?") : msk
262 | msk = !mirror && blur ? msk.ex_boxblur(2,mode="mean") : msk
263 | msk = isy ? CombinePlanes(msk,c,planes="YUV",sample_clip=c) : msk
264 |
265 | fill = mskonly ? msk : FalPos ? trim(c,0,current_frame-1)++trim(FixFalPos,current_frame,-1)++trim(c,current_frame+1,0) : \
266 | (ter ? Defined(FillBordersc) ? mt_merge(c,FillBordersc,msk) : \
267 | InpaintLogo(c, radius=max(x1,y1,x2,y2)+max(2,pad), mask=msk,ChromaTensor=subsampl,PixelAspect=PAR,PreBlur=mirror && blur ? 2.5 : Undefined()) : \
268 | PaCl)
269 |
270 | debug ? ter ? subtitle(msk,"Bordered",align=3,size=round(h/20.0)) : msk : fill
271 |
272 | } )
273 |
274 | !debug ? Fill : \
275 | Eval("""
276 | box = h/4.0
277 | m = 2
278 |
279 | corner = crop(ex_lut("range_max"),nmod(w-box,m),nmod(h-box,m),0,0,true)
280 | corner = corner.PadBorders(0,0,nmod(w/2.0-box,m),nmod(box,m)).ex_lut("x range_max < 0 range_max ?")
281 |
282 | horiz = stackhorizontal(corner,corner.fliphorizontal())
283 | verti = stackvertical(horiz,horiz.flipvertical())
284 | ex_merge(c,Fill.PointResize(w,h),verti,luma=true)""") }
285 |
286 |
287 |
288 |
289 | ####################################
290 | ###
291 | ### FindBlackBorders()
292 | ###
293 | ###
294 | ### Script to find sources with black borders for example as a result of bad deshaking, run on analysis pass
295 | ### The output file is formatted to be imported to avspmod as bookmarks
296 | ### use ClipClop() afterwards on a scene by scene basis to fix this.
297 | ###
298 | ### "width" is border thickness for detection
299 | ### "thr" is threshold, pixel values below this will be considered borders
300 | ### "path" is the path to store the statistics file, with end backslash. Default is "C:"
301 | ### "filename" is the statistics file name. In case you don't want to overwrite old ones
302 | ###
303 | ####################################
304 |
305 | function FindBlackBorders(clip c, int "width", int "thr", string "path", string "filename") {
306 |
307 | add = Default(width,1) # Width for detection, normally 1 should suffix to most situations
308 | thr = Default(thr, 1) # Threshold for detection, pixels lower than this value will be considered a border
309 | path = Default(path, "C:") # This is the path to store the statistics file
310 | filename = Default(filename, "FindBlackBorders - Statistics.log") # Filename of the statistics file
311 |
312 | c.ExtractY()
313 |
314 | w=width()
315 | h=height()
316 |
317 | L1=crop(0,0,-w+add,0,true)
318 | R1=crop(w-add,0,0 ,0,true)
319 | T1=crop(0,0,0,-h+add,true)
320 | B1=crop(0,h-add,0 ,0,true)
321 |
322 | WriteFileIf(""+path+"\"+filename+"",
323 | \ function[thr,L1,R1,T1,B1] () {
324 | x1 = AverageLuma(L1) < thr
325 | x2 = AverageLuma(R1) < thr
326 | y1 = AverageLuma(T1) < thr
327 | y2 = AverageLuma(B1) < thr
328 | x1||y1||x2||y2 },
329 | \ function() {"CHAPTER00="},
330 | \ function() {stab_FFFormatTime(round((current_frame * 1000) / framerate()))},
331 | \ append=false)
332 |
333 | # Here I need to retrieve the clip passed through WriteFileIf, so it is evaluated (or use Echo() ?)
334 | return last }
335 |
336 |
337 | ####################################
338 | ###
339 | ### StabPlus() v4.1
340 | ###
341 | ###
342 | ### For completeness I'm going to list all the shortcomings of Depan plugin
343 | ### maybe a programmer realises the urge of an avisynth bug-free stabilizer:
344 | ### -Artifacts occasionally on frame borders (1px skew) --> crop out, check example
345 | ### -No advanced border fill --> addressed above ( FillBorder() )
346 | ### -Some false-positives when people clapping, trembling...
347 | ### -Requires mod 4 inputs?
348 | ### -No medium jitter fix
349 | ### -Some thick borders (false positives) aren't 0 black on the inner side
350 | ###
351 | #######################################
352 | ###
353 | ### Implemented a FixPalPos to replace frames that present black borders of 3 or more pixels
354 | ### with source frames, check output just in case, since some borders don't average to 0 black (rare).
355 | ### Also supplied a more contrasty clip version for more subtle global motion analysis
356 | ### Prefilter is for the prefilter clip, in case the clip is very grainy/noisy
357 | ### Finally a few more things were introduced by testing and checking other script versions.
358 | ###
359 | ###
360 | ### Required:
361 | ### ------------
362 | ### Depan (v2.13.1.6 or higher) (https://avisynth.nl/index.php/DePan)
363 | ### DePanEstimate (v2.10.0.4 or higher) (https://avisynth.nl/index.php/DePanEstimate)
364 | ### RgTools (v1.2) (https://avisynth.nl/index.php/RgTools)
365 | ### ResizersPack (v11.1 or higher)
366 | ### AVSInpaint* (v1.3 or higher for fill=3) (https://avisynth.nl/index.php/AvsInpaint)
367 | ### SMDegrain (v3.6.0 or higher for Luma_Exp=1) (https://avisynth.nl/index.php/SMDegrain)
368 | ### GradePack (v8.3 or higher for Luma_Exp=2)
369 | ###
370 | ### Example:
371 | ###
372 | ### StabPlus(dxmax=20, fill=3, FixFalPos=true)
373 | ###
374 | ####################################
375 |
376 | function StabPlus(clip clp, int "ts", int "range", int "dxmax", int "dymax", bool "FixFalPos", clip "FalPosclip", float "zoom", int "fill", float "PAR", clip "Prefilter", int "Luma_Exp") {
377 |
378 | ts = Default(ts, 7) # frames to temporal average for better motion estimation (max. 7)
379 | range = Default(range, 3) # frames before/after to estimate motion
380 | dxmax = Default(dxmax, round(width(clp)/120.)) # maximum deviation in pixels
381 | dymax = Default(dymax, dxmax) # x, and y should be the same
382 | zoom = Default(zoom, 1) # maximum zoom factor (1 disabled)
383 | fill = Default(fill, 2) # Border filling. -1: off 0: extend 1: mirror 2: copy from source 3: process with inpaint
384 | PAR = Default(PAR, 1.0) # PAR of your source
385 | FixFalPos = Default(FixFalPos, true) # Fixes borders of 3 or more pixels wide. Use along crop(2,2,-2,-2)...
386 | # ...after StabPlus() to get rid of border issues entirely
387 | Lumae = Default(Luma_Exp, 1) # Luma Expansion for better accuracy
388 | # 0: disabled 1: TV to PC levels 2: Auto Contrast
389 |
390 | Source = Defined(Prefilter) ? Prefilter : clp
391 | Pref = Source.isy() ? Source : Source.ExtractY()
392 |
393 |
394 | temp = Pref.TemporalSoften(ts,255,0,25,2) # SC thr to 25 otherwise pans will stutter
395 | rep = temp.Repair(Pref.TemporalSoften(1, 255,0,25,2))
396 | repc = CombinePlanes(rep, Source, planes="YUV", source_planes="YUV", sample_clip=Source)
397 | inter = Interleave(rep,Pref)
398 |
399 | # temporal stable auto-contrast (better subpixel detection)
400 | Luma_Expa = Lumae==2 ? ex_autolevels(inter, hi=true, th=0.13, tv_out=false) : \
401 | Lumae==1 ? inter.ex_Luma_Rebuild(S0=5, c=1.0/32, UV=2, tv_out=false) : \
402 | inter
403 |
404 | mdata = DePanEstimate(Luma_Expa,range=range,pixaspect=PAR,trust=0.0,dxmax=dxmax,dymax=dymax,zoommax=zoom)
405 | DePan(Interleave(repc,Source),data=mdata,offset=-1,mirror=fill==1?15:0,pixaspect=PAR,matchfields=false,subpixel=2)
406 | SelectEven()
407 |
408 | subsampl = !(clp.is444() || clp.isy())
409 |
410 | abs(fill) != 1 ? FillBorder(pad=subsampl ? 1 : 0,subsample=subsampl,FixFalPos=Defined(FalPosclip) ? FalPosclip : FixFalPos ? clp : Undefined(), mirror=fill==0, FillBordersc=fill==2 ? clp : Undefined(), PAR=PAR) : last }
411 |
412 |
413 |
414 | # Wrapper for videoFred stabilize function. Works so good that it replaces StabPlus(), me thinks.
415 | # https://forum.doom9.org/showthread.php?p=1981048
416 | function Stabilize(clip c, int "offset", bool "rot", bool "zoom", bool "info") {
417 |
418 | in = Default(info, false)
419 | ro = Default(rot, false)
420 | zm = Default(zoom, false)
421 | of = Default(offset, 40)
422 |
423 | c
424 | vectors = MSuper().MAnalyse(isb=false)
425 | mdata = MDepan(vectors, rot=ro, zoom=zm, error= 65)
426 |
427 | DePanStabilize(data=mdata,dxmax=of, dymax=of, zoommax=0, rotmax=0, method=1, mirror=15, prev=1, next=1, info=in)
428 | }
429 |
430 |
431 | ######### HELPER FUNCTIONS #########
432 |
433 | # Helper function for FindBlackBorders() from FFMS2.avsi
434 | function stab_FFFormatTime(int ms) {
435 | s = ms / 1000
436 | ms = ms % 1000
437 | m = s / 60
438 | s = s % 60
439 | h = m / 60
440 | m = m % 60
441 | return string(h) + ":" + string(m,"%02.0f") + ":" + string(s,"%02.0f") + "." + string(ms,"%03.0f")}
--------------------------------------------------------------------------------
/Tools/Notepad3/DogwayChalk.ini:
--------------------------------------------------------------------------------
1 | # Lexer Style "Chalk" from Dogway (https://github.com/Dogway)
2 | # encoding:CP437[Custom Colors]
3 | # find grey colors: #([0-9A-Fa-f])([0-9A-Fa-f])((?=\2)\1|(?:\1\2){2})\b
4 |
5 | [Custom Colors]
6 | 01=#3399FF
7 | 02=#B4E1F5
8 | 03=#B4E1F5
9 | 04=#89ABEC
10 | 05=#71F8AD
11 | 06=#B1D765
12 | 07=#D8F766
13 | 08=#F6B05A
14 | 09=#141414
15 | 10=#B4E1F5
16 | 11=#B4E1F5
17 | 12=#F2B50D
18 | 13=#F2460D
19 | 14=#F53C3D
20 | 15=#F651F6
21 | 16=#BE944E
22 | [Common Base]
23 | Default Style=font:Lucida Console; size:+3; fore:#C4C4C4; back:#535353
24 | Selected Text (Colors)=back:#0A246A; eolfilled; alpha:70
25 | Matching Braces (Indicator)=fore:#FF0000; indic_roundbox
26 | Matching Braces Error (Indicator)=fore:#000080; alpha:140; alpha2:140; indic_textfore
27 | Caret (Color, Size 1-3)=size:3; fore:#000000
28 | Mark Occurrences (Indicator)=fore:#112FFF; alpha:99; alpha2:99; indic_roundbox
29 | Margins and Line Numbers=font:Consolas; bold; size:-3; fore:#7C7C7C; back:#444444
30 |
31 | Indentation Guide (Color)=fore:#606060
32 | Current Line Background (Color)=size:2; fore:#606060; back:#F2F20D; alpha:50
33 | Long Line Marker (Colors)=fore:#F2B50D
34 | Bookmarks and Folding (Colors, Size)=size:+2; fore:#DEDEDE; back:#0CE50B; alpha:100
35 | Hyperlink Hotspots=fore:#8C99ED; back:#A1D8F2; indic_plain
36 | Unicode-Point Hover=fore:#0BCF0A; alpha:60; alpha2:180; indic_compositionthick
37 | Multi Edit Indicator=fore:#F29A0D; alpha:60; alpha2:180; indic_roundbox
38 | Inline-IME Color=fore:#4EF64D
39 | [2nd Common Base]
40 | 2nd Selected Text (Colors)=eolfilled
41 | 2nd Matching Braces (Indicator)=bold; fore:#FF0000; indic_roundbox
42 | 2nd Matching Braces Error (Indicator)=bold; fore:#000080; indic_roundbox
43 | 2nd Margins and Line Numbers=size:-1; fore:#A5FAFA; back:#454545
44 |
45 | 2nd Indentation Guide (Color)=fore:#606060
46 | 2nd Whitespace (Colors, Size 0-12)=fore:#F2460D
47 | 2nd Current Line Background (Color)=size:2; fore:#A1B7F2; back:#F2F20D; alpha:50
48 | 2nd Long Line Marker (Colors)=fore:#F2B50D
49 | 2nd Bookmarks and Folding (Colors, Size)=size:+2; charset:2; fore:#DEDEDE; back:#0CE50B; case:U; alpha:100
50 | 2nd Mark Occurrences (Indicator)=fore:#7B83E9; alpha:60; alpha2:60; indic_box
51 | 2nd Hyperlink Hotspots=fore:#1EF31D; back:#57F655; alpha:180; indic_compositionthin
52 | 2nd Unicode-Point Hover=fore:#7D86EA; alpha:60; alpha2:180; indic_compositionthick
53 | 2nd Multi Edit Indicator=fore:#7BC5E9; indic_box
54 | 2nd Inline-IME Color=fore:#F20C0D
55 | 2nd Default Style=font:Consolas
56 | [Text Files]
57 | FileNameExtensions=txt; text; wtx; log; asc; doc
58 | Default Style=font:Lucida Console; size:14
59 | Default=font:Lucida Console; size:+3; fore:#C4C4C4; back:#535353
60 | Margins and Line Numbers=size:-2; fore:#B0B0B0
61 | Matching Braces=size:+1; bold; fore:#FF0000
62 | Matching Braces Error=size:+1; bold; fore:#000080
63 | Control Characters (Font)=size:-1
64 | Indentation Guide (Color)=fore:#A0A0A0
65 | Selected Text (Colors)=back:#0A246A; eolfilled; alpha:95
66 | Whitespace (Colors, Size 0-12)=size:1; fore:#FF4000; alpha:255
67 | Current Line Background (Color)=back:#FFFF00; alpha:50
68 | Caret (Color, Size 1-3)=
69 | Long Line Marker (Colors)=fore:#FFC000
70 | Extra Line Spacing (Size)=size:2
71 | 2nd Default Style=font:Courier New; size:10
72 | 2nd Margins and Line Numbers=font:Tahoma; size:-2; fore:#FF0000
73 | 2nd Matching Braces=bold; fore:#FF0000
74 | 2nd Matching Braces Error=bold; fore:#000080
75 | 2nd Control Characters (Font)=size:-1
76 | 2nd Indentation Guide (Color)=fore:#A0A0A0
77 | 2nd Selected Text (Colors)=eolfilled
78 | 2nd Whitespace (Colors, Size 0-5)=fore:#FF4000
79 | 2nd Current Line Background (Color)=back:#FFFF00; alpha:50
80 | 2nd Caret (Color, Size 1-3)=
81 | 2nd Long Line Marker (Colors)=fore:#FFC000
82 | 2nd Extra Line Spacing (Size)=
83 | [ANSI Art]
84 | Margins and Line Numbers=font:Lucida Console; size:-2; fore:#DEDEDE; back:#454545
85 | FileNameExtensions=nfo; diz
86 | [Apache Config Files]
87 | Comment=fore:#6B9F60
88 | String=fore:#F651F6
89 | Number=fore:#F2460D
90 | Directive=fore:#89ABEC
91 | IP Address=bold; fore:#F2460D
92 | FileNameExtensions=conf; htaccess
93 | [Assembly Script]
94 | Comment=fore:#6B9F60
95 | String=fore:#61F75F
96 | Number=fore:#F20C0D
97 | Operator=fore:#B4E1F5
98 | CPU Instruction=fore:#B4E1F5
99 | FPU Instruction=fore:#B4E1F5
100 | Extended Instruction=fore:#B4E1F5
101 | Directive=fore:#B4E1F5
102 | Directive Operand=fore:#B4E1F5
103 | Register=fore:#F27E0D
104 | FileNameExtensions=asm
105 | [AutoHotkey Script]
106 | Comment=fore:#6B9F60
107 | Syntax Operator=fore:#B02D15
108 | String=fore:#FE0AF8
109 | Number=fore:#F28B0D
110 | Variable Dereferencing=fore:#F761B5; back:#69644E
111 | Label=fore:#80FF80
112 | Flow of Control=fore:#556AFF
113 | Command=fore:#008FC6
114 | Function=fore:#CF2F0F
115 | Directive=italic; fore:#CC3743
116 | Keys & Buttons=fore:#EC882D
117 | Special=italic; fore:#556AFF
118 | FileNameExtensions=ahk; ia; scriptlet
119 | [AutoIt3 Script]
120 | Comment=fore:#6B9F60
121 | Number=fore:#76F8F8
122 | Function=fore:#7B83E9
123 | User-Defined Function=fore:#7B83E9
124 | Keyword=fore:#7B83E9
125 | Macro=fore:#7BB6E9
126 | String=fore:#76F8F8
127 | Operator=fore:#F544F5
128 | Variable=fore:#F8F876
129 | Send Key=fore:#F20C0D
130 | Preprocessor=fore:#F27E0D
131 | Special=fore:#F27E0D
132 | [AviSynth Script]
133 | Default=font:Cascadia Code; size:+4; fore:#BABABA; back:#535353
134 | Comment=fore:#63A646
135 | Operator=fore:#BABABA
136 | String=fore:#4C004C
137 | Number=fore:#42B7B4
138 | Keyword=fore:#00007F
139 | Filter=fore:#00007F
140 | Plugin=fore:#39A2D9
141 | Function=fore:#00007F
142 | Clip Property=fore:#00007F
143 | User Defined Function=fore:#83B1D1
144 | FileNameExtensions=avs; avsi; vpy
145 | Identifier=fore:#BABABA
146 | [Awk Script]
147 | Keyword=bold; fore:#A7C0F4
148 | Keyword 2nd=bold; italic; fore:#3031DB
149 | Comment=fore:#6B9F60
150 | String=fore:#6FF76C
151 | Number=fore:#F57C44
152 | Operator=fore:#F651F6
153 | [Batch Files]
154 | Comment=fore:#6B9F60
155 | Keyword=fore:#5180EE
156 | Identifier=fore:#71F8AD; back:#544604
157 | Operator=fore:#F651F6
158 | Label=fore:#F53C3D; back:#141414; eolfilled
159 | [C# Source Code]
160 | Comment=fore:#6B9F60
161 | Keyword=bold; fore:#F8B076
162 | Keyword 2nd=bold; italic; fore:#F8B076
163 | Global Class=fore:#9DD1DC
164 | String=fore:#5BF659
165 | Number=fore:#F20C0D
166 | Operator=fore:#F651F6
167 | Preprocessor=fore:#F27E0D
168 | Verbatim String=fore:#6FF76C
169 | Comment Doc=fore:#7F7F7F
170 | Comment Doc Word=bold; fore:#7F7F7F
171 | Comment Doc Error=italic; fore:#F87376
172 | Task Marker=bold; fore:#79DBDB
173 | FileNameExtensions=cs
174 | [C/C++ Source Code]
175 | Comment=fore:#6B9F60
176 | Keyword=bold; fore:#B4E1F5
177 | Keyword 2nd=bold; italic; fore:#7B9AD2
178 | Typedefs/Classes=bold; italic; fore:#F87376
179 | String=fore:#61F75F
180 | Number=fore:#F20C0D
181 | Operator=fore:#F651F6
182 | Preprocessor=fore:#F27E0D
183 | Verbatim=fore:#F651F6
184 | Comment Doc=fore:#7F7F7F
185 | Comment Doc Word=bold; fore:#7F7F7F
186 | Comment Doc Error=italic; fore:#F87376
187 | Task Marker=bold; fore:#79DBDB
188 | FileNameExtensions=c; cpp; cxx; cc; h; hpp; hxx; hh; m; mm; idl; inl; odl
189 | [Cmake Script]
190 | Comment=fore:#6B9F60
191 | String=fore:#F877F8; back:#393939
192 | Function=fore:#B0D1F7
193 | Parameter=fore:#EC8577
194 | Variable=fore:#F5663A
195 | While Def=fore:#B0D1F7
196 | For Each Def=fore:#B0D1F7
197 | If Def=fore:#B0D1F7
198 | Macro Def=fore:#B0D1F7
199 | Variable within String=fore:#F5663A; back:#393939
200 | Number=fore:#76F8F8
201 | FileNameExtensions=cmake; ctest
202 | [Coffeescript]
203 | Comment=fore:#6B9F60
204 | String=fore:#6AF768
205 | Preprocessor=fore:#F27E0D
206 | Identifier=bold; fore:#B4E1F5
207 | Operator=fore:#F651F6
208 | Number=fore:#F20C0D
209 | Regex=fore:#81F8B5; back:#544604
210 | [Configuration Files]
211 | Key=fore:#AADAFA
212 | Comment=fore:#6B9F60
213 | Section=bold; fore:#DEDEDE; back:#B8430A; eolfilled
214 | Assignment=fore:#F20C0D
215 | Default Value=fore:#F20C0D
216 | FileNameExtensions=ini; inf; reg; cfg; properties; oem; sif; url; sed; theme
217 | Default=font:Lucida Console; size:+3; fore:#C4C4C4; back:#535353
218 | [CSS Style Sheets]
219 | Comment=fore:#6B9F60
220 | HTML Tag=bold; fore:#B4E1F5
221 | Tag-Class=fore:#D0F548
222 | Tag-ID=fore:#D8F766
223 | Tag-Attribute=italic; fore:#D6F761
224 | Pseudo-Class=fore:#F651F6
225 | Pseudo-Element=fore:#F6509C
226 | CSS Property=fore:#F2460D
227 | String=fore:#6FF76C
228 | Value=fore:#A1C3D3
229 | Operator=fore:#F651F6
230 | Important=bold; fore:#F53C3D
231 | Directive=bold; fore:#DEDEDE; back:#544604
232 | Media=bold; fore:#B4E1F5
233 | Variable=bold; fore:#F2460D
234 | Unknown Pseudo-Class=fore:#F53C3D; back:#7B7B06
235 | Unknown Property=fore:#F53C3D; back:#7B7B06
236 | FileNameExtensions=css
237 | [CSV Prism]
238 | Margins and Line Numbers=fore:#DEDEDE; back:#454545
239 | Column 0=fore:#BAA1EE
240 | Column 1=fore:#A8B8F2
241 | Column 2=fore:#81B1EA
242 | Column 3=fore:#60AEE4
243 | Column 4=fore:#42F4F4
244 | Column 5=fore:#23F351
245 | Column 6=fore:#A2F426
246 | Column 7=fore:#E1F219
247 | Column 8=fore:#F1940E
248 | Column 9=fore:#F42D2E
249 | [D Source Code]
250 | Comment=fore:#6B9F60
251 | Comment Doc=fore:#A7D5F4
252 | Number=fore:#F20C0D
253 | Keyword=bold; fore:#B4E1F5
254 | Keyword 2nd=bold; fore:#B4E1F5
255 | Typedef=italic; fore:#B4E1F5
256 | String=italic; fore:#7B9AD2
257 | Operator=fore:#F651F6
258 | [Dart Source Code]
259 | Keyword=fore:#7B83E9
260 | Keyword 2nd=fore:#7B83E9
261 | Meta-Data=fore:#F27E0D
262 | Class=fore:#7BB6E9
263 | Enumeration=fore:#F27E0D
264 | Function=fore:#F6B05A
265 | Comment=fore:#6B9F60
266 | Comment Doc=fore:#76BA74
267 | Task Marker=bold; fore:#7CBDBD
268 | String=fore:#69F767
269 | TriQ-String=fore:#F38B1A
270 | Verbatim String=fore:#F38B1A
271 | ESC Sequence=fore:#9BDAF1
272 | Label=fore:#6950D3
273 | Number=fore:#F20C0D
274 | Variable=fore:#D27F60
275 | Operator=fore:#6950D3
276 | [Diff Files]
277 | Comment=fore:#6B9F60
278 | Command=bold; fore:#B4E1F5
279 | Source and Destination=fore:#F53C3D; back:#544604; eolfilled
280 | Position Setting=fore:#7B83E9
281 | Line Addition=fore:#A3FA9C; back:#045403; eolfilled
282 | Line Removal=fore:#FBA9B2; back:#7B0506; eolfilled
283 | Line Change=fore:#B5DCF9; back:#2324CE; eolfilled
284 | [Fortran Source Code]
285 | Keyword=bold; fore:#0080FF
286 | Function=bold; italic; fore:#00B3FF
287 | User-Defined Function=bold; italic; fore:#8678FE
288 | Number=fore:#7C00F9
289 | Operator=bold; fore:#0AB456
290 | Label=fore:#FF0080
291 | Continuation=fore:#D8F766
292 | [Go Source Code]
293 | Comment=fore:#6B9F60
294 | Number=fore:#F20C0D
295 | Keyword=bold; fore:#B4E1F5
296 | Keyword 2nd=bold; fore:#B4E1F5
297 | Typedef=italic; fore:#B4E1F5
298 | String=italic; fore:#7B9AD2
299 | Operator=fore:#F651F6
300 | [Inno Setup Script]
301 | Comment=fore:#6B9F60
302 | Keyword=fore:#7B83E9
303 | Parameter=fore:#7B83E9
304 | Section=bold; fore:#B0D1F7
305 | Preprocessor=fore:#F5393A
306 | Inline Expansion=fore:#F876F8
307 | Pascal Comment=fore:#6B9F60
308 | Pascal Keyword=fore:#7B83E9
309 | [Java Source Code]
310 | Comment=fore:#6B9F60
311 | Keyword=bold; fore:#F6B05A
312 | Keyword 2nd=bold; fore:#F6B05A
313 | String=fore:#65F763
314 | Number=fore:#F20C0D
315 | Operator=fore:#F651F6
316 | Comment Doc=fore:#7F7F7F
317 | Comment Doc Word=bold; fore:#7F7F7F
318 | Comment Doc Error=italic; fore:#F87376
319 | Task Marker=bold; fore:#79DBDB
320 | FileNameExtensions=java
321 | [JavaScript]
322 | Comment=fore:#6B9F60
323 | Keyword=bold; fore:#F6B05A
324 | String=fore:#65F763
325 | Regex=fore:#77F8B0; back:#544604
326 | Number=fore:#F20C0D
327 | Operator=fore:#F651F6
328 | Comment Doc=fore:#7F7F7F
329 | Comment Doc Word=bold; fore:#7F7F7F
330 | Comment Doc Error=italic; fore:#F87376
331 | Task Marker=bold; fore:#79DBDB
332 | FileNameExtensions=js; jse; jsm; json; as
333 | [JSON]
334 | Comment=fore:#6B9F60
335 | Keyword=bold; fore:#F7C966
336 | LD Keyword=bold; fore:#F36E58
337 | String=fore:#66F764
338 | Number=fore:#F20C0D
339 | Operator=fore:#F651F6
340 | Property Name=fore:#A9D1F5
341 | ESC Sequence=fore:#3DE966
342 | Parsing Error=fore:#F2F20D; back:#F75C5E; eolfilled
343 | [Julia Script]
344 | Comment=fore:#6B9F60
345 | Number=fore:#F20C0D
346 | Keyword=bold; fore:#7B83E9
347 | Keyword 2nd=bold; fore:#F76EF7
348 | String=fore:#F57148
349 | Operator=fore:#F6804D
350 | Type Operator=fore:#F766F7
351 | Identifier=fore:#B1D3F7
352 | Symbol=fore:#CCA941
353 | Macro Def=fore:#7BB6E9
354 | Comment Doc=fore:#7F7F7F
355 | Literal String=fore:#F651F6
356 | Command=bold; fore:#8E9BED
357 | Annotation=fore:#F27E0D
358 | Parsing Error=fore:#F2F20D; back:#F75C5E; eolfilled
359 | [KiXtart Script]
360 | Keyword=bold; fore:#6285E4
361 | Function=fore:#F761F7
362 | Macro=fore:#F2B50D
363 | Comment=fore:#6B9F60
364 | String=italic; fore:#717171
365 | Operator=fore:#F53C3D
366 | Number=fore:#65F7F7
367 | Variable=fore:#D27F60
368 | [Kotlin Source Code]
369 | Keyword=fore:#7B83E9
370 | Annotation=fore:#F27E0D
371 | Class=fore:#7BB6E9
372 | Interface=bold; fore:#67A9E5
373 | Enumeration=fore:#F27E0D
374 | Function=fore:#F6B05A
375 | Comment=fore:#6B9F60
376 | Comment Doc=fore:#7CBDBD
377 | Comment Doc Word=fore:#7CBDBD
378 | Task Marker=bold; fore:#79DBDB
379 | String=fore:#65F763
380 | Verbatim String=fore:#F38B1A
381 | ESC Sequence=fore:#9BDAF1
382 | Back Ticks=fore:#D27F60
383 | Label=fore:#6950D3
384 | Number=fore:#F20C0D
385 | Variable=fore:#D27F60
386 | Operator=fore:#F651F6
387 | [LaTeX Files]
388 | Command=fore:#7B83E9
389 | Comment=fore:#6B9F60
390 | Math=fore:#F20C0D
391 | Special Char=fore:#F6F656
392 | Tag=fore:#7B83E9
393 | Verbatim Segment=fore:#979797
394 | Error=fore:#F2F20D; back:#F75C5E
395 | FileNameExtensions=tex; latex; sty
396 | [Lua Script]
397 | Comment=fore:#6B9F60
398 | Number=fore:#76F8F8
399 | Keyword=fore:#B0D1F7
400 | Basic Functions=fore:#B0D1F7
401 | String, Table & Math Functions=fore:#B0D1F7
402 | Input, Output & System Facilities=fore:#B0D1F7
403 | String=fore:#F651F6
404 | Literal String=fore:#F651F6
405 | Preprocessor=fore:#F27E0D
406 | Label=fore:#F8F876
407 | FileNameExtensions=lua
408 | [Makefiles]
409 | Comment=fore:#6B9F60
410 | Identifier=fore:#89ABEC
411 | Preprocessor=fore:#F27E0D
412 | FileNameExtensions=mak; make; mk; dsp; msc; msvc
413 | [Markdown]
414 | Header 1=bold; fore:#272702; back:#848DCF; eolfilled
415 | Header 2=bold; fore:#A8CCDA; back:#1F6AB4; eolfilled
416 | Header 3=bold; fore:#A8CCDA; back:#154B7F; eolfilled
417 | Header 4=bold; fore:#A8CCDA; eolfilled
418 | Header 5=bold; fore:#99B9CD; eolfilled
419 | Header 6=bold; fore:#85A5BF; eolfilled
420 | Pre Char=fore:#B0D1F7
421 | Unordered List=bold; fore:#7BB6E9
422 | Ordered List=bold; fore:#7BB6E9
423 | Block Quote=fore:#B0D1F7
424 | Link=fore:#7B83E9
425 | Code=fore:#B0D1F7; back:#141414
426 | [MATLAB]
427 | Comment=fore:#6B9F60
428 | Number=fore:#F27E0D
429 | Keyword=bold; fore:#B0D1F7
430 | String=fore:#F877F8
431 | [Nim Source Code]
432 | Comment=fore:#6B9F60
433 | Keyword=bold; fore:#5F8E5F
434 | String Double Quoted=fore:#D7598F
435 | String Single Quoted=fore:#D7598F
436 | String Triple Double Quotes=fore:#D7598F
437 | String Triple Single Quotes=fore:#D7598F
438 | Number=fore:#97A9DD
439 | Operator=bold; fore:#AEAEAE
440 | Function name=fore:#AEAEAE
441 | Parsing Error=italic; fore:#F2F20D; back:#F75C5E
442 | [NSIS Script]
443 | Comment=fore:#6B9F60
444 | String=fore:#979797; back:#393939
445 | Function=fore:#96B8EF
446 | Variable=fore:#F5663A
447 | Variable within String=fore:#F5663A; back:#393939
448 | Number=fore:#F20C0D
449 | Constant=fore:#F2940D
450 | Section=fore:#96B8EF
451 | Sub Section=fore:#96B8EF
452 | Section Group=fore:#96B8EF
453 | Function Definition=fore:#96B8EF
454 | PageEx=fore:#96B8EF
455 | If Definition=fore:#96B8EF
456 | Macro Definition=fore:#96B8EF
457 | [Pascal Source Code]
458 | Comment=fore:#6B9F60
459 | Keyword=bold; fore:#F876F8
460 | String=fore:#61F75F
461 | Number=fore:#F20C0D
462 | Inline Asm=fore:#7B83E9
463 | Preprocessor=fore:#F20DF2
464 | FileNameExtensions=pas; dpr; dpk; dfm; inc; pp
465 | [Perl Script]
466 | Comment=fore:#6B9F60
467 | Keyword=bold; fore:#F8B076
468 | String Double Quoted=fore:#61F75F
469 | String Single Quoted=fore:#64F762
470 | Number=fore:#F20C0D
471 | Scalar $var=fore:#B4E1F5
472 | Array @var=fore:#89ABEC
473 | Hash %var=fore:#F651F6
474 | Symbol Table *var=fore:#A1C3D3
475 | Regex /re/ or m{re}=fore:#70F7AD; back:#544604
476 | Substitution s/re/ore/=fore:#88F9B7; back:#544604
477 | Back Ticks=fore:#F46027; back:#544604
478 | Here-Doc (Delimiter)=fore:#DBF872
479 | Here-Doc (Single Quoted, q)=fore:#D6F75F
480 | Here-Doc (Double Quoted, qq)=fore:#D7F762
481 | Here-Doc (Back Ticks, qx)=fore:#F46027; back:#544604
482 | Single Quoted String (Generic, q)=fore:#75F872
483 | Double Quoted String (qq)=fore:#61F75F
484 | Back Ticks (qx)=fore:#F46027; back:#544604
485 | Regex (qr)=fore:#88F9B7; back:#544604
486 | Array (qw)=fore:#89ABEC
487 | Prototype=fore:#F876F8; back:#270227
488 | Format Identifier=bold; fore:#DBF873; back:#544604
489 | Format Body=fore:#DBF872; back:#544604
490 | POD (Common)=fore:#F6B05A; back:#3D3D03; eolfilled
491 | POD (Verbatim)=fore:#F6B05A; back:#3D3D03; eolfilled
492 | Data Section=fore:#F6B05A; back:#3D3D03; eolfilled
493 | Parsing Error=fore:#F53C3D; back:#7B7B06
494 | FileNameExtensions=pl; pm; cgi; pod
495 | [PowerShell Script]
496 | Comment=fore:#6B9F60
497 | Keyword=bold; fore:#F8B076
498 | String=fore:#61F75F
499 | Number=fore:#F20C0D
500 | Variable=fore:#B4E1F5
501 | Cmdlet=fore:#F8B076; back:#544604
502 | Alias=bold; fore:#B4E1F5
503 | FileNameExtensions=ps1; psd1; psm1
504 | [Python Script]
505 | Comment=fore:#6B9F60
506 | Keyword=bold; fore:#AECDF6
507 | Keyword 2nd=fore:#AECDF6
508 | Attribute=fore:#C2C2C2
509 | String Single Quoted=fore:#F877F8
510 | String Double Quoted=fore:#F877F8
511 | String Triple Single Quotes=fore:#92C339
512 | String Triple Double Quotes=fore:#6B9F60
513 | Decorator=fore:#F3B819
514 | Number=fore:#F2460D
515 | Operator=bold; fore:#F9F988
516 | Function Name=fore:#F988F9
517 | Class Name=fore:#F988F9
518 | FileNameExtensions=py; pyw
519 | [Registry Files]
520 | Comment=fore:#6B9F60
521 | String=fore:#62F760
522 | Value Type=bold; fore:#B0D1F7
523 | Hex=fore:#EF7478
524 | Added Key=bold; fore:#DEDEDE; back:#B8430A; eolfilled
525 | Deleted Key=fore:#F20C0D
526 | Escaped=bold; fore:#A4B4B4
527 | GUID in Key Path=fore:#E6C07B
528 | Parameter=fore:#79EDDB
529 | [Resource Script]
530 | Comment=fore:#6B9F60
531 | Keyword=bold; fore:#B4E1F5
532 | String=fore:#49F548
533 | Number=fore:#F20C0D
534 | Operator=fore:#B4E1F5
535 | Preprocessor=fore:#F27E0D
536 | Comment Doc=fore:#7F7F7F
537 | Comment Doc Word=bold; fore:#7F7F7F
538 | Comment Doc Error=italic; fore:#F87376
539 | Task Marker=bold; fore:#79DBDB
540 | FileNameExtensions=rc; rc2; rct; rh; r; dlg
541 | [R-S-SPlus Statistics Code]
542 | Comment=fore:#6B9F60
543 | Keyword=bold; fore:#B4E1F5
544 | Base Package Functions=bold; fore:#F87477
545 | Other Package Functions=bold; fore:#F877F8
546 | Number=fore:#7B83E9
547 | String=italic; fore:#7B9AD2
548 | Operator=bold; fore:#F651F6
549 | Infix=fore:#F988F9
550 | Infix EOL=fore:#F2460D; back:#402040; eolfilled
551 | [Ruby Script]
552 | Comment=fore:#6B9F60
553 | Keyword=fore:#B0D1F7
554 | Number=fore:#76F8F8
555 | String=fore:#F27E0D
556 | Class Name=fore:#7B83E9
557 | Function Name=fore:#77F8F8
558 | POD=fore:#8FF98A; back:#022701; eolfilled
559 | Regex=fore:#DEDEDE; back:#022B01
560 | Symbol=fore:#CCA941
561 | Module Name=fore:#F75EF7
562 | Instance Var=fore:#F650C9
563 | Class Var=fore:#BEB7F2
564 | Data Section=fore:#F9888C; back:#271802; eolfilled
565 | FileNameExtensions=rb; ruby; rbw; rake; rjs; Rakefile
566 | [Rust Source Code]
567 | Keyword=bold; fore:#89E973
568 | Build-In Type=fore:#F65490
569 | Other Keyword=italic; fore:#7CE665
570 | Number=fore:#979797
571 | Comment=fore:#6B9F60
572 | String=fore:#E04D4D
573 | Operator=fore:#979797
574 | Macro Definition=fore:#B4E1F5
575 | Rust Lifetime=fore:#F651F6
576 | Parsing Error=fore:#141414; back:#F3191A
577 | Byte String=fore:#404040
578 | [Shell Script]
579 | Comment=fore:#6B9F60
580 | Number=fore:#76F8F8
581 | Keyword=fore:#7B83E9
582 | String Double Quoted=fore:#76F8F8
583 | String Single Quoted=fore:#F876F8
584 | Scalar=fore:#F8F876
585 | Parameter Expansion=fore:#F8F876; back:#636305
586 | Back Ticks=fore:#F20C80
587 | Here-Doc (Single Quoted, q)=fore:#76F8F8
588 | FileNameExtensions=sh
589 | [SQL Query]
590 | Comment=fore:#6B9F60
591 | Keyword=bold; fore:#73B9FF
592 | Value Type=bold; fore:#CFE3FA
593 | String=fore:#8C8C8C
594 | Identifier=fore:#DCDCDC
595 | Quoted Identifier=fore:#00CCCC
596 | Number=fore:#B973FF
597 | Operator=bold; fore:#EC880D
598 | FileNameExtensions=sql
599 | [Tcl Script]
600 | Comment=fore:#6B9F60
601 | Keyword=fore:#7B83E9
602 | Number=fore:#76F8F8
603 | String=fore:#76F8F8
604 | Identifier=fore:#F876F8
605 | Substitution=fore:#F5393A
606 | Modifier=fore:#F20DF2
607 | FileNameExtensions=tcl; itcl
608 | [TOML Config]
609 | Keyword=bold; fore:#F20C80
610 | Comment=fore:#6B9F60
611 | Section=bold; fore:#DEDEDE; back:#544604; eolfilled
612 | Key=bold; fore:#A9BDBD
613 | Assignment=bold; fore:#D50A0B
614 | Value=fore:#CDCDCD
615 | Number=fore:#8C99ED
616 | Date-Time=fore:#F766F7
617 | String=italic; fore:#9C9C9C
618 | Parsing Error=fore:#F2F20D; back:#F75C5E; eolfilled
619 | [VBScript]
620 | Comment=fore:#6B9F60
621 | Keyword=bold; fore:#F651F6
622 | String=fore:#67F765
623 | Number=fore:#F20C0D
624 | [VHDL]
625 | Comment=fore:#6B9F60
626 | Number=fore:#F20C0D
627 | String=fore:#6FF76C
628 | Operator=fore:#F651F6
629 | Keyword=bold; fore:#B4E1F5
630 | Standard Operator=bold; fore:#B4E1F5
631 | Standard Type=fore:#F27E0D
632 | [Visual Basic]
633 | Comment=fore:#6B9F60
634 | Keyword=bold; fore:#F651F6
635 | String=fore:#67F765
636 | Number=fore:#F20C0D
637 | Preprocessor=fore:#F2960D
638 | [Web Source Code]
639 | HTML Tag=fore:#DBF873
640 | HTML Unknown Tag=fore:#F53C3D; back:#7B7B06
641 | HTML Attribute=fore:#F2460D
642 | HTML Unknown Attribute=fore:#F53C3D; back:#7B7B06
643 | HTML Value=fore:#A1C3D3
644 | HTML String=fore:#A1C3D3
645 | HTML Other Inside Tag=fore:#A1C3D3
646 | HTML Comment=fore:#6B9F60
647 | HTML Entity=fore:#F651F6
648 | XML Identifier=bold; fore:#E96EE1
649 | SGML=fore:#E96EE1
650 | CDATA=fore:#999999
651 | ASP Start Tag=bold; fore:#B0D1F7
652 | PHP Start Tag=bold; fore:#B0D1F7
653 | PHP Comment=fore:#6B9F60
654 | PHP Keyword=bold; fore:#F6B05A
655 | PHP String=fore:#65F763
656 | PHP Simple String=fore:#63F761
657 | PHP Number=fore:#F20C0D
658 | PHP Operator=fore:#F651F6
659 | PHP Variable=italic; fore:#B0D1F7
660 | PHP String Variable=italic; fore:#B0D1F7
661 | PHP Complex Variable=italic; fore:#B0D1F7
662 | JS Comment=fore:#6B9F60
663 | JS Keyword=bold; fore:#F6B05A
664 | JS String=fore:#65F763
665 | JS Regex=fore:#77F8B0; back:#544604
666 | JS Number=fore:#F20C0D
667 | JS Symbols=fore:#F651F6
668 | ASP JS Comment=fore:#6B9F60
669 | ASP JS Keyword=bold; fore:#F6B05A
670 | ASP JS String=fore:#65F763
671 | ASP JS Regex=fore:#77F8B0; back:#544604
672 | ASP JS Number=fore:#F20C0D
673 | ASP JS Symbols=fore:#F651F6
674 | VBS Comment=fore:#6B9F60
675 | VBS Keyword=bold; fore:#F651F6
676 | VBS String=fore:#67F765
677 | VBS Number=fore:#F20C0D
678 | ASP VBS Comment=fore:#6B9F60
679 | ASP VBS Keyword=bold; fore:#F651F6
680 | ASP VBS String=fore:#67F765
681 | ASP VBS Number=fore:#F20C0D
682 | FileNameExtensions=html; htm; asp; aspx; shtml; htd; xhtml; php; php3; phtml; htt; cfm; tpl; dtd; hta; htc
683 | [XML Document]
684 | XML Tag=fore:#E96EE1
685 | XML Attribute=fore:#F7A163
686 | XML Value=fore:#A2B7E7
687 | XML String=fore:#A2B7E7
688 | XML Other Inside Tag=fore:#A2B7E7
689 | XML Comment=fore:#6B9F60
690 | XML Entity=fore:#F651F6
691 | XML Identifier=bold; fore:#E96EE1
692 | SGML=fore:#E96EE1
693 | CDATA=fore:#999999
694 | FileNameExtensions=xml; xsl; rss; svg; xul; xsd; xslt; axl; rdf; xaml; vcproj
695 | [YAML]
696 | Comment=fore:#6B9F60
697 | Identifier=bold; fore:#B4E1F5
698 | Keyword=fore:#F770F7
699 | Number=fore:#F27E0D
700 | Reference=fore:#70F7F7
701 | Document=bold; fore:#141414; back:#AECDF6; eolfilled
702 | Text=fore:#B7B7B7
703 | Error=bold; italic; fore:#141414; back:#F20C0D; eolfilled
704 | Operator=fore:#B6D8E1
705 |
--------------------------------------------------------------------------------
/Tools/Notepad3/DogwayGraphite.ini:
--------------------------------------------------------------------------------
1 | # Lexer Style "Graphite" from Dogway (https://github.com/Dogway)
2 | # encoding:CP437[Custom Colors]
3 | # find grey colors: #([0-9A-Fa-f])([0-9A-Fa-f])((?=\2)\1|(?:\1\2){2})\b
4 |
5 | [Custom Colors]
6 | 01=#3399FF
7 | 02=#B4E1F5
8 | 03=#B4E1F5
9 | 04=#89ABEC
10 | 05=#71F8AD
11 | 06=#B1D765
12 | 07=#D8F766
13 | 08=#F6B05A
14 | 09=#141414
15 | 10=#B4E1F5
16 | 11=#B4E1F5
17 | 12=#F2B50D
18 | 13=#F2460D
19 | 14=#F53C3D
20 | 15=#F651F6
21 | 16=#BE944E
22 | [Common Base]
23 | Default Style=font:Lucida Console; size:+3; fore:#B3B3B3; back:#383838
24 | Selected Text (Colors)=back:#000000; eolfilled; alpha:90
25 | Matching Braces (Indicator)=fore:#FF0000; indic_roundbox
26 | Matching Braces Error (Indicator)=fore:#000080; alpha:140; alpha2:140; indic_textfore
27 | Caret (Color, Size 1-3)=size:3; fore:#C8C8C8
28 | Mark Occurrences (Indicator)=fore:#112FFF; alpha:99; alpha2:99; indic_roundbox
29 | Margins and Line Numbers=font:Consolas; bold; size:-3; fore:#7C7C7C; back:#444444
30 |
31 | Indentation Guide (Color)=fore:#606060
32 | Current Line Background (Color)=size:2; fore:#606060; back:#F2F20D; alpha:50
33 | Long Line Marker (Colors)=fore:#F2B50D
34 | Bookmarks and Folding (Colors, Size)=size:+2; fore:#DEDEDE; back:#0CE50B; alpha:100
35 | Hyperlink Hotspots=fore:#8C99ED; back:#A1D8F2; indic_plain
36 | Unicode-Point Hover=fore:#0BCF0A; alpha:60; alpha2:180; indic_compositionthick
37 | Multi Edit Indicator=fore:#F29A0D; alpha:60; alpha2:180; indic_roundbox
38 | Inline-IME Color=fore:#7C7C7C
39 | [2nd Common Base]
40 | 2nd Selected Text (Colors)=eolfilled
41 | 2nd Matching Braces (Indicator)=bold; fore:#FF0000; indic_roundbox
42 | 2nd Matching Braces Error (Indicator)=bold; fore:#000080; indic_roundbox
43 | 2nd Margins and Line Numbers=size:-1; fore:#A5FAFA; back:#454545
44 |
45 | 2nd Indentation Guide (Color)=fore:#606060
46 | 2nd Whitespace (Colors, Size 0-12)=fore:#F2460D
47 | 2nd Current Line Background (Color)=size:2; fore:#A1B7F2; back:#F2F20D; alpha:50
48 | 2nd Long Line Marker (Colors)=fore:#F2B50D
49 | 2nd Bookmarks and Folding (Colors, Size)=size:+2; charset:2; fore:#DEDEDE; back:#0CE50B; case:U; alpha:100
50 | 2nd Mark Occurrences (Indicator)=fore:#7B83E9; alpha:60; alpha2:60; indic_box
51 | 2nd Hyperlink Hotspots=fore:#1EF31D; back:#57F655; alpha:180; indic_compositionthin
52 | 2nd Unicode-Point Hover=fore:#7D86EA; alpha:60; alpha2:180; indic_compositionthick
53 | 2nd Multi Edit Indicator=fore:#7BC5E9; indic_box
54 | 2nd Inline-IME Color=fore:#F20C0D
55 | 2nd Default Style=font:Consolas
56 | [Text Files]
57 | FileNameExtensions=txt; text; wtx; log; asc; doc
58 | Default Style=font:Lucida Console; size:14
59 | Default=font:Lucida Console; size:+3; fore:#B3B3B3; back:#383838
60 | Margins and Line Numbers=size:-2; fore:#B0B0B0
61 | Matching Braces=size:+1; bold; fore:#FF0000
62 | Matching Braces Error=size:+1; bold; fore:#000080
63 | Control Characters (Font)=size:-1
64 | Indentation Guide (Color)=fore:#A0A0A0
65 | Selected Text (Colors)=back:#0A246A; eolfilled; alpha:95
66 | Whitespace (Colors, Size 0-12)=size:1; fore:#FF4000; alpha:255
67 | Current Line Background (Color)=back:#FFFF00; alpha:50
68 | Caret (Color, Size 1-3)=
69 | Long Line Marker (Colors)=fore:#FFC000
70 | Extra Line Spacing (Size)=size:2
71 | 2nd Default Style=font:Courier New; size:10
72 | 2nd Margins and Line Numbers=font:Tahoma; size:-2; fore:#FF0000
73 | 2nd Matching Braces=bold; fore:#FF0000
74 | 2nd Matching Braces Error=bold; fore:#000080
75 | 2nd Control Characters (Font)=size:-1
76 | 2nd Indentation Guide (Color)=fore:#A0A0A0
77 | 2nd Selected Text (Colors)=eolfilled
78 | 2nd Whitespace (Colors, Size 0-5)=fore:#FF4000
79 | 2nd Current Line Background (Color)=back:#FFFF00; alpha:50
80 | 2nd Caret (Color, Size 1-3)=
81 | 2nd Long Line Marker (Colors)=fore:#FFC000
82 | 2nd Extra Line Spacing (Size)=
83 | [ANSI Art]
84 | Margins and Line Numbers=font:Lucida Console; size:-2; fore:#DEDEDE; back:#454545
85 | FileNameExtensions=nfo; diz
86 | [Apache Config Files]
87 | Comment=fore:#6B9F60
88 | String=fore:#F651F6
89 | Number=fore:#F2460D
90 | Directive=fore:#89ABEC
91 | IP Address=bold; fore:#F2460D
92 | FileNameExtensions=conf; htaccess
93 | [Assembly Script]
94 | Comment=fore:#6B9F60
95 | String=fore:#61F75F
96 | Number=fore:#F20C0D
97 | Operator=fore:#B4E1F5
98 | CPU Instruction=fore:#B4E1F5
99 | FPU Instruction=fore:#B4E1F5
100 | Extended Instruction=fore:#B4E1F5
101 | Directive=fore:#B4E1F5
102 | Directive Operand=fore:#B4E1F5
103 | Register=fore:#F27E0D
104 | FileNameExtensions=asm
105 | [AutoHotkey Script]
106 | Comment=fore:#6B9F60
107 | Syntax Operator=fore:#B02D15
108 | String=fore:#FE0AF8
109 | Number=fore:#F28B0D
110 | Variable Dereferencing=fore:#F761B5; back:#69644E
111 | Label=fore:#80FF80
112 | Flow of Control=fore:#556AFF
113 | Command=fore:#008FC6
114 | Function=fore:#CF2F0F
115 | Directive=italic; fore:#CC3743
116 | Keys & Buttons=fore:#EC882D
117 | Special=italic; fore:#556AFF
118 | FileNameExtensions=ahk; ia; scriptlet
119 | [AutoIt3 Script]
120 | Comment=fore:#6B9F60
121 | Number=fore:#76F8F8
122 | Function=fore:#7B83E9
123 | User-Defined Function=fore:#7B83E9
124 | Keyword=fore:#7B83E9
125 | Macro=fore:#7BB6E9
126 | String=fore:#76F8F8
127 | Operator=fore:#F544F5
128 | Variable=fore:#F8F876
129 | Send Key=fore:#F20C0D
130 | Preprocessor=fore:#F27E0D
131 | Special=fore:#F27E0D
132 | [AviSynth Script]
133 | Default=font:Cascadia Code; size:+4; fore:#C8C8C8; back:#383838
134 | Comment=fore:#6B9F60
135 | Operator=fore:#C8C8C8
136 | String=fore:#D984DB
137 | Number=fore:#96F5F5
138 | Keyword=fore:#6F98EE
139 | Filter=fore:#6F98EE
140 | Plugin=fore:#78B6E9
141 | Function=fore:#6F98EE
142 | Clip Property=fore:#6F98EE
143 | User Defined Function=fore:#B0D1F7
144 | FileNameExtensions=avs; avsi; vpy
145 | Identifier=fore:#C8C8C8
146 | [Awk Script]
147 | Keyword=bold; fore:#A7C0F4
148 | Keyword 2nd=bold; italic; fore:#3031DB
149 | Comment=fore:#6B9F60
150 | String=fore:#6FF76C
151 | Number=fore:#F57C44
152 | Operator=fore:#F651F6
153 | [Batch Files]
154 | Comment=fore:#6B9F60
155 | Keyword=fore:#5180EE
156 | Identifier=fore:#71F8AD; back:#544604
157 | Operator=fore:#F651F6
158 | Label=fore:#F53C3D; back:#141414; eolfilled
159 | [C# Source Code]
160 | Comment=fore:#6B9F60
161 | Keyword=bold; fore:#F8B076
162 | Keyword 2nd=bold; italic; fore:#F8B076
163 | Global Class=fore:#9DD1DC
164 | String=fore:#5BF659
165 | Number=fore:#F20C0D
166 | Operator=fore:#F651F6
167 | Preprocessor=fore:#F27E0D
168 | Verbatim String=fore:#6FF76C
169 | Comment Doc=fore:#7F7F7F
170 | Comment Doc Word=bold; fore:#7F7F7F
171 | Comment Doc Error=italic; fore:#F87376
172 | Task Marker=bold; fore:#79DBDB
173 | FileNameExtensions=cs
174 | [C/C++ Source Code]
175 | Comment=fore:#6B9F60
176 | Keyword=bold; fore:#B4E1F5
177 | Keyword 2nd=bold; italic; fore:#7B9AD2
178 | Typedefs/Classes=bold; italic; fore:#F87376
179 | String=fore:#61F75F
180 | Number=fore:#F20C0D
181 | Operator=fore:#F651F6
182 | Preprocessor=fore:#F27E0D
183 | Verbatim=fore:#F651F6
184 | Comment Doc=fore:#7F7F7F
185 | Comment Doc Word=bold; fore:#7F7F7F
186 | Comment Doc Error=italic; fore:#F87376
187 | Task Marker=bold; fore:#79DBDB
188 | FileNameExtensions=c; cpp; cxx; cc; h; hpp; hxx; hh; m; mm; idl; inl; odl
189 | [Cmake Script]
190 | Comment=fore:#6B9F60
191 | String=fore:#F877F8; back:#393939
192 | Function=fore:#B0D1F7
193 | Parameter=fore:#EC8577
194 | Variable=fore:#F5663A
195 | While Def=fore:#B0D1F7
196 | For Each Def=fore:#B0D1F7
197 | If Def=fore:#B0D1F7
198 | Macro Def=fore:#B0D1F7
199 | Variable within String=fore:#F5663A; back:#393939
200 | Number=fore:#76F8F8
201 | FileNameExtensions=cmake; ctest
202 | [Coffeescript]
203 | Comment=fore:#6B9F60
204 | String=fore:#6AF768
205 | Preprocessor=fore:#F27E0D
206 | Identifier=bold; fore:#B4E1F5
207 | Operator=fore:#F651F6
208 | Number=fore:#F20C0D
209 | Regex=fore:#81F8B5; back:#544604
210 | [Configuration Files]
211 | Key=fore:#AADAFA
212 | Comment=fore:#6B9F60
213 | Section=bold; fore:#DEDEDE; back:#B8430A; eolfilled
214 | Assignment=fore:#F20C0D
215 | Default Value=fore:#F20C0D
216 | FileNameExtensions=ini; inf; reg; cfg; properties; oem; sif; url; sed; theme
217 | Default=font:Lucida Console; size:+3; fore:#B3B3B3; back:#383838
218 | [CSS Style Sheets]
219 | Comment=fore:#6B9F60
220 | HTML Tag=bold; fore:#B4E1F5
221 | Tag-Class=fore:#D0F548
222 | Tag-ID=fore:#D8F766
223 | Tag-Attribute=italic; fore:#D6F761
224 | Pseudo-Class=fore:#F651F6
225 | Pseudo-Element=fore:#F6509C
226 | CSS Property=fore:#F2460D
227 | String=fore:#6FF76C
228 | Value=fore:#A1C3D3
229 | Operator=fore:#F651F6
230 | Important=bold; fore:#F53C3D
231 | Directive=bold; fore:#DEDEDE; back:#544604
232 | Media=bold; fore:#B4E1F5
233 | Variable=bold; fore:#F2460D
234 | Unknown Pseudo-Class=fore:#F53C3D; back:#7B7B06
235 | Unknown Property=fore:#F53C3D; back:#7B7B06
236 | FileNameExtensions=css
237 | [CSV Prism]
238 | Margins and Line Numbers=fore:#DEDEDE; back:#454545
239 | Column 0=fore:#BAA1EE
240 | Column 1=fore:#A8B8F2
241 | Column 2=fore:#81B1EA
242 | Column 3=fore:#60AEE4
243 | Column 4=fore:#42F4F4
244 | Column 5=fore:#23F351
245 | Column 6=fore:#A2F426
246 | Column 7=fore:#E1F219
247 | Column 8=fore:#F1940E
248 | Column 9=fore:#F42D2E
249 | [D Source Code]
250 | Comment=fore:#6B9F60
251 | Comment Doc=fore:#A7D5F4
252 | Number=fore:#F20C0D
253 | Keyword=bold; fore:#B4E1F5
254 | Keyword 2nd=bold; fore:#B4E1F5
255 | Typedef=italic; fore:#B4E1F5
256 | String=italic; fore:#7B9AD2
257 | Operator=fore:#F651F6
258 | [Dart Source Code]
259 | Keyword=fore:#7B83E9
260 | Keyword 2nd=fore:#7B83E9
261 | Meta-Data=fore:#F27E0D
262 | Class=fore:#7BB6E9
263 | Enumeration=fore:#F27E0D
264 | Function=fore:#F6B05A
265 | Comment=fore:#6B9F60
266 | Comment Doc=fore:#76BA74
267 | Task Marker=bold; fore:#7CBDBD
268 | String=fore:#69F767
269 | TriQ-String=fore:#F38B1A
270 | Verbatim String=fore:#F38B1A
271 | ESC Sequence=fore:#9BDAF1
272 | Label=fore:#6950D3
273 | Number=fore:#F20C0D
274 | Variable=fore:#D27F60
275 | Operator=fore:#6950D3
276 | [Diff Files]
277 | Comment=fore:#6B9F60
278 | Command=bold; fore:#B4E1F5
279 | Source and Destination=fore:#F53C3D; back:#544604; eolfilled
280 | Position Setting=fore:#7B83E9
281 | Line Addition=fore:#A3FA9C; back:#045403; eolfilled
282 | Line Removal=fore:#FBA9B2; back:#7B0506; eolfilled
283 | Line Change=fore:#B5DCF9; back:#2324CE; eolfilled
284 | [Fortran Source Code]
285 | Keyword=bold; fore:#0080FF
286 | Function=bold; italic; fore:#00B3FF
287 | User-Defined Function=bold; italic; fore:#8678FE
288 | Number=fore:#7C00F9
289 | Operator=bold; fore:#0AB456
290 | Label=fore:#FF0080
291 | Continuation=fore:#D8F766
292 | [Go Source Code]
293 | Comment=fore:#6B9F60
294 | Number=fore:#F20C0D
295 | Keyword=bold; fore:#B4E1F5
296 | Keyword 2nd=bold; fore:#B4E1F5
297 | Typedef=italic; fore:#B4E1F5
298 | String=italic; fore:#7B9AD2
299 | Operator=fore:#F651F6
300 | [Inno Setup Script]
301 | Comment=fore:#6B9F60
302 | Keyword=fore:#7B83E9
303 | Parameter=fore:#7B83E9
304 | Section=bold; fore:#B0D1F7
305 | Preprocessor=fore:#F5393A
306 | Inline Expansion=fore:#F876F8
307 | Pascal Comment=fore:#6B9F60
308 | Pascal Keyword=fore:#7B83E9
309 | [Java Source Code]
310 | Comment=fore:#6B9F60
311 | Keyword=bold; fore:#F6B05A
312 | Keyword 2nd=bold; fore:#F6B05A
313 | String=fore:#65F763
314 | Number=fore:#F20C0D
315 | Operator=fore:#F651F6
316 | Comment Doc=fore:#7F7F7F
317 | Comment Doc Word=bold; fore:#7F7F7F
318 | Comment Doc Error=italic; fore:#F87376
319 | Task Marker=bold; fore:#79DBDB
320 | FileNameExtensions=java
321 | [JavaScript]
322 | Comment=fore:#6B9F60
323 | Keyword=bold; fore:#F6B05A
324 | String=fore:#65F763
325 | Regex=fore:#77F8B0; back:#544604
326 | Number=fore:#F20C0D
327 | Operator=fore:#F651F6
328 | Comment Doc=fore:#7F7F7F
329 | Comment Doc Word=bold; fore:#7F7F7F
330 | Comment Doc Error=italic; fore:#F87376
331 | Task Marker=bold; fore:#79DBDB
332 | FileNameExtensions=js; jse; jsm; json; as
333 | [JSON]
334 | Comment=fore:#6B9F60
335 | Keyword=bold; fore:#F7C966
336 | LD Keyword=bold; fore:#F36E58
337 | String=fore:#66F764
338 | Number=fore:#F20C0D
339 | Operator=fore:#F651F6
340 | Property Name=fore:#A9D1F5
341 | ESC Sequence=fore:#3DE966
342 | Parsing Error=fore:#F2F20D; back:#F75C5E; eolfilled
343 | [Julia Script]
344 | Comment=fore:#6B9F60
345 | Number=fore:#F20C0D
346 | Keyword=bold; fore:#7B83E9
347 | Keyword 2nd=bold; fore:#F76EF7
348 | String=fore:#F57148
349 | Operator=fore:#F6804D
350 | Type Operator=fore:#F766F7
351 | Identifier=fore:#B1D3F7
352 | Symbol=fore:#CCA941
353 | Macro Def=fore:#7BB6E9
354 | Comment Doc=fore:#7F7F7F
355 | Literal String=fore:#F651F6
356 | Command=bold; fore:#8E9BED
357 | Annotation=fore:#F27E0D
358 | Parsing Error=fore:#F2F20D; back:#F75C5E; eolfilled
359 | [KiXtart Script]
360 | Keyword=bold; fore:#6285E4
361 | Function=fore:#F761F7
362 | Macro=fore:#F2B50D
363 | Comment=fore:#6B9F60
364 | String=italic; fore:#717171
365 | Operator=fore:#F53C3D
366 | Number=fore:#65F7F7
367 | Variable=fore:#D27F60
368 | [Kotlin Source Code]
369 | Keyword=fore:#7B83E9
370 | Annotation=fore:#F27E0D
371 | Class=fore:#7BB6E9
372 | Interface=bold; fore:#67A9E5
373 | Enumeration=fore:#F27E0D
374 | Function=fore:#F6B05A
375 | Comment=fore:#6B9F60
376 | Comment Doc=fore:#7CBDBD
377 | Comment Doc Word=fore:#7CBDBD
378 | Task Marker=bold; fore:#79DBDB
379 | String=fore:#65F763
380 | Verbatim String=fore:#F38B1A
381 | ESC Sequence=fore:#9BDAF1
382 | Back Ticks=fore:#D27F60
383 | Label=fore:#6950D3
384 | Number=fore:#F20C0D
385 | Variable=fore:#D27F60
386 | Operator=fore:#F651F6
387 | [LaTeX Files]
388 | Command=fore:#7B83E9
389 | Comment=fore:#6B9F60
390 | Math=fore:#F20C0D
391 | Special Char=fore:#F6F656
392 | Tag=fore:#7B83E9
393 | Verbatim Segment=fore:#979797
394 | Error=fore:#F2F20D; back:#F75C5E
395 | FileNameExtensions=tex; latex; sty
396 | [Lua Script]
397 | Comment=fore:#6B9F60
398 | Number=fore:#76F8F8
399 | Keyword=fore:#B0D1F7
400 | Basic Functions=fore:#B0D1F7
401 | String, Table & Math Functions=fore:#B0D1F7
402 | Input, Output & System Facilities=fore:#B0D1F7
403 | String=fore:#F651F6
404 | Literal String=fore:#F651F6
405 | Preprocessor=fore:#F27E0D
406 | Label=fore:#F8F876
407 | FileNameExtensions=lua
408 | [Makefiles]
409 | Comment=fore:#6B9F60
410 | Identifier=fore:#89ABEC
411 | Preprocessor=fore:#F27E0D
412 | FileNameExtensions=mak; make; mk; dsp; msc; msvc
413 | [Markdown]
414 | Header 1=bold; fore:#272702; back:#848DCF; eolfilled
415 | Header 2=bold; fore:#A8CCDA; back:#1F6AB4; eolfilled
416 | Header 3=bold; fore:#A8CCDA; back:#154B7F; eolfilled
417 | Header 4=bold; fore:#A8CCDA; eolfilled
418 | Header 5=bold; fore:#99B9CD; eolfilled
419 | Header 6=bold; fore:#85A5BF; eolfilled
420 | Pre Char=fore:#B0D1F7
421 | Unordered List=bold; fore:#7BB6E9
422 | Ordered List=bold; fore:#7BB6E9
423 | Block Quote=fore:#B0D1F7
424 | Link=fore:#7B83E9
425 | Code=fore:#B0D1F7; back:#141414
426 | [MATLAB]
427 | Comment=fore:#6B9F60
428 | Number=fore:#F27E0D
429 | Keyword=bold; fore:#B0D1F7
430 | String=fore:#F877F8
431 | [Nim Source Code]
432 | Comment=fore:#6B9F60
433 | Keyword=bold; fore:#5F8E5F
434 | String Double Quoted=fore:#D7598F
435 | String Single Quoted=fore:#D7598F
436 | String Triple Double Quotes=fore:#D7598F
437 | String Triple Single Quotes=fore:#D7598F
438 | Number=fore:#97A9DD
439 | Operator=bold; fore:#AEAEAE
440 | Function name=fore:#AEAEAE
441 | Parsing Error=italic; fore:#F2F20D; back:#F75C5E
442 | [NSIS Script]
443 | Comment=fore:#6B9F60
444 | String=fore:#979797; back:#393939
445 | Function=fore:#96B8EF
446 | Variable=fore:#F5663A
447 | Variable within String=fore:#F5663A; back:#393939
448 | Number=fore:#F20C0D
449 | Constant=fore:#F2940D
450 | Section=fore:#96B8EF
451 | Sub Section=fore:#96B8EF
452 | Section Group=fore:#96B8EF
453 | Function Definition=fore:#96B8EF
454 | PageEx=fore:#96B8EF
455 | If Definition=fore:#96B8EF
456 | Macro Definition=fore:#96B8EF
457 | [Pascal Source Code]
458 | Comment=fore:#6B9F60
459 | Keyword=bold; fore:#F876F8
460 | String=fore:#61F75F
461 | Number=fore:#F20C0D
462 | Inline Asm=fore:#7B83E9
463 | Preprocessor=fore:#F20DF2
464 | FileNameExtensions=pas; dpr; dpk; dfm; inc; pp
465 | [Perl Script]
466 | Comment=fore:#6B9F60
467 | Keyword=bold; fore:#F8B076
468 | String Double Quoted=fore:#61F75F
469 | String Single Quoted=fore:#64F762
470 | Number=fore:#F20C0D
471 | Scalar $var=fore:#B4E1F5
472 | Array @var=fore:#89ABEC
473 | Hash %var=fore:#F651F6
474 | Symbol Table *var=fore:#A1C3D3
475 | Regex /re/ or m{re}=fore:#70F7AD; back:#544604
476 | Substitution s/re/ore/=fore:#88F9B7; back:#544604
477 | Back Ticks=fore:#F46027; back:#544604
478 | Here-Doc (Delimiter)=fore:#DBF872
479 | Here-Doc (Single Quoted, q)=fore:#D6F75F
480 | Here-Doc (Double Quoted, qq)=fore:#D7F762
481 | Here-Doc (Back Ticks, qx)=fore:#F46027; back:#544604
482 | Single Quoted String (Generic, q)=fore:#75F872
483 | Double Quoted String (qq)=fore:#61F75F
484 | Back Ticks (qx)=fore:#F46027; back:#544604
485 | Regex (qr)=fore:#88F9B7; back:#544604
486 | Array (qw)=fore:#89ABEC
487 | Prototype=fore:#F876F8; back:#270227
488 | Format Identifier=bold; fore:#DBF873; back:#544604
489 | Format Body=fore:#DBF872; back:#544604
490 | POD (Common)=fore:#F6B05A; back:#3D3D03; eolfilled
491 | POD (Verbatim)=fore:#F6B05A; back:#3D3D03; eolfilled
492 | Data Section=fore:#F6B05A; back:#3D3D03; eolfilled
493 | Parsing Error=fore:#F53C3D; back:#7B7B06
494 | FileNameExtensions=pl; pm; cgi; pod
495 | [PowerShell Script]
496 | Comment=fore:#6B9F60
497 | Keyword=bold; fore:#F8B076
498 | String=fore:#61F75F
499 | Number=fore:#F20C0D
500 | Variable=fore:#B4E1F5
501 | Cmdlet=fore:#F8B076; back:#544604
502 | Alias=bold; fore:#B4E1F5
503 | FileNameExtensions=ps1; psd1; psm1
504 | [Python Script]
505 | Comment=fore:#6B9F60
506 | Keyword=bold; fore:#AECDF6
507 | Keyword 2nd=fore:#AECDF6
508 | Attribute=fore:#C2C2C2
509 | String Single Quoted=fore:#F877F8
510 | String Double Quoted=fore:#F877F8
511 | String Triple Single Quotes=fore:#92C339
512 | String Triple Double Quotes=fore:#6B9F60
513 | Decorator=fore:#F3B819
514 | Number=fore:#F2460D
515 | Operator=bold; fore:#F9F988
516 | Function Name=fore:#F988F9
517 | Class Name=fore:#F988F9
518 | FileNameExtensions=py; pyw
519 | [Registry Files]
520 | Comment=fore:#6B9F60
521 | String=fore:#62F760
522 | Value Type=bold; fore:#B0D1F7
523 | Hex=fore:#EF7478
524 | Added Key=bold; fore:#DEDEDE; back:#B8430A; eolfilled
525 | Deleted Key=fore:#F20C0D
526 | Escaped=bold; fore:#A4B4B4
527 | GUID in Key Path=fore:#E6C07B
528 | Parameter=fore:#79EDDB
529 | [Resource Script]
530 | Comment=fore:#6B9F60
531 | Keyword=bold; fore:#B4E1F5
532 | String=fore:#49F548
533 | Number=fore:#F20C0D
534 | Operator=fore:#B4E1F5
535 | Preprocessor=fore:#F27E0D
536 | Comment Doc=fore:#7F7F7F
537 | Comment Doc Word=bold; fore:#7F7F7F
538 | Comment Doc Error=italic; fore:#F87376
539 | Task Marker=bold; fore:#79DBDB
540 | FileNameExtensions=rc; rc2; rct; rh; r; dlg
541 | [R-S-SPlus Statistics Code]
542 | Comment=fore:#6B9F60
543 | Keyword=bold; fore:#B4E1F5
544 | Base Package Functions=bold; fore:#F87477
545 | Other Package Functions=bold; fore:#F877F8
546 | Number=fore:#7B83E9
547 | String=italic; fore:#7B9AD2
548 | Operator=bold; fore:#F651F6
549 | Infix=fore:#F988F9
550 | Infix EOL=fore:#F2460D; back:#402040; eolfilled
551 | [Ruby Script]
552 | Comment=fore:#6B9F60
553 | Keyword=fore:#B0D1F7
554 | Number=fore:#76F8F8
555 | String=fore:#F27E0D
556 | Class Name=fore:#7B83E9
557 | Function Name=fore:#77F8F8
558 | POD=fore:#8FF98A; back:#022701; eolfilled
559 | Regex=fore:#DEDEDE; back:#022B01
560 | Symbol=fore:#CCA941
561 | Module Name=fore:#F75EF7
562 | Instance Var=fore:#F650C9
563 | Class Var=fore:#BEB7F2
564 | Data Section=fore:#F9888C; back:#271802; eolfilled
565 | FileNameExtensions=rb; ruby; rbw; rake; rjs; Rakefile
566 | [Rust Source Code]
567 | Keyword=bold; fore:#89E973
568 | Build-In Type=fore:#F65490
569 | Other Keyword=italic; fore:#7CE665
570 | Number=fore:#979797
571 | Comment=fore:#6B9F60
572 | String=fore:#E04D4D
573 | Operator=fore:#979797
574 | Macro Definition=fore:#B4E1F5
575 | Rust Lifetime=fore:#F651F6
576 | Parsing Error=fore:#141414; back:#F3191A
577 | Byte String=fore:#404040
578 | [Shell Script]
579 | Comment=fore:#6B9F60
580 | Number=fore:#76F8F8
581 | Keyword=fore:#7B83E9
582 | String Double Quoted=fore:#76F8F8
583 | String Single Quoted=fore:#F876F8
584 | Scalar=fore:#F8F876
585 | Parameter Expansion=fore:#F8F876; back:#636305
586 | Back Ticks=fore:#F20C80
587 | Here-Doc (Single Quoted, q)=fore:#76F8F8
588 | FileNameExtensions=sh
589 | [SQL Query]
590 | Comment=fore:#6B9F60
591 | Keyword=bold; fore:#73B9FF
592 | Value Type=bold; fore:#CFE3FA
593 | String=fore:#8C8C8C
594 | Identifier=fore:#DCDCDC
595 | Quoted Identifier=fore:#00CCCC
596 | Number=fore:#B973FF
597 | Operator=bold; fore:#EC880D
598 | FileNameExtensions=sql
599 | [Tcl Script]
600 | Comment=fore:#6B9F60
601 | Keyword=fore:#7B83E9
602 | Number=fore:#76F8F8
603 | String=fore:#76F8F8
604 | Identifier=fore:#F876F8
605 | Substitution=fore:#F5393A
606 | Modifier=fore:#F20DF2
607 | FileNameExtensions=tcl; itcl
608 | [TOML Config]
609 | Keyword=bold; fore:#F20C80
610 | Comment=fore:#6B9F60
611 | Section=bold; fore:#DEDEDE; back:#544604; eolfilled
612 | Key=bold; fore:#A9BDBD
613 | Assignment=bold; fore:#D50A0B
614 | Value=fore:#CDCDCD
615 | Number=fore:#8C99ED
616 | Date-Time=fore:#F766F7
617 | String=italic; fore:#9C9C9C
618 | Parsing Error=fore:#F2F20D; back:#F75C5E; eolfilled
619 | [VBScript]
620 | Comment=fore:#6B9F60
621 | Keyword=bold; fore:#F651F6
622 | String=fore:#67F765
623 | Number=fore:#F20C0D
624 | [VHDL]
625 | Comment=fore:#6B9F60
626 | Number=fore:#F20C0D
627 | String=fore:#6FF76C
628 | Operator=fore:#F651F6
629 | Keyword=bold; fore:#B4E1F5
630 | Standard Operator=bold; fore:#B4E1F5
631 | Standard Type=fore:#F27E0D
632 | [Visual Basic]
633 | Comment=fore:#6B9F60
634 | Keyword=bold; fore:#F651F6
635 | String=fore:#67F765
636 | Number=fore:#F20C0D
637 | Preprocessor=fore:#F2960D
638 | [Web Source Code]
639 | HTML Tag=fore:#DBF873
640 | HTML Unknown Tag=fore:#F53C3D; back:#7B7B06
641 | HTML Attribute=fore:#F2460D
642 | HTML Unknown Attribute=fore:#F53C3D; back:#7B7B06
643 | HTML Value=fore:#A1C3D3
644 | HTML String=fore:#A1C3D3
645 | HTML Other Inside Tag=fore:#A1C3D3
646 | HTML Comment=fore:#6B9F60
647 | HTML Entity=fore:#F651F6
648 | XML Identifier=bold; fore:#E96EE1
649 | SGML=fore:#E96EE1
650 | CDATA=fore:#999999
651 | ASP Start Tag=bold; fore:#B0D1F7
652 | PHP Start Tag=bold; fore:#B0D1F7
653 | PHP Comment=fore:#6B9F60
654 | PHP Keyword=bold; fore:#F6B05A
655 | PHP String=fore:#65F763
656 | PHP Simple String=fore:#63F761
657 | PHP Number=fore:#F20C0D
658 | PHP Operator=fore:#F651F6
659 | PHP Variable=italic; fore:#B0D1F7
660 | PHP String Variable=italic; fore:#B0D1F7
661 | PHP Complex Variable=italic; fore:#B0D1F7
662 | JS Comment=fore:#6B9F60
663 | JS Keyword=bold; fore:#F6B05A
664 | JS String=fore:#65F763
665 | JS Regex=fore:#77F8B0; back:#544604
666 | JS Number=fore:#F20C0D
667 | JS Symbols=fore:#F651F6
668 | ASP JS Comment=fore:#6B9F60
669 | ASP JS Keyword=bold; fore:#F6B05A
670 | ASP JS String=fore:#65F763
671 | ASP JS Regex=fore:#77F8B0; back:#544604
672 | ASP JS Number=fore:#F20C0D
673 | ASP JS Symbols=fore:#F651F6
674 | VBS Comment=fore:#6B9F60
675 | VBS Keyword=bold; fore:#F651F6
676 | VBS String=fore:#67F765
677 | VBS Number=fore:#F20C0D
678 | ASP VBS Comment=fore:#6B9F60
679 | ASP VBS Keyword=bold; fore:#F651F6
680 | ASP VBS String=fore:#67F765
681 | ASP VBS Number=fore:#F20C0D
682 | FileNameExtensions=html; htm; asp; aspx; shtml; htd; xhtml; php; php3; phtml; htt; cfm; tpl; dtd; hta; htc
683 | [XML Document]
684 | XML Tag=fore:#E96EE1
685 | XML Attribute=fore:#F7A163
686 | XML Value=fore:#A2B7E7
687 | XML String=fore:#A2B7E7
688 | XML Other Inside Tag=fore:#A2B7E7
689 | XML Comment=fore:#6B9F60
690 | XML Entity=fore:#F651F6
691 | XML Identifier=bold; fore:#E96EE1
692 | SGML=fore:#E96EE1
693 | CDATA=fore:#999999
694 | FileNameExtensions=xml; xsl; rss; svg; xul; xsd; xslt; axl; rdf; xaml; vcproj
695 | [YAML]
696 | Comment=fore:#6B9F60
697 | Identifier=bold; fore:#B4E1F5
698 | Keyword=fore:#F770F7
699 | Number=fore:#F27E0D
700 | Reference=fore:#70F7F7
701 | Document=bold; fore:#141414; back:#AECDF6; eolfilled
702 | Text=fore:#B7B7B7
703 | Error=bold; italic; fore:#141414; back:#F20C0D; eolfilled
704 | Operator=fore:#B6D8E1
705 |
--------------------------------------------------------------------------------
/FilmGrain+.avsi:
--------------------------------------------------------------------------------
1 | #######################################################
2 | ### ###
3 | ### ###
4 | ### FilmGrain+ v2.7 (06-01-2025) ###
5 | ### ###
6 | ### by Dogway (Jose Linares) ###
7 | ### ###
8 | ### ###
9 | ### https://forum.doom9.org/showthread.php?t=182881 ###
10 | ### ###
11 | ### ###
12 | #######################################################
13 | ###
14 | ### Accurate and performant synthetic film grain filter. Y/YUV at any bitdepth.
15 | ###
16 | ### This is a grain restoration filter therefore film and lens aberrations like;
17 | ### vignette, veiling, lens blur, light wrap, bokeh, halation, dilation, dust & scratches, etc, aren't emulated.
18 | ###
19 | ### For convenience 'preblur' is included but if you need a superior preblur
20 | ### or any other effect, set 'preblur=0.0' and apply them prior to this filter.
21 | ###
22 | ###
23 | ### Dependencies: > ExTools
24 | ### ResizersPack
25 | ### GradePack
26 | ### AddGrainC
27 | ### vsTCanny
28 | ### GradePack (for emulsion>0 or show=2)
29 | ### TransformsPack (for fast=false)
30 | ###
31 | ### Examples:
32 | ###
33 | ### FilmGrainPlus(str=0.2,size=1.5) # Good example for digital 1080p films, ideally at 16-bit
34 | ### FilmGrainPlus(str=0.8,size=2.0,sharpness=0.3,temp=0.1) # Example for UHD, not only size, but also strength should be raised
35 | ###
36 | ### * Note: To speed up the filter for UHD, you can set strc=0, temp=0.0 and mode="gamma" ('gamma' is the default anyway)
37 | ###
38 | ###
39 | ### Function Definition:
40 | ### (
41 | ### clip,
42 | ### float str=1.0 (0.0 to 5.0),
43 | ### float "size"=1.0 (0.0 to 2.0),
44 | ### float "sharpness"=0.9 (0.0 to 1.0),
45 | ### float "temp"=0.0 (0.0 to 1.0),
46 | ### float "lo"=1.0 (0.0 to 2.0),
47 | ### float "mid"=1.0 (0.0 to 2.0),
48 | ### float "hi"=1.0 (0.0 to 2.0),
49 | ### string "preset"="--" ("--"/ "8mm"/ "16mm"/ "35mm"/ "--"/ "EXR 5245 50D"/ "EXR 5248 100T"/ "EXR 5293 200T"/ "EXR 5298 500T"/ "Vision 5274 200T"/ "Vision 5246 250D"/ "Vision 5277 320T"/ "Vision 5279 500T"/ "Vision2 5201 50D"/ "Vision2 5212 100T"/ "Vision2 5217 200T"/ "Vision2 5218 500T"/ "Vision3 5203 50D"/ "Vision3 5213 200T"/ "Vision3 5207 250D"/ "Vision3 5219 500T"/ "FX 214 480D"/ "--"/ "Fuji 8510 64T"/ "Fuji 8520 64D"/ "Fuji 8530 125T"/ "Fuji 8550 250T"/ "Fuji 8560 250D"/ "Fuji 8570 500T"/ "Super F 8522 64D"/ "Super F 8532 125T"/ "Super F 8552 250T"/ "Super F 8562 250D"/ "Super F 8582 400T"/ "Super F 8572 500T"/ "EternaV 8543 160T"/ "Eterna 8563 250D"/ "Eterna 8583 400T"/ "Eterna 8573 500T"/ "Reala 8592 500D"/ "--"/ "FilmGrain"/ "GrainFactory3"/ "DigitalNoise"),
50 | ### string "mode"="gamma" ("gamma"/ "linear"/ "log"),
51 | ### float "bump"=0.0 (0.0 to 1.0),
52 | ### float "emulsion"=0.0 (0.0 to 1.0),
53 | ### float "skin"=1.0 (0.0 to 1.0),
54 | ### float "preblur"=1.0 (0.0 to 2.0),
55 | ### float "conv"=0.0 (0.0 to 1.0),
56 | ### bool "s16mm"=false,
57 | ### bool "PTH"=true,
58 | ### bool "deterministic"=true,
59 | ### bool "fast"=true,
60 | ### float "strc"=0.1 (0.0 to 1.0),
61 | ### int "show"=0 (0 to 2)
62 | ### )
63 | ###
64 | ###
65 | function FilmGrainPlus(clip a, \
66 | float "str", float "size", float "sharpness", float "temp", \
67 | float "lo", float "mid", float "hi", \
68 | string "preset", string "mode", \
69 | float "bump", float "emulsion", float "skin", float "preblur", \
70 | bool "s16mm", bool "PTH", bool "deterministic",bool "fast", \
71 | val "conv", float "strc", bool "tv_range", int "show") {
72 |
73 | w = width (a)
74 | h = height(a)
75 | isy = isy(a)
76 | is44 = is444(a)
77 | bi = BitsPerComponent(a)
78 | fs = propNumElements (a,"_ColorRange") > 0 ? \
79 | propGetInt (a,"_ColorRange") == 0 : false
80 | isUHD = w > 2599 || h > 1499
81 |
82 | # The naming convention follows; Series, Film Stock number, ASA/ISO, White Point balance (Daylight -5500- / Tungsten -3200K-)
83 | # 'FX214' is a special Kodak film stock aimed at bluescreens for VFX composition, hence grain is low but at the cost of loss of sharpness
84 | # Many of the Kodak film stocks have 16mm counterparts, they are labelled in the 7000 series, so for example 7248 is the 16mm version of 5248
85 | # Sometimes 'clean' stocks like 5248 or 5219 are "pushed" one or more stops making the look more grainy and contrasty.
86 | preset= Default( preset, "--" )
87 | pr = preset == "" ? 0 : \
88 | preset == "--" ? 0 : \
89 | preset == "8mm" ? 1 : \
90 | preset == "16mm" ? 2 : \
91 | preset == "35mm" ? 3 : \
92 | preset == "--" ? 0 : \
93 | preset == "EXR 5245 50D" || FindStr(preset,"5245")>0 ? 4 : \
94 | preset == "EXR 5248 100T" || FindStr(preset,"5248")>0 ? 5 : \
95 | preset == "EXR 5293 200T" || FindStr(preset,"5293")>0 ? 6 : \
96 | preset == "EXR 5298 500T" || FindStr(preset,"5298")>0 ? 7 : \
97 | preset == "Vision 5274 200T" || FindStr(preset,"5274")>0 ? 8 : \
98 | preset == "Vision 5246 250D" || FindStr(preset,"5246")>0 ? 9 : \
99 | preset == "Vision 5277 320T" || FindStr(preset,"5277")>0 ? 10 : \
100 | preset == "Vision 5279 500T" || FindStr(preset,"5279")>0 ? 11 : \
101 | preset == "Vision2 5201 50D" || FindStr(preset,"5201")>0 ? 12 : \
102 | preset == "Vision2 5212 100T" || FindStr(preset,"5212")>0 ? 13 : \
103 | preset == "Vision2 5217 200T" || FindStr(preset,"5217")>0 ? 14 : \
104 | preset == "Vision2 5218 500T" || FindStr(preset,"5218")>0 ? 15 : \
105 | preset == "Vision3 5203 50D" || FindStr(preset,"5203")>0 ? 16 : \
106 | preset == "Vision3 5213 200T" || FindStr(preset,"5213")>0 ? 17 : \
107 | preset == "Vision3 5207 250D" || FindStr(preset,"5207")>0 ? 18 : \
108 | preset == "Vision3 5219 500T" || FindStr(preset,"5219")>0 ? 19 : \
109 | preset == "FX 214 480D" || FindStr(preset, "214")>0 ? 20 : \
110 | preset == "--" ? 0 : \
111 | preset == "Fuji 8510 64T" || FindStr(preset,"8510")>0 ? 21 : \
112 | preset == "Fuji 8520 64D" || FindStr(preset,"8520")>0 ? 22 : \
113 | preset == "Fuji 8530 125T" || FindStr(preset,"8530")>0 ? 23 : \
114 | preset == "Fuji 8550 250T" || FindStr(preset,"8550")>0 ? 24 : \
115 | preset == "Fuji 8560 250D" || FindStr(preset,"8560")>0 ? 25 : \
116 | preset == "Fuji 8570 500T" || FindStr(preset,"8570")>0 ? 26 : \
117 | preset == "Super F 8522 64D" || FindStr(preset,"8522")>0 ? 27 : \
118 | preset == "Super F 8532 125T" || FindStr(preset,"8532")>0 ? 28 : \
119 | preset == "Super F 8552 250T" || FindStr(preset,"8552")>0 ? 29 : \
120 | preset == "Super F 8562 250D" || FindStr(preset,"8562")>0 ? 30 : \
121 | preset == "Super F 8582 400T" || FindStr(preset,"8582")>0 ? 31 : \
122 | preset == "Super F 8572 500T" || FindStr(preset,"8572")>0 ? 32 : \
123 | preset == "EternaV 8543 160T" || FindStr(preset,"8543")>0 ? 33 : \
124 | preset == "Eterna 8563 250D" || FindStr(preset,"8563")>0 ? 34 : \
125 | preset == "Eterna 8583 400T" || FindStr(preset,"8583")>0 ? 35 : \
126 | preset == "Eterna 8573 500T" || FindStr(preset,"8573")>0 ? 36 : \
127 | preset == "Reala 8592 500D" || FindStr(preset,"8592")>0 ? 37 : \
128 | preset == "--" ? 0 : \
129 | preset == "FilmGrain" ? 38 : \
130 | preset == "GrainFactory3" ? 39 : \
131 | preset == "DigitalNoise" ? 40 : \
132 | Assert( false, "FilmGrain+: 'Preset' choice is invalid" )
133 |
134 | strD = Defined( str )
135 | strcD = Defined( strc )
136 | szD = Defined( size )
137 | shrpD = Defined( sharpness )
138 | pblD = Defined( preblur )
139 |
140 | # Presets at 1080p: Default 8mm 16mm 35mm | 5245 5248 5293 5298 | 5274 5246 5277 5279 | 5201 5212 5217 5218 | 5203 5213 5207 5219 FX214 | 8510 8520 8530 8550 8560 8570 | 8522 8532 8552 8562 8582 8572 | 8543 8563 8583 8573 8592 | FilmGrain GF3 DigitalNoise
141 | str = Default( str , Select ( pr, 0.2 , 7.0, 2.0, 0.8, 0.1, 1.0, 1.0, 1.0, 0.4, 0.9, 1.0, 1.4, 1.0, 1.0, 0.2, 0.1, 1.0, 1.0, 1.0, 0.1, 0.3, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.4, 1.0, 1.0))
142 | sz = Default( size , Select ( pr, w/1920., 2.0, 1.7, 1.0, 0.8, 1.8, 1.0, 1.0, 0.4, 0.2, 1.0, 1.9, 1.0, 1.0, 1.4, 1.3, 1.0, 1.0, 1.0, 0.5, 0.8, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.5, 1.0, 1.0))
143 | shrp = Default( sharpness, Select ( pr,szD?-0.87*sz+2:0.93-0.244*str, 0.6, 0.8, 0.8, 0.8, 0.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.9, 1.0, 1.0, 1.0, 1.0, 1.0, 0.8, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.9, 0.5, 1.0))
144 | temp = Default( temp , Select ( pr,max((0.147*str-0.073),0)+0.06, 0.2, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.1, 0.0))
145 | strc = Default( strc , Select ( pr, str*0.5, 0.6, 0.1, 0.1, 0.0, 1.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 0.3, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0))
146 | conv = Default( conv, false ) # 0.0 - 1.0. Set to true or set strength for the convolution to "break" edges
147 | bmp = Default( bump, 0.0 ) # 0.0 - 1.0. Raise to make the grain have a 3D volumetric effect
148 | skin = Default( skin, 1.0 ) # 0.0 - 1.0. Lower to reduce the effect of grain on faces. Assumes source is YCbCr format in Rec709 space
149 | eml = Default( emulsion, 0.0 ) # 0.0 - 1.0. Raise to mimic the emulsion artifacts common in old film stocks
150 | pbl = Default( preblur, 1.0 ) # 0.0 - 2.0. Multiplier for internal blur. Lower or disable by setting it to 0.0 if coming from an upscale for example
151 | sxmm = Default( s16mm, false) # Enable to choose the 16mm version of the film stock in the Kodak 7000 series
152 | pth = Default( PTH, true) # Path to White for chroma grain. Disable if you run out of performance
153 | det = Default( deterministic,true) # Set to false when rendering/encoding. This is to have a fixed preview of the look while modelling the grain
154 | fast = Default( fast, true) # Generally with 'true' an overlay is applied which is faster. With 'false' you do get some natural convolution from AddGrainC. Use it when high 'str' or 'size' to blend in grain better
155 | md = Default( mode, "gamma") # Add grain in "log", "linear" or "gamma" space
156 | sh = Default( show, 0 ) # 1. Show grain matte centered at 126 if tv_range=true or 128 otherwise, 2. Show output with settings overlay
157 | tv = Default( tv_range, !fs)
158 | ls = md=="log"
159 | ln = md=="linear"
160 | bmp = bmp+1
161 | skn = 1-skin
162 | strc = strc==-1.0 ? str*0.5 : strc
163 | ygrey = tv ? 126 : 128
164 | rnghlf= ex_bs( ygrey, 8, bi, fulls=false, flt=true)
165 | MX = ex_bs( 255, 8, bi, fulls=true, flt=true)
166 | rmax = bi==32 ? "" : bi > 12 ? "range_max /" : string(1./MX)+" *"
167 |
168 | lo = Default( lo, ls ? 1.5 : ln ? 0.5 : 0.8) # 0.0 - 2.0, non linear strength multiplier for dark areas
169 | mi = Default( mid,ls ? 1.0 : ln ? 1.0 : 1.0) # 0.0 - 2.0, non linear strength multiplier for grey areas
170 | hi = Default( hi, ls ? 0.7 : ln ? 1.2 : 1.0) # 0.0 - 2.0, non linear strength multiplier for light areas
171 |
172 | # Presets params auto-scale for sources other than 1080p (you can override them)
173 | istr = str str = (pr != 0 && !strD ? str * ( 0.409*w*0.001 + 0.214 ) : str ) * (sxmm ? 1.25 : 1) / (bmp>1.0 ? sqrt(bmp) : 1.0)
174 | istrc = strc strc = (pr != 0 && !strcD ? strc * ( 0.409*w*0.001 + 0.214 ) : strc) * (sxmm ? 1.25 : 1) / (bmp>1.0 ? sqrt(bmp) : 1.0)
175 | ishrp = shrp shrp = (pr != 0 && !shrpD ? clamp(shrp * ( -0.347*w*0.001 + 1.667 ),0,1) : shrp) * (sxmm ? 0.90 : 1)
176 | isz = sz sz = (pr != 0 && !szD ? sz * ( 0.173*w*0.001 + 0.667 ) : sz )
177 | sz = sxmm ? 1.5*sz+0.5 : sz
178 |
179 | Assert(IsVersionOrGreater(3,7,3), "FilmGrain+: Update AviSynth+ version")
180 |
181 | Chr = strc > 0.0 && !isy
182 | Chr32 = Chr ? 3 : 2
183 | crs = ((1- shrp) *3)+1
184 | shrpL = 2-( shrp *2)
185 | shrpC = max(2-((shrp-0.3) *2),0)
186 | sz = max(1.0,4-sz*1.5)
187 | binom = sqrt(crs)/2.*sqrt(2)
188 |
189 | if (!fast) {
190 | blk = a. ConvertBits(8,dither=-1)
191 | blk = blk.ConvertFormat(sz,fmt_out="YCbCr444",cs_out="",EOTFi="",kernel="Bilinear",tv_in=tv,gpuid=-1)
192 | } else {
193 | blk = a. BlankClip(width=nmod(w*sz),height=nmod(h*sz),pixel_type=isy||!Chr?Undefined():"YUV444P"+string(bi>16?"S":bi),color_yuv=Eval(ColortoHex(Format("[{ygrey},128,128]"))),channels=0)
194 | }
195 |
196 | blk.AddGrainC(str*100*sz, strc*100*sz, constant=false, seed=det?17:-1)
197 | !fast ? ex_makediff(blk,last,UV=Chr32) : nop()
198 | # Anti-moiree + 'sharpness' support blur
199 | crs != 1.0 ? vsTCanny(binom,mode=-1,u=2,v=2) : removegrain(12,0)
200 | # Volumetric grain
201 | bmp > 1.0 ? ex_lut(Format("x[-1,1] x - {bmp} * x +"), UV=2) : last
202 |
203 | # Back to original size, Jab and blur chroma + adds temporal coherence
204 | if (Chr && !is44) {
205 |
206 | is22 = is422(a) ? 1 : 2
207 | Y = ExtractY().BicubicResize(w, h, b=shrpL,c=(1.0-shrpL)/2.)
208 | Y = temp > 0.0 ? Merge(Y,Y.TemporalSoften(1,255,0,255,2),temp/2 ) : Y
209 | U = ExtractU().BicubicResize(w/2,h/is22,b=shrpL,c=(1.0-shrpL)/2.)
210 | V = ExtractV().BicubicResize(w/2,h/is22,b=shrpC,c=(1.0-shrpC)/2.) # Red channel is typically blurrier
211 | eml>0 && sh==1 ? last : CombinePlanes(Y,U,V, planes="YUV", pixel_type="YUV4"+(is422(a)?"22":"20")+"P"+string(bi))
212 |
213 | } else { # For performance reasons in 444 red channel is not blurred
214 | BicubicResize(w,h, b=shrpL,c=(1.0-shrpL)/2.)
215 | temp > 0.0 ? last.MergeLuma( TemporalSoften(1,255,0,255,2),temp/2 ) : last
216 | is44 ? last : ConvertFormat(fmt_out="YCbCr4"+(is422(a)?"22":"20"),cs_out="",EOTFi="",kernel="RobiSharp",tv_in=tv,gpuid=-1)
217 | }
218 |
219 |
220 | if (sh==1) {
221 |
222 | fast || Chr ? last : ConvertBits(bi)
223 |
224 | if (eml>0 && !isy) {
225 |
226 | HSS = is422(a) || is44 ? 2 : 4
227 | WSS = is44 ? 2 : 4
228 | Y = VarExist("Y") ? Y : ExtractY()
229 | U = VarExist("U") ? U : ExtractU()
230 | V = VarExist("V") ? V : ExtractV()
231 | sample = PadResize(Y,w/16,h/16).TemporalSoften(1,255,0,255,2)
232 | UP = BilinearResize(sample, w/WSS, h/HSS)
233 |
234 | stains = ex_blend(UP,UP.FlipHorizontal(),mode="subtract",tv_range=false).ex_inpand()
235 | UVer = StackVertical (stains,stains)
236 | UHor = StackHorizontal(UVer, UVer)
237 | Unew = ex_lutxy(U,UHor,Format("x y {eml} * -"))
238 | CombinePlanes(Y,Unew,V, planes="YUV", sample_clip=a)
239 | }
240 |
241 | } else {
242 |
243 | fast || Chr ? last : ConvertBits(bi)
244 |
245 | expr = binom*(pow(str,0.318)-0.61)*(pow(w/1920.-0.46,0.4)+0.2)*pbl
246 | pbl = expr > 0.35 ? a.vsTCanny(expr ,mode=-1,u=Chr32,v=Chr32) : \
247 | pblD ? sqrt(pbl)/2.*sqrt(2) > 0.35 ? a.vsTCanny(sqrt(pbl)/2.*sqrt(2),mode=-1,u=Chr32,v=Chr32) : a : a
248 |
249 |
250 | # 'frei-chen' with 9 and 'conv' for lo and hi respectively
251 | cn = isBool(conv) ? conv ? 1-str*0.1 : 1.0 : clamp(1-conv*0.8,0.2,1.0)
252 | cop = -0.625*cn + 1.125
253 | clo = ex_bs( 9, 8, bi, fulls=true, flt=true)
254 | chi = ex_bs(cn*100, 8, bi, fulls=true, flt=true)
255 | norm = 1. / (chi - clo)
256 |
257 | th1st = ex_bs( 45, 8, bi, tv_in=true, tv_out=tv)
258 | th2st = ex_bs( 85, 8, bi, tv_in=true, tv_out=tv)
259 | th3st = ex_bs( 140, 8, bi, tv_in=true, tv_out=tv)
260 | th4st = ex_bs( 200, 8, bi, tv_in=true, tv_out=tv)
261 |
262 | th21st = MX / (th2st - th1st)
263 | th43st = MX / (th3st - th4st)
264 |
265 | SEG = lo!=1.0 || mi!=1.0 || hi!=1.0
266 |
267 | lop = bi > 12 ? Format("{lo} * range_max /") : string(lo / MX)+" *"
268 | mip = bi > 12 ? Format("{mi} * range_max /") : string(mi / MX)+" *"
269 | hip = bi > 12 ? Format("{hi} * range_max /") : string(hi / MX)+" *"
270 | rh = string(sqrt((0.501960785-(tv?0.062745098:0))*0.3))
271 |
272 | rngmx = tv ? "ymax ymin -" : "range_max"
273 | srcmx = tv ? "ymin - " : ""
274 | tvout = tv ? "ymin + " : ""
275 | lgnor = tv ? "2.57 * 1.105" : "2.791 * 1.045"
276 | linor = tv ? "0.5023" : string(0.501960785)
277 |
278 | # Merge 'mode'
279 | GML = "x "+srcmx+" A@ "+rngmx+" 3 * / sqrt y "+srcmx+rngmx+" 3 * / sqrt + "+rh+" - dup * "+lgnor+" ^ 0 1 clip "+rngmx+" * "
280 | GMI = "x "+srcmx+" A@ "+rngmx+" / 0 1 clip 2.4 ^ y "+srcmx+rngmx+" / + "+linor+" - 0 1 clip 0.416666667 ^ "+rngmx+" * "
281 | GMC = "x "+srcmx+" A@ y "+srcmx+" + range_half "+srcmx+" - 0 "+rngmx+" clip "
282 | GM = ls ? GML : ln ? GMI : ReplaceStr(GMC,"range_half",Format("{rnghlf}"))
283 |
284 | # 'lo', 'mid' and 'hi' mix
285 | LMH = Format(" Y@ x dup swap2 - range_max x {th1st} - {th21st} * - LO@ "+lop+" 0 1 clip * -
286 | dup Y - x {th3st} - {th43st} * neg HI@ "+hip+" 0 1 clip * -
287 | dup Y - range_max HI LO max - "+mip+" 0 1 clip * -")
288 |
289 | # 'conv' with frei-chen gradient
290 | EM = Format(" x[1,1] C@ x[1,-1] H@ + x[-1,1] A@ - x[-1,-1] F@ - x[1,0] x[-1,0] - 1.414213562 * + dup *
291 | F H + C - A - x[0,-1] x[0,1] - 1.414213562 * + dup * + sqrt {clo} - {norm} * 0 1 clip {cop} * * - ")
292 |
293 | # Construct expression
294 | COM = cn<1. ? SEG ? GM+tvout+LMH+" dup Y - "+EM : GM+Format(" dup swap2 - ")+EM+tvout : \
295 | SEG ? GM+tvout+LMH : GM+tvout
296 |
297 | # Expression fit for Chroma
298 | COC = ReplaceStr(COM," x "," z ").ReplaceStr("x[", "z[").ReplaceStr(GM,GMC)
299 | PTW = PTH ? " dup x - "+(SEG ? "HI" : Format("z {th3st} - {th43st} * neg"))+" "+rmax+" 0 1 clip * -" : ""
300 | GL = last
301 |
302 | !Chr ? ex_lutxy (pbl,last, COM, UV=2) : \
303 | ex_lutxyz(pbl,last,mskY_to_YYY(pbl,luma=true,bits=bi),COM,COC+PTW,UV=3)
304 |
305 |
306 | if (skn>0 && !isy) {
307 |
308 | U = ExtractU(a)
309 | V = ExtractV(a)
310 | rh1 = bi==32 ? "range_half 0.430 - + " : rmax+" 0.430 -"
311 | rh2 = bi==32 ? "range_half 0.588 - + " : rmax+" 0.588 -"
312 | rhm = bi==32 ? "range_half - " : ""
313 | msk = ex_lutxy(U,V,Format("x "+rh1+" 4 ^ -40000 * 1 + 0 max
314 | y "+rh2+" 4 ^ -40000 * 1 + 0 max * range_max {skn} * * "+rhm)).ex_inpand().ex_expand()
315 | ex_merge(pbl,msk,luma=true,UV=Chr32)
316 | }
317 |
318 | if (eml>0 && !isy) {
319 |
320 | is22 = is422(a) || is44 ? 2 : 4
321 | is44 = is44 ? 2 : 4
322 | sample = padresize(GL.ExtractY(),w/16,h/16).TemporalSoften(1,255,0,255,2)
323 | UP = BilinearResize(sample, w/is44, h/is22)
324 | Y = ExtractY()
325 | U = ExtractU()
326 | V = ExtractV()
327 |
328 | stains = ex_blend(UP,UP.FlipHorizontal(),mode="subtract",tv_range=false).ex_inpand()
329 | UVer = StackVertical (stains,stains)
330 | UHor = StackHorizontal(UVer, UVer)
331 | Unew = ex_lutxy(U,UHor,Format("x y {eml} * -"))
332 | CombinePlanes(Y,Unew,V, planes="YUV", sample_clip=last)
333 | }
334 |
335 | if (sh==2) {
336 | msize = min(w,h)
337 | bg = BoxMask(0,round(msize/(preset=="--"?2.6:1.8)),0,round(msize/1.3), invert=true, tv_out=tv)
338 | ex_blend(bg,"multiply",opacity=0.5,tv_range=tv)
339 |
340 | Subtitle(" FilmGrain+", size=msize/16,lsp=4,text_color=$ff5050,font="Segoe UI")
341 | Subtitle("\n\n SETTINGS:", size=msize/25,lsp=4,text_color=$ffcc99)
342 | Subtitle("\n\n\n\n " \
343 | +"Preset:\n " \
344 | +"Mode:\n\n " \
345 | +"strength:\n " \
346 | +"strengthC:\n " \
347 | +"size:\n " \
348 | +"sharpness:\n " \
349 | +"temp:\n\n " \
350 | +"bump:\n " \
351 | +"emulsion:\n " \
352 | +"skin:\n " \
353 | +"conv:\n " \
354 | +"PTH:\n ", size=msize/25,lsp=4,text_color=$ffcc99)
355 | Subtitle(Format("\n\n\n\n " \
356 | +"'"+ReplaceStr(preset," "," ").ReplaceStr(" "," ").ReplaceStr(" 52",sxmm?" 72":" 52")+"'"+"\n "\
357 | +"'"+md+"'"+"\n\n " \
358 | +string(istr, "%1.2f")+" \n " \
359 | +string(istrc,"%1.2f")+" \n " \
360 | +string(isz, "%1.2f")+" \n " \
361 | +string(ishrp,"%1.2f")+" \n " \
362 | +string(temp, "%1.2f")+" \n\n " \
363 | +string(bump, "%1.2f")+" \n " \
364 | +string(eml, "%1.2f")+" \n " \
365 | +string(skin, "%1.2f")+" \n " \
366 | +string(isBool(conv) ? conv ? str*0.1 : 0 : (1-cn)*1.25,"%1.2f")+"\n "\
367 | +"{pth} \n "), x=msize/4.5, size=msize/25,lsp=4,text_color=$ffcc99)
368 | } } }
369 |
--------------------------------------------------------------------------------
/ScenesPack.avsi:
--------------------------------------------------------------------------------
1 | ######################################################
2 | ### ##
3 | ### ##
4 | ### Scenes Pack v4.5 (19-02-2023) ##
5 | ### ##
6 | ### by Dogway (Jose Linares) ##
7 | ### ##
8 | ### https://forum.doom9.org/showthread.php?t=182881 ##
9 | ### ##
10 | ### ##
11 | ### Functions: ##
12 | ### SceneStats ##
13 | ### ReadStats ##
14 | ### ClipStats ##
15 | ### ##
16 | ######################################################
17 | ###
18 | ###
19 | ### SceneStats() by Dogway (19-02-2023)
20 | ###
21 | ### SceneStats does a robust Scene Change Detection and calculates scene's statistics.
22 | ### Therefore it allows to work or apply filters on a per-scene ("per-shot" in film terms) basis,
23 | ### making better decisions than going per-frame or constant through the clip.
24 | ###
25 | ### It writes defined scene pixel statistics into frame properties for on-the-go drafting or offloads them to a file for speed:
26 | ### "_SceneRange": [SceneStart, SceneEnd]
27 | ### "_SceneStats": [min, max, th_min, th_max, average, median, IQM, (Pearson's Skewness)]
28 | ### "_SceneStatsStdErr": [min, max, th_min, th_max, average, median, StDev]
29 | ### "_SceneMotion": float
30 | ### "_SceneDetail": float
31 | ### "_SceneExposure": int
32 | ### "_SceneChangePrev": int
33 | ###
34 | ### _SceneExposure: 0: Very Dark, 1: Dark, 2: Balanced, 3: Bright, 4: Very Bright
35 | ### Pearson's Skewness: Pearson's nonparametric skew of the scene's histogram distribution: (3*(average - median))/stdev = 0 (uniform distribution), +n (gamma distribution -> tilted to dark), -n (beta distribution -> tilted to bright)
36 | ### Tip1: A big difference between average and median depicts an asymmetric contrasty scene (bright frames + dark frames) or set of asymmetric contrasty frames (bright pixels + dark pixels)
37 | ### * IQM is like a interframe thresholded average, removing outliers at both sides discarding strong frame average biases. Probably more representative than average or median.
38 | ###
39 | ###
40 | ### Dependencies: > AviSynth v3.7.3 test9+
41 | ### ExTools
42 | ### ResizersPack
43 | ###
44 | ###
45 | ### Stats arguments:
46 | ### mode: Set the frame properties to write, almost* any combinations is possible (ie. "Range+Stats"): "Range" / "Stats" / "Motion" / "Detail" / "EV" / "Stats+StdErr"
47 | ### *'Range' is mandatory if no '_SceneRange' frameprops exist. 'StdErr' requires 'Stats' and 'Y=true', also "Detail" and "EV" require 'Y=true'
48 | ### interval: Interval of frames to calculate statistics from. The lower the more precise but slower.
49 | ### A value of 0.0 will only look into 'I' frames (aside start and end scene frames). Good for long shots in old movies.
50 | ### th: Threshold in percentage of pixels to ignore for 'th_min' and 'th_max' stats.
51 | ###
52 | ### Scene Change arguments:
53 | ### dFactor: Detection factor, a multiplier applied to frame difference metrics to decide if a scene changes.
54 | ### Mindif: Supply MinDif as if in 8 bit range (0.0 - 255.0). An additional component part (a bias) of scene change detection. Not very important when iFactor=true
55 | ### iFactor: If true (Default) it will give half weights to dFactor for 'I' type frames. This increases succesful detection rates for scene changes. Disable if clip is only I-frames.
56 | ### Anime: Scene Change Detection for anime should be handled differently, therefore this bool arg. Hard-codes 'iFactor=true' internally.
57 | ###
58 | ### Other:
59 | ### path: Define a path (anything other than "") to write stats to a file.
60 | ### dClip: You can supply an external clip to compute scene change and stats from. It can be a cropped version but for SC the clip should be grain free, if not supply a 'dClip' prefiltered with ex_minblur() or some kind of lightweight median or temporal denoiser.
61 | ### show: Enable to output frame properties, Prev frame diff factor, next frame diff factor and a scene change vertical bar.
62 | ###
63 | ###
64 | ### Function Definition:
65 | ### (
66 | ### clip,
67 | ### string "mode"="ALL" ("ALL"/ "none"/ "Range"/ "Stats"/ "Motion"/ "Detail"/ "EV"/ "Stats+StdErr"/ "Range+Stats"/ "Range+Stats+Motion"/ "Range+Stats+Motion+Detail"/ "Range+Stats+Motion+Detail+EV"),
68 | ### float "interval"=0.5 (0.0 to 2.0),
69 | ### float "th"=0.5 (0.0 to 5.0),
70 | ### float "dFactor"=3.7 (2.5 to 4.0),
71 | ### [float "MinDif"=1.0 (0.5 to 4.0)],
72 | ### [bool "iFactor"=true],
73 | ### [bool "Y"=true],
74 | ### [bool "UV"=false],
75 | ### bool "show"=false
76 | ### )
77 | ###
78 | ###
79 | ### Example for online filtering:
80 | ### setmemorymax(2048) # Higher recommended though
81 | ### ffvideoSource("source.mkv") # CPU loader recommended as apposed to ie. DGSource()
82 | ### SceneStats(mode="Range+Stats",Y=true,UV=false)
83 | ### prefetch(n)
84 | ###
85 | ### Example file output (run over analysis pass):
86 | ### setmemorymax(2048*3) # I wouldn't go any lower than 3 (6Gb)
87 | ### ffvideoSource("source.mkv")
88 | ### SceneStats("Range+Stats+Motion+EV",path="E:\source_stats.log")
89 | ### prefetch(1) # linear access
90 | ###
91 | ### ### and load the stats ###
92 | ###
93 | ### ReadStats("E:\source_stats.log")
94 | ### or
95 | ### ClipStats("E:\source_stats.log") # Slow initialization
96 | ###
97 | ###
98 | function SceneStats(clip a, string "mode", float "interval", float "th", float "dFactor", float "MinDif", bool "iFactor", bool "anime", clip "dClip", string "path", bool "Y", bool "UV", bool "show") {
99 |
100 | rgb = isRGB(a)
101 | isy = isy(a)
102 | FC = FrameCount(a)-1
103 | FR = FrameRate (a)
104 | w = width (a)
105 | bi = BitsPerComponent(a)
106 | sr = propNumElements (a,"_SceneRange") > 0
107 | pt = propNumElements (a,"_PictType" ) > 0
108 | fs = propNumElements (a,"_ColorRange") > 0 ? \
109 | propGetInt (a,"_ColorRange") == 0 : rgb
110 |
111 | in = Default(interval, 0.5) # Interval in seconds for fetching frames
112 | th = Default(th, 0.454) # Pixel ignore % threshold
113 | dFactor = Float(Default(dFactor,3.7)) # Range 2.5~4.0 ::: Change default to 4.0 to emulate SCSelect. Raise for noisy sources
114 | Mindif = Float(Default(MinDif ,1.0)) # Range 0.5~4.0 ::: Change default to 0.0 to emulate SCSelect (disabled for 'I' frames when iFactor=true)
115 | md = Default(mode,"Range+Stats") # Stats to write to frame properties: "ALL", "none", "Range", "", "Stats", "Motion", "Detail", "EV" or "Exposure", "Stats+StdErr"
116 | wr = Default(path, "") # Set a file path to offload SceneStats' stats to a file. Doesn't pair well with multithreading, so wisely use RequestLinear() and Prefetch(1)
117 | sh = Default(show, false)
118 | Y = Default(Y, true) # Enable to output Luma plane stats
119 | UV = Default(UV, false) # Enable to output Chroma plane stats
120 | UV = isy ? false : UV
121 | ib = Default(iFactor, true) # Halves dFactor multiplier for 'I' frames
122 | an = Default(anime, false) # Anime SC
123 | ib = pt ? an ? true : ib : false
124 | Ifactor = (an ? 0.35 : 0.5) * dfactor # For anime, SC algo is practically an 'I' frames reader (with some conditions)
125 | dfactor = (an ? 15.0 : 1.0) * dfactor
126 | YUV = Y && UV
127 |
128 | la = round(FR * 600) # Hard-coded 10 mins max look-ahead
129 | stp = round(FR * in)
130 | stp0= stp==0
131 |
132 | ZN = (fs ? 0.01961 : 0.02283)
133 | PSA = (fs ? 0 : 16 )
134 |
135 | md = LCase (md)
136 | all = FindSTr(md, "all" ) > 0
137 | rn = all || FindSTr(md, "range" ) > 0
138 | mo = all || FindSTr(md, "motion") > 0
139 | dt = all || FindSTr(md, "detail") > 0
140 | ev = all || FindSTr(md, "ev" ) > 0 || FindSTr(md, "exposure") > 0
141 | st = all || FindSTr(md, "stats" ) > 0 || FindSTr(md, "stderr") > 0
142 | std = (all || FindSTr(md, "stderr") > 0) && wr=="" # stderr are not written to log
143 | sr = sr && !rn
144 |
145 | Assert(IsVersionOrGreater(3,7,3), "SceneStats: Update AviSynth+ version")
146 | !rn ? Assert(sr, "SceneStats: '_SceneRange' frameprops required when 'Range' mode is not enabled") : nop()
147 | Assert(!rgb, "SceneStats: Only YUV formats supported")
148 | Assert(dFactor >= 1.0, "SceneStats: dFactor should be 1.0 or above")
149 | Assert(Mindif >= 0.0, "SceneStats: MinDif should be 0.0 or above")
150 |
151 | dClip = Defined(dClip) ? dClip : a
152 | uClip = UV ? dClip.ExtractU().ConvertBits(8, dither=-1, fulls=fs, fulld=fs) : nop()
153 | vClip = UV ? dClip.ExtractV().ConvertBits(8, dither=-1, fulls=fs, fulld=fs) : nop()
154 | dClip = !UV ? dClip.ExtractY().ConvertBits(8, dither=-1, fulls=fs, fulld=st ? fs : true) : dClip.ConvertBits(8, dither=-1, fulls=fs, fulld=fs)
155 | sClip = UV && !Y ? vClip : dClip.RatioResize(0.5, "%" ,2,"bicubic",b=-0.5,c=0.3)
156 | dClip = rn || mo ? width(dClip) > 1024 ? dClip.RatioResize(480, "adjust2w",2,"bicubic",b=-0.5,c=0.3) : dClip : dClip
157 | uClip = YUV ? sClip.ExtractU() : uClip
158 | vClip = YUV ? sClip.ExtractV() : vClip
159 | dClip = an ? dClip.Limiter(0,100) : dClip # AntiFlash & Anti-BiModal for Anime
160 | oClip = dClip.SelectEvery(1,-1)
161 | dClip = dClip.SelectEvery(1, 1)
162 | tClip = dt ? sClip.ex_edge("tritical",0) : nop() # Sub with SVM()? Should be lightweight though since we're looking back+ahead
163 |
164 | ScriptClip(a, function [oClip,dClip,sClip,tClip,uClip,vClip,Y,UV,stp,stp0,la,th,dfactor,ib,iFactor,MinDif,FC,an,rn,mo,ev,dt,st,std,sr,ZN,PSA,sh] () {
165 |
166 | n = current_frame
167 |
168 | # SCENE CHANGE
169 | if (!sr || sh && rn) {
170 | pDf0 = !an ? oClip.YDifferenceFromPrevious() : oClip.YDifferenceToNext(-2)
171 | nDf0 = !an ? oClip.YDifferenceToNext() : oClip.YDifferenceToNext( 1)
172 |
173 | nTh = ib ? oClip.propGetString("_PictType",offset=1)=="I" ? pDf0*iFactor : pDf0*dfactor+MinDif : pDf0*dfactor+MinDif
174 | SC = !an ? n!=1 && (nDf0>nTh || n==0) : n==0 ? true : \
175 | n!=1 && min(27.3375,nDf0)>-0.461*(nDf0-nTh)+27.3375 # 2nd factor pass for "anime=true". Kind of a "nTh2" based on 'nDf0-nTh' instead of 'pDf0'. 'nDf0>nTh' check is implicit in the expression
176 |
177 | sh ? Subtitle(Format("Prev: {nTh} Next: {nDf0}"), align=9) : nop()
178 | } else {
179 | srn1 = propGetAsArray("_SceneRange")
180 | sr1 = srn1[1]
181 | SC = propGetInt("_SceneChangePrev")==1
182 | }
183 |
184 | # Evaluate Scene End only when Scene Start
185 | if (SC) {
186 | pDfp = rn || mo ? !an ? dClip.YDifferenceFromPrevious() : dClip.YDifferenceToNext(-2) : 0
187 |
188 | nDf0 = 0 nTh = 0 nDf = 0 avga = [] sum = 0
189 | avg = 0 SE = FC divy = 0.000001 aarr = [] divm = divy
190 | avgt = 0 pDf1 = n > 2 ? pDfp : 255
191 | arrz = [0.0,0.0,0.0,0.0,0.0]
192 | stats = ArrayAdd(arrz,0.0)
193 | EVr = 0 EVm = 0
194 |
195 | if (UV) {
196 | statsu = arrz statsv = arrz divu = divy
197 | avgu = 0 avgv = 0 }
198 |
199 |
200 | # SCENE STATS
201 | lookahead = sr ? sr1-n : min(la, FC-n)
202 |
203 | for (f=1, lookahead, 1) {
204 |
205 | if (rn || mo) {
206 | dClip = dClip.SelectEvery(1,1)
207 | nDf0 = dClip.YDifferenceToNext()
208 | pDf0 = pDf1
209 | pDf1 = nDf0
210 |
211 | Ifr = ib || st && stp0 ? dClip.propGetString("_PictType",offset= 1)=="I" : false
212 | nTh = ib ? Ifr ? pDf0*iFactor : pDf0*dfactor+MinDif : pDf0*dfactor+MinDif
213 | } else {
214 | Ifr = ib || st && stp0 ? sClip.propGetString("_PictType",offset=f+1)=="I" : false
215 | }
216 | SC = sr ? n==sr1 : !an ? nDf0>nTh || f==lookahead : \
217 | min(27.3375,nDf0)>-0.461*(nDf0-nTh)+27.3375 || f>=lookahead
218 |
219 | # SCENE STATS
220 | ED = """EVr = EV ? EVr + YPlaneMinMaxDifference(sClip, 1) : EVr
221 | EVm = EV ? EVm + YPlaneMedian(sClip) : EVm
222 | avgt = DT ? avgt + tClip.AverageLuma(f1) : avgt"""
223 | DI = """divy = divy + 1"""
224 |
225 | if (!st && Y && (EV || DT)) {
226 | fe1 = f==1
227 |
228 | if (!stp0 && (fe1 || f%stp==0)) {
229 |
230 | f1 = fe1 ? 0 : f
231 | Eval(ED+Chr(10)+DI)
232 |
233 | } else if (stp0 && (fe1 || Ifr)) {
234 |
235 | f1 = fe1 ? 0 : SC ? f : f+1
236 | Eval(ED+Chr(10)+DI)
237 |
238 | } } else if (st) {
239 |
240 | fe1 = f==1
241 | blk = """pmms = PlaneMinMaxStats(sClip, th, f1, 0, false)
242 | aarr = ArrayAdd(aarr,pmms[5])
243 | stats = ArrayOp(stats,pmms,"+")"""+Chr(10)+ED+Chr(10)+DI
244 |
245 | blku= """statsu = Y ? ArrayOp(statsu, PlaneMinMaxStats(sClip, th, f1, 1, false),"+") : \
246 | ArrayOp(statsu, PlaneMinMaxStats(uClip, th, f1, 0, false),"+")
247 | statsv = Y ? ArrayOp(statsv, PlaneMinMaxStats(sClip, th, f1, 2, false),"+") : \
248 | ArrayOp(statsv, PlaneMinMaxStats(vClip, th, f1, 0, false),"+")
249 | divu = divu + 1"""
250 |
251 | if (!stp0 && (fe1 || f%stp==0)) {
252 |
253 | f1 = fe1 ? 0 : f
254 | Y ? Eval(blk) : last
255 | UV ? Eval(blku) : last
256 |
257 | } else if (stp0 && (fe1 || Ifr)) {
258 |
259 | f1 = fe1 ? 0 : SC ? f : f+1
260 | Y ? Eval(blk) : last
261 | UV ? Eval(blku) : last
262 | } }
263 |
264 | if (mo) {
265 | divm = f
266 | nDf =!SC ? nDf + nDf0 : nDf
267 | }
268 |
269 | SE = n+f
270 | f = SC ? lookahead : f
271 | }
272 |
273 | div = Y && (st || EV || DT) ? 1. / divy : 0.000001
274 | divu = UV && st ? 1. / divu : 0.000001
275 |
276 | # Scene's IQM & avg standard deviation
277 | if (st && Y) {
278 | sze = int(divy)-1
279 | mea = stats[5] *div
280 | med = stats[4] *div
281 |
282 | if (std) {
283 | for (i=0, sze, 1) {
284 | sum = sum + pow(aarr[i]-mea,2) }
285 | stdev = sqrt(sum*div)
286 | }
287 |
288 | if (sze>5) {
289 | if (sze%2==1) {
290 | srt = ArrayMedian(aarr,list=true)
291 | vl = abs(srt[0]-med) >= abs(srt[sze]-med) ? 0 : sze
292 | aarr = ArrayDel(srt,vl) # remove highest outlier to make it odd sized
293 | IQM = ArrayIQM(aarr, true)
294 | } else {
295 | IQM = ArrayIQM(aarr, false)
296 | } } else {
297 | IQM = mea
298 | } }
299 |
300 | rn ? propSet("_SceneChangePrev", 1 ) : last
301 | rn ? propSet("_SceneRange" , [n,min(SE+1,FC)]) : last
302 | mo ? propSet("_SceneMotion", (nDf/max(1,divm-1)) *0.03125) : last # Motion in a scale of 0.0 - 1.0 (0-0.2 calm, 0.2-0.4 busy, >0.4 high motion)
303 | dt && Y ? propSet("_SceneDetail", min(100,(avgt*div)*0.784313725)) : last # Detail in a scale of 0.0 - 100.0
304 | ev && Y ? propSet("_SceneExposure", min(4, round( max(0, (EVm * div - PSA) * ZN - 1) + max(0, EVr * div * ZN - 2)))) : last
305 | if (st) {
306 | Y ? std ? propSet("_SceneStats" , [stats[0] *div, stats[1] *div, stats[2] *div, stats[3] *div, mea, med, stdev, divy]) : \
307 | propSet("_SceneStats" , [stats[0] *div, stats[1] *div, stats[2] *div, stats[3] *div, mea, med, IQM]) : last
308 | UV ? propSet("_SceneStatsU", [statsu[0]*divu,statsu[1]*divu,statsu[2]*divu,statsu[3]*divu,statsu[5] *divu,statsu[4]*divu]) : last
309 | UV ? propSet("_SceneStatsV", [statsv[0]*divu,statsv[1]*divu,statsv[2]*divu,statsv[3]*divu,statsv[5] *divu,statsv[4]*divu]) : last }
310 |
311 | } else {rn ? propSet("_SceneRange" , [-1,-1]) : last
312 | rn ? propSet("_SceneChangePrev", 0 ) : last
313 | mo ? propSet("_SceneMotion", 0.0 ) : last
314 | Y && dt ? propSet("_SceneDetail", 0.0 ) : last
315 | Y && ev ? propSet("_SceneExposure", 0 ) : last
316 | if (st) {
317 | Y ? std ? propSet("_SceneStats" , [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.000001] ) : \
318 | propSet("_SceneStats" , [0.0,0.0,0.0,0.0,0.0,0.0,0.0] ) : last
319 | UV ? propSet("_SceneStatsU", [0.0,0.0,0.0,0.0,0.0] ) : last
320 | UV ? propSet("_SceneStatsV", [0.0,0.0,0.0,0.0,0.0] ) : last } } } )
321 |
322 | # Propagates Scene Stats to each scene's frame (by means of lookback)
323 | sClip = std && Y ? sClip : nop()
324 | lvl = Histogram(mode="levels").crop(w,0,0,0)
325 | th!=0 && sh && st ? ex_lutspa(mode="mix", expr=Format("sx width 100 {th} / sqrt A@ / round % 1 < sy height A / % 1 < or x ymin + x ?"), UV=2) : last
326 | sh ? stackhorizontal(last,lvl) : last
327 |
328 |
329 | ScriptClip( function[sClip,th,bi,mo,ev,dt,la,st,std,sh,sr,Y,UV] () {
330 |
331 | n = current_frame
332 |
333 | if (!sr) {
334 |
335 | for (lb=0, -la, -1) {
336 | PR = propGetAsArray("_SceneRange",offset=lb)
337 | of = lb
338 | lb = PR[1] != -1 ? -la : lb }
339 |
340 | propSet("_SceneRange" , propGetAsArray("_SceneRange",offset=of))
341 |
342 | } else {
343 |
344 | srn = propGetAsArray("_SceneRange")
345 | SS = srn[0]
346 | of = SS-n
347 | }
348 |
349 | mo ? propSet("_SceneMotion", propGetFloat("_SceneMotion", offset=of)) : last
350 | if (Y) {
351 | ev ? propSet("_SceneExposure",propGetInt("_SceneExposure", offset=of)) : last
352 | dt ? propSet("_SceneDetail", propGetFloat("_SceneDetail", offset=of)) : last }
353 |
354 | if (st) {
355 |
356 | PS = Y ? propGetAsArray("_SceneStats" ,offset=of) : nop()
357 | PSU = UV ? propGetAsArray("_SceneStatsU",offset=of) : nop()
358 | PSV = UV ? propGetAsArray("_SceneStatsV",offset=of) : nop()
359 |
360 | Y ? Eval(Format("PS6 = nmod(ex_bs(PS[6], 8, {bi}, true, flt=true),dec=3)")) : nop()
361 | for (i=0, 5, 1) {
362 | Y ? Eval(Format("PS{i} = nmod(ex_bs(PS[{i}], 8, {bi}, true, flt=true),dec=3)")) : nop()
363 | if (UV) {
364 | Eval(Format("PSU{i} = nmod(ex_bs(PSU[{i}], 8, {bi}, true, flt=true),dec=3)"))
365 | Eval(Format("PSV{i} = nmod(ex_bs(PSV[{i}], 8, {bi}, true, flt=true),dec=3)")) } }
366 | if (UV) {
367 | propSet("_SceneStatsU", [PSU0,PSU1,PSU2,PSU3,PSU4,PSU5])
368 | propSet("_SceneStatsV", [PSV0,PSV1,PSV2,PSV3,PSV4,PSV5]) }
369 |
370 | if (Y) {
371 |
372 | if (std) {
373 | stdev = PS[6] divy = PS[7] sdiv = 1./sqrt(divy) div = 1./divy
374 | propSet("_SceneStats" , [PS0,PS1,PS2,PS3,PS4,PS5,3*(PS4-PS5)/stdev])
375 | } else {
376 | propSet("_SceneStats" , [PS0,PS1,PS2,PS3,PS4,PS5,PS6]) }
377 |
378 | if (std) {
379 | fst = PlaneMinMaxStats(sClip, th, 0, 0, false)
380 | for (i=0, 5, 1) {
381 | Eval(Format("fst{i} = nmod(ex_bs(fst[{i}], 8, {bi}, true, flt=true),dec=3)")) }
382 |
383 | # Standard Error of the Mean; 0~1 Accurate, 1~2 Good, 2~3 Bad, 3~4 Very Bad
384 | propSet("_SceneStatsStdErr", [sqrt(pow(fst[0]-PS0,2)*div)*sdiv, \
385 | sqrt(pow(fst[1]-PS1,2)*div)*sdiv, \
386 | sqrt(pow(fst[2]-PS2,2)*div)*sdiv, \
387 | sqrt(pow(fst[3]-PS3,2)*div)*sdiv, \
388 | sqrt(pow(fst[5]-PS4,2)*div)*sdiv, \
389 | sqrt(pow(fst[4]-PS5,2)*div)*sdiv,stdev]) } } }
390 |
391 | sh ? propGetInt("_SceneChangePrev")==1 ? Crop(0,0,-256,0).AddBorders(0,0,256,0, color_yuv = $EB8080) : last : last
392 | } )
393 |
394 |
395 | wr != "" ? WriteFile(wr, function[mo,ev,dt,st,Y,UV] () {
396 | range = " Range: " + ArrayPrint(propGetAsArray("_SceneRange" ),true)
397 | motion = mo ? " Motion: " + string( propGetFloat ("_SceneMotion")) : ""
398 | if (Y) {
399 | detail = dt ? " Detail: " + string( propGetFloat ("_SceneDetail")) : ""
400 | expos = ev ? " Exposure: " + string( propGetInt ("_SceneExposure")) : ""
401 | } else {
402 | detail = ""
403 | expos = "" }
404 | if (st) {
405 | stats = y ? " Stats: " + ArrayPrint(propGetAsArray("_SceneStats" ),true) : ""
406 | statsu = uv ? " StatsU: " + ArrayPrint(propGetAsArray("_SceneStatsU"),true) : ""
407 | statsv = uv ? " StatsV: " + ArrayPrint(propGetAsArray("_SceneStatsV"),true) : ""
408 | } else {
409 | stats = ""
410 | statsu = ""
411 | statsv = "" }
412 | str = string(current_frame) + ":" + range + motion + detail + expos + stats + statsu + statsv
413 | current_frame == 0 ? "Type string"+Chr(10)+str : str } ) : last
414 |
415 | sh ? propShow() : last
416 | }
417 |
418 |
419 |
420 |
421 | ###
422 | ### ReadStats() by Dogway (04-02-2023)
423 | ###
424 | ### Reads scene statistics from a file created by SceneStats() and writes them into frame properties:
425 | ### "_SceneRange": [SceneStart, SceneEnd]
426 | ### "_SceneStats": [min, max, th_min, th_max, average, median, IQM, (Pearson's Skewness)]
427 | ### "_SceneMotion": float
428 | ### "_SceneDetail": float
429 | ### "_SceneExposure": int
430 | ### "_SceneChangePrev": int
431 | ###
432 | ### BEWARE!! For some reason in the exported log (from AvspMod) the first scene has repeated stats so manually remove those lines before loading the file.
433 | ###
434 | function ReadStats(clip a, string "path") {
435 |
436 | Assert(Exist(path), "ReadStats: Defined file path doesn't exist.")
437 |
438 | ScriptClip(a, function [] () {
439 |
440 | text = LCase(ReplaceStr(text,", ",","))+" "
441 | rn = FindStr(text, "range" )
442 | mo = FindStr(text, "motion" ) mo0 = mo > 0
443 | dt = FindStr(text, "detail" ) dt0 = dt > 0
444 | ev = FindStr(text, "exposure") ev0 = ev > 0
445 | st = FindStr(text, "stats:" ) st0 = st > 0
446 | stu = FindStr(text, "statsu" ) stu0= stu > 0
447 | stv = FindStr(text, "statsv" ) stv0= stv > 0
448 | sts = FindStr(text, "stat" )
449 | rn7 = rn+7
450 | rnp = FindStr(MidStr(text, rn7)," ")
451 |
452 | range = MidStr(text, rn7, rnp)
453 | motio = MidStr(text, mo +8, 8)
454 | detai = MidStr(text, dt +8, 9)
455 | expos = MidStr(text, ev +10, 2)
456 | stats = MidStr(text, st +7, 81)
457 | statu = MidStr(text, stu+8, 64)
458 | statv = MidStr(text, stv+8, 64)
459 |
460 | rng = ArrayEval(range,false)
461 | propSet("_SceneRange" , rng)
462 | propSet("_SceneChangePrev", current_frame==rng[0]?1:0)
463 | stu0 ? propSet("_SceneStatsU", ArrayEval(statu,false)) : last
464 | stv0 ? propSet("_SceneStatsV", ArrayEval(statv,false)) : last
465 | st0 ? propSet("_SceneStats" , ArrayEval(stats,false)) : last
466 | mo0 ? propSet("_SceneMotion", Eval(motio)) : last
467 | dt0 ? propSet("_SceneDetail", Eval(detai)) : last
468 | ev0 ? propSet("_SceneExposure", Eval(expos)) : last
469 |
470 | } )
471 |
472 | ConditionalReader(path, "text", false)
473 | }
474 |
475 |
476 | ###
477 | ### ClipStats() by Dogway (24-09-2022)
478 | ###
479 | ### Dependencies:
480 | ### ExTools
481 | ### RT_Stats
482 | ###
483 | ### Returns Global clip stats. Good for infering better global settings for clip-wide filtering.
484 | ### Simply point to the SceneStats output log and frame properties will be written for the whole clip.
485 | ###
486 | function ClipStats(clip a, string "path") {
487 |
488 | Assert(Exist(path), "ClipStats: Defined file path doesn't exist.")
489 | a
490 | text = LCase(ReplaceStr(RT_ReadTxtFromFile(path),", ",","))
491 | count = min( RT_TxtQueryLines (text), FrameCount())-1
492 |
493 | ScriptClip(function [text,count] () {
494 |
495 | motio = 0.0
496 | detai = 0.0
497 | expos = 0
498 | stats = [0.0,0.0,0.0,0.0,0.0,0.0,0.0]
499 | statu = [0.0,0.0,0.0,0.0,0.0,0.0]
500 | statv = [0.0,0.0,0.0,0.0,0.0,0.0]
501 |
502 | if (current_frame==0) {
503 |
504 | for (i = 1, count, 1) {
505 |
506 | line = RT_TxtGetLine(text,i)+" "
507 | rn = FindStr(line, "range" )
508 | mo = FindStr(line, "motion" ) mo0 = mo > 0
509 | dt = FindStr(line, "detail" ) dt0 = dt > 0
510 | ev = FindStr(line, "exposure") ev0 = ev > 0
511 | st = FindStr(line, "stats:" ) st0 = st > 0
512 | stu = FindStr(line, "statsu" ) stu0= stu > 0
513 | stv = FindStr(line, "statsv" ) stv0= stv > 0
514 | sts = FindStr(line, "stat" )
515 | rn7 = rn+7
516 | rnp = FindStr( MidStr(line, rn7)," ")
517 |
518 | range = ArrayEval(MidStr(line, rn7, rnp),false)
519 | rn0 = range[0]
520 | sc = i==rn0+1
521 |
522 | if (sc) {
523 | rng = range[1]-rn0+1
524 | motio = mo0 ? motio + Eval(MidStr(line, mo +8, 8))*rng : motio
525 | detai = dt0 ? detai + Eval(MidStr(line, dt +8, 9))*rng : detai
526 | expos = ev0 ? expos + Eval(MidStr(line, ev +10, 2))*rng : expos
527 | stats = st0 ? ArrayOp(stats,ArrayOp(rng,ArrayEval(MidStr(line, st +7, 81),false),"*"),"+") : stats
528 | statu = stu0 ? ArrayOp(statu,ArrayOp(rng,ArrayEval(MidStr(line, stu+8, 64),false),"*"),"+") : statu
529 | statv = stv0 ? ArrayOp(statv,ArrayOp(rng,ArrayEval(MidStr(line, stv+8, 64),false),"*"),"+") : statv
530 | }
531 |
532 | }
533 | count = float(count)
534 | stu0 ? propSet("_SceneStatsU", ArrayOp(statsu,count,"/")) : last
535 | stv0 ? propSet("_SceneStatsV", ArrayOp(statsv,count,"/")) : last
536 | st0 ? propSet("_SceneStats" , ArrayOp(stats, count,"/")) : last
537 | mo0 ? propSet("_SceneMotion", motio/count) : last
538 | dt0 ? propSet("_SceneDetail", detai/count) : last
539 | ev0 ? propSet("_SceneExposure", round(expos/count)) : last
540 | } } )
541 |
542 | # Copying frame#0 properties to index#0 (clip wide) properties
543 | propNumElements("_SceneStats") > 0 ? propSet("_SceneStats" ,propGetAsArray("_SceneStats" ,0)) : nop()
544 | propNumElements("_SceneStatsU") > 0 ? propSet("_SceneStatsU" ,propGetAsArray("_SceneStatsU" ,0)) : nop()
545 | propNumElements("_SceneStatsV") > 0 ? propSet("_SceneStatsV" ,propGetAsArray("_SceneStatsV" ,0)) : nop()
546 | propNumElements("_SceneMotion") > 0 ? propSet("_SceneMotion" ,propGetFloat ("_SceneMotion" ,0)) : nop()
547 | propNumElements("_SceneDetail") > 0 ? propSet("_SceneDetail" ,propGetFloat ("_SceneDetail" ,0)) : nop()
548 | propNumElements("_SceneExposure") > 0 ? propSet("_SceneExposure",propGetInt ("_SceneExposure",0)) : nop()
549 | }
--------------------------------------------------------------------------------
/EX mods/FrameRateConverterEX.avsi:
--------------------------------------------------------------------------------
1 | ##
2 | ## This program is free software; you can redistribute it and/or modify
3 | ## it under the terms of the GNU General Public License as published by
4 | ## the Free Software Foundation; either version 2 of the License, or
5 | ## (at your option) any later version.
6 | ##
7 | ## This program is distributed in the hope that it will be useful,
8 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | ## GNU General Public License for more details.
11 | ##
12 | ## You should have received a copy of the GNU General Public License
13 | ## along with this program; if not, write to the Free Software
14 | ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
15 | ## https:#www.gnu.org/copyleft/gpl.html.
16 | ##
17 | ##############################################################
18 | ##
19 | ## Frame Rate Converter By Etienne Charland
20 | ## https://forum.doom9.org/showthread.php?t=174793
21 | ##
22 | ## Based on Oleg Yushko's YFRC artifact masking,
23 | ## johnmeyer's frame interpolation code, and
24 | ## raffriff42's "weak mask" and output options.
25 | ##
26 | ## Pinterf is the one who spent the most time working on the core libraries, adding features and fixing bugs
27 | ##
28 | #############################################################
29 | ##
30 | ## Frame Rate Converter by Etienne Charland - v2.0.0 b11 (19-09-2021)
31 | ## Frame Rate Converter EX by Dogway - v2.3.3 (10-10-2022)
32 | ## https://forum.doom9.org/showthread.php?t=182881
33 | ##
34 | ## Increases the frame rate with interpolation and fine artifact removal.
35 | ## EX Mod for performance optimizations, minimum dependencies, HBD support, frame properties support and RIFE support.
36 | ##
37 | ## Dependencies: > FrameRateConverter.dll
38 | ## ExTools
39 | ## MVTools2
40 | ## GradePack
41 | ## RIFE (for preset="RIFE")
42 | ## TransformsPack (for preset="RIFE")
43 | ##
44 | ##
45 | ## Example: ConvertBits(16).FrameRateConverterEX(Preset="RIFE",FrameDouble=true)
46 | ##
47 | ##
48 | ## Function Definition:
49 | ## (
50 | ## clip,
51 | ## [int "NewNum"=0 (10000 to 60000)],
52 | ## [int "NewDen"=0 (1000 to 2000)],
53 | ## string "Preset"="RIFE" ("Faster"/ "Fast"/ "Normal"/ "Slow"/ "Slower"/ "Slowest"/ "Anime"/ "RIFE"/ "RIFE-HQ"/ "RIFEanime"),
54 | ## [int "BlkSize"=16 (6/ 8/ 12/ 16/ 24/ 32/ 48/ 64)],
55 | ## bool "FrameDouble"=true,
56 | ## [string "Output"="auto" ("auto"/ "flow"/ "over"/ "none"/ "raw"/ "mask"/ "skip"/ "diff"/ "stripe")],
57 | ## [int "MaskThr"=120 (0 to 255)],
58 | ## [int "MaskOcc"=105 (0 to 255)],
59 | ## [int "SkipThr"=55 (0 to 255)],
60 | ## [int "BlendOver"=70 (0 to 255)],
61 | ## [int "SkipOver"=210 (0 to 255)],
62 | ## [bool "Stp"=true],
63 | ## [int "Dct"=1 (0 to 10)],
64 | ## [int "DctRe"=4 (0 to 10)],
65 | ## [int "RIFE"=1 (0 to 2)],
66 | ## [int "rifeModel"=6 (0 to 9)],
67 | ## [int "BlendRatio"=40 (0 to 100)],
68 | ## [bool "tv_range"=true],
69 | ## [bool "luma_rebuild"=true],
70 | ## [bool "Debug"=false],
71 | ## int "gpuid"=0
72 | ## )
73 | ##
74 | ##
75 | ## SETTINGS:
76 | ##
77 | ## @ Input - YV12/YV24/Y8 over any bitdepth
78 | ##
79 | ## @ NewNum - The new framerate numerator (if FrameDouble = false, default = 60)
80 | ##
81 | ## @ NewDen - The new framerate denominator (if FrameDouble = false, default = 1)
82 | ##
83 | ## @ Preset - The speed/quality preset [slowest|slower|slow|normal|fast|faster|anime|rife|rifeHQ|rifeanime]. (default="normal")
84 | ## Faster: Basic interpolation
85 | ## Fast: MRecalculate
86 | ## Normal: MRecalculate with DCT=4
87 | ## Slow: MAnalyse + MRecalculate with DCT=4
88 | ## Slower: Calculate diff between DCT=4 and DCT=0 to take the best from both
89 | ## Slowest: Calculate diff between DCT=1 and DCT=0 to take the best from both
90 | ## Anime: 'Slow' with BlendOver=40, SkipOver=140
91 | ## RIFE: 'Slow' with rife=1, maskThr=80 and DctRe=4
92 | ## RIFE-HQ: 'Slowest' with rife=1, maskThr=80 and DctRe=4
93 | ## RIFEanime: Both 'Anime' and 'RIFE' presets
94 | ##
95 | ## @ BlkSize - The block size. Latest MvTools2.dll version from Pinterf supports 6, 8, 12, 16, 24, 32, 48 and 64.
96 | ## Defaults for 4/3 video of height:
97 | ## 0-359: 8
98 | ## 360-749: 12
99 | ## 750-1199: 16
100 | ## 1200-1699: 24
101 | ## 1600-2160: 32
102 | ##
103 | ## @ BlkSizeV - The vertical block size. (default = BlkSize)
104 | ##
105 | ## @ FrameDouble - Whether to double the frame rate and preserve original frames (default = true)
106 | ##
107 | ## @ Output - Output mode [auto|flow|over|none|raw|mask|skip|diff|stripe] (default = "auto")
108 | ## auto = normal artifact masking
109 | ## flow = interpolation only
110 | ## over = mask as cyan overlay, stripes mask as yellow
111 | ## none = ConvertFPS only
112 | ## raw = raw mask
113 | ## mask = mask only
114 | ## skip = mask used to Skip
115 | ## diff = mask where alternate interpolation is better
116 | ## stripe = mask used to cover stripes
117 | ##
118 | ## @ Debug - Whether to display AverageLuma values of Skip, Mask and Raw. (Default = false)
119 | ##
120 | ## @ Prefilter - Specifies a prefilter such as RgTools' RemoveGrain(21). Recommended only when not using a denoiser (Default=none)
121 | ##
122 | ## @ MaskThr - The threshold where a block is considered bad, between 0 and 255. Smaller = stronger.
123 | ## 0 to disable artifact masking. (Default = 120)
124 | ##
125 | ## @ MaskOcc - Occlusion mask threshold, between 0 and 255. 0 to disable occlusion masking. (Default = 105)
126 | ##
127 | ## @ SkipThr - The threshold where a block is counted for the skip mask, between 0 and 255. Smaller = stronger.
128 | ## Must be smaller (stronger) than MaskThr. (Default = 55)
129 | ##
130 | ## @ BlendOver - Try fallback block size when artifacts cover more than specified threshold, or 0 to disable.
131 | ## If it fails again, it will revert to frame blending. (default = 70)
132 | ##
133 | ## @ SkipOver - Skip interpolation of frames when artifacts cover more than specified threshold,
134 | ## or 0 to disable. (Default = 210)
135 | ##
136 | ## @ Stp - Whether to detect and blend stripes (default=true)
137 | ##
138 | ## @ Dct - Overrides DCT parameter for MAnalyse (default: Normal=0, Slow=4, Slowest=1)
139 | ##
140 | ## @ DctRe - Overrides DCT parameter for MRecalculate (default: Fast=0, Normal=4, Slowest=1)
141 | ##
142 | ## @ BlendRatio - Changes the blend ratio used to fill artifact zones. 0 = frame copy and 100 = full blend.
143 | ## Other values provide a result in-between to eliminate ghost effects. (Default = 40)
144 | ##
145 | ## @ RIFE - Uses RIFE to double the framerate of the frame blending clip used to mask artifacts, reducing the need for frame blending.
146 | ## 0 disables RIFE and uses only frame blending. 1 runs RIFE once but you will still notice frame blending. 2 runs RIFE twice for better quality.
147 | ## You can lower MaskThr to see more of the RIFE clip.
148 | ## More about the RIFE implementation: https://forum.doom9.org/showthread.php?t=174793&page=25
149 | ##
150 | ## @ tv_range - True if source is Limited/TV range, False if source is Full/PC range. (Default = true)
151 | ##
152 | ## @ luma_rebuild- True to improve detail in dark areas for motion analysis
153 | ##
154 | ##
155 | function FrameRateConverterEX (clip C, int "NewNum", int "NewDen", string "Preset", int "BlkSize", int "BlkSizeV", bool "FrameDouble", string "Output",
156 | \ clip "Prefilter", int "MaskThr", int "MaskOcc", int "SkipThr", int "BlendOver", int "SkipOver", bool "Stp", int "Dct", int "DctRe", int "RIFE", int "rifeModel", int "BlendRatio", bool "tv_range", bool "luma_rebuild", bool "Debug", int "gpuid")
157 | {
158 | Preset = Default(Preset, "normal")
159 |
160 | num = Preset == "slowest" ? 5 : \
161 | Preset == "slower" ? 4 : \
162 | Preset == "slow" ? 3 : \
163 | Preset == "normal" ? 2 : \
164 | Preset == "fast" ? 1 : \
165 | Preset == "faster" ? 0 : \
166 | Preset == "anime" ? 6 : \
167 | Preset == "RIFE" ? 7 : \
168 | Preset == "RIFE-HQ" ? 8 : \
169 | Preset == "RIFEanime"? 9 : \
170 | Assert(false, "FrameRateConverterEX: 'Preset' must be slowest, slower, slow, normal, fast, faster, anime, RIFE, RIFE-HQ or RIFEanime {'" + Preset + "'}")
171 |
172 | Output = Default(Output, "auto")
173 |
174 | OPut = Output == "auto" ? 0 : \
175 | Output == "flow" ? 1 : \
176 | Output == "over" ? 2 : \
177 | Output == "none" ? 3 : \
178 | Output == "raw" ? 4 : \
179 | Output == "mask" ? 5 : \
180 | Output == "skip" ? 6 : \
181 | Output == "diff" ? 7 : \
182 | Output == "stripe" ? 8 : \
183 | Assert(false, "FrameRateConverterEX: 'Output' not one of (auto|flow|none|mask|skip|raw|diff|over) {'" + Output + "'}")
184 |
185 | fs = propNumElements(C,"_ColorRange") > 0 ? \
186 | propGetInt (C,"_ColorRange") == 0 : false
187 | bi = C.BitsPerComponent()
188 | w = C.width()
189 | h = C.height()
190 | frn = C.FrameRateNumerator()
191 | frd = C.FrameRateDenominator()
192 | isUHD = (w > 2599 || h > 1499)
193 | isHD = (w > 1099 || h > 599)
194 | Stp = Default(Stp, true)
195 | FrameDouble = Default(FrameDouble, !Defined(NewNum))
196 | NewNum = FrameDouble ? frn * 2 : Default(NewNum, 60)
197 | NewDen = FrameDouble ? frd : Default(NewDen, 1)
198 | FrameDouble = FrameDouble || (NewNum == frn * 2 && NewDen == frd)
199 | DefH = Max(h, w/4*3)
200 | BlkSize = Default(BlkSize, DefH<360 ? 8 : \
201 | DefH<750 ? 12 : \
202 | DefH<1200 ? 16 : \
203 | DefH<1600 ? 24 : 32)
204 | BlkSizeV = Default(BlkSizeV, BlkSize)
205 | MaskThr = Default(MaskThr, num>6 ? 80 : 120)
206 | SkipThr = Default(SkipThr, min(55,MaskThr-1))
207 | MaskOcc = MaskThr > 0 ? Default(MaskOcc, 105) : 0
208 | CalcPrefilter = Defined(Prefilter)
209 | Prefilter = Default(Prefilter, C)
210 | Debug = Default(Debug, false)
211 | tv = Default(tv_range, !fs)
212 | lr = Default(luma_rebuild, true)
213 | BlendRatio = Default(BlendRatio, 40)
214 | gpuid = Default(gpuid, 0)
215 | rifeI = Default(rife, 0)
216 | rife = rifeI>0 || num>6
217 | rifeModel = Default(rifeModel, rife ? num>8 ? 3 : num>7 ? 22 : 23 : 0) # model=5 distorts more than 6 which does more blending (though pleasant)
218 | /* https://github.com/nihui/rife-ncnn-vulkan/issues/50#issuecomment-1229203013
219 | The rife architecture has two parameters called ensembling and fastmode integrated.
220 | You can't just export rife into one single model without such parameters.
221 | Nihui always just exports the fastest model (ensemble False, Fast True), while the other ones can result in a better image.
222 | Ensembling combines the flow of two different interpolations within the model and if fastmode is false it calls contextnet */
223 |
224 | OutFps = OPut < 4 # Whether output has altered frame rate
225 | wb = w/BlkSize
226 | wb4 = round(wb/4.0)*4
227 | hb = h/BlkSizeV
228 | hb4 = round(hb/4.0)*4
229 |
230 | # Faster Fast Normal Slow Slower Slowest Anime RIFE RIFE-HQ RIFEanime ('RIFEanime' matches 'Slow' defaults)
231 | Dctn = Select (num, 0, 0, 0, 4, 4, 1, 4, 4, 1, 4) # DCT=4 helps over hight motion or panning compared to DCT=1
232 | DctRe = Select (num, 0, 0, 4, 4, 4, 1, 4, 4, 4, 4)
233 | BlendOvern = Select (num, 70, 70, 70, 70, 70, 70, 40, 70, 70, 70)
234 | SkipOvern = Select (num, 210, 210, 210, 210, 210, 210, 140, 210, 210, 210)
235 | Recalculate = Select (num, false, true, true, true, true, true, true, true, true, true)
236 | CalcDiff = Select (num, false, false, false, false, true, true, true, true, true, false)
237 |
238 | # Overrides
239 | Dctre = Default(Dct, DctRe)
240 | Dct = Default(Dct, Dctn)
241 | BlendOver = Default(BlendOver, BlendOvern)
242 | SkipOver = Default(SkipOver, SkipOvern)
243 |
244 | RIFE ? \
245 | Assert(IsVersionOrGreater(3,7,3), "FrameRateConverterEX: RIFE requires AviSynth+ v3.7.3 or above") : nop()
246 | Assert(IsVersionOrGreater(3,7,2), "FrameRateConverterEX: Update AviSynth+ version")
247 | Assert(MaskThr >= 0 && MaskThr <= 255, String(MaskThr, "FrameRateConverterEX: MaskThr must be between 0 and 255 {%.f}"))
248 | Assert(MaskOcc >= 0 && MaskOcc <= 255, String(MaskOcc, "FrameRateConverterEX: MaskOcc must be between 0 and 255 {%.f}"))
249 | Assert(BlendOver >= 0 && BlendOver <= 255, String(BlendOver, "FrameRateConverterEX: BlendOver must be between 0 and 255 {%.f}"))
250 | Assert(SkipOver >= 0 && SkipOver <= 255, String(SkipOver, "FrameRateConverterEX: SkipOver must be between 0 and 255 {%.f}"))
251 | Assert(SkipThr < MaskThr, "FrameRateConverterEX: SkipThr must be lower (stronger) than MaskThr")
252 | Assert(BlendOver==0 || SkipOver==0 || SkipOver > BlendOver, "FrameRateConverterEX: SkipOver must be greater than BlendOver")
253 | Assert(CalcDiff || OPut!=7, "FrameRateConverterEX: You can only use Output='Diff' when using Preset=slower or slowest")
254 |
255 | # "BSoft" - Blending, "BHard" - No blending, "B" = RIFE + Blending
256 | B = C.ConvertFpsLimit(NewNum, NewDen, ratio=BlendRatio)
257 | BSoft = B
258 |
259 | if (RIFE) {
260 | matA = (isUHD ? "2020" : isHD ? "709" : "170m") + (tv ? ":l" : ":f")
261 | B = is444(C) ? C.ConvertToPlanarRGB(matrix=matA) : C.ConvertToPlanarRGB(matrix=matA,chromaresample="spline36")
262 | B = B.ConvertBits(32,fulls=true)
263 | for (i=1, frameDouble ? 1 : min(rifeI,2), 1) {
264 | B = B.RIFE(uhd=isUHD, model=rifeModel, tta=false, gpu_id=gpuid)
265 | }
266 | B = MatchClip(B,C,matrix=matA,Size=false)
267 | B = B.ConvertFpsLimit(NewNum, NewDen, ratio=BlendRatio)
268 | }
269 | BHard = C.ChangeFps (NewNum, NewDen)
270 | C_luma = C.ExtractY()
271 | Blank = BlankClip(C_luma, color_yuv=$000000, pixel_type=PixelType(C), channels=0)
272 |
273 | # Adjust parameters for different BlkSize (block sizes), causing stronger or weaker masks
274 | blk = Max(BlkSize, BlkSizeV)
275 | MaskThr = MaskThr + (-90.4/pow(exp(blk),0.066)+30.9)
276 | MaskThr = clamp(MaskThr, 0, 255)
277 | SkipThr = SkipThr + (-75.4/pow(exp(blk),0.065)+25.7)
278 | SkipThr = clamp(SkipThr, 0, 255)
279 | gam = -0.0078*blk+0.63
280 | dct_pow = !Recalculate ? 1.00 : 0 < DctRe < 5 ? 1.069+0.102*pow(DctRe-2.56,2) : 1.0
281 | dct_mult = !Recalculate ? 0.90 : \
282 | DctRe==1 ? 1.90 : \
283 | DctRe==2 ? 1.30 : \
284 | DctRe==3 ? 1.20 : \
285 | DctRe==4 ? 1.09 : 1
286 |
287 |
288 | # For some reason feeding PC range and increasing chroma weight for good sources doesn't improve motion interpolation. Prolly the filter is very tuned to tv range
289 | # Hard-coded ex_luma_rebuild(S0=3) with tv range output (didn't scale up tv range as an optimization trick)
290 | rangePC = tv ? "ymin - 0 max A@" : "" callX = tv ? "A" : "x"
291 | rangeTV = tv ? " ymin +" : ""
292 | pre = prefilter.ConvertBits(8,dither=-1,fulls=!tv)
293 | Cp = C.ConvertBits(8,dither=-1,fulls=!tv)
294 | pre = lr ? pre.ex_lut("f32 0.125 1.0625 0.0664 x "+rangePC+" 0.0625 + / - * "+callX+" 0.875 * +"+rangeTV, scale_inputs=tv?"int":"intf",fulls=!tv) : pre
295 | Cp = lr ? Cp.ex_lut("f32 0.125 1.0625 0.0664 x "+rangePC+" 0.0625 + / - * "+callX+" 0.875 * +"+rangeTV, scale_inputs=tv?"int":"intf",fulls=!tv) : Cp
296 |
297 |
298 | # jm_fps interpolation
299 | superfilt = MSuper(pre, hpad=16, vpad=16, sharp=1, rfilter=isHD?1:4) # all levels for MAnalyse
300 | super = CalcPrefilter ? MSuper(Cp, hpad=16, vpad=16, levels=1, sharp=1, rfilter=isHD?1:4) : superfilt # one level is enough for MRecalculate
301 | superR = MSuper(C, hpad=16, vpad=16, levels=1, sharp=1, rfilter=isHD?1:4)
302 | bak = MAnalyse(superfilt, isb=true, blksize=BlkSize, blksizev=BlkSizeV, overlap = BlkSize >4?(BlkSize/4+1)/2*2:0, overlapv = BlkSizeV >4?(BlkSizeV/4+1)/2*2:0, search=3, dct=Dct, mt=true)
303 | fwd = MAnalyse(superfilt, isb=false, blksize=BlkSize, blksizev=BlkSizeV, overlap = BlkSize >4?(BlkSize/4+1)/2*2:0, overlapv = BlkSizeV >4?(BlkSizeV/4+1)/2*2:0, search=3, dct=Dct, mt=true)
304 | fwd = Recalculate ? MRecalculate(super, fwd, blksize=BlkSize/2, blksizev=BlkSizeV/2, overlap = BlkSize/2>4?(BlkSize/8+1)/2*2:0, overlapv = BlkSizeV/2>4?(BlkSizeV/8+1)/2*2:0, thSAD=100, dct=DctRe, mt=true) : fwd
305 | bak = Recalculate ? MRecalculate(super, bak, blksize=BlkSize/2, blksizev=BlkSizeV/2, overlap = BlkSize/2>4?(BlkSize/8+1)/2*2:0, overlapv = BlkSizeV/2>4?(BlkSizeV/8+1)/2*2:0, thSAD=100, dct=DctRe, mt=true) : bak
306 | Flow = MFlowFps(C, superR, bak, fwd, num=NewNum, den=NewDen, blend=false, ml=200, mask=2, thSCD2=255)
307 |
308 | # "EM" - error or artifact mask
309 | # Mask: SAD
310 | EM = MaskThr > 0 ? C_luma.MMask(bak, ml=255, kind=1, gamma=1/gam, ysc=255, thSCD2=SkipOver) : Blank
311 | # Mask: Temporal blending
312 | EMfwd = MaskThr > 0 ? C_luma.MMask(fwd, ml=255, kind=1, gamma=1/gam, thSCD2=SkipOver) : EM
313 | EM = MaskThr > 0 ? ex_blend(EM, EMfwd,"lighten",0.6,UV=1,tv_range=false) : EM
314 |
315 |
316 | # Mask: Occlusion
317 | EMocc = MaskOcc > 0 ? C_luma.MMask(bak, ml=MaskOcc, kind=2, gamma=1/gam, ysc=255, thSCD2=SkipOver).ex_inpand() : Blank
318 | EM = MaskOcc > 0 ? ex_blend(EM, EMocc,"lighten",0.4,UV=1,tv_range=false) : EM
319 | EM = dct_mult!=1 || dct_pow!=1 ? ex_lut(EM,Format("x {dct_mult} * {dct_pow} ^"), scale_inputs="allf", fulls=true) : EM
320 |
321 | ## For CalcDiff, calculate a 2nd version and create mask to restore from 2nd version the areas that look better
322 | bak2 = CalcDiff ? MAnalyse(superfilt, isb=true, blksize=BlkSize, blksizev=BlkSizeV, overlap = BlkSize >4?(BlkSize/4+1)/2*2:0, overlapv = BlkSizeV >4?(BlkSizeV/4+1)/2*2:0, search=3, dct=0, mt=true) : nop()
323 | fwd2 = CalcDiff ? MAnalyse(superfilt, isb=false, blksize=BlkSize, blksizev=BlkSizeV, overlap = BlkSize >4?(BlkSize/4+1)/2*2:0, overlapv = BlkSizeV >4?(BlkSizeV/4+1)/2*2:0, search=3, dct=0, mt=true) : nop()
324 | fwd2 = CalcDiff ? Recalculate ? MRecalculate(super, fwd2, blksize=BlkSize/2, blksizev=BlkSizeV/2, overlap = BlkSize/2>4?(BlkSize/8+1)/2*2:0, overlapv = BlkSizeV/2>4?(BlkSizeV/8+1)/2*2:0, thSAD=100, dct=num==8 ? 4 : 0, mt=true) : fwd : nop()
325 | bak2 = CalcDiff ? Recalculate ? MRecalculate(super, bak2, blksize=BlkSize/2, blksizev=BlkSizeV/2, overlap = BlkSize/2>4?(BlkSize/8+1)/2*2:0, overlapv = BlkSizeV/2>4?(BlkSizeV/8+1)/2*2:0, thSAD=100, dct=num==8 ? 4 : 0, mt=true) : bak : nop()
326 | Flow2 = CalcDiff ? MFlowFps(C, superR, bak2, fwd2, num=NewNum, den=NewDen, blend=false, ml=200, mask=2, thSCD2=255) : nop()
327 |
328 | # Get raw mask again
329 | EM2 = CalcDiff ? MaskThr > 0 ? C_luma.MMask(bak2, ml=255, kind=1, gamma=1/gam, ysc=255, thSCD2=SkipOver) : Blank : nop()
330 | EMfwd2 = CalcDiff ? MaskThr > 0 ? C_luma.MMask(fwd2, ml=255, kind=1, gamma=1/gam, thSCD2=SkipOver) : EM2 : nop()
331 | EM2 = CalcDiff ? MaskThr > 0 ? ex_blend(EM2,EMfwd2,"lighten",0.6,UV=1,tv_range=false) : EM2 : nop()
332 | EMocc2 = CalcDiff ? MaskOcc > 0 ? C_luma.MMask(bak2, ml=MaskOcc, kind=2, gamma=1/gam, ysc=255, thSCD2=SkipOver).ex_inpand() : Blank : nop()
333 | EM2 = CalcDiff ? MaskOcc > 0 ? ex_blend(EM2,EMocc2,"lighten",0.4,UV=1,tv_range=false) : EM2 : nop()
334 |
335 | # Get difference mask between two versions
336 | thb = ex_bs(60,8,bi,fulls=true)
337 | EMdiff = CalcDiff ? ex_makediff(EM, EM2, dif=false, fulls=true)
338 | \ .BicubicResize(round(wb)*4, round(hb)*4)
339 | \ .ex_lut(Format("x[0,-2] x[-1,-1] max x[0,-1] max x[1,-1] max x[-2,0] max x[-1,0] max x[1,0] max x[2,0] max x[-1,1] max x[0,1] max x[1,1] max x[0,2] max x max {thb} > range_max 0 ?"), fulls=true)
340 | \ .GaussResize(w, h, p=3.5) : nop()
341 |
342 | # Apply mask to Flow / EM
343 | EMdiff = CalcDiff ? OutFps ? EMdiff.ChangeFPS(NewNum, NewDen) : EMdiff : nop()
344 | Flow = CalcDiff ? ex_merge(Flow, Flow2, EMdiff, luma=true, UV=3) : Flow
345 | EM = CalcDiff ? ex_merge(EM, EM2, EMdiff, luma=true, UV=3) : EM
346 |
347 |
348 | # Last mask frame is white. Replace with previous frame.
349 | LF = EM.Framecount()-1
350 | EM = EM.DeleteFrame(LF).Loop(2, LF)
351 |
352 | # Create skip mask
353 | SkipThrb = ex_bs(SkipThr,8,bi,fulls=true,flt=true)
354 | EMs = EM.BicubicResize(wb4, hb4)
355 | EMskip = EMs.ex_lut(Format("x[-1,0] x[0,-1] max x[0,1] max x[1,0] max x max {SkipThrb} > range_max 0 ?"), fulls=true)
356 | OutSkip = EMskip.BicubicResize(w, h)
357 |
358 | # Create artifact correction mask
359 | OutRaw = EM
360 | MaskThrb = ex_bs(MaskThr,8,bi,fulls=true,flt=true)
361 | EM = EMs.ex_lut(Format("x[-1,0] x[0,-1] max x[0,1] max x[1,0] max x max {MaskThrb} > range_max 0 ?"), fulls=true)
362 | EM = RIFE ? EM.ex_expand() : EM
363 | EM = EM.GaussResize(w, h, p=15)
364 |
365 | # Mask: Stripes
366 | thb = ex_bs(82,8,bi,fulls=true)
367 | EMstp = C.ex_StripeMask(blksize=BlkSize, blksizev=BlkSizeV, str=round(min(SkipThr*2+20, 255)), strf=round(min(SkipThr+10, 255)), fullRange=!tv)
368 | \ .BicubicResize(round(wb)*4, round(hb)*4)
369 | \ .ContinuousMask(22)
370 | EMstp = EMstp.BicubicResize(EMstp.Width()/2, EMstp.Height()/2)
371 | \ .ex_lut(Format("x[-1,-1] x[0,-1] min x[1,-1] min x[-1,0] min x[1,0] min x[-1,1] min x[0,1] min x[1,1] min x min {thb} > range_max 0 ?"), fulls=true)
372 | \ .ex_expand (3,mode="circle").ex_expand(5,mode="ring")
373 | \ .ex_boxblur(2,mode="mean")
374 | \ .GaussResize(w, h, p=4)
375 |
376 | ## "M" - Apply artifact removal
377 | EM = OutFps ? EM.ChangeFPS(NewNum, NewDen) : EM
378 | EMskip = OutFps ? EMskip.ChangeFPS(NewNum, NewDen) : EMskip
379 | EMstp = OutFps ? EMstp.ChangeFPS(NewNum, NewDen) : EMstp
380 | EMm = mskY_to_YYY(Flow, EM, true, false, 3, bi)
381 | EMstpm = mskY_to_YYY(Flow, EMstp, true, false, 3, bi)
382 | M = OutFps && Stp ? ex_lutxyza(Flow, B, EMm, EMstpm, "x dup y - z range_max / * - dup y - a range_max / * -", UV=3, fulls=!tv) : \
383 | OutFps ? ex_merge (Flow, B, EM, luma=true, UV=3) : Flow
384 |
385 | ## Apply BlendOver and SkipOver
386 | SO = ex_bs(SkipOver ,8,bi,fulls=true)
387 | BO = ex_bs(BlendOver,8,bi,fulls=true)
388 | M2 = SkipOver > 0 ? ConditionalFilter(EMskip, BSoft, BHard, "AverageLuma", "<", string(SO)) : B
389 | M = BlendOver > 0 ? ConditionalFilter(EMskip, M, M2, "AverageLuma", "<", string(BO)) : M
390 |
391 | # Prepare Output=Over: Mask(cyan), Stripes(yellow)
392 | FlowOver = ex_blend(Flow.ConverttoPlanarRGB(), CombinePlanes(Blank, EM, EM, source_planes="YYY", planes="RGB", pixel_type="RGBP"+string(bi==32?"S":bi)), "add", 0.4, UV=3, tv_range=false)
393 | FlowOver = Stp ? ex_blend(FlowOver, CombinePlanes(EMstp, EMstp, Blank, source_planes="YYY", planes="RGB", pixel_type="RGBP"+string(bi==32?"S":bi)), "add", 0.4, UV=3, tv_range=false) : FlowOver
394 |
395 | # Output modes
396 | R= (Oput==0) [** auto: artifact masking *]
397 | \ ? (FrameDouble ? Interleave(C, SelectOdd(M)) : M)
398 | \ : (Oput==1) [** flow: interpolation only *]
399 | \ ? Flow
400 | \ : (Oput==2) [** over: mask as cyan overlay *]
401 | \ ? FlowOver
402 | \ : (Oput==3) [** none: ConvertFPS only *]
403 | \ ? B
404 | \ : (Oput==4) [** raw: raw mask *]
405 | \ ? OutRaw
406 | \ : (Oput==5) [** mask: mask only *]
407 | \ ? EM
408 | \ : (Oput==6) [** skip: skip mask *]
409 | \ ? OutSkip
410 | \ : (Oput==7) [** diff: diff mask *]
411 | \ ? EMdiff
412 | \ : (Oput==8) [** stripe: stripes mask *]
413 | \ ? EMstp
414 | \ : Assert(false, "FrameRateConverterEX: 'Output' INTERNAL ERROR")
415 |
416 | # Debug: display AverageLuma values of Skip, Mask and Raw
417 | ShowRaw = OutFps ? OutRaw.ChangeFPS(NewNum, NewDen) : OutRaw
418 | R = Debug ? R.ScriptClip(function [EM,EMskip,EMstp,EMdiff,ShowRaw,BlkSize,SkipOver,BlendOver,CalcDiff,Stp,bi] () {
419 |
420 | Skip = EMskip. AverageLuma() Skip = ex_bs(Skip ,bi,8,fulls=true,flt=true)
421 | EMdiff = EMdiff. AverageLuma() EMdiff = ex_bs(EMdiff ,bi,8,fulls=true,flt=true)
422 | EMstp = EMstp. AverageLuma() EMstp = ex_bs(EMstp ,bi,8,fulls=true,flt=true)
423 | EM = EM. AverageLuma() EM = ex_bs(EM ,bi,8,fulls=true,flt=true)
424 | ShowRaw = ShowRaw.AverageLuma() ShowRaw = ex_bs(ShowRaw ,bi,8,fulls=true,flt=true)
425 |
426 | SkipSoft = BlendOver > 0 && Skip >= BlendOver && (Skip < SkipOver || SkipOver == 0)
427 |
428 | Subtitle("BlkSize: " + string(BlkSize) +
429 | \ (SkipSoft ? " - Blend" : "") +
430 | \ (SkipOver > 0 && Skip >= SkipOver ? " - Skip" : "") +
431 | \ "\nSkip: " + string(Skip, " %.4f") +
432 | \ "\nRaw: " + string(ShowRaw," %.4f") +
433 | \ "\nMask: " + string(EM, " %.4f") +
434 | \ (CalcDiff ? "\nDiff: " + string(EMdiff, " %.4f") : "") +
435 | \ (Stp ? "\nStripes: " + string(EMstp, "%.4f") : "")
436 | \ , lsp=0) } ) : R
437 |
438 | return R }
439 |
440 |
441 |
442 | #######################################################################################
443 | ##
444 | ## InterpolateDoubles
445 | ## Replace double frames with interpolated frames using FrameRateConverter
446 | ##
447 | ## @ Thr - Frames will be replaced when Luma difference with previous frame is greater than threshold (default=0.1)
448 | ##
449 | ## @ Show - If true, "FRAME FIXED" will be written on replaced frames (default=false)
450 | ##
451 | ## @ All other parameters are the same as FrameRateConverter.
452 | ##
453 | function ex_InterpolateDoubles(clip C, float "Thr", bool "Show", string "Preset", int "BlkSize", int "BlkSizeV", int "MaskThr", int "MaskOcc", int "SkipThr", int "BlendOver", int "SkipOver", bool "Stp", int "Dct", int "DctRe", bool "tv_range") {
454 |
455 | bi = BitsPerComponent(C)
456 | fs = propNumElements (C,"_ColorRange") > 0 ? \
457 | propGetInt (C,"_ColorRange") == 0 : false
458 | thr = Default(thr, 0.1)
459 | tv = Default(tv_range, !fs)
460 | Show = Default(Show, false)
461 |
462 | thr = bi > 8 ? ex_bs(thr,8, bi, fulls=!tv, flt=true) : thr
463 | PrevC = C.DeleteFrame(c.FrameCount()-1).DuplicateFrame(0)
464 | #NextC = C.DuplicateFrame(C.FrameCount-1).DeleteFrame(0)
465 | Flow = FrameRateConverterEX(C, FrameDouble=true, Preset=preset, BlkSize=BlkSize, BlkSizeV=BlkSizeV, MaskThr=MaskThr, MaskOcc=MaskOcc, SkipThr=SkipThr, BlendOver=BlendOver, SkipOver=SkipOver, Stp=Stp, Dct=Dct, DctRe=DctRe, tv_range=tv).SelectOdd()
466 | Flow = Show ? Flow.Subtitle("FRAME FIXED",size=30,text_color=$0000FF,align=5) : Flow
467 |
468 | return ConditionalFilter(PrevC, Flow, C, "YDifferenceToNext", "lessthan", string(thr)) }
469 |
470 |
471 | #######################################################################################
472 | ##
473 | ## StripeMask
474 | ## Create a mask detecting horizontal and vertical stripes.
475 | ##
476 | ## @ blkSize - The processing block size.
477 | ##
478 | ## @ blkSizeV - The vertical block size. (default = blkSize)
479 | ##
480 | ## @ str - The grey color of the masked areas.
481 | ##
482 | ## @ strf - The grey color of the masked areas from the next frame.
483 | ##
484 | function ex_StripeMask(clip C, int "blksize", int "blksizev", int "str", int "strf", bool "fullRange") {
485 |
486 | bi = C.BitsPerComponent()
487 | blksize = Default(blksize, 16)
488 | blksizev = Default(blksizev, blksize)
489 | str = Default(str, 200)
490 | strf = Default(strf, 0)
491 | fullRange = Default(fullRange, false)
492 |
493 | mask1 = C.StripeMaskPass(blksize=blkSize, blksizev=blkSizeV, overlap=16/2+1, overlapV=16/2+1, thr=29, range=241, gamma=2.222, str=str, fullRange=fullRange)
494 | blksize = int(float(blksize) * 1.25)
495 | blksizev = int(float(blksizev) * 1.25)
496 | mask2 = C.StripeMaskPass(blksize=blkSize, blksizev=blkSizeV, overlap=16/2+1, overlapV=16/2+1, thr=42, range=214, gamma=2.222, str=str, fullRange=fullRange, comp=5)
497 |
498 | mask1f = mask1.DeleteFrame(0).DuplicateFrame(C.FrameCount() - 2)
499 | mask2f = mask2.DeleteFrame(0).DuplicateFrame(C.FrameCount() - 2)
500 |
501 | strf = ex_bs(strf,8,bi,fulls=false)
502 | return strf > 0 ?
503 | \ ex_lutxyza(mask1, mask2, mask1f, mask2f, Format("x dup y dup z {strf} a {strf} 0 ? ? ? ?"), UV=1) :
504 | \ ex_lutxy (mask1, mask2, "x dup y dup 0 ? ?", UV=1) }
505 |
--------------------------------------------------------------------------------