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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 27th April 2019, 21:48   #4661  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,507
Quote:
Originally Posted by Groucho2004 View Post
Time for a new thread or a moderator to update the first post. I think the latter is a better option.
My EDIT in first post have a link to last pinterf version (Avisynth+ r2772-MT) and to first post than begin with pinterf avs+ discussion.

I can't do anything more. I think is better a new thread by pinterf.
__________________
BeHappy, AviSynth audio transcoder, in Doom9 forums. NicAudio, BassAudio, audio decoders.
tebasuna51 is offline   Reply With Quote
Old 27th April 2019, 21:51   #4662  |  Link
videoh
Registered User
 
Join Date: Jul 2014
Posts: 691
You done good, tebasuna51. Thank you.
videoh is offline   Reply With Quote
Old 28th April 2019, 01:49   #4663  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 1,008
Quote:
Originally Posted by Groucho2004 View Post
In fear of repeating myself...
Quote:
Originally Posted by Dogway View Post
I have no clue what scale_inputs does.
?
Dogway is offline   Reply With Quote
Old 28th April 2019, 06:57   #4664  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,148
Quote:
Originally Posted by Dogway View Post
In fear of repeating myself...
?
Use it when you don't want to bother with the different bit-depths within your Expr script. Depending on your choice, the Expr expression will always see your input clip to be 8 (or other bit depth, fine tuned with the i8, i10, etc Expr keywords)

The parameter helps converting old 8-bit-only Expr (or mt_lutxxx family) expression strings to a generic good-for-all-bit-depth string.

Since there is an automatic input conversion phase (e.g. pixel values of a 10 bit input clip will be divided by 4.0 to have them in the 8 bit range), then a back-conversion phase (result will be multiplied by 4.0 before converting the intermediate pixel result back to 10 bit integer). Using this method Expr itself is a little bit slower, but the conversion takes place only when the input bit-depth is different from the bit-depth used in Expr.
pinterf is offline   Reply With Quote
Old 28th April 2019, 07:08   #4665  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,148
Regarding the new thread, yeah, I'll start it, promise, unfortunately my draftsman is on holiday , I wanted to write a proper intro w/o mis-spelling.
Anyway it's time for a new release but I found way too many other tasks and coding adventures for myself, so it's just a question of weeks.
pinterf is offline   Reply With Quote
Old 28th April 2019, 19:06   #4666  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 1,008
Thanks pinterf, I think I got it.

Float style code only works with 32bit float videos, but integer style code works with everything, unless you have uknown bitdepth variables (float, integers, clips) in which case you can use the scale_inputs setting to bring them to a common denominator (8-bit).

This is my Expr version of mt_merge(), if you pinpoint something odd or not optimized please correct me. (not working with 32bit float)


Code:
function expr_merge ( clip a, clip b, clip msk, bool "luma", string "scale_inputs") {

luma = Default(luma, true)
scale_inputs = Default(scale_inputs, "all")

luma ? Eval("""
 msk
 w = Width()
 h = Height()
 Y = ConvertToY8()
 U = Y.BicubicResize(W/2,H/2,-.5,.25, src_left=0.25 - (0.25/w))
 V = U
 msk=CombinePlanes(Y, U, V, planes = "YUV", sample_clip=msk)""") : nop()

code="x z range_max - abs * y z * + range_size / "
expr(a,b,msk,code,code,code, scale_inputs=scale_inputs) }

Last edited by Dogway; 28th April 2019 at 19:12.
Dogway is offline   Reply With Quote
Old 28th April 2019, 19:58   #4667  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,148
1.) You can omit abs by exchanging range_max and z in your script
Code:
(x * (range_max - z) + y * z) / range_max
(Expr uses 32 bit floats internally, regardless of the input pixel bit depth, so 255 becomes 255.0 and this floating point number is used until at the end the result is automatically rounded and converted back to integer (for 8-16 bit clips).
But in actual integer pixel-type implementations like in mt_merge or Avisynth Overlay there are simplifications:

Code:
(x * range_max - x * z + y * z) / range_max -->
x + (y - x) * z / range_max
is used, this is one less multiplication. But in real life it's a bit more difficult, as masks are stretching from 0..255 (8 bits example). E.g. for 8 bits division by range_max is replaced by division by 256 which is an easy right-bit-shift-8. In exchange the mask extremes (255) have to be treated specially: for maximum mask value we are returning always y. The * 255 right-shift-8 will not work properly for all input combinations.

-- end of popular science -- )

