Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
1st August 2015, 19:13 | #2 | Link |
Registered User
Join Date: Mar 2014
Posts: 308
|
The conversion is pretty straightforward; all you need to do is to replace inpand/expand with mt_inpand/mt_expand, yv12subtract with mt_makediff, and yv12lutxy with mt_lutxy.
__________________
Say no to AviSynth 2.5.8 and DirectShowSource! |
2nd August 2015, 07:42 | #4 | Link |
Registered User
Join Date: Mar 2014
Posts: 308
|
I just checked the MaskTools v1 docs (probably should've done this before writing the first post) and apparently that's not quite right. (Four different calculation modes depending on the options?! v1 is pure insanity.)
Code:
function pSharpen (clip clp, \int "strength", int "threshold", \float "ss_x", float "ss_y", \int "dest_x", int "dest_y") { # getting the input image size ox = clp.width() oy = clp.height() # parsing the input values strength = default(strength, 25) threshold = default(threshold, 75) ss_x = default(ss_x, 1.0) ss_y = default(ss_y, 1.0) dest_x = default(dest_x, ox) dest_y = default(dest_y, oy) strength = strength<0 ? 0 : strength>100 ? 100 : strength threshold = threshold<0 ? 0 : threshold>100 ? 100 : threshold ss_x = ss_x<1.0 ? 1.0 : ss_x ss_y = ss_y<1.0 ? 1.0 : ss_y # oversampling val = ss_x!=1.0 || ss_y!=1.0 ? \clp.lanczosresize(round(ox*ss_x/8)*8,round(oy*ss_y/8)*8) : \clp # calculating the max and min in every 3*3 square max = val.mt_expand() min = val.mt_inpand() # normalizing max and val to values from 0 to (max-min) nmax = average(max, 1, min, -1) nval = average(val, 1, min, -1) # initializing the strings used to obtain the output luma value s = string(strength/100.0) t = string(threshold/100.0) x0 = string((threshold/100.0)*(1.0-strength/100.0)/(1.0-(1.0-threshold/100.0)*(1.0-strength/100.0))) expr = \ "x y / 2 * 1 - abs "+x0+" < " +\ s+" 1 = " +\ "x y 2 / = 0 y 2 / ? " +\ "x y / 2 * 1 - abs 1 "+s+" - / " +\ "? " +\ "x y / 2 * 1 - abs 1 "+t+" - * "+t+" + " +\ "? " +\ "x y 2 / > 1 -1 ? * 1 + y * 2 /" # calculates the new luma value pushing it towards min or max nval = mt_lutxy(nval, nmax, expr) # normalizing val to values from min to max val = average(nval, 1, min, 1) # applying the new luma value to the original clip & # resizing the image to the output values val = val.lanczosresize(dest_x, dest_y) clp = clp.lanczosresize(dest_x, dest_y).mergeluma(val) return clp } Edit (2016-03-07): changed dest_x/dest_y to be ints instead of floats. Edit (2016-03-16): actually make it work when ss_x and ss_y are not both 1, because I broke the script when I originally ported it.
__________________
Say no to AviSynth 2.5.8 and DirectShowSource! Last edited by colours; 16th March 2016 at 11:25. |
1st March 2016, 06:12 | #6 | Link |
Registered User
Join Date: Mar 2007
Posts: 26
|
Hi, I am trying to use the updated Masktools2 version on Win10, and I get this error when I try to use it in a script "
pSharpen(strength=25, threshold=75, ss_x=1.0, ss_y=1.0, dest_x=1.0, dest_y=1.0) Script error: Invalid arguments to function 'lanczosresize'. (C:/Program Files (x86)/AviSynth+/plugins64/pSharpen.avsi, line 60) (D:\Downloads\Clip Output\Clip.avs, line 5)" Line 60 being " clp = ss_x!=1.0 || ss_y!=1.0 || dest_x!=ox || dest_y!=oy ? clp.lanczosresize(dest_x,dest_y) : clp" Line 5 being "pSharpen(strength=25, threshold=75, ss_x=1.0, ss_y=1.0, dest_x=1.0, dest_y=1.0)" any thoughts on what could be causing that? |
1st March 2016, 08:36 | #7 | Link | |
Registered User
Join Date: Mar 2007
Posts: 26
|
Quote:
Ok so just changing it to pSharpen() in the script at least lets it load. Just seems the example usage of the script should have added a bit of clarity to the line stating that the Dest_x+y should be the final video size. Thanks for pointing me in the right direction |
|
1st March 2016, 14:56 | #8 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
However, it wrongly says they default to 1.0 - the defaults are the original input dimensions (see the code in post #4 above). Like HolyWu, I am puzzled about them being declared as float, when they must be integers for the function to work properly. |
|
7th March 2016, 10:13 | #10 | Link | |
Registered User
Join Date: Mar 2014
Posts: 308
|
Quote:
(I do not claim authorship over this script and will not be offering further fixes/changes for it.)
__________________
Say no to AviSynth 2.5.8 and DirectShowSource! |
|
8th March 2016, 12:06 | #11 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,255
|
btw. using 'pSharpen(ss_x=2.00,ss_y=2.00)' causes a 'MergeLuma: Images must have same width and height!'-error
adding clp=val in line 26 at the end of the oversampling part seems to fix it: Code:
function pSharpen (clip clp, \int "strength", int "threshold", \float "ss_x", float "ss_y", \int "dest_x", int "dest_y") { # getting the input image size ox = clp.width() oy = clp.height() # parsing the input values strength = default(strength, 25) threshold = default(threshold, 75) ss_x = default(ss_x, 1.0) ss_y = default(ss_y, 1.0) dest_x = default(dest_x, ox) dest_y = default(dest_y, oy) strength = strength<0? 0 : strength>100? 100 : strength threshold = threshold<0? 0 : threshold>100? 100 : threshold ss_x = ss_x<1.0? 1.0 : ss_x ss_y = ss_y<1.0? 1.0 : ss_y # oversampling val = ss_x!=1.0 || ss_y!=1.0 ? \clp.lanczosresize(round(ox*ss_x/8)*8,round(oy*ss_y/8)*8) : \clp clp=val # calculating the max and min in every 3*3 square max = val.mt_expand() min = val.mt_inpand() # normalizing max and val to values from 0 to (max-min) nmax = average(max,1,min,-1) nval = average(val,1,min,-1) # initializing the strings used to obtain the output luma value s = string(strength/100.0) t = string(threshold/100.0) x0 = string((threshold/100.0)*(1.0-strength/100.0)/(1.0-(1.0-threshold/100.0)*(1.0-strength/100.0))) expr = \ "x y / 2 * 1 - abs "+x0+" < " +\ s+" 1 = " +\ "x y 2 / = 0 y 2 / ? " +\ "x y / 2 * 1 - abs 1 "+s+" - / " +\ "? " +\ "x y / 2 * 1 - abs 1 "+t+" - * "+t+" + " +\ "? " +\ "x y 2 / > 1 -1 ? * 1 + y * 2 /" # calculates the new luma value pushing it towards min or max nval = mt_lutxy(nval,nmax,expr) # normalizing val to values from min to max val = average(nval,1,min,1) # applying the new luma value to the original clip clp = clp.mergeluma(val) # resizing the image to the output values clp = ss_x!=1.0 || ss_y!=1.0 || dest_x!=ox || dest_y!=oy ? clp.lanczosresize(dest_x,dest_y) : clp return clp } Last edited by Selur; 8th March 2016 at 12:09. |
8th March 2016, 20:12 | #12 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
This may behave differently in v2.58 and v2.6 (2.6 enforces eg conversion client supplied ss_x as int to type float, v2.58 will evaluate as int).
Code:
ss_x = default(ss_x, 1.0) ss_y = default(ss_y, 1.0) Code:
ss_x = Float(default(ss_x, 1.0)) ss_y = Float(default(ss_y, 1.0)) EDIT: Whether the rest of the function behaves ok, I have no idea (I dont want to look at it any further).
__________________
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; 8th March 2016 at 20:26. |
16th March 2016, 11:30 | #13 | Link | |
Registered User
Join Date: Mar 2014
Posts: 308
|
Quote:
StainlessS: Nobody should still be using 2.5.8 or any earlier version when upgrading is as simple as stuffing a newer DLL in system32/syswow64. Don't suggest nonsolutions to nonproblems.
__________________
Say no to AviSynth 2.5.8 and DirectShowSource! |
|
16th March 2016, 11:35 | #14 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Yeh well tell that to the people that are still using v2.57. (there are some)
__________________
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 ??? |
Thread Tools | Search this Thread |
Display Modes | |
|
|