hello_hello
8th December 2021, 15:07
anton_foy,
Something else you might want to try...
Expanding a limited range source to full range for MAnalyse seems to be common in functions these days. I've been meaning to add it for a while but never got round to it. It might compensate for reducing the bitdepth though. I don't know, but I added some new arguments to FastDegrain and MDegrainNL for MAnalyse bitdepth and range, and while I was at it I added Degrain4/5/6 to FastDegrain, in case you want to encode even slower. :)
# ===============================================================================
# ===============================================================================
# MDegrainNL (MDegrainN Light) 2021-12-09
# ===============================================================================
# ===============================================================================
function MDegrainNL(clip Source, \
int "TR", int "thSAD", int "thSAD2", int "BLKSize", int "Overlap", int "Pel", bool "Precise", \
bool "TrueM", bool "GlobalM", bool "Exp", bool "SBits", int "BitD", int "lambda", int "pnew", bool "MT", bool "LSB") {
TR = default(TR, 1) # Temporal radius
thSAD = default(thSAD, 150) # Denoising strength
BLKSize = default(BLKSize, 16) # Block size
Overlap = default(Overlap, BLKSize/2) # Block overlap
Pel = default(Pel, 2) # MVAnalyse pel (1, 2, 4)
Precise = default(Precise, false) # Recalculate
TrueM = default(TrueM, false) # Enable/disable truemotion
GlobalM = default(GlobalM, true) # Enable/disable global motion
Exp = default(Exp, true) # Limited->Full range expansion for MAnalyse search
SBits = default(SBits, false) # Use source bitdepth for MAnalyse search
BitD = default(BitD, 8) # Bit depth for MAnalyse search (max = source bits)
MT = default(MT, false) # Internal multithreading
LSB = default(LSB, false) # Stacked 16-bit
# Uncommenting the two lines below results in the same MVTools2 settings as QTGMC when truemotion=false
# lambda = default(lambda, (TrueM ? 1000 : 100 ) * BLKSize * BLKSize / 64)
# pnew = default(pnew, TrueM ? 50 : 25)
# -------------------------------------------------------------------------------
AvsVerStrLC = LCase(VersionString())
IsAvsPlus = (FindStr(AvsVerStrLC, "avisynth+") > 0)
IsAvsNeo = (FindStr(AvsVerStrLC, "avisynth neo") > 0)
AvsStrNum = IsAvsPlus || IsAvsNeo ? FindStr(AvsVerStrLC, "(r") + 2 : 0
AvsBuildNum = (AvsStrNum > 2) ? int(value(MidStr(AvsVerStrLC, AvsStrNum))) : 0
IsAvsHBD = (AvsBuildNum > 2294)
# -------------------------------------------------------------------------------
Super = MSuper(Source, pel=Pel, mt=MT)
Search = Exp ? Super.ColorYUV(levels="TV->PC") : Super
Search = IsAvsHBD && !SBits && (BitD < BitsPerComponent(Source)) ? Search.ConvertBits(BitD) : Search
MultiVec1 = MAnalyse(Search, multi=true, delta=TR, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, global=GlobalM, lambda=lambda, pnew=pnew, mt=MT)
MultiVec2 = !Precise ? MultiVec1 : \
MRecalculate(Search, MultiVec1, tr=TR, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD2, truemotion=TrueM, lambda=lambda, pnew=pnew)
MDegrainN(Source, Super, MultiVec2, TR, thSAD=thSAD, thSAD2=thSAD2, mt=MT, lsb=LSB) }
# ===============================================================================
# ===============================================================================
# ===============================================================================
# ===============================================================================
# FastDegrain 2021-12-09
# ===============================================================================
# ===============================================================================
#
# FastDegrain by Sagekilla
# Easy to use alias for MDegrain 1, 2, or 3
# Features optional sharpening if you should desire
# Required plugins: LSFMod (to enable sharpening) & MVTools2.dll
#
# Changes by Hello_Hello
# Updated the required plugins list
# Added missing "thSAD" argument for MDegrain1, MDegrain2 & MDegrain3
# Added "TrueM" argument and made truemotion=false the default
# Added "GlobalM" argument and made global=true the default
# Added "MT" argument
# Added "Precise" argument
# Added "Exp" argument
# Added "SBits" argument
# Added "BitD" argument
# LimitedSharpenFaster variable "oshot" corrected to "OShoot"
# Replaced LimitedSharpenFaster with LSFMod
# Added "SFirst" argument and moved the sharpening to after the degraining by default
# Changed the default for "Sharp" from 160 to 75
#
# -------------------------------------------------------------------------------
#
# Degrain: MVDegrain 1, 2, or 3. Each is increasingly stronger and slower.
# thSAD: Affects degraining: Low values reduce degraining, high values raise it.
# BLKSize: MVAnalsye blksize. See MVTools documentation for details.
# Overlap: MVAnalyse overlap. Must be even & <= BLKSize/2. Higher values are better & slower.
# Pel: MVAnalyse subpixel accuracy. Higher values give better MVs and lowers speed.
# Precise: Recalculate. It's quite a bit slower.
# Limit: Limits max MVDegrain change. Decrease if you experience artifacts.
# TrueM: Enables truemotion.
# GlobalM: Disables global motion.
# Exp: Limited->Full range expansion for MAnalyse search. Set false for full range source. Default true.
# SBits: For bit depths > 8, use the same bit depth for MAnalyse search as the source. Default false.
# BitD: Bit depth for MAnalyse search when SBits=false. Max = source bits. Default 8.
# MT: Enables internal multithreading.
# Sharp: Enables LSFMod sharpening.
# Str: LSFMod's sharpening strength. Increase for more sharpening.
# SS: Supersampling for LSFMod, values over 1 decrease edge aliasing.
# Sft: Dampens LSFMod sharpening (it weakens the sharpening)
# OShoot: Sharpening limit, increase it too much and it causes haloing.
# SFirst: SFirst=true sharpens before denoising. The default is false.
#
# ===============================================================================
# ===============================================================================
function FastDegrain(clip Source, \
int "Degrain", int "BLKSize", int "thSAD", int "Overlap", int "Pel", bool "Precise", int "Limit", \
bool "TrueM", bool "GlobalM", bool "Exp", bool "SBits", int "BitD", bool "MT", int "lambda", int "pnew", \
bool "Sharp", int "Str", int "SS", int "Sft", int "OShoot", bool "SFirst") {
# -------------------------------------------------------------------------------
Degrain = default(Degrain, 2) # Degraining method (1 - 3)
thSAD = default(thSAD, 400) # MVDegrain thSAD
BLKSize = default(BLKSize, 8) # MAnalyse block size (4, 8, 16)
Overlap = default(Overlap, BLKSize/2) # MVAnalyse block overlap
Pel = default(Pel, 1) # MVAnalyse pel (1, 2, 4)
Precise = default(Precise, false) # Recalculate
Limit = default(Limit, 255) # MVDegrain limit (0 - 255)
TrueM = default(TrueM, false) # Enable/disable truemotion
GlobalM = default(GlobalM, true) # Enable/disable global motion
Exp = default(Exp, true) # Limited->Full range expansion for MAnalyse search
SBits = default(SBits, false) # Use source bitdepth for MAnalyse search
BitD = default(BitD, 8) # Bit depth for MAnalyse search (max = source bits)
MT = default(MT, false) # Internal multithreading (through avstp.dll)
Sharp = default(Sharp, false) # Toggles LSFMod
Str = default(Str, 75) # LSFMod strength
SS = default(SS, 1.5) # LSFMod supersampling
Sft = default(Sft, 30) # LSFMod soft
OShoot = default(OShoot, 1) # LSFMod overshoot
SFirst = default(SFirst, false) # Enable sharpening before denoising
# Uncommenting the two lines below results in the same MVTools2 settings as QTGMC when truemotion=false
# lambda = default(lambda, (TrueM ? 1000 : 100 ) * BLKSize * BLKSize / 64)
# pnew = default(pnew, TrueM ? 50 : 25)
# -------------------------------------------------------------------------------
AvsVerStrLC = LCase(VersionString())
IsAvsPlus = (FindStr(AvsVerStrLC, "avisynth+") > 0)
IsAvsNeo = (FindStr(AvsVerStrLC, "avisynth neo") > 0)
AvsStrNum = IsAvsPlus || IsAvsNeo ? FindStr(AvsVerStrLC, "(r") + 2 : 0
AvsBuildNum = (AvsStrNum > 2) ? int(value(MidStr(AvsVerStrLC, AvsStrNum))) : 0
IsAvsHBD = (AvsBuildNum > 2294)
# -------------------------------------------------------------------------------
Input = !Sharp || !SFirst ? Source : \
Source.LSFMod(strength=Str, ss_x=SS, ss_y=SS, soft=Sft, overshoot=OShoot)
Super = Input.MSuper(pel=Pel, mt=MT)
Search = Exp ? Super.ColorYUV(levels="TV->PC") : Super
Search = IsAvsHBD && !SBits && (BitD < BitsPerComponent(Source)) ? Search.ConvertBits(BitD) : Search
bvec1 = (Degrain >= 1) ? MAnalyse(Search, isb=true, delta=1, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, global=GlobalM, lambda=lambda, pnew=pnew, mt=MT) : nop()
bvec2 = (Degrain >= 2) ? MAnalyse(Search, isb=true, delta=2, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, global=GlobalM, lambda=lambda, pnew=pnew, mt=MT) : nop()
bvec3 = (Degrain >= 3) ? MAnalyse(Search, isb=true, delta=3, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, global=GlobalM, lambda=lambda, pnew=pnew, mt=MT) : nop()
bvec4 = (Degrain >= 4) ? MAnalyse(Search, isb=true, delta=4, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, global=GlobalM, lambda=lambda, pnew=pnew, mt=MT) : nop()
bvec5 = (Degrain >= 5) ? MAnalyse(Search, isb=true, delta=5, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, global=GlobalM, lambda=lambda, pnew=pnew, mt=MT) : nop()
bvec6 = (Degrain >= 6) ? MAnalyse(Search, isb=true, delta=6, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, global=GlobalM, lambda=lambda, pnew=pnew, mt=MT) : nop()
fvec1 = (Degrain >= 1) ? MAnalyse(Search, isb=false, delta=1, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, global=GlobalM, lambda=lambda, pnew=pnew, mt=MT) : nop()
fvec2 = (Degrain >= 2) ? MAnalyse(Search, isb=false, delta=2, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, lambda=lambda, pnew=pnew, global=GlobalM, mt=MT) : nop()
fvec3 = (Degrain >= 3) ? MAnalyse(Search, isb=false, delta=3, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, global=GlobalM, lambda=lambda, pnew=pnew, mt=MT) : nop()
fvec4 = (Degrain >= 4) ? MAnalyse(Search, isb=false, delta=4, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, global=GlobalM, lambda=lambda, pnew=pnew, mt=MT) : nop()
fvec5 = (Degrain >= 5) ? MAnalyse(Search, isb=false, delta=5, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, lambda=lambda, pnew=pnew, global=GlobalM, mt=MT) : nop()
fvec6 = (Degrain >= 6) ? MAnalyse(Search, isb=false, delta=6, blksize=BLKSize, overlap=Overlap, \
truemotion=TrueM, global=GlobalM, lambda=lambda, pnew=pnew, mt=MT) : nop()
# -------------------------------------------------------------------------------
Precise ? Eval("""
bvec1 = (Degrain >= 1) ? MRecalculate(Search, bvec1, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
bvec2 = (Degrain >= 2) ? MRecalculate(Search, bvec2, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
bvec3 = (Degrain >= 3) ? MRecalculate(Search, bvec3, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
bvec4 = (Degrain >= 4) ? MRecalculate(Search, bvec4, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
bvec5 = (Degrain >= 5) ? MRecalculate(Search, bvec5, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
bvec6 = (Degrain >= 6) ? MRecalculate(Search, bvec6, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
fvec1 = (Degrain >= 1) ? MRecalculate(Search, fvec1, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
fvec2 = (Degrain >= 2) ? MRecalculate(Search, fvec2, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
fvec3 = (Degrain >= 3) ? MRecalculate(Search, fvec3, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
fvec4 = (Degrain >= 4) ? MRecalculate(Search, fvec4, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
fvec5 = (Degrain >= 5) ? MRecalculate(Search, fvec5, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
fvec6 = (Degrain >= 6) ? MRecalculate(Search, fvec6, blksize=BLKSize/2, overlap=Overlap/2, \
thSAD=thSAD/2, truemotion=TrueM, lambda=lambda, pnew=pnew) : nop()
""") : nop()
# -------------------------------------------------------------------------------
Output = \
(Degrain < 1) ? Input : \
(Degrain == 1) ? \
MDegrain1(Input, Super, bvec1, fvec1, \
thSAD=thSAD, limit=Limit) : \
(Degrain == 2) ? \
MDegrain2(Input, Super, bvec1, fvec1, bvec2, fvec2, \
thSAD=thSAD, limit=Limit) : \
(Degrain == 3) ? \
MDegrain3(Input, Super, bvec1, fvec1, bvec2, fvec2, bvec3, fvec3, \
thSAD=thSAD, limit=Limit) : \
(Degrain == 4) ? \
MDegrain4(Input, Super, bvec1, fvec1, bvec2, fvec2, bvec3, fvec3, bvec4, fvec4, \
thSAD=thSAD, limit=Limit) : \
(Degrain == 5) ? \
MDegrain5(Input, Super, bvec1, fvec1, bvec2, fvec2, bvec3, fvec3, bvec4, fvec4, bvec5, fvec5, \
thSAD=thSAD, limit=Limit) : \
(Degrain >= 6) ? \
MDegrain6(Input, Super, bvec1, fvec1, bvec2, fvec2, bvec3, fvec3, bvec4, fvec4, bvec5, fvec5, bvec6, fvec6, \
thSAD=thSAD, limit=Limit) : nop()
Output = \
!Sharp || SFirst ? Output : Output.LSFMod(strength=Str, ss_x=SS, ss_y=SS, soft=Sft, overshoot=OShoot)
return Output }
# ===============================================================================
# ===============================================================================
# FastDegrainSharp
# ===============================================================================
# ===============================================================================
function FastDegrainSharp(clip Source, \
int "Degrain", int "BLKSize", int "thSAD", int "Overlap", int "Pel", bool "Precise", int "Limit", \
bool "TrueM", bool "GlobalM", bool "Exp", bool "SBits", int "BitD", bool "MT", int "lambda", int "pnew", \
bool "Sharp", int "Str", int "SS", int "Sft", int "OShoot", bool "SFirst") {
Sharp = default(Sharp, true)
FastDegrain(Source, Degrain, BLKSize, thSAD, Overlap, Pel, Precise, Limit, \
TrueM, GlobalM, Exp, SBits, BitD, lambda, pnew, MT, Sharp, Str, SS, Sft, OShoot, SFirst) }
# ===============================================================================
# ===============================================================================
anton_foy
9th December 2021, 00:44
Is it used in MAnalyse?"
Yes. Archive have compiled version SO1_PT4 with hardcoded PredictorType=4 option for users without ability to edit complicated scripts. So you can simply load this dll. It also have some simple optimizations for CPUs up to SSE4.1.
Yes it works! I get the impression it keeps a little more details but speed is 0.0375x with this script:
# FastDegrain - MOD #
function FastDegrain( clip src, int "degrain", int "blksize", int "overlap", int "pel",
\ int "thSAD", int "limit", bool "MT")
{
degrain = default( degrain, 2 ) # Degraining method (1 - 3)
blksize = default( blksize, 8 ) # MAnalyse block size (4, 8, 16)
overlap = default( overlap, blksize/2 ) # MVAnalyse block overlap (even, ov<=blksize/2)
pel = default( pel, 1 ) # MVAnalyse pel (1, 2, 4)
thSAD = default( thSAD, 400 ) # MVDegrain thSAD
limit = default( limit, 255 ) # MVDegrain limit (0 - 255)
MT = default( MT, false) # Internal multithreading (through avstp.dll)
# Create our Super clip for MV search. Then, search for motion vectors.
super8 = src.convertbits(8).ex_KNLMeansCL(D=1, A=2, h=6, s=2, device_type="gpu").MSuper(pel=pel)
super = src.MSuper(pel=pel)
bvec3 = (degrain>=3) ? super8.MAnalyse(isb=true, delta=3, blksize=blksize, overlap=overlap, mt=MT, PredictorType=4) : NOP()
bvec2 = (degrain>=2) ? super8.MAnalyse(isb=true, delta=2, blksize=blksize, overlap=overlap, mt=MT, PredictorType=4) : NOP()
bvec1 = (degrain>=1) ? super8.MAnalyse(isb=true, delta=1, blksize=blksize, overlap=overlap, mt=MT, PredictorType=4) : NOP()
fvec1 = (degrain>=1) ? super8.MAnalyse(isb=false, delta=1, blksize=blksize, overlap=overlap, mt=MT, PredictorType=4) : NOP()
fvec2 = (degrain>=2) ? super8.MAnalyse(isb=false, delta=2, blksize=blksize, overlap=overlap, mt=MT, PredictorType=4) : NOP()
fvec3 = (degrain>=3) ? super8.MAnalyse(isb=false, delta=3, blksize=blksize, overlap=overlap, mt=MT, PredictorType=4) : NOP()
# Degraining the video using MVDegrain. Nothing special here.
src = (degrain==1) ? src.MDegrain1(super, bvec1, fvec1, thSAD=thSAD, limit=limit) : src
src = (degrain==2) ? src.MDegrain2(super, bvec1, fvec1, bvec2, fvec2, thSAD=thSAD, limit=limit) : src
src = (degrain>=3) ? src.MDegrain3(super, bvec1, fvec1, bvec2, fvec2, bvec3, fvec3, thSAD=thSAD, limit=limit) : src
return src
}
With this script its 0.0378x. So very close speedwise:
# FastDegrain - MOD #
function FastDegrain( clip src, int "degrain", int "blksize", int "overlap", int "pel",
\ int "thSAD", int "limit", bool "MT")
{
degrain = default( degrain, 2 ) # Degraining method (1 - 3)
blksize = default( blksize, 8 ) # MAnalyse block size (4, 8, 16)
overlap = default( overlap, blksize/2 ) # MVAnalyse block overlap (even, ov<=blksize/2)
pel = default( pel, 1 ) # MVAnalyse pel (1, 2, 4)
thSAD = default( thSAD, 400 ) # MVDegrain thSAD
limit = default( limit, 255 ) # MVDegrain limit (0 - 255)
MT = default( MT, false) # Internal multithreading (through avstp.dll)
# Create our Super clip for MV search. Then, search for motion vectors.
super8 = src.convertbits(8).ex_KNLMeansCL(D=1, A=2, h=6, s=2, device_type="gpu").MSuper(pel=pel)
super = src.MSuper(pel=pel)
bvec3 = (degrain>=3) ? super8.MAnalyse(isb=true, delta=3, blksize=blksize, overlap=overlap, mt=MT) : NOP()
bvec2 = (degrain>=2) ? super8.MAnalyse(isb=true, delta=2, blksize=blksize, overlap=overlap, mt=MT) : NOP()
bvec1 = (degrain>=1) ? super8.MAnalyse(isb=true, delta=1, blksize=blksize, overlap=overlap, mt=MT) : NOP()
fvec1 = (degrain>=1) ? super8.MAnalyse(isb=false, delta=1, blksize=blksize, overlap=overlap, mt=MT) : NOP()
fvec2 = (degrain>=2) ? super8.MAnalyse(isb=false, delta=2, blksize=blksize, overlap=overlap, mt=MT) : NOP()
fvec3 = (degrain>=3) ? super8.MAnalyse(isb=false, delta=3, blksize=blksize, overlap=overlap, mt=MT) : NOP()
# Degraining the video using MVDegrain. Nothing special here.
src = (degrain==1) ? src.MDegrain1(super, bvec1, fvec1, thSAD=thSAD, limit=limit) : src
src = (degrain==2) ? src.MDegrain2(super, bvec1, fvec1, bvec2, fvec2, thSAD=thSAD, limit=limit) : src
src = (degrain>=3) ? src.MDegrain3(super, bvec1, fvec1, bvec2, fvec2, bvec3, fvec3, thSAD=thSAD, limit=limit) : src
return src
}
EDIT: THSAD=200 makes it freeze every time for me.
For a speed check, using my script commenting out everything but convertbits(16), Levels, ConverttoYUV444() and convertbits(10) has a speed of 0.0562x
hello_hello
9th December 2021, 03:11
Fastdegrain(degrain=3,bitd=8,globalm=false,thsad=300) speed = 0.029x so pretty fast! Although it is very different in appearence to my old FastDegrain script because it is softer overall.
It's probably related to a truemotion setting (truemotion and global motion are enabled by default). And maybe the reduction in bitdepth or expansion of levels for MAnalyse. You'd need to change them one at a time to find out what's causing it to look softer. There's no reason why the scripts should run at different speeds if the settings are identical.
I downloaded your original script from post # 26. The only changes I made were to add the missing thSAD arguments and the MT argument so I could enable/disable MT easily, and I changed the name to FDegrain so I could put it in the auto-loading folder and run both versions, then I did a comparison with the version I posted yesterday. When the settings are the same they're exactly the same.
A = FastDegrain(degrain=3, TrueM=true, thsad=300, Sbits=true, Exp=false)
B = FDegrain(degrain=3, thsad=300)
ShowDiff(A, B, Amp=true)
https://i.postimg.cc/F7qzfWQz/same.jpg (https://postimg.cc/F7qzfWQz)
As a side note, enabling internal multithreading definitely changes the output, although when it's enabled for both versions the result is still the same.
A = FastDegrain(degrain=3, TrueM=true, thsad=300, Sbits=true, Exp=false, MT=true)
B = FDegrain(degrain=3, thsad=300, MT=false)
ShowDiff(A, B, Amp=true)
https://i.postimg.cc/TLR38Bn7/mt-true.jpg (https://postimg.cc/TLR38Bn7)
I ran a couple of test encodes with Exp=true. Expanding the levels for MAnalyse obviously makes a difference. I think it does retain a tad more detail during motion but it probably removes a little less noise during motion too.
The bitrate of the encode was a little lower than with Exp=false for both tests, so I think I'll keep using Exp=true.
A = FastDegrain(degrain=3, TrueM=true, thsad=300, Sbits=true, Exp=true, MT=false)
B = FDegrain(degrain=3, thsad=300, MT=false)
ShowDiff(A, B, Amp=true)
https://i.postimg.cc/Cn5M5DPb/exp.jpg (https://postimg.cc/Cn5M5DPb)
The MDegrainNL is not working at all sadly I get allocated memory error.
I'm not sure what the deal is with MDegrainNL. It's working here. Maybe it relates to the version of MVTools2 you're testing.
function ShowDiff(clip Clip1, clip Clip2, val "Amp", val "Comp", val "Show") {
Amp = defined(Amp) && IsInt(Amp) ? ((Amp == 0) ? false : true) : default(Amp, false)
Show = defined(Show) && IsInt(Show) ? ((Show == 0) ? false : true) : default(Show, false)
Comp = defined(Comp) && IsInt(Comp) ? ((Comp == 0) ? false : true) : default(Comp, false)
assert((IsInt(Amp) || IsBool(Amp)) && (IsInt(Comp) || IsBool(Comp)) && (IsInt(Show) || IsBool(Show)), \
" ShowDiff " + chr(10) + """ "Amp", "Comp" & "Show", can only be integer or bool. """ + chr(10) + \
" For Integer: Zero specifies false, and any other integer specifies true. " + chr(10) + \
" For Bool: They be true or false. " + chr(10))
C1 = Clip1.levels(96, 1.0, 160, 96, 160).GreyScale()
C2 = Subtract(Clip1, Clip2)
C3 = !Amp ? C2 : C2.levels(124, 1.0, 131, 0, 255)
C4 = !Show ? C3 : Merge(C1, C3)
C5 = !Comp ? C4 : Compare(Clip1, Clip2, show_graph=true)
return C5 }
function FDegrain( clip src, int "degrain", int "blksize", int "overlap", int "pel",
\ int "thSAD", int "limit", bool "MT")
{
degrain = default( degrain, 2 ) # Degraining method (1 - 3)
blksize = default( blksize, 8 ) # MAnalyse block size (4, 8, 16)
overlap = default( overlap, blksize/2 ) # MVAnalyse block overlap (even, ov<=blksize/2)
pel = default( pel, 1 ) # MVAnalyse pel (1, 2, 4)
thSAD = default( thSAD, 400 ) # MVDegrain thSAD
limit = default( limit, 255 ) # MVDegrain limit (0 - 255)
MT = default( MT, false ) # Internal multithreading (through avstp.dll)
# Create our Super clip for MV search. Then, search for motion vectors.
super = src.MSuper(pel=pel, mt=MT)
bvec3 = (degrain>=3) ? super.MAnalyse(isb=true, delta=3, blksize=blksize, overlap=overlap, mt=MT) : NOP()
bvec2 = (degrain>=2) ? super.MAnalyse(isb=true, delta=2, blksize=blksize, overlap=overlap, mt=MT) : NOP()
bvec1 = (degrain>=1) ? super.MAnalyse(isb=true, delta=1, blksize=blksize, overlap=overlap, mt=MT) : NOP()
fvec1 = (degrain>=1) ? super.MAnalyse(isb=false, delta=1, blksize=blksize, overlap=overlap, mt=MT) : NOP()
fvec2 = (degrain>=2) ? super.MAnalyse(isb=false, delta=2, blksize=blksize, overlap=overlap, mt=MT) : NOP()
fvec3 = (degrain>=3) ? super.MAnalyse(isb=false, delta=3, blksize=blksize, overlap=overlap, mt=MT) : NOP()
# Degraining the video using MVDegrain. Nothing special here.
src = (degrain==1) ? src.MDegrain1(super, bvec1, fvec1, thSAD=thSAD, limit=limit, mt=MT) : src
src = (degrain==2) ? src.MDegrain2(super, bvec1, fvec1, bvec2, fvec2, thSAD=thSAD, limit=limit, mt=MT) : src
src = (degrain>=3) ? src.MDegrain3(super, bvec1, fvec1, bvec2, fvec2, bvec3, fvec3, thSAD=thSAD, limit=limit, mt=MT) : src
return src
}
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.