2.) You can write code, code, code as code: when an expression is not given for a plane plane, it will be copied from the previous one.
pinterf is offline   Reply With Quote
Old 28th April 2019, 20:28   #4668  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 770
Quote:
Originally Posted by Reel.Deel View Post
Thanks to Asd there is now a 64-bit VariableBlur v0.7 (among other plugins). See http://avisynth.nl/index.php/AviSynth%2B_x64_plugins

Source code(s) available here: http://avisynth.nl/index.php/User_talk:Asd
I have put it on github https://github.com/avisynth-repository/VariableBlur
__________________
Search and denoise
ChaosKing is offline   Reply With Quote
Old 29th April 2019, 11:45   #4669  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 1,121
Quote:
Originally Posted by Dogway View Post

This is my Expr version of mt_merge(), if you pinpoint something odd or not optimized please correct me. (not working with 32bit float)


Code:
function expr_merge ( clip a, clip b, clip msk, bool "luma", string "scale_inputs") {

luma = Default(luma, true)
scale_inputs = Default(scale_inputs, "all")

luma ? Eval("""
 msk
 w = Width()
 h = Height()
 Y = ConvertToY8()
 U = Y.BicubicResize(W/2,H/2,-.5,.25, src_left=0.25 - (0.25/w))
 V = U
 msk=CombinePlanes(Y, U, V, planes = "YUV", sample_clip=msk)""") : nop()

code="x z range_max - abs * y z * + range_size / "
expr(a,b,msk,code,code,code, scale_inputs=scale_inputs) }
why you made merge function? if it because this old bug then pinterf already fix it

and there are already MasknotCL, MaskCL and my https://pastebin.com/aLP9Mb3z and all these in avs26 nowadays is useless since the bug fixed, unless you use avs 2.5
__________________
My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 29th April 2019, 15:41   #4670  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 1,008
The goal was that if someone wanted to keep a 32f bit process chain they could saving on quantization processing time and error accumulation (bitdepth down conversion) on the usual heavy filtering done in the scripts, but without removing the support for integer type bitdepths. Float precision is also benefitial for less degradation in dark images or parts of them.

I understand this is currently not possible due to the right-shift mechanism (discrepancies in masks), unless we get an official expr_merge with said optimizations. For now I will apply your suggestions (a ternary op in masks) until we get an internal function. I haven't cared for cosmetics yet.

Edit: @real.finder, because I asked a few days ago about an internal equivalent of mt_merge and nobody replied, so assumed there were none (long time out of touch) . Your script does the job perfectly although with a dependency. I will spend my time on my other tools.

Edit2: After testing smaskmerge() also didn't work for 32bit so I adapted mine and now is bitdepth agnostic.

Last edited by Dogway; 30th April 2019 at 15:26.
Dogway is offline   Reply With Quote
Old 30th April 2019, 20:20   #4671  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 1,121
Quote:
Originally Posted by Dogway View Post

Edit: @real.finder, because I asked a few days ago about an internal equivalent of mt_merge and nobody replied, so assumed there were none (long time out of touch) . Your script does the job perfectly although with a dependency. I will spend my time on my other tools.

Edit2: After testing smaskmerge() also didn't work for 32bit so I adapted mine and now is bitdepth agnostic.


and



and



the formula seems work fine even in float, what you mean by "didn't work for 32bit"?
__________________
My Avisynth Stuff

Last edited by real.finder; 30th April 2019 at 20:24.
real.finder is offline   Reply With Quote
Old 1st May 2019, 17:11   #4672  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 1,008
Test with this, as pinterf explained a hack is needed when mask is range_max in float precision. I also had to remove the try catch for cl_exprxyz() in smaskmerge.avsi since it was triggering an error in the script.

16-bit integer__________32-bit float


Code:
blankclip(length=48,width=720,height=480, color=$00000,pixel_type="YV12")
expr("sx frameno + 32 % 16 < range_half range_max ?","sx frameno 2 / + 16 % 8 < range_half sx 15 / - range_half ?","sx frameno 2 / + 16 % 8 < range_half sx 8 / - range_half ?")

