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. |
28th January 2017, 21:49 | #2921 | Link |
Registered User
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
|
Bug in overlay?
Code:
background = blankclip(width=400,height=400,length=1,pixel_type="y8").mt_lut("255") box = blankclip(width=100,height=100,length=1,pixel_type="y8").mt_lut("0") mask = box.mt_lut("255") #overlay(background, box, x=150, y=150, mask=mask) # black box value is 0 overlay(background, box, x=150, y=150) # black box value is 1 scriptclip(""" subtitle(string(yplanemax)+"\n"+string(yplanemin),lsp=0) """) Last edited by ajp_anton; 28th January 2017 at 21:51. |
28th January 2017, 23:04 | #2922 | Link | |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
|
Quote:
edit: in original avisynth Code:
#overlay(background, box, x=150, y=150, mask=mask) # black box value is 1 overlay(background, box, x=150, y=150) # black box value is 0
__________________
See My Avisynth Stuff Last edited by real.finder; 28th January 2017 at 23:20. |
|
29th January 2017, 09:52 | #2923 | Link |
Registered User
Join Date: Jan 2014
Posts: 2,314
|
The original blending formula is something like that, where an ideal mask is 0..1.0:
new_value = orig*(1-mask) + overlay*mask This is equivalent to (only one multiplication, faster): new_value = orig+(overlay-orig)*mask As mask is coming from a clip, its value is 0..255 The approximation in overlay core: new_value = ((orig * 256 + 128)+(overlay-orig)*mask) / 256 When orig=255, overlay=0, mask=255 (overlay is fully visible), we would expect 0 (=overlay) Unfortunately the approximation above results in: new_value = ((orig * 256 + 128)+(overlay-orig)*mask) / 256: (255*256+128) + (0-255)*255) / 256 = 383/256 = (65408 - 65025) / 256 = 383/256 = 1 which is obviously incorrect For orig=0, overlay=255, mask=255 the result is 254 instead of 255. |
29th January 2017, 11:04 | #2924 | Link |
Registered User
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
|
So can it be fixed? I guess it's a bit complicated if you need
0 -> 0% 128 -> 50% 255 -> 100% Do you need two separate linear scales on both sides of 128, a non-linear scale, or a special case for 255? Or treat both 0 and 1 as 0%? |
29th January 2017, 14:30 | #2925 | Link | |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
|
Quote:
but if you need it in 8 bit there are RMerge with mode=256 @pinterf but there are difference between normal avs and avs+ like I mention
__________________
See My Avisynth Stuff Last edited by real.finder; 29th January 2017 at 14:38. |
|
29th January 2017, 16:58 | #2926 | Link | |
Registered User
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
|
Quote:
|
|
29th January 2017, 18:01 | #2927 | Link | |
Registered User
Join Date: Jan 2014
Posts: 2,314
|
Quote:
On the other hand in classic avisynth the alpha channel of an RGB32 after an Overlay is undefined. At least after having a quick look at the source, it is not filled up by any defaults. There is always an RGB->444->RGB conversion sequence, and the final conversion back from internal 444 to rgb32 fills only r, g and b channels. Avisynth+ Overlay may use ConvertToRGB32 (which fills up alpha with 255; full transparency). Or it just simply preserves source clip's alpha info if it works in conversionless mode (no RGB->444->RGB conversion, blend works in RGB natively) |
|
29th January 2017, 18:05 | #2928 | Link | |
Registered User
Join Date: Jan 2014
Posts: 2,314
|
Quote:
It really should work as maximum transparency. Much more special, I think than 128 / 50% |
|
29th January 2017, 23:30 | #2929 | Link | |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
|
Quote:
Code:
background = blankclip(width=400,height=400,length=1, color=$FFFFFF,pixel_type="rgb32") box = blankclip(width=100,height=100,length=1,pixel_type="rgb32") overlay(background, box, x=150, y=150) but I say something else here in avs+ as ajp_anton say Code:
#overlay(background, box, x=150, y=150, mask=mask) # black box value is 0 overlay(background, box, x=150, y=150) # black box value is 1 and here what I get with normal avs Code:
#overlay(background, box, x=150, y=150, mask=mask) # black box value is 1 overlay(background, box, x=150, y=150) # black box value is 0 Code:
overlay(background.invert, box.invert, x=150, y=150) #white box value is 255, background is 0
__________________
See My Avisynth Stuff Last edited by real.finder; 29th January 2017 at 23:39. |
|
30th January 2017, 05:45 | #2930 | Link |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
|
let's back to grun
Code:
SetFilterMTMode("GScriptClip", 3) SetFilterMTMode("RequestLinear", 1) #or 3, mode 2 will make avs+ freeze and not respond (with real clip not ColorBars, ColorBars seems ok even with RequestLinear in mode 2 here) ColorBars(width=640, height=480, pixel_type="yv12").AddGrainC(10000, 10000, seed=1) #~ srestore() #seems ok admfilter() #show error on screen Prefetch(6)
__________________
See My Avisynth Stuff Last edited by real.finder; 30th January 2017 at 10:16. |
30th January 2017, 11:12 | #2931 | Link | |
Registered User
Join Date: Jan 2014
Posts: 2,314
|
Quote:
My experience is: Code:
background = blankclip(width=400,height=400,length=1,pixel_type="y8").mt_lut("255") box = blankclip(width=100,height=100,length=1,pixel_type="y8").mt_lut("0") mask = box.mt_lut("255") #overlay(background, box, x=150, y=150, mask=mask) # black box value is 1 overlay(background, box, x=150, y=150) # black box value is 0 scriptclip(""" subtitle(string(yplanemax)+"\n"+string(yplanemin),lsp=0) """) return last |
|
30th January 2017, 11:13 | #2932 | Link |
Registered User
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
|
Yes, sorry, looks like I got the 0 and 1 wrong there.
How is 8(or higher)bit to float handled? Shouldn't it also be 0 -> .0 128 -> .5 255 -> 1.0 ? Using "averageluma", 128 is converted to 0.501961 (128/255). Using "yplanemax"/"-min", 128 is converted to 32896 (is this a bug? should be a float number, not a 16bit int) Also, y=128 in 8bit -> float is different from 8bit -> 16bit -> float. Last edited by ajp_anton; 30th January 2017 at 11:16. |
30th January 2017, 11:20 | #2933 | Link | |
Registered User
Join Date: Jan 2014
Posts: 2,314
|
Quote:
|
|
30th January 2017, 16:34 | #2935 | Link | |
Registered User
Join Date: Jan 2014
Posts: 2,314
|
Quote:
Code:
PVideoFrame dst = env->NewVideoFrame(vi, 64); |
|
30th January 2017, 23:01 | #2938 | Link | |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
|
Quote:
__________________
See My Avisynth Stuff |
|
31st January 2017, 02:53 | #2940 | Link | |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,666
|
Quote:
Edit: also pinterf's MVTools, MDepan, and DepanEstimate support 10-16 bit. There's also VirtualDubFilterMod, avs2pipemod, and Avs2Yuv which support some of the new HBD colorspaces. Last edited by Reel.Deel; 31st January 2017 at 20:33. Reason: add ffms2 |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|