Thread: Avisynth+
View Single Post
Old 7th October 2019, 18:15   #4886  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
NNEDI3_RPow2 intended for UPSCALE ONLY, it can eg double (x2, x4, x8, power of 2, etc) the dimensions of input clip with good-ish neural net type stuff upsize, and then
using the 'CShift="Spline64"' bit, downsize to the exact required size, and fix center shift imposed by the NNEDI3_RPow2 upsizing.

Is likely slower than LSB high bit depth when down sizing, because you upsize with NNEDI3_RPow2 (probably 4x the area of source), and then downsize to target size.
Only use NNEDI3_RPow2 if UPSIZE.

I usually use NNedi3_RPow2, but assume EDI_RPow2 works the same-ish.

EDIT: Intended for NNedi3_RPow2, but I assume will work with Edi_RPow2
Estimate_Nnedi3_Rpow2() :- https://forum.doom9.org/showthread.php?t=176437

Quote:
Originally Posted by StainlessS View Post
Rough usage
Code:
ColorBars(Width=400,Height=400,Pixel_type="YV12")
InW=Width
InH=Height

SCALE = 3.3
TH    = 1.5
TH2   = TH
TAPS  = 5

RND   = 4    # Rounding to multiple of RND
OutW  = (InW * SCALE + RND-1).Int  / RND * RND   # Round UP
OutH  = (InH * SCALE + RND-1).Int  / RND * RND   # Round UP
#OutW  = (InW * SCALE + RND/2).Int / RND * RND   # Round Nearest
#OutH  = (InH * SCALE + RND/2).Int / RND * RND   # Round Nearest

rFactor=Last.Estimate_Nnedi3_Rpow2(OutW,OutH,th=TH,th2=TH2)
(rFactor>1)
    \ ? nnedi3_rpow2(rfactor=rfactor,cshift="LanczosResize",fwidth=OutW,fheight=OutH,ep0=TAPS)  [* Upsizing *]
    \ : LanczosResize(OutW, OUTH, src_left=-0.5, src_top=-0.5, taps=TAPS)                       [* NOT Upsizing *]

S=String(InW,"InW=%.0f")+String(InH," : InH=%.0f")+String(OutW,"\nOutW=%.0f")+String(OutH," : OutH=%.0f")+String(rFactor,"\nrFactor=%.0f\n") + ((rFactor>1) ? "Using RPOW2" : "Not Using RPOW2")

Return Subtitle(S,Size=Height/16.0,lsp=0)
Change the stuff above in BLUE

EDIT: Nnedi3 resize16() script has ratiothr [instead of above TH and TH2] to do similar:- http://avisynth.nl/index.php/Nnedi3_...io_Calculation
Quote:
Scaling Ratio Calculation
float ratiothr = 1.125

When scale ratio is larger than ratiothr, use nnedi3+Dither_resize16 upscale method instead of pure Dither_resize16.
When horizontal/vertical scale ratio > "ratiothr", we assume it's upscaling
When horizontal/vertical scale ratio <= "ratiothr", we assume it's downscaling
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 7th October 2019 at 18:45.
StainlessS is offline