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. |
8th December 2018, 12:57 | #301 | Link |
Registered User
Join Date: Jan 2014
Posts: 2,309
|
What is the error message?
From v2.2.17 the width and height (for each affected plane) is checked agains the size of the supplied parameters. Lack of this kind of check resulted in sometimes crash, or for "luckier" run it only corrupted pixels and/or memory. E.g. a clip with width=2 will have an error for a 3x3 convolution. Note that if chroma is also processed, the subsampled size (e.g. width/2 for a YV12 chroma plane) should fulfill the size requirements as well. |
8th December 2018, 13:32 | #302 | Link |
Registered User
Join Date: Jan 2011
Location: Donetsk
Posts: 58
|
"mt-convolution:Plane height should be at least the vertical element count"
With masktools2 v.2.2.16 no error function BalanceBorders(clip c, int cTop, int cBottom, int cLeft, int cRight, int "thresh", int "blur") { Assert(isYV12(c), "This is not an YV12 clip. Convert color space to YV12 before using BalanceBorders().") thresh = Default(thresh, 128) blur = Default(blur, 999) Assert(blur > 0, "Blur parameter in BalanceBorders() must be > 0") Assert(thresh > 0, "Thresh parameter in BalanceBorders() must be > 0") c cTop >0 ? BalanceTopBorder(cTop, thresh, blur).TurnRight() : last.TurnRight() cLeft >0 ? BalanceTopBorder(cLeft, thresh, blur).TurnRight() : last.TurnRight() cBottom >0 ? BalanceTopBorder(cBottom, thresh, blur).TurnRight() : last.TurnRight() cRight >0 ? BalanceTopBorder(cRight, thresh, blur).TurnRight() : last.TurnRight() } function BalanceTopBorder(clip c, int cTop, int "thresh", int "blur") { cWidth = c.width cHeight = c.height cTop = min(cTop,cHeight-1) blurWidth = max(4,floor(cWidth/blur)) c2 = c.PointResize(cWidth*2,cHeight*2) c2.\ Crop(0,cTop*2,cWidth*2,2) PointResize(cWidth*2,cTop*2) BilinearResize(blurWidth*2,cTop*2) mt_convolution("1 1 1","0 1 0",y=3,u=3,v=3) BilinearResize(cWidth*2,cTop*2) referenceBlur = last original = c2.Crop(0,0,cWidth*2,cTop*2) original BilinearResize(blurWidth*2,cTop*2) mt_convolution("1 1 1","0 1 0",y=3,u=3,v=3) BilinearResize(cWidth*2,cTop*2) originalBlur = last balanced = mt_lutXYZ(original,originalBlur,referenceBlur,"z y - x +",y=3,u=3,v=3) difference = mt_makeDiff(balanced,original,y=3,u=3,v=3) tp = string(128+thresh) tm = string(128-thresh) difference = difference.mt_lut("x "+tp+" > "+tp+" x ?",y=3,u=3,v=3) difference = difference.mt_lut("x "+tm+" < "+tm+" x ?",y=3,u=3,v=3) mt_addDiff(original,difference,y=3,u=3,v=3) StackVertical(last,c2.Crop(0,cTop*2,cWidth*2,(cHeight-cTop)*2)).PointResize(cWidth,cHeight) } Last edited by Tempter57; 8th December 2018 at 13:47. |
8th December 2018, 15:00 | #303 | Link |
Registered User
Join Date: Sep 2010
Location: Ukraine, Bohuslav
Posts: 377
|
BalanceBorders is just an old script, I suggest you to try https://github.com/sekrit-twc/EdgeFixer. Write me into telegram, if you need x64 build.
|
11th December 2018, 00:45 | #304 | Link |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
|
mod for BalanceBorders https://pastebin.com/sbpK1GGC
it work now and it support new color spaces, and some speed up in non plus old avs
__________________
See My Avisynth Stuff Last edited by real.finder; 28th July 2019 at 05:05. |
19th February 2019, 19:56 | #306 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Hi P, is there some way to achieve this:-
Quote:
something like [EDIT: Below mixed bittage clips, first(K) 10 bit, 2nd(Last) 8 bit, want 10 bit result (same as 1st clip K)] Code:
AviSource("D:\Parade.avi").GreyScale # 8 bit 490x360 YUV12 K=Last.ConvertBits(10).BlankClip # 10 bit 490x360 YUV420P10 Mt_lutxy(K,Last,Expr="y") # Ideally something like Expr="y 2 *" ie shift 8 bit clip over one bit, result 10 bit clip ......0xxxxxxxx0 where x are bits from 8 bit clip. #info I'm totally new to non 8 bit stuff, and a bit thick EDIT: This seems to construct the 10 bit encrypt/decrypt key ok Code:
Function MakeRandomKeyClip(clip c,int Seed,int "Matrix") { Return RandomSource(Length=c.FrameCount,Width=c.width,Height=c.Height,Seed=Seed) \ .ConvertToPlanarRGB \ .ConvertBits(10) \ .ConvertToYUV420(Matrix=Default(Matrix,"rec601")) } EDIT: Perhaps making Stacked 10 bit clip possible, then convert to non stacked. EDIT: Not sure, but suspect we need a 7 bit shift if 10 bit colorspace occupies 10 most significant bits of 16 bit word. EDIT: Think that the below does as we require. Code:
Function EncryptPrep8To10(clip c,Bool "Shift") { # Convert from 8 bit to 10 bit (Shift on luma only if it proves useful, doubtful) c Shift=Default(Shift,False) Limiter() # Dump illegal values StackVertical(Last,Last.Blankclip.Mt_lut("0")) # Stack16 16 bit ConvertFromStacked(Last,16) # 16 bit Native (Shift) ? Mt_Lut(Last,Yexpr="x 1 >>u",y=3,u=2,v=2) : NOP ConvertBits(10) } Function DecryptPrep10To8bit(clip c,Bool "Shift") { # Convert from 10 bit to 8 bit c Shift=Default(Shift,False) ConvertBits(16) # Maybe this dont work as required (Shift) ? Mt_Lut(Last,Yexpr="x 1 <<u",y=3,u=2,v=2) : NOP ConvertToStacked Crop(0,0,0,Height/2) Limiter() # Dump illegal values } SHIFT=True # Experimental (probably of no use) AMP=True # Amplifiy Difference AviSource("D:\Parade.avi") Limiter() # Dont let Limiter inside functions produce difference between in and out clips. ORG=Last EncryptPrep8To10(SHIFT) DecryptPrep10To8bit(SHIFT) D = Subtract(Last,ORG) D = (AMP) ? D.Levels(126-20,1,126+20,16,235,coring=false) : D StackVertical(StackHorizontal(ORG,D),StackHorizontal(Last,D))
__________________
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; 20th February 2019 at 02:57. |
|
20th February 2019, 09:02 | #308 | Link |
Registered User
Join Date: Jan 2014
Posts: 2,309
|
Use Expr when you want to mix together different bit depths.
This one properly shifts luma by one. Code:
AviSource("D:\Parade.avi").GreyScale # 8 bit 490x360 YUV12 K=Last.ConvertBits(10).BlankClip # 10 bit 490x360 YUV420P10 #Mt_lutxy(K,Last,Expr="y") # Ideally something like Expr="y 2 *" ie shift 8 bit clip over one bit, result 10 bit clip ......0xxxxxxxx0 where x are bits from 8 bit clip. Expr(K,Last,"y 2 *","","") http://avisynth.nl/index.php/ConvertBits Tha fact that masktools mt_lutxy does not check for similar input bit-depth is a bit annoying now (I was surprised on StainlessS' example giving me a vertical bar ). It cannot handle properly inputs with different bit depths, unlike Expr. |
20th February 2019, 09:14 | #309 | Link | |
Registered User
Join Date: Jan 2014
Posts: 2,309
|
Quote:
http://avisynth.nl/index.php/D_Notat...te_on_notation In other systems there are other formats e.g. P210, P216 (https://docs.microsoft.com/en-us/win...-video-formats) which are always on the 16 bit magnitude, but the 10 bit version having the six LSB set to 0. These formats are used by Avisynth, e.g. these type of fourCC codes can be negotiated by Avisource, but you, as a script writer will never see it because it will be converted to Avisynth's internal YUV422P10 and YUV422P16 format. |
|
20th February 2019, 18:20 | #310 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Thanks very much Pinterf, guess I gots lots and lots to read up on.
Guess I havta try out Expr, I thought that Masktools now supported mixed bittage, I musta mixed it up with Expr(). Quote:
All of these weird colorspace/bittage formats seem awfully complicated, I think I'll go to bed.
__________________
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 ??? |
|
25th April 2019, 14:57 | #311 | Link |
Registered User
Join Date: Nov 2009
Posts: 2,352
|
I might have dull day, but the next doesn't work for me:
Code:
mt_lut(mt_polish("abs(-40)"),u=-128,v=-128) Same with pow(), the next example renders black. Code:
mt_lut("x 1 pow",u=-128,v=-128) Last edited by Dogway; 25th April 2019 at 15:34. |
25th April 2019, 15:36 | #313 | Link |
Registered User
Join Date: Nov 2009
Posts: 2,352
|
The result is "a"
and Code:
subtitle(mt_polish("pow(x,1)")) Ok, it uses the ^ operator not the pow() function. The abs() issue still intrigues me. Last edited by Dogway; 25th April 2019 at 16:03. |
25th April 2019, 16:03 | #314 | Link |
Registered User
Join Date: Jan 2014
Posts: 2,309
|
Use ^ instead of pow
http://avisynth.nl/index.php/MaskTools2 |
25th April 2019, 16:38 | #315 | Link |
Registered User
Join Date: Nov 2009
Posts: 2,352
|
Making a vignette function but something is not right.
Code:
strength = string(2.0) w=string(width(last)) h=string(height(last)) a=mt_lutspa( last, mode = "absolute", expr = " x "+w+" 2 / - abs "+w+" 2 / / 255 * "+strength+" ^ 255 / 0 max", chroma = "-128" ) b=mt_lutspa( last, mode = "absolute", expr = " y "+h+" 2 / - abs "+w+" 2 / / 255 * "+strength+" ^ 255 / 0 max", chroma = "-128" ) c=mt_lutxy(a,b,"x y + 2 / 255 - abs") c Code:
strength = string(0.75) # range 0,1 w=string(width(last)) h=string(height(last)) a=mt_lutspa( last, mode = "absolute", expr = " x "+w+" 2 / - abs "+w+" 2 / / 255 * 1.5 "+strength+" 2 / + ^ 255 / 0 max", chroma = "-128" ) b=mt_lutspa( last, mode = "absolute", expr = " y "+h+" 2 / - abs "+w+" 2 / / 255 * 1.5 "+strength+" 2 / + ^ 255 / 0 max", chroma = "-128" ) c=mt_lutxy(a,b,"x y + 255 - abs") c Last edited by Dogway; 25th April 2019 at 16:53. |
25th April 2019, 17:52 | #316 | Link |
Registered User
Join Date: Jan 2014
Posts: 2,309
|
You can find some mt_lutspa examples here:
http://avisynth.nl/index.php/MaskTools2/mt_lutspa or use sx, sy, sxr and syr in "Expr" (Avisynth+ only) http://avisynth.nl/index.php/Expr Last edited by pinterf; 25th April 2019 at 17:59. |
25th April 2019, 18:57 | #318 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
I just installed Avisynth for this test,
Code:
BlankClip(pixel_type="YV12") # added strength = string(0.75) # range 0,1 w=string(width(last)) h=string(height(last)) a=mt_lutspa( last, mode = "absolute", expr = " x "+w+" 2 / - abs "+w+" 2 / / 255 * 1.5 "+strength+" 2 / + ^ 255 / 0 max", chroma = "-128" ) b=mt_lutspa( last, mode = "absolute", expr = " y "+h+" 2 / - abs "+w+" 2 / / 255 * 1.5 "+strength+" 2 / + ^ 255 / 0 max", chroma = "-128" ) c=mt_lutxy(a,b,"x y + 255 - abs") c Looks like it might be as intended. EDIT: During testing, suggest use RT_Stats RT_DebugF() to show result expr (and perhaps infix equivalent too [check if RPN parses OK]). EDIT: eg Code:
BlankClip(pixel_type="YV12") strength = string(0.75) # range 0,1 w=string(width(last)) h=string(height(last)) RPN_X = " x "+w+" 2 / - abs "+w+" 2 / / 255 * 1.5 "+strength+" 2 / + ^ 255 / 0 max" RPN_Y = " y "+h+" 2 / - abs "+w+" 2 / / 255 * 1.5 "+strength+" 2 / + ^ 255 / 0 max" INFIX_X=Mt_Infix(RPN_X) INFIX_Y=Mt_Infix(RPN_Y) myName="DoggyDoo: " RT_DebugF("DBGVIEWCLEAR") # Clear DebugView window (thanx Wonkey Donkey) RT_DebugF("RPN_X = '%s'",RPN_X,name=myName) RT_DebugF("RPN_Y = '%s'",RPN_Y,name=myName) RT_DebugF("INFIX_X = '%s'",INFIX_X,name=myName) RT_DebugF("INFIX_Y = '%s'",INFIX_Y,name=myName) a=mt_lutspa( last, mode = "absolute", expr = RPN_X, chroma = "-128" ) b=mt_lutspa( last, mode = "absolute", expr = RPN_Y, chroma = "-128" ) c=mt_lutxy(a,b,"x y + 255 - abs") c Code:
00000074 0.00000000 [2176] DoggyDoo: RPN_X = ' x 640 2 / - abs 640 2 / / 255 * 1.5 0.750000 2 / + ^ 255 / 0 max' 00000075 0.00006196 [2176] DoggyDoo: RPN_Y = ' y 480 2 / - abs 640 2 / / 255 * 1.5 0.750000 2 / + ^ 255 / 0 max' 00000076 0.00012101 [2176] DoggyDoo: INFIX_X = 'max(((((abs((x-(640/2)))/(640/2))*255)^(1.5+(0.750000/2)))/255),0)' 00000077 0.00017681 [2176] DoggyDoo: INFIX_Y = 'max(((((abs((y-(480/2)))/(640/2))*255)^(1.5+(0.750000/2)))/255),0)'
__________________
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; 25th April 2019 at 20:15. |
25th April 2019, 19:17 | #319 | Link |
Registered User
Join Date: Nov 2009
Posts: 2,352
|
Useful to grab plain text result of mt_polish() (or infix)
The mask is in PC levels but I ported the functions to avs+ internal Expr and added an option to merge with source in TV levels. Still a few things might improve since I don't understand well the scale_inputs setting. Code:
function Vignette(clip c, float "Vignette", bool "show") { strength = string(default(Vignette, 0.7)) show = Default(show, false) a=expr( c, " sx width 2 / - abs width 2 / / 255 * 1.5 "+strength+" 2 / + ^ 255 / 0 max", "","", scale_inputs = "allf" ) b=expr( c, " sy height 2 / - abs width 2 / / 255 * 1.5 "+strength+" 2 / + ^ 255 / 0 max", "","", scale_inputs = "allf" ) msk=expr(a,b,"x y + 255 - abs", "128","128", scale_inputs = "allf" ) msktv=msk.expr("x 128 - 224 * 255 / 128 +", scale_inputs = "allf" ) show ? msk : expr(msktv,c,"x 16 - y 16 - * 220 / 1 * x 16 - 1 1 - * + 16 + ", "y", "y", scale_inputs = "all" ) } |
25th April 2019, 19:37 | #320 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Dogways see RED edit in prev post.
Also, can eg calc WD2 = W / 2 in script instead of masktools. Guess if using relative mode, can just use 0.5 instead.
__________________
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; 25th April 2019 at 19:44. |
Thread Tools | Search this Thread |
Display Modes | |
|
|