Log in

View Full Version : MaskTools2 - pfmod


Pages : 1 2 3 [4] 5 6 7 8 9

pinterf
20th June 2017, 08:01
Check your original clip.

First, run with a simple Limiter() first.
http://avisynth.nl/index.php/Limiter

If mt_lut conversions are now O.K., go back and check by Limiter(...,show="luma_grey") where the original clip exceeds luma (or chroma: show="chroma_grey) limits.

edcrfv94
20th June 2017, 14:45
Check your original clip.

First, run with a simple Limiter() first.
http://avisynth.nl/index.php/Limiter

If mt_lut conversions are now O.K., go back and check by Limiter(...,show="luma_grey") where the original clip exceeds luma (or chroma: show="chroma_grey) limits.

mt_lut conversions are work fine.
Because original clip out of tv range(max luma Y:237), so can not invert back to original image.
Default PC range is more safe, it my bad.

StainlessS
22nd June 2017, 23:10
Hi Pinterf,
When you get the time, can you please put note on first post noting most recent version to support Mt_Polish/Mt_Infix for XP. Thanx :)

javidial
12th July 2017, 21:19
Hi,
I'm trying to use QTGMC. I've downloaded all the plugins necesary, like the latest Masktools2, but still when I preview my script in MeGUI, it pops an error saying "there is no function named MSuper".

The function supposed to be included in the masktools2.dll, right? what am I missing. The masktools2 seems to load correctly cos it doesn't give me any error loading it.

Can somebody help me? Thanks

Motenai Yoda
12th July 2017, 21:33
Hi,
I'm trying to use QTGMC. I've downloaded all the plugins necesary, like the latest Masktools2, but still when I preview my script in MeGUI, it pops an error saying "there is no function named MSuper".

The function supposed to be included in the masktools2.dll, right? what am I missing. The masktools2 seems to load correctly cos it doesn't give me any error loading it.

Can somebody help me? Thanks

msuper is from mvtools

javidial
12th July 2017, 21:50
msuper is from mvtools

Thanks! There're so many filters that I'm getting super confused sometimes.

MysteryX
13th July 2017, 05:43
you mean, getting msuper confused

hello_hello
13th July 2017, 12:05
Can somebody help me? Thanks

Doesn't mvtools require a runtime flavour, depending on the version? I think the latest needs Microsoft Visual C++ Redistributable 2015 Update 3. Maybe that's the problem.

real.finder
22nd July 2017, 15:06
hi pinterf

check this https://forum.doom9.org/showthread.php?t=174752

and what about adding mt_merge parameter (https://forum.doom9.org/showthread.php?p=1804907#post1804907) for mpeg2 vs mpeg1 in 420 with luma=true?

pinterf
24th July 2017, 12:51
hi pinterf

check this https://forum.doom9.org/showthread.php?t=174752

and what about adding mt_merge parameter (https://forum.doom9.org/showthread.php?p=1804907#post1804907) for mpeg2 vs mpeg1 in 420 with luma=true?
I have bookmarked it, but will look at it later (summertime lazyness)

edcrfv94
5th August 2017, 17:35
when I change mt_lutxy 8bit to 16bit from 410 fps drop to 0.8 fps.

8bit: 410 fps

SetMemoryMax(3000)

colorbars(width = 1920, height = 1080, pixel_type = "yv12")

ConvertToY8()
trim(0, 5000)

test_in = last#.ConvertBits(bits=16)

a = test_in
b = test_in

kf_limit_dif8(a, b, thr=1, elast=36, y=3, u=1, v=1).kf_limit_dif8(b, thr=1, elast=36, y=3, u=1, v=1)

#ConvertToStacked().DitherPost(mode=6, ampo=1)

Function kf_limit_dif8(clip filtered, clip original, bool "smooth", float "thr", float "elast", float "darkthr", int "Y", int "U", int "V")
{
smooth = Default(smooth, True )
thr = Default(thr, 1.0 )
elast = Default(elast, smooth ? 3.0 : 255./thr)
darkthr = Default(darkthr,thr )
Y = Default(Y, 3 )
U = Default(U, 3 )
V = Default(V, 3 )

Y = min(Y, 4)
U = min(U, 4)
V = min(V, 4)

thr = max(min( thr, 255.0), 0.0)
darkthr = max(min(darkthr, 255.0), 0.0)
elast = max(elast, 1.0)
mode = thr == 0 && darkthr == 0 ? 4 : thr == 255 && darkthr == 255 ? 2 : 3
smooth = elast==1 ? False : smooth

diffstr = " x y - "
elaststr = " "+string(elast)+" "

thrstr = diffstr+" 0 > "+string(darkthr)+" scalef "+string(thr)+" scalef ? "
alphastr = elaststr+" 1 <= 0 1 "+elaststr+" 1 - "+thrstr+" * / ? "
betastr = thrstr+elaststr+" * "
sexpr = smooth ? alphastr+diffstr+" * "+betastr+diffstr+" abs - * y + "
\ : thrstr+diffstr+diffstr+" abs / * y + "
expr = diffstr+" abs "+thrstr+" <= x "+diffstr+" abs "+betastr+" >= y "+sexpr+" ? ? "

thrstrc = " "+string(thr)+" scalef "
alphastrc= elaststr+" 1 <= 0 1 "+elaststr+" 1 - "+thrstrc+" * / ? "
betastrc = thrstrc+elaststr+" * "
sexprc = smooth ? alphastrc+diffstr+" * "+betastrc+diffstr+" abs - * y + "
\ : thrstrc+diffstr+diffstr+" abs / * y + "
exprc = diffstr+" abs "+thrstrc+" <= x "+diffstr+" abs "+betastrc+" >= y "+sexprc+" ? ? "

# diff = filtered - original
# alpha = 1 / (thr * (elast - 1))
# beta = elast * thr
# When smooth=True :
# output = diff <= thr ? filtered : \
# diff >= beta ? original : \
# original + alpha * diff * (beta - abs(diff))
# When smooth=False :
# output = diff <= thr ? filtered : \
# diff >= beta ? original : \
# original + thr * (diff / abs(diff))

return mode == 4 ? original
\ : mode == 2 ? filtered
\ : mt_lutxy(filtered, original, yExpr=expr, uExpr=exprc, vExpr=exprc, Y=Y, U=U, V=V)
}


16bit: 0.8 fps

SetMemoryMax(3000)

colorbars(width = 1920, height = 1080, pixel_type = "yv12")

ConvertToY8()
trim(0, 5000)

test_in = last.ConvertBits(bits=16)

a = test_in
b = test_in

kf_limit_dif8(a, b, thr=1, elast=36, y=3, u=1, v=1).kf_limit_dif8(b, thr=1, elast=36, y=3, u=1, v=1)

ConvertToStacked().DitherPost(mode=6, ampo=1)

Function kf_limit_dif8(clip filtered, clip original, bool "smooth", float "thr", float "elast", float "darkthr", int "Y", int "U", int "V")
{
smooth = Default(smooth, True )
thr = Default(thr, 1.0 )
elast = Default(elast, smooth ? 3.0 : 255./thr)
darkthr = Default(darkthr,thr )
Y = Default(Y, 3 )
U = Default(U, 3 )
V = Default(V, 3 )

Y = min(Y, 4)
U = min(U, 4)
V = min(V, 4)

thr = max(min( thr, 255.0), 0.0)
darkthr = max(min(darkthr, 255.0), 0.0)
elast = max(elast, 1.0)
mode = thr == 0 && darkthr == 0 ? 4 : thr == 255 && darkthr == 255 ? 2 : 3
smooth = elast==1 ? False : smooth

diffstr = " x y - "
elaststr = " "+string(elast)+" "

thrstr = diffstr+" 0 > "+string(darkthr)+" scalef "+string(thr)+" scalef ? "
alphastr = elaststr+" 1 <= 0 1 "+elaststr+" 1 - "+thrstr+" * / ? "
betastr = thrstr+elaststr+" * "
sexpr = smooth ? alphastr+diffstr+" * "+betastr+diffstr+" abs - * y + "
\ : thrstr+diffstr+diffstr+" abs / * y + "
expr = diffstr+" abs "+thrstr+" <= x "+diffstr+" abs "+betastr+" >= y "+sexpr+" ? ? "

thrstrc = " "+string(thr)+" scalef "
alphastrc= elaststr+" 1 <= 0 1 "+elaststr+" 1 - "+thrstrc+" * / ? "
betastrc = thrstrc+elaststr+" * "
sexprc = smooth ? alphastrc+diffstr+" * "+betastrc+diffstr+" abs - * y + "
\ : thrstrc+diffstr+diffstr+" abs / * y + "
exprc = diffstr+" abs "+thrstrc+" <= x "+diffstr+" abs "+betastrc+" >= y "+sexprc+" ? ? "

# diff = filtered - original
# alpha = 1 / (thr * (elast - 1))
# beta = elast * thr
# When smooth=True :
# output = diff <= thr ? filtered : \
# diff >= beta ? original : \
# original + alpha * diff * (beta - abs(diff))
# When smooth=False :
# output = diff <= thr ? filtered : \
# diff >= beta ? original : \
# original + thr * (diff / abs(diff))

return mode == 4 ? original
\ : mode == 2 ? filtered
\ : mt_lutxy(filtered, original, yExpr=expr, uExpr=exprc, vExpr=exprc, Y=Y, U=U, V=V)
}

MysteryX
5th August 2017, 22:17
According to this table (Feature Matrix)
http://avisynth.nl/index.php/MaskTools2

mt_lutxy will evaluate in real-time instead of using a LUT table when bits>=14, otherwise the LUT table would be too large. You can override this behavior with the "realtime" parameter.

edcrfv94
5th August 2017, 23:06
According to this table (Feature Matrix)
http://avisynth.nl/index.php/MaskTools2

mt_lutxy will evaluate in real-time instead of using a LUT table when bits>=14, otherwise the LUT table would be too large. You can override this behavior with the "realtime" parameter.

realtime=True 0.8 fps
realtime=False 10 min still initialization LUT tables?

real.finder
6th August 2017, 02:56
realtime=True 0.8 fps
realtime=False 10 min still initialization LUT tables?

you mustn't use SetMemoryMax when realtime=False

and you must use avs+ 64 and have large ram (6g or more)

MysteryX
6th August 2017, 05:22
and yes several minutes can be normal, that's why LUT is disabled by default in such cases. It grows exponentially with the bitrate. Now sure how much it actually takes.

TheFluff
6th August 2017, 09:23
A LUT is just a dictionary that translates each possible value in the input to a value in the output. A 16-bit mt_lutx needs 2^16 = 65,536 entries per plane, and each entry takes 2 bytes, so that's 65536*2*3 = 384 kB. That's gonna be really slow since it doesn't fit in CPU cache, but it's technically "usable". mt_lutxy though takes two clips, so now there's 65535*65536 possible values, and 65536*65536*3*2 is 25,769,803,776 bytes or 24.5 gigabytes. Have fun allocating that, and don't even think about mt_lutxyz.

Masktools is in practice unusable for high bitdepth until and unless someone ports the Vapoursynth expr filter (which works by compiling the RPN expression to SSE2-optimized native code (https://forum.doom9.org/showthread.php?p=1807048#post1807048)).

real.finder
6th August 2017, 11:15
A LUT is just a dictionary that translates each possible value in the input to a value in the output. A 16-bit mt_lutx needs 2^16 = 65,536 entries per plane, and each entry takes 2 bytes, so that's 65536*2*3 = 384 kB. That's gonna be really slow since it doesn't fit in CPU cache, but it's technically "usable". mt_lutxy though takes two clips, so now there's 65535*65536 possible values, and 65536*65536*3*2 is 25,769,803,776 bytes or 24.5 gigabytes. Have fun allocating that, and don't even think about mt_lutxyz.

Masktools is in practice unusable for high bitdepth until and unless someone ports the Vapoursynth expr filter (which works by compiling the RPN expression to SSE2-optimized native code (https://forum.doom9.org/showthread.php?p=1807048#post1807048)).

what about https://github.com/tp7/CLExpr ? since people can use opencl even with cpu only

TheFluff
6th August 2017, 12:20
Didn't know that was a thing! Sounds promising though.

edcrfv94
6th August 2017, 16:19
Dither tools must faster than masktools at 16bit

Dither tools:59 fps

SetMemoryMax(6000)

colorbars(width = 1920, height = 1080, pixel_type = "yv12")

ConvertToY8()
trim(0, 5000)

test_in = last.ConvertBits(bits=16)

a = test_in
b = test_in

kf_limit_dif16(a, b, thr=1, elast=36, y=3, u=1, v=1).kf_limit_dif16(b, thr=1, elast=36, y=3, u=1, v=1)

ConvertToStacked().DitherPost(mode=6, ampo=1)

Function kf_limit_dif16(clip filtered, clip original, bool "smooth", float "thr", float "elast", float "darkthr", int "Y", int "U", int "V")
{
Is16bit = (filtered.BitsPerComponent == 16) ? True : False

filtered = Is16bit ? filtered.ConvertToStacked() : filtered
original = Is16bit ? original.ConvertToStacked() : original

smooth = Default(smooth, True )
thr = Default(thr, 1.0 )
elast = Default(elast, smooth ? 3.0 : 128./thr)
darkthr = Default(darkthr,thr )
Y = Default(Y, 3 )
U = Default(U, 3 )
V = Default(V, 3 )

Y = min(Y, 4)
U = min(U, 4)
V = min(V, 4)
Yt = Y == 3
Ut = U == 3
Vt = V == 3
Y31 = Yt ? 3 : 1
U31 = Ut ? 3 : 1
V31 = Vt ? 3 : 1

thr = max(min( thr, 128.0), 0.0)
darkthr = max(min(darkthr, 128.0), 0.0)
elast = max(elast, 1.0)
mode = thr == 0 && darkthr == 0 ? 4 : thr == 128 && darkthr == 128 ? 2 : 3
smooth = elast==1 ? False : smooth
thr = thr / 255 * 65535
darkthr = darkthr / 255 * 65535

diffstr = " x 32768 - "
elaststr = " "+string(elast)+" "

thrstr = diffstr+" 0 > "+string(darkthr)+" "+string(thr)+" ? "
alphastr = elaststr+" 1 <= 0 1 "+elaststr+" 1 - "+thrstr+" * / ? "
betastr = thrstr+elaststr+" * "
sexpr = smooth ? alphastr+diffstr+" * "+betastr+diffstr+" abs - * 32768 + "
\ : thrstr+diffstr+diffstr" abs / * 32768 + "
expr = diffstr+" abs "+thrstr+" <= x "+diffstr+" abs "+betastr+" >= 32768 "+sexpr+" ? ? "

thrstrc = " "+string(thr)+" "
alphastrc= elaststr+" 1 <= 0 1 "+elaststr+" 1 - "+thrstrc+" * / ? "
betastrc = thrstrc+elaststr+" * "
sexprc = smooth ? alphastrc+diffstr+" * "+betastrc+diffstr+" abs - * 32768 + "
\ : thrstrc+diffstr+diffstr" abs / * 32768 + "
exprc = diffstr+" abs "+thrstrc+" <= x "+diffstr+" abs "+betastrc+" >= 32768 "+sexprc+" ? ? "

# diff = filtered - original
# alpha = 1 / (thr * (elast - 1))
# beta = elast * thr
# When smooth=True :
# output = diff <= thr ? filtered : \
# diff >= beta ? original : \
# original + alpha * diff * (beta - abs(diff))
# When smooth=False :
# output = diff <= thr ? filtered : \
# diff >= beta ? original : \
# original + thr * (diff / abs(diff))

diff = Dither_sub16(filtered, original, y=Y31, u=U31, v=V31, dif=True)
ldiff = Dither_lut16(diff, yexpr=expr, uexpr=exprc, vexpr=exprc, y=Y31, u=U31, v=V31)
merged = Dither_add16(original, ldiff , y=Y31, u=U31, v=V31, dif=True)
merged = Y==2 || U==2 || V==2 || Y==4 || U==4 || V==4 ? mt_lutxyz(filtered, original, merged, Y=Y==3?5:Y, U=U==3?5:U, V=V==3?5:V) : merged

out = mode == 4 ? original
\ : mode == 2 ? filtered
\ : merged

return Is16bit ? out.ConvertFromStacked() : out
}


cl_exprxy 11 fps with GPU(i7 3770k intel HD4000) 13x speedup than mt_lutxy


SetMemoryMax(6000)

colorbars(width = 1920, height = 1080, pixel_type = "yv12")

ConvertToY8()
trim(0, 5000)

test_in = last.ConvertBits(bits=16).ConvertToStacked()

a = test_in
b = test_in

kf_limit_dif8(a, b, thr=1, elast=36, y=3, u=1, v=1).kf_limit_dif8(b, thr=1, elast=36, y=3, u=1, v=1)

DitherPost(mode=6, ampo=1)

Function kf_limit_dif8(clip filtered, clip original, bool "smooth", float "thr", float "elast", float "darkthr", int "Y", int "U", int "V")
{
smooth = Default(smooth, True )
thr = Default(thr, 1.0 )
elast = Default(elast, smooth ? 3.0 : 255./thr)
darkthr = Default(darkthr,thr )
Y = Default(Y, 3 )
U = Default(U, 3 )
V = Default(V, 3 )

Y = min(Y, 4)
U = min(U, 4)
V = min(V, 4)

thr = max(min( thr, 255.0), 0.0)/255*65535
darkthr = max(min(darkthr, 255.0), 0.0)/255*65535
elast = max(elast, 1.0)
mode = thr == 0 && darkthr == 0 ? 4 : thr == 255 && darkthr == 255 ? 2 : 3
smooth = elast==1 ? False : smooth

diffstr = " x y - "
elaststr = " "+string(elast)+" "

thrstr = diffstr+" 0 > "+string(darkthr)+" "+string(thr)+" ? "
alphastr = elaststr+" 1 <= 0 1 "+elaststr+" 1 - "+thrstr+" * / ? "
betastr = thrstr+elaststr+" * "
sexpr = smooth ? alphastr+diffstr+" * "+betastr+diffstr+" abs - * y + "
\ : thrstr+diffstr+diffstr+" abs / * y + "
expr = diffstr+" abs "+thrstr+" <= x "+diffstr+" abs "+betastr+" >= y "+sexpr+" ? ? "

thrstrc = " "+string(thr)+" "
alphastrc= elaststr+" 1 <= 0 1 "+elaststr+" 1 - "+thrstrc+" * / ? "
betastrc = thrstrc+elaststr+" * "
sexprc = smooth ? alphastrc+diffstr+" * "+betastrc+diffstr+" abs - * y + "
\ : thrstrc+diffstr+diffstr+" abs / * y + "
exprc = diffstr+" abs "+thrstrc+" <= x "+diffstr+" abs "+betastrc+" >= y "+sexprc+" ? ? "

# diff = filtered - original
# alpha = 1 / (thr * (elast - 1))
# beta = elast * thr
# When smooth=True :
# output = diff <= thr ? filtered : \
# diff >= beta ? original : \
# original + alpha * diff * (beta - abs(diff))
# When smooth=False :
# output = diff <= thr ? filtered : \
# diff >= beta ? original : \
# original + thr * (diff / abs(diff))

return mode == 4 ? original
\ : mode == 2 ? filtered
\ : cl_exprxy(filtered, original, yExpr=expr, uExpr=exprc, vExpr=exprc, Y=Y, U=U, V=V, lsb=True)
}

real.finder
6th August 2017, 21:54
edcrfv94

dithertools don't has any full 16bit lut except Dither_lut16

don't know and didn't check the way you use to make something like mt_lutxy with dithertools but I think it's will not be real thing or just a hack

edcrfv94
7th August 2017, 03:55
edcrfv94

dithertools don't has any full 16bit lut except Dither_lut16

don't know and didn't check the way you use to make something like mt_lutxy with dithertools but I think it's will not be real thing or just a hack

kf_limit_dif16 copy from HQDeringmod_v1.8.avsi and small modify added avs+ 16bit support .

will AVS+ compatible VapourSynth Plugins, scripts and core Function easily than VapourSynth compatible AVS Plugins? like MP_Pipeline 32bit/64bit compatible way

dithertools only can calculated, other way will becomes very complicated.

GMJCZP
7th August 2017, 16:02
Friends, I have a question:

I'm practicing with mt_infix and mt_polish and I'm getting different frames with mt_lut on screen. Here is the script:

expr_RPN="x 126 < 126 x 130 > 130 x ? ?"
expr_INF=mt_infix(expr_RPN)
expr_INF2="(x<126) ? 126 : (x>130) ? 130 : x"
expr_RPN2=mt_polish(expr_INF2)

I do not know if I'm missing something, but with mt_infix(expr_RPN) I'm getting "(((x<126)) ? 126 : (((x>130)) ? 130 : x))" which is equivalent to "(x<126) ? 126 : (x>130) ? 130 : x".

The problem is that with mt_lut (expr_RPN) I'm getting a different result than with mt_lut (expr_RPN2), what's the reason? Is it a rounding problem?

TheFluff
7th August 2017, 20:33
In this code:
expr_INF2="(x<126) ? 126 : (x>130) ? 130 : x"
expr_RPN2=mt_polish(expr_INF2)

expr_RPN2 evaluates to

x 126 < 126 x 130 > ? 130 x ?

which, translated back to infix again is (after removing redundant parens):

((x<126) ? 126 : (x>130)) ? 130 : x

Which is obviously not what you want. This is because unlike the arithmetic operators which are generally left-associative (https://en.wikipedia.org/wiki/Operator_associativity), the ternary operator in C (and most other languages that use it, except PHP because of course PHP does everything wrong) is right-associative, so the entire expression "(x<126) ? 126 : (x>130)" is evaluated as the condition for the following ?.

edit: no, wait, hold on, I have my head screwed on backwards. If it was actually right-associative, it'd do what you want. mt_infix is parsing it as if it was left-associative, it seems.

GMJCZP
7th August 2017, 20:44
Thank you, I will analyze your answer because I confess that I am not yet clear enough.

Edit: to overcome associativity I must generously apply parentheses, do not I?

TheFluff
7th August 2017, 20:59
Yes, but I was confused when I wrote my post. Your original way of writing it actually should work if the mt_infix ternary operator worked like it does in C (i.e. right-associative). In Perl, which also has a right-associative ternary operator, this works as expected:

$x = 120;
$x = ($x<126) ? 126 : ($x>130) ? 130 : $x;
print "$x"; # prints 126

In PHP, however, which has a left-associative ternary operator:
$x = 120;
$x = ($x<126) ? 126 : ($x>130) ? 130 : $x;
echo $x; # prints 130!

You have to add parens around the third operand (that is, after the colon) to prevent the following ? from grabbing everything to its left as its first operand. Like so:
$x = 120;
$x = ($x<126) ? 126 : (($x>130) ? 130 : $x);
echo $x; # prints 126, as expected

Gavino
7th August 2017, 23:24
The problem is that with mt_lut (expr_RPN) I'm getting a different result than with mt_lut (expr_RPN2), what's the reason?
I think this is the bug I reported a while back (Feb 2014), where mt_polish() parses nested conditionals incorrectly.

I can't remember if it was ever supposedly corrected.

GMJCZP
7th August 2017, 23:49
Thank you to both.

For me the simplest solution would be, as I stated earlier, to apply parentheses generously, but I would be putting the garbage under the carpet. I want to learn this perfectly and it is difficult for me to understand the associativity of : on the left.

TheFluff
8th August 2017, 00:31
Operator associativity is similar to operator precedence, but for operators that have the same precedence. For example, 2*3+1 is (2*3)+1 = 7, not 2*(3+1) = 8, because * has higher precedence than +. However, if you nest operators with the same precedence, you have to decide in which direction the operations should be grouped. For example, consider the expression 10-4-2. The way I intuitively read this is from left to right - we first group the two first operands (10-4), evaluate the result (we get 6) and then take that result as the operand for the next minus operator and end up with 6-2 = 4. Or to write it another way, (10-4)-2. This is also the way it is evaluated in basically all programming languages. We say that the arithmetic subtraction operator is left-associative, because the operations are grouped from left to right.

On the other hand, if it were right-associative instead, the same expression 10-4-2 would be grouped from right to left instead, and we'd end up with 10-(4-2) = 8. That is very unintuitive to me, and no programming language I know of has a right-associative subtraction operator.

Now, the ternary operator is a bit more complex because it takes three operands, not two, but it's essentially the same thing. When looking at an expression like the one you originally posted, all the parser sees is:
operand_A ? operand_B : operand_C ? operand_D : operand_E
Now, how should it read this? Each ?: needs three operands, but we actually only seem to have five total. Is operand_C the third operand for the leftmost ternary op, or is it the first operand for the rightmost ternary op? If you group from the right (like in every language other than PHP), the rightmost ternary operator is evaluated first and the righthand side sub-expression (operand_C ? operand_D : operand_E) becomes the third operand for the leftmost ternary op. If you instead group from the left like in PHP and mt_polish, the expression (operand_A ? operand_B : operand_C) becomes the first operand to the rightmost ternary op. Or, with parens:
# right associative (almost everything)
operand_A ? operand_B : (operand_C ? operand_D : operand_E)

# left associative (PHP, mt_polish)
(operand_A ? operand_B : operand_C) ? operand_D : operand_E

Does that make it any clearer?

StainlessS
8th August 2017, 01:52
I think this is the bug I reported a while back (Feb 2014), where mt_polish() parses nested conditionals incorrectly.

I can't remember if it was ever supposedly corrected.

Nope, dont think so, tis horrible the way that it works, but cant see how it could be fixed without causing perhaps a great deal of upset. [EDIT: Nah, no upset necessary]

@GMJCZP, did my head in when I first came across that.

GMJCZP
8th August 2017, 04:55
Let's look at this:

$x = 120;
$x = ($x<126) ? 126 : ($x>130) ? 130 : $x;

To see if I understand, both php and mt_polish are doing this to me:

$x = 120;
$x = ($x<126) ? (126 : ($x>130) ? 130) : $x;

That's why it gives 130?

TheFluff
8th August 2017, 08:44
No, it's doing this:
(($x<126) ? 126 : ($x>130)) ? 130 : $x
This part:
(($x<126) ? 126 : ($x>130))
returns 126 if $x is less than 126, or else it returns ($x>130). ($x>130) evaluates to 1 if $x is greater than 130, else 0. So if $x is 120, you get
120 ? 130 : $x
and 120 is obviously true. That's why it returns 130.

GMJCZP
8th August 2017, 19:02
Thanks once again.

I honestly had a hard time understanding this. Now my only doubt is:

120 ? 130 : $x

Are you sure it's 120? will not be:

126 ? 130 : $x

Or

True ? 130 : $x

TheFluff
8th August 2017, 19:38
You're right, that's a typo. It should be 126, not 120.

GMJCZP
8th August 2017, 22:31
Ok. Thanks.

$x = 120
126 ? 130 : $x

Do you start from here why X = 130?

FranceBB
25th August 2017, 01:02
MPEG2Source ("video_sd.d2v")

Dither_convert_yuv_to_rgb (matrix="601", output="rgb48y")
Dither_resize16 (1280, 720, y=3, u=1, v=1)
r = SelectEvery (3, 0)
g = SelectEvery (3, 1)
b = SelectEvery (3, 2)
Dither_convert_rgb_to_yuv (r, g, b, matrix="709", lsb=false, mode=0)

I get an error:
http://i.imgur.com/Lup0lFi.png

I'm trying to understand if it's intentional or if it's the dither tool wiki that is wrong.

Groucho2004
25th August 2017, 06:27
MPEG2Source ("video_sd.d2v")

Dither_convert_yuv_to_rgb (matrix="601", output="rgb48y")
Dither_resize16 (1280, 720, y=3, u=1, v=1)
r = SelectEvery (3, 0)
g = SelectEvery (3, 1)
b = SelectEvery (3, 2)
Dither_convert_rgb_to_yuv (r, g, b, matrix="709", lsb=false, mode=0)

I get an error:
http://i.imgur.com/Lup0lFi.png

I'm trying to understand if it's intentional or if it's the dither tool wiki that is wrong.I tried your script and works fine with a PAL DVD source.
- Is this your complete script?
- Run AVSMeter with the switches "-avsinfo -log" and post the "avsinfo_x86.log" file.

FranceBB
26th August 2017, 22:55
Looks like it doesn't work. Not sure whether it's related to virtualbox (I use Linux - Fedora) or not.
If I try "avsmeter.exe test.avs" it crashes as well.
That's my full avs, 'cause I was testing out of curiosity (it's not gonna be used for a real encode).
OS: Windows XP Professional x86
I'll test it in my server, which uses Windows Server 2008 R2 x64 (the one I actually use to encode) if XP it's a problem.

The instruction "0x03d9f6c0" referenced memory at "0x03d9f6c0". The required data was not placed into memory because of an I/O error status of "0x75b2b11c".

http://i.imgur.com/HwTNrkA.png

Groucho2004
27th August 2017, 07:20
Looks like it doesn't work. Not sure whether it's related to virtualbox (I use Linux - Fedora) or not.
If I try "avsmeter.exe test.avs" it crashes as well.
I never tried Virtualbox but have no problem running AVSMeter in a VMWare VM. XP should not be the problem.

edcrfv94
29th August 2017, 19:30
mt_expand(thY=42, u=3, v=3)
not equal
mt_lutsx(last, last, last, mode="max", pixels=mt_square(1), yexpr="y x - 42 > x 42 + y ?", u=3, v=3)

mt_expand(thY=255, u=3, v=3)
equal
mt_lutsx(last, last, last, mode="max", pixels=mt_square(1), yexpr="y x - 255 > x 255 + y ?", u=3, v=3)

Look like thX limit not work.

sl1pkn07
1st September 2017, 22:30
@FranceBB for curiosity, why you use virtualbox for avisynth(+)? wine(-staging) works ok with it (more or less)

FranceBB
2nd September 2017, 18:36
Some filters are just .avsi, other are DLLs that could be either statically or dynamically compiled and could require other dependencies to run, like .NET Framework or C++ Redistributable etc... Wine and Mono might not be the best solution. On the other hand, there are other Linux -friendly alternatives like AVXSynth and Vapoursynth, but I got used to Avisynth. I started using it in 2006 lurking in this forum for quite some time without registering an account. I also don't encode on my PC: it's just an i7 6700HQ 4c/8th with 16 GB of RAM DDR4, I prepare scripts, see the preview and then encode in my Windows Server 2008 R2 which has a far better Xeon processor and way more RAM (even though I've never actually used more than 5 GB of RAM in an encode).

DJATOM
2nd September 2017, 19:43
FranceBB
wine-staging is quite good. I'm using it on the server with Debian 8 and it works fine with my chains (there are 64-bit versions of masktools2, mvtools2, dfttest, f3kdb, dither tools, rgtools, eedi3, nnedi3 and some other filters).

FranceBB
3rd September 2017, 00:45
I see... well, I guess I'll give it a shot, then. :)

pinterf
11th September 2017, 16:01
A LUT is just a dictionary that translates each possible value in the input to a value in the output. A 16-bit mt_lutx needs 2^16 = 65,536 entries per plane, and each entry takes 2 bytes, so that's 65536*2*3 = 384 kB. That's gonna be really slow since it doesn't fit in CPU cache, but it's technically "usable". mt_lutxy though takes two clips, so now there's 65535*65536 possible values, and 65536*65536*3*2 is 25,769,803,776 bytes or 24.5 gigabytes. Have fun allocating that, and don't even think about mt_lutxyz.

Masktools is in practice unusable for high bitdepth until and unless someone ports the Vapoursynth expr filter (which works by compiling the RPN expression to SSE2-optimized native code (https://forum.doom9.org/showthread.php?p=1807048#post1807048)).
True, true, true, I know it since I have tried mt_lutxy(za) in real life for anything over 8 bits.

But I'm still reluctant to use ("steal") anything from Vapoursynth project, I feel that they have worked hard for giving the Expr functionality to their own community and being more modern and different to Avisynth.

MysteryX
11th September 2017, 17:56
and being more modern and different to Avisynth.
Pinterf, you've already done the damage

real.finder
11th September 2017, 20:56
True, true, true, I know it since I have tried mt_lutxy(za) in real life for anything over 8 bits.

But I'm still reluctant to use ("steal") anything from Vapoursynth project, I feel that they have worked hard for giving the Expr functionality to their own community and being more modern and different to Avisynth.

what about clexpr?

and it's not steal cuz it's open source Policy :) Vapoursynth did so with avs so why avs+ can't with Vapoursynth?

edit: and ultim in the first place aimed to make avs+ modern just like Vapoursynth if you back to https://forum.doom9.org/showthread.php?t=168856 discussions and Myrsloik (Vapoursynth author) encourage supports avs+


Session Start: Thu Dec 18 17:06:03 2014
Session Ident: #avs-plus
03[17:06] * Now talking in #avs-plus
03[17:06] * Topic is 'Avisynth+ official development channel | Help test MT! Experimental build at http://goo.gl/e0VFYn | Help filling mt modes: https://pad.riseup.net/p/avs_plus_mt_modes | Intrinsics guide: http://asm.avs-plus.net/ | Plugins porting queue: http://goo.gl/kPywxZ'
03[17:06] * Set by ultim!~ultim@somloi.galuska.rulez on Thu Mar 06 02:12:36
[17:06] <***> Buffer Playback...
[17:06] <Myrsloik> [06:18:30] has ultim been seen here recently?
[17:06] <torch> [06:19:55] last message seems to have been three months ago
[17:06] <@tp7> [06:42:32] I'm still hoping my PR will get merged one day
[17:06] <Myrsloik> [06:51:56] it'd be nice if this project undied and killed off all the other avisynth branches

Myrsloik
11th September 2017, 21:26
True, true, true, I know it since I have tried mt_lutxy(za) in real life for anything over 8 bits.

But I'm still reluctant to use ("steal") anything from Vapoursynth project, I feel that they have worked hard for giving the Expr functionality to their own community and being more modern and different to Avisynth.

Uh, that's not how open source is supposed to work...

TheFluff
11th September 2017, 22:53
True, true, true, I know it since I have tried mt_lutxy(za) in real life for anything over 8 bits.

But I'm still reluctant to use ("steal") anything from Vapoursynth project, I feel that they have worked hard for giving the Expr functionality to their own community and being more modern and different to Avisynth.
I guess I'm more guilty than most when it comes to complaining about how awful Avisynth is, but really now, it's not like anyone actually wants you to make it even more awful, or for you to keep it awful just because that's how it's always been. I mean, I think work spent on improving Avisynth provides little gain for the amount of effort spent because of all the legacy annoyances, so what you really don't need is to decide to reinvent wheels just because elitist Vapoursynth nerds are acting smugly superior on an internet forum.

Also, as was already mentioned, Vapoursynth has "stolen" a ton of Avisynth code and Avisynth plugins. Re-solving solved problems in a software niche this small with this few developers benefits absolutely nobody, so port away.

StainlessS
12th September 2017, 00:48
Open source is a joint community effort, it is in everyone's interest that the concept of open source succeed, no matter which team you support.
Don't waste any further time wondering about whether or not you personally have to invent every wheel that you use, just steal steal steal,
anything and everything (open source) that can be of use. I'm quite sure that along the way, you may inadvertently create source that will be stolen
back and reused by others in the community.

Go Pinterf, pinterficate like the wind :) And, Thank You for being Pinterf.

pinterf
15th September 2017, 16:28
Thanks for sharing your thoughts.