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. |
23rd July 2010, 05:37 | #322 | Link |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
I'd like to know whether I'm correct in believing that mt_makediff is supposed to be commutative, so that this will produce the original input:
Code:
s=Source() dn=s.Denoise() df=mt_makediff(s,dn,chroma="process") rn=mt_makediff(dn,df,chroma="process") s+rn+df Last edited by foxyshadis; 23rd July 2010 at 05:41. |
23rd July 2010, 09:47 | #323 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
mt_makediff is not commutative - what makes you think it should be? (Subtraction is not a commutative operation.)
Loosely speaking, df = s-dn+128 and rn = dn-df+128, ie dn+dn-s. To reconstitute s, use mt_adddiff(df, dn). (Or mt_adddiff(dn, df), since mt_adddiff is commutative.) |
23rd July 2010, 21:41 | #324 | Link |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
Ah, once I think through the math, it's obvious. Here I've been using mt_makediff as an equivalent to xor for ages now, because it looks close enough. That's my fault for not ever actually thinking all the way through it - I probably munged a few projects that way. Thanks.
Now of course there's mt_logic with a real xor. |
24th July 2010, 01:40 | #325 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Depending on what exactly you want to to. All the "AND", "OR" / "XOR" of mt_logic are only well-defined for clips' values of [0] and [255]. For values [1,254], the behaviour isn't well-defined. After all, those are binary operators.
For general-case usage (i.e: difference clips), the equivalent of "OR" is "max", the equivalent of "AND" is "min". There is no equivalent for "XOR", since that doesn't make sense if the argument is a field/range of possible values. (Slight possibility that Manao was aware and made AND/OR also working that way, I never actually checked. But per documentation, IIRC, AND/OR are really laid out for binary logic.)
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
24th July 2010, 09:12 | #326 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
It even uses pixel values of 11 and 5 as an example, eg for xor, 11 ^ 5 = 1011 ^ 101 = 1110 = 14. Edit: I thought this conversation seemed familiar, and after some searching I found this. Last edited by Gavino; 24th July 2010 at 09:28. |
|
7th September 2010, 13:44 | #327 | Link |
Registered User
Join Date: Jan 2002
Location: France
Posts: 2,856
|
*Bump*
In store, a fix to a problem with mt_clamp and SSE2, pointed out by tp7 on IRC. I also implemented Bi11 proposal to mt_lutspa conundrum. There's now a "mode" parameter, which takes the positional place of the "relative" parameter, which is in turn, together with the "biased" parameter, moved further away and shouldn't be used anymore. Consequently, backward compatibility with named parameters is preserved, but is (yet again) broken with positional parameters.
__________________
|
9th September 2010, 00:50 | #328 | Link |
Registered User
Join Date: Jan 2010
Posts: 270
|
Looks like my first post here. ^^
Since I work a lot with HD video, I have a realy stupid question about scripts optimization. Is there any possibility to replace mt_**pand with predefined custom modes (i.e. mt_square) with multiple calls of mt_**pand internally in masktools? For example, in gradfun2dbmod, one can replace Code:
mt_luts(input,input,mode="range",pixels=mt_square(radius),expr="y",u=1,v=1) Code:
mt_lutxy(input.mt_expand(mode=mt_square(radius)),input.mt_inpand(mode=mt_square(radius)),"x y -",u=1,v=1) Code:
mt_lutxy(input.mt_expand().mt_expand(),input.mt_inpand().mt_inpand(),"x y -",u=1,v=1) Works good, but without *for* statement totaly unoptimal and nonuniversal. It's still possible to optimize script for some often usable modes, but it looks too silly for me. Code:
GFmask = radius==1 ? input.mt_edge(mode="min/max",thY1=0,thY2=255,u=1,v=1) \ : radius==2? mt_lutxy(input.mt_expand().mt_expand(),input.mt_inpand().mt_inpand(),"x y -",u=1,v=1) \ : radius==3? mt_lutxy(input.mt_expand().mt_expand().mt_expand(),input.mt_inpand().mt_inpand().mt_inpand(),"x y -",u=1,v=1) \ : radius==4? mt_lutxy(input.mt_expand().mt_expand().mt_expand().mt_expand(),input.mt_inpand().mt_inpand().mt_inpand().mt_inpand(),"x y -",u=1,v=1) \ : radius==5? mt_lutxy(input.mt_expand().mt_expand().mt_expand().mt_expand().mt_expand(),input.mt_inpand().mt_inpand().mt_inpand().mt_inpand().mt_inpand(),"x y -",u=1,v=1) \ : mt_luts(input,input,mode="range",pixels=mt_square(radius),expr="y",u=1,v=1) Last edited by TurboPascal7; 9th September 2010 at 01:02. |
9th September 2010, 05:34 | #329 | Link |
Registered User
Join Date: Jan 2002
Location: France
Posts: 2,856
|
There are no "for" statements, but you can still do recursive functions :
Code:
function mt_inpand_rec(clip c, int radius) { return radius <= 0 ? c : radius <= 1 ? c.mt_inpand : mt_inpand_rec(c.mt_inpand, radius - 1) }
__________________
|
9th September 2010, 07:47 | #331 | Link | |
Registered User
Join Date: Jan 2002
Location: France
Posts: 2,856
|
Quote:
__________________
|
|
11th September 2010, 11:46 | #332 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
It made me think about two helper functions I wrote for this kind of task, and I thought that I could share them:
Code:
#============================================================================= # mt_expand_multi # mt_inpand_multi # # Calls mt_expand or mt_inpand multiple times in order to grow or shrink # the mask from the desired width and height. # # Parameters: # - sw : Growing/shrinking shape width. 0 is allowed. Default: 1 # - sh : Growing/shrinking shape height. 0 is allowed. Default: 1 # - mode : "rectangle" (default), "ellipse" or "losange". Replaces the # mt_xxpand mode. Ellipses are actually combinations of # rectangles and losanges and look more like octogons. # Losanges are truncated (not scaled) when sw and sh are not # equal. # Other parameters are the same as mt_xxpand. #============================================================================= Function mt_expand_multi (clip src, int "thY", int "thC", string "mode", \ int "offx", int "offy", int "w", int "h", int "y", int "u", int "v", \ string "chroma", int "sw", int "sh") { sw = Default (sw, 1) sh = Default (sh, 1) mode = Default (mode, "rectangle") mode_m = \ (sw > 0 && sh > 0) ? ( \ (mode == "losange" || (mode == "ellipse" && (sw % 3) != 1)) \ ? "both" : "square" \ ) \ : (sw > 0 ) ? "horizontal" \ : ( sh > 0) ? "vertical" \ : "" (mode_m != "") ? src.mt_expand ( \ thY=thY, thC=thC, mode=mode_m, \ offx=offx, offy=offy, w=w, h=h, y=y, u=u, v=v, chroma=chroma \ ).mt_expand_multi ( \ thY=thY, thC=thC, mode=mode, \ offx=offx, offy=offy, w=w, h=h, y=y, u=u, v=v, chroma=chroma, \ sw=sw-1, sh=sh-1 \ ) : src } Function mt_inpand_multi (clip src, int "thY", int "thC", string "mode", \ int "offx", int "offy", int "w", int "h", int "y", int "u", int "v", \ string "chroma", int "sw", int "sh") { sw = Default (sw, 1) sh = Default (sh, 1) mode = Default (mode, "rectangle") mode_m = \ (sw > 0 && sh > 0) ? ( \ (mode == "losange" || (mode == "ellipse" && (sw % 3) != 1)) \ ? "both" : "square" \ ) \ : (sw > 0 ) ? "horizontal" \ : ( sh > 0) ? "vertical" \ : "" (mode_m != "") ? src.mt_inpand ( \ thY=thY, thC=thC, mode=mode_m, \ offx=offx, offy=offy, w=w, h=h, y=y, u=u, v=v, chroma=chroma \ ).mt_inpand_multi ( \ thY=thY, thC=thC, mode=mode, \ offx=offx, offy=offy, w=w, h=h, y=y, u=u, v=v, chroma=chroma, \ sw=sw-1, sh=sh-1 \ ) : src }
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
21st September 2010, 17:51 | #333 | Link |
Registered User
Join Date: Feb 2003
Location: Russia, Moscow
Posts: 854
|
Hi all!
I want organize following calculation: source data prefiltered prefiltered clip 3 masks center, backward and forward, 3 filtered clip centerfiltered, backwardfiltered and forwardfiltered output=prefiltered if (center<backward)&(center<forward) then output=centerfiltered if (backward<center)&(backward<forward) then output=backwardfiltered if (forward<bacward)&(forward<center) then output=forwardfiltered Can this make using masktools? Please advice. yup. |
21st September 2010, 18:17 | #334 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Sure, that can be done. But sorry, the description of the chain is not clear enough.
- you create "3 masks center, backward and forward", but don't explain what is done with those masks - how exactly are centerfiltered, backwardfilterd and forwardfiltered created? (Probably with the three masks from above...) - what means "(center<backward)" etc.? Do you mean "pixel value is smaller"? Or rather "difference to prefiltered", or "difference to source", or ... For "pixel value is smaller", you can use mt_logic(mode="min"). If it's really the difference-to-something, then you can use the Corrector() plugin.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
22nd September 2010, 04:54 | #335 | Link |
Registered User
Join Date: Feb 2003
Location: Russia, Moscow
Posts: 854
|
@Didée
It is very long story, hope you remember http://forum.doom9.org/showthread.php?t=121197 3 masks center, backward and forward is min SAD value from both predictors (for center is backward1 and forward1, for backward backward1 and backward2, for forward forward1 and forward2 ) centerfiltered is median from 3 value center, backward and forward predictors. backwardfiltered is median from 3 value center, backward and backward2 predictors. forwardfiltered in a similar. center<backward mean less by value and this try find better motion predictor from 3 variants. yup. |
24th September 2010, 08:04 | #336 | Link |
Registered User
Join Date: Feb 2003
Location: Russia, Moscow
Posts: 854
|
I think need use cascade mt_lutxyz
if (center<backward)&(center<forward) then output=centerfiltered masktools equivalent mt_lutxyz(center,backward,forward,'x y < x z < &') output=mt_lutxy(last,centerfiltered,output, 'x y z?') Please advice. yup. Last edited by yup; 25th September 2010 at 05:56. Reason: uderstanding how work if operator |
21st November 2010, 17:23 | #337 | Link |
Registered User
Join Date: Jan 2002
Location: France
Posts: 2,856
|
Yet another bugfix, which concerns mt_lutf and "std" mode. Thanks again to TurboPascal7 for pointing out the bug.
__________________
|
1st December 2010, 11:57 | #338 | Link | |
User of free A/V tools
Join Date: Jul 2006
Location: SK
Posts: 826
|
Quote:
|
|
6th December 2010, 15:40 | #339 | Link |
Registered User
Join Date: Nov 2010
Posts: 14
|
How are the luts organized?
I'm asking because I'm worried about CPU cache locality. Considering 'mask' is 99% zeros, which is better, speedwise: a: MT_Lutxyz(mask, frame1, frame2, yexpr="some expression f(x,y,z)") b: MT_Lutxyz(frame2, mask, frame1, yexpr="some expression f(y,z,x)") c: MT_Lutxyz(frame1, frame2, mask, yexpr="some expression f(z,x,y)") Same question could be asked for MT_Lutxy, but since the lut is small, it's not a big deal. In the same vein, while trying to measure the speed difference, I noticed x264 didn't give exactly the same output for options a,b,c. This suggests a fundamental bug. Chris |
6th December 2010, 16:41 | #340 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
|
|
|
|