ConvertBits(32) # 32bit float vs 8-16bit integer

video=last
video2=video.trim(20,0)

	x1=string(20)
	x2=string(600)
	y1=string(50)
	y2=string(340)
msk=expr("sx "+x1+" >= sx "+x2+" <= & sy "+y1+" >= sy "+y2+" <= & & range_max range_min ?", "range_half", "range_half").trim(0,-1).FreezeFrame(0, FrameCount(last)-1, 0)

##########################

smaskmerge(video, video2, msk,3,3,3, luma=true)

ConvertBits(8)

# Debug Chroma planes
# ExtractU()

Last edited by Dogway; 1st May 2019 at 17:14.
Dogway is offline   Reply With Quote
Old 1st May 2019, 17:40   #4673  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 1,121
so the problem only in chroma? I think this because the zero-chroma-center transition, don't know how chroma mask in float should be, let see what pinterf said and how it work in mt_edge and mt_merge
__________________
My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 2nd May 2019, 08:05   #4674  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,148
Without reverse engineering the Expr itself, yep, float chroma goes -from 0.5 to 0.5, sometimes it can be tricky to apply on it a universal Expr. Perhaps with "range_size"? Anyway, masks are just weights going from 0 to 1.0.
pinterf is offline   Reply With Quote
Old 2nd May 2019, 10:11   #4675  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 1,121
Quote:
Originally Posted by pinterf View Post
Without reverse engineering the Expr itself, yep, float chroma goes from -0.5 to 0.5, sometimes it can be tricky to apply on it a universal Expr. Perhaps with "range_size"? Anyway, masks are just weights going from 0 to 1.0.
in this case range_size not suitable for non-float, in 8 bit will be 256 not 255

maybe temporary shifting to 0-1.0 for float chroma if there are only universal (luma) Expr available? or with some parameter to set that
__________________
My Avisynth Stuff

Last edited by real.finder; 2nd May 2019 at 10:26.
real.finder is offline   Reply With Quote
Old 9th May 2019, 01:58   #4676  |  Link
LouieChuckyMerry
Registered User
 
LouieChuckyMerry's Avatar
 
Join Date: Feb 2014
Posts: 283
Script Translation From SEt's AviSynth MT To pinterf's AviSynt+

Hello, and thanks in advance for any help. About five years ago, kind, patient people here and elsewhere helped me develop a quite nice basic template for shriveling and improving my Blu-rays with 10-bit x264 using MeGUI with SEt's MT AviSynth. I'm still using MeGUI, but I've recently upgraded to pinterf's AviSynth+ and am wanting to verify that I've translated my template correctly.

The original SEt AviSynth MT template is:

Code:
SetMemoryMax(XXXX)
SetMTMode(X,X)
SOURCE INFORMATION HERE
SetMTMode(X)
SMDegrain(TR=X,ThSAD=XXX,RefineMotion=True,Plane=0,Chroma=False,LSB=True,LSB_Out=True)
F=DitherPost(Mode=-1)
S=F.FastLineDarkenMod("Settings Depend On Source")
D=MT_MakeDiff(S,F).Dither_Convert_8_To_16()
Dither_Add16(Last,D,Dif=True,U=2,V=2)
GradFun3("Settings Depend On Source",LSB_In=True,LSB=True)
### Preview Source OR Send 16-bit Output To x264 10-bit ###
# DitherPost()
Dither_Out()
with the x264 custom command line:

Code:
--demuxer raw --input-depth 16 --sar 1:1
while my current pinterf AviSynth+ template, with the same above x264 custom command line, is:

Code:
SOURCE INFORMATION HERE
SetFilterMTMode("Default_MT_Mode",2)
SMDegrain(TR=X,ThSAD=XXX,RefineMotion=True,Plane=0,Chroma=False,LSB=True,LSB_Out=True)
F=DitherPost(Mode=-1)
S=F.FastLineDarkenMod("Settings Depend On Source")
D=MT_MakeDiff(S,F).Dither_Convert_8_To_16()
Dither_Add16(Last,D,Dif=True,U=2,V=2)
GradFun3("Settings Depend On Source",LSB_In=True,LSB=True)
ConvertFromStacked
ConvertBits(10,Dither=0)
Prefetch(X)
which outputs normal-looking 10-bit video at ~15% higher frames per second than the SEt AviSynth MT script. Thanks pinterf .

Anyway, I just want to make sure that all is well before I attack further encoding. I'm using the newest .dll's-.avsi's I could find: pinterf's dual signature MaskTools2.2.18.dll, pinterf's MVTools2.7.41.dll, Dither1.27.2.avsi, SMDegrain3.1.2.93s.avsi.

And some questions:

0) Is the new AviSynth+ template truly processing in 16-bits from the beginning to the output?

1) Is the "ConvertBits(10,Dither=0")" call necessary given that I'm sending 16-bit to 10-bit x264; ie, would removing this cause a lack of proper dithering?

2) Is the:

Code:
F=DitherPost(Mode=-1)
S=F.FastLineDarkenMod("Settings Depend On Source")
D=MT_MakeDiff(S,F).Dither_Convert_8_To_16()
Dither_Add16(Last,D,Dif=True,U=2,V=2)
block proper for AviSynth+? Or can it be improved?

3) What have I missed?

Thanks again for any help; I really appreciate it .
LouieChuckyMerry is offline   Reply With Quote
Old 16th May 2019, 13:24   #4677  |  Link
LouieChuckyMerry
Registered User
 
LouieChuckyMerry's Avatar
 
Join Date: Feb 2014
Posts: 283
As I was checking some test clips, I noticed that very rarely there's an error message from, I think, AviSynth+ superimposed across the top, center of single frames:

Code:
Script error: Invalid arguments to function 'IsCombedTIVTC'
([ScriptClip], line 1)
Here's a couple screenshots: S1.E1-Simpsons[NTSC]-AviSynth+ErrorMessages. Is there any way to stop this happening (other than not creating script errors )? The script runs fine otherwise (I've used it successfully in the past with SEt's AviSynth MT and this never happened). Also, if anyone would answer my questions above from 7 May about syntax I'd be very thankful for the help .

EDIT: Turns out that adding "PreFetch(X)" to the end of a script for encoding interlaced video improves speed but causes errors. Sorry for the bother; a more detailed explanation is in the MeGUI: General Questions and Troubleshooting Thread.

Last edited by LouieChuckyMerry; 16th May 2019 at 23:54. Reason: Coffee; Solution
LouieChuckyMerry is offline   Reply With Quote
Old 16th May 2019, 13:57   #4678  |  Link
stax76
Registered User
 
Join Date: Jun 2002
Location: Germany
Posts: 5,454
ConvertBits(10,Dither=0)

This outputs 10 bit, you can certainly serve 16 bit to x265, I don't know which way is better.
stax76 is online now   Reply With Quote
Old 16th May 2019, 14:54   #4679  |  Link
LouieChuckyMerry
Registered User
 
LouieChuckyMerry's Avatar
 
Join Date: Feb 2014
Posts: 283
Quote:
Originally Posted by stax76 View Post
ConvertBits(10,Dither=0)

This outputs 10 bit, you can certainly serve 16 bit to x265, I don't know which way is better.
Thanks, stax76. Can you explain the difference between:

Code:
ConvertFromStacked.ConvertBits(10,Dither=0)
and

Code:
ConvertFromStacked
given the script? That is, does the first line dither the raw 16-bit to 10-bit then send this 10-bit output to x264 10-bit while the second would send raw 16-bit to x264 ten bit? More importantly, I guess, is there a difference in quality? Seems silly to me to dither then serve instead of just serving the 16-bit to x264 10-bit, if that's the case.
LouieChuckyMerry is offline   Reply With Quote
Old 16th May 2019, 18:32   #4680  |  Link
Motenai Yoda
Registered User
 
Motenai Yoda's Avatar
 
Join Date: Jan 2010
Posts: 701
If wasn't fixed, x265's --dither doesn't work other than for 8bit output, without --dither it'll do a truncate.
for x264 it should work well as it apply a sierra dithering iirc
__________________
powered by Google Translator
Motenai Yoda is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:02.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.