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 Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 2nd September 2021, 11:17   #1  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,317
OverlayPlus: layering script similar to Overlay with addidional modes.

So I finally finished my OverlayPlus script. Most of it is a port of VapourSynth's havsfunc Overlay function. In addition, it includes 5 additional modes from Overlay_MTools, "multiply128" from FFmpeg (line #298), "linearadd" and "linearsubtract" are modes I added based on Gimp's v2.10 add and subtract mode, "linearadd" is also known as "hypot" in Nuke.

Aside from that OverlayPlus works the same ways as the internal Overlay. The base and overlay clip do not have be the same dimensions and placement of the overlay clip can be adjusted, just like in overlay. All of OverlayPlus' parameters have the same meaning as Overlay, only difference is that Overlay's greymask parameter is called mask_first_plane in OverlayPlus.

As Arx1meD pointed out in the Overlay_MTools thread, internal Overlay does not produce results that are similar to Photostop and Gimp, etc (except for "blend" mode). That is because Overlay works internally in YUV and applies additional formulas on the U/V channels. Even in RGB some of the results are not too similar. In greyscale, most of the results are the same between the 2 functions.

Detailed documentation: http://avisynth.nl/index.php/OverlayPlus

Without further ado:
overlayplus-v1.2.0.avsi

Download the script from the link above or copy it from below.

PHP Code:
################################################################################
# OverlayPlus v1.2.0 (2021/09/27)
# Port of VapourSynth's havsfunc Overlay function to AviSynth+.
# http://avisynth.nl/index.php/OverlayPlus
# author: reel.deel
#
# REQUIREMENTS
# ************
# AviSynth+ v3.7.0 or greater
# Masktools2 v2.2.27 or greater
################################################################################

/*
SYNTAX and PARAMETERS
**********************
OverlayPlus (clip base, clip overlay, clip "mask", string "mode", float "opacity", int "x", int "y", bool "chroma", bool "mask_first_plane", string "cplace")

base:
-----
    Base clip; all colorspaces (except YV411) are supported.
    Alpha channel is copied from the base clip (if applicable). 
    
overlay:
--------
    Overlay clip that will be placed over the base clip.

mask:
-----
    Optional transparency mask to use for the overlay clip.
    
mode:
-----
    Blend mode to use. Names in parenthesis are aliases that can also be used.
    Default: "normal"

        GROUP      |   BLEND MODE
        -----------|--------------------------------------------------------------------------
        Simple     | average, blend (normal)
        -----------|--------------------------------------------------------------------------
        Darken     | burn (colorburn), darken, linearburn, multiply, multiply128
        -----------|--------------------------------------------------------------------------
        Lighten    | add (lineardodge), dodge (colordodge), lighten, linearadd (hypot), screen
        -----------|--------------------------------------------------------------------------
        Mix        | hardlight, hardmix, interpolation, linearlight, overlay, 
                   | pinlight, softburn, softdodge, softlight, softlight2, vividlight
        -----------|--------------------------------------------------------------------------
        Difference | difference, divide, exclusion, extremity, grainextract, grainmerge, 
                   | linearsubtract, negation, phoenix, subtract

opacity:
--------
    Blend transparency; the range is from 0.0 to 1.0, where 0.0 is transparent and 1.0 is fully opaque.
    Default: 1.0
    
x/y:
----
    Horizontal and vertical placement of the overlay clip on the base clip, in pixels. Can be positive or negative.
    Default: 0
    
chroma:
-------
    Enable or disable chroma processing. When chroma=false, chroma planes are copied from the base clip.
    Dafault: false (for RGB all planes are always processed)
    
mask_first_plane:
-----------------
    When set to true, the first plane of the the mask clip will be used as a mask for all channels.
    Default: true
    
cplace:
-------
    Chroma location placement to use on the mask when resizing the chroma channels.
    Only applicable when mask_first_plane=true and for YUV420 and YUV422 colorspaces only.
      "mpeg1" : also known as "center", "jpeg" and "chromaloc type 1" chroma placement.
      "mpeg2" : also known as "left" and "chromaloc type 0" chroma placement, most consumer SD/HD formats use this.
      "topleft" : also known as "chromaloc type 2"; used on UHD formats and only available for YUV 4:2:0 colorspaces.
    Default: "mpeg2"
    
################################################################################
CHANGELOG
*********
Version      Date            Changes
1.2.0        2021/09/27      - mask_first_plane is ignored if the mask clip is a Y grayscale clip
                             - The chroma paramater now defaults to false for YUV clips
                             - Padding and cropping stage is bypassed when not needed
                             - A single frame mask is used when mask clip is undefined
                             - Correct output when all the following conditions are true: 
                               * mask is not defined, opacity=1.0, x=0, y=0, and overlay clip is a smaller dimension than the base clip
                             - If the base clip is RGB or YUV444, the mask clip can be either YUV444 or RGB
1.1.0        2021/09/10      - Add support for all interleaved colorspaces (RBG24/32/48/64 and YUY2)
                             - Copy alpha channel from base clip when available
                             - Fix wrong output when opacity=1.0 and mask was not used and x or y > 0 
                             - Add "cplace" parameter
                             - Cosmetics and other minor improvements
1.0.0        2021/09/01      - Initial release
*/


function OverlayPlus (clip baseclip overlayclip "mask"string "mode"float "opacity"int "x"int "y"bool "chroma"bool "mask_first_plane"string "cplace")
{
    
# Defaults
    
msk     = default(mask,        Undefined)
    
mode    = default(mode,          "blend")
    
opacity = default(opacity,           1.0)
    
x       = default(x,                   0)
    
y       = default(y,                   0)
    
chroma  = default(chroma,          false
    
mfp     = default(mask_first_planetrue)
    
    
# Convert interleaved formats to planar and extract alpha from base
    
alpha = (HasAlpha(base)) ? ExtractA(base) : false
    base  
= (IsRGB(base) && IsInterleaved(base)) ? ConvertToPlanarRGB(base) : \
            (
IsYUY2(base)) ? ConvertToYV16(base) : (HasAlpha(base)) ? RemoveAlphaPlane(base) : base
    over  
= (IsRGB(overlay) && IsInterleaved(overlay)) ? ConvertToPlanarRGB(overlay) : \
            (
IsYUY2(overlay)) ? ConvertToYV16(overlay) : (HasAlpha(overlay)) ? RemoveAlphaPlane(overlay) : overlay
    mask  
= (Defined(msk) && IsRGB(msk) && IsInterleaved(msk)) ? ConvertToPlanarRGB(msk) : \
            (
Defined(msk) && IsYUY2(msk)) ? ConvertToYV16(msk) : (Defined(msk) && HasAlpha(msk)) ? RemoveAlphaPlane(msk) : msk

    
# Generate mask clip
    
mfp  = (Defined(msk) && NumComponents(mask) != 1) ? mfp true
    mask 
= (Defined(msk)) ? mask Trim(over0, -1).mt_lut(expr="range_max"y=3u=1v=1# white mask
    
mask = (IsRGB(mask) && mfp==true) ? ExtractR(mask) : (IsYUV(mask) && mfp==true) ? ExtractY(mask) : mask
 
    
# Dimensions and other checks
    
IsSameSize = (Width(base) == Width(over) && Height(base) == Height(over)) ? true false
    IsSmaller  
= (Width(base) > Width(over) || Height(base) > Height(over)) ? true false
    IsMask444  
= (IsRGB(base) || Is444(base) && IsRGB(mask) || Is444(mask)) ? true false
       
    
# Sanity checks
    
opacity Min(Max(opacity0.0), 1.0)
    
Assert(!IsYV411(base), "OverlayPlus: YV411 colorspace is not accepted")
    
Assert(PixelType(base) == PixelType(over), "OverlayPlus: overlay clip must be the same colorspace as the base clip")
    
Assert(mfp == true || isMask444 == true || PixelType(mask) == PixelType(base), "OverlayPlus: mask clip must be the same colorspace as the base clip")
    
Assert(BitsPerComponent(base) == BitsPerComponent(mask), "OverlayPlus: mask clip must be the same bitdepth as the base clip")
    
Assert(Width(over) == Width(mask) && Height(over) == Height(mask), "OverlayPlus: mask clip must be the same dimensions as the overlay clip")
    
Assert(!Is420(base) || y%== 0"OverlayPlus: the value of 'y' must be mod2")
    
Assert(!Is420(base) || !Is422(base) && x%== 0"OverlayPlus: the value of 'x' must be mod2")

    
# Padding and cropping stage
    
if (|| || IsSameSize == false) {
        
# Calculate padding sizes
        
x
        r 
base.Width over.Width x
        t 
y
        b 
base.Height over.Height y

        
# Split into crop and padding values
        
cl min(l0) * -1
        pl 
max(l0)
        
ct min(t0) * -1
        pt 
max(t0)
        
cr min(r0) * -1
        pr 
max(r0)
        
cb min(b0) * -1
        pb 
max(b0)

        
# Crop and padding    
        
over over.Crop(clct, -cr, -cb)
        
over over.IsRGB over.AddBorders(plptprpbcolor=$000000) : over.AddBorders(plptprpbcolor_yuv=$000000)
        
mask mask.Crop(clct, -cr, -cb)
        
mask mask.IsRGB mask.AddBorders(plptprpbcolor=$000000) : mask.AddBorders(plptprpbcolor_yuv=$000000)
    }
    
    
# Range based on bitdepth
    
if (BitsPerComponent(base) != 32) {
        
ntrl String(BitLShift(1, (BitsPerComponent(base) - 1))) # 128 ... 32768 - neutral
        
peak String(BitLShift(1BitsPerComponent(base)) - 1)   # 255 ... 65535 - peak
        
fctr String(BitLShift(1BitsPerComponent(base)))       # 256 ... 65536 - factor
    
}
    else {
        
ntrl String(0.5)
        
peak String(1.0)
        
fctr String(1.0)
    }

    
# Blending modes
    
if (mode == "blend" || mode == "normal") {
        
expr ""
    
}
    else if (
mode == "add" || mode == "addition" || mode == "lineardodge") {
        
expr "x y +"
    
}
    else if (
mode == "average") {
        
expr "x y + 2 /"
    
}
    else if (
mode == "burn" || mode == "colorburn") {
        
expr "y 0 <= y "+peak+" "+peak+" x - "+fctr+" * y / - ?"
    
}
    else if (
mode == "darken") {
        
expr "x y min"
    
}
    else if (
mode == "difference") {
        
expr "x y - abs"
    
}
    else if (
mode == "divide") {
        
expr "y 0 <= "+peak+" "+peak+" x * y / ?"
    
}
    else if (
mode == "dodge" || mode == "colordodge") {
        
expr "y "+peak+" >= y x "+fctr+" * "+peak+" y - / ?"
    
}
    else if (
mode == "exclusion") {
        
expr "x y + 2 x * y * "+peak+" / -"
    
}
    else if (
mode == "extremity") {
        
expr ""+peak+" x - y - abs"
    
}
    else if (
mode == "freeze") {
        
expr "y 0 <= 0 "+peak+" "+peak+" x - dup * y / "+peak+" min - ?"
    
}
    else if (
mode == "glow") {
        
expr "x "+peak+" >= x y y * "+peak+" x - / ?"
    
}
    else if (
mode == "grainextract") {
        
expr "x y - "+ntrl+" +"
    
}
    else if (
mode == "grainmerge") {
        
expr "x y + "+ntrl+" -"
    
}
    else if (
mode == "hardlight") {
        
expr "y "+ntrl+" < 2 y x * "+peak+" / * "+peak+" 2 "+peak+" y - "+peak+" x - * "+peak+" / * - ?"
    
}
    else if (
mode == "hardmix") {
        
expr "x "+peak+" y - < 0 "+peak+" ?"
    
}
    else if (
mode == "heat") {
        
expr "x 0 <= 0 "+peak+" "+peak+" y - dup * x / "+peak+" min - ?"
    
}
    else if (
mode == "interpolation") {
        
expr ""+peak+" 0.5 pi x * "+peak+" / cos 4 / - pi y * "+peak+" / cos 4 / - *" # from Overlay_MTools
    
}
    else if (
mode == "lighten") {
        
expr "x y max"
    
}
    else if (
mode == "linearadd" || mode == "hypot") {
        
expr "x 2 ^ y 2 ^ + sqrt" # same as Gimp's 2.10 addition blending mode, aka as Nuke's "hypot"
    
}
    else if (
mode == "linearburn") {
        
expr "x y + "+peak+" < 0 x y + "+peak+" - ?" # from Overlay_MTools
    
}
    else if (
mode == "linearlight") {
        
expr "x "+ntrl+" < x 2 y * + "+peak+" - x 2 y "+ntrl+" - * + ?"
    
}
    else if (
mode == "linearsubtract") {
        
expr "x 2 ^ y 2 ^ - sqrt" # same as Gimp's 2.10 subtract blending mode
    
}
    else if (
mode == "multiply") {
        
expr "x y * "+peak+" /"
    
}
    else if (
mode == "multiply128") {
        
expr "x "+ntrl+" - y * "+ntrl+" 4 / / "+ntrl+" +" # from ffmpeg
    
}
    else if (
mode == "negation") {
        
expr ""+peak+" "+peak+" x - y - abs -"
    
}
    else if (
mode == "overlay") {
        
expr "x "+ntrl+" < 2 x y * "+peak+" / * "+peak+" 2 "+peak+" x - "+peak+" y - * "+peak+" / * - ?"
    
}
    else if (
mode == "phoenix") {
        
expr "x y min x y max - "+peak+" +"
    
}
    else if (
mode == "pinlight") {
        
expr "y "+ntrl+" < x 2 y * min x 2 y "+ntrl+" - * max ?"
    
}
    else if (
mode == "reflect") {
        
expr "y "+peak+" >= y x x * "+peak+" y - / ?"
    
}
    else if (
mode == "screen") {
        
expr ""+peak+" "+peak+" x - "+peak+" y - * "+peak+" / -"
    
}
    else if (
mode == "softburn") {
        
expr "x y + "+peak+" < x "+peak+" == x "+peak+" y * 2 "+peak+" x - * / ? y 0 == y "+peak+" "+peak+" x - "+peak+" * y 2 * / - ? ?" # from Overlay_MTools
    
}
    else if (
mode == "softdodge") {
        
expr "x y + "+peak+" < y "+peak+" == y x "+peak+" * 2 "+peak+" y - * / ? x 0 == x "+peak+" "+peak+" "+peak+" y - * 2 x * / - ? ?" # from Overlay_MTools
    
}
    else if (
mode == "softlight") {
        
expr "x "+peak+" / x y 2 * + x y * "+ntrl+" / - *" # from Overlay_MTools
    
}
    else if (
mode == "softlight2") {
        
expr "y "+ntrl+" > x "+peak+" x - y "+ntrl+" - * "+ntrl+" / 0.5 x "+ntrl+" - abs "+peak+" / - * + x x "+ntrl+" y - "+ntrl+" / * 0.5 x "+ntrl+" - abs "+peak+" / - * - ?"
    
}
    else if (
mode == "subtract") {
        
expr "x y -"
    
}
    else if (
mode == "vividlight") {
        
expr "y "+ntrl+" < y 0 <= 2 y * "+peak+" "+peak+" x - "+fctr+" * 2 y * / - ? 2 y "+ntrl+" - * "+peak+" >= 2 y "+ntrl+" - * x "+fctr+" * "+peak+" 2 y "+ntrl+" - * - / ? ?"
    
}
    else {
        
Assert(false"OverlayPlus: invalid 'mode' specified")
    }

    
# Process
    
opac    String(opacity)
    
chroma  = (base.IsRgb || chroma==true) ? "process" "copy"
    
chromax = (chroma == "process") ? expr ""
    
mfp2    = (chroma == "process") ? mfp false # bug in mt_merge; does not honor chroma copy if luma=true
    
mask    = (opacity 1.0) ? (mfp==true && mask.NumComponents!=1) ? Expr(mask"x "+opac+" *""") : Expr(mask"x "+opac+" *") : mask
    over    
= (mode != "blend" && mode != "normal") ? (base.NumComponents==1) ? Expr(baseoverexpr) : Expr(baseoverexprchromax) : over
    blend   
= (!Defined(msk) && opacity==1.0 && x==&& y==&& !IsSmaller) ? over :  mt_merge(baseovermaskchroma=chromaluma=mfp2cplace=cplace)
    
    return (
IsClip(alpha)) ? AddAlphaPlane(blendalpha) : blend


TO DO LIST:
  • Replace chroma parameters with a planes parameter (maybe);
  • Add hue and saturation modes;
  • Add some other modes from MATLAB (provided I can find formulas).
  • Fix any bugs that you guys find

Last edited by Reel.Deel; 27th September 2021 at 09:28. Reason: Update - v1.2.0
Reel.Deel is offline   Reply With Quote
Old 2nd September 2021, 11:26   #2  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 924
Thanks, one man stand

Edit: can you up file to github for easy to monitor changes between versions??
kedautinh12 is offline   Reply With Quote
Old 2nd September 2021, 16:11   #3  |  Link
Arx1meD
Registered User
 
Arx1meD's Avatar
 
Join Date: Feb 2021
Posts: 90
Hi Reel.Deel
I noticed an error in your script:
In the OverlayPlus function, the "chroma" option is defined as bool:
Quote:
function OverlayPlus (... bool "chroma" ...)
...
chroma = default(chroma, true)
Then you assign chroma the string:
Quote:
chroma = (base.IsRgb || chroma==true) ? "process" : "copy"

Last edited by Arx1meD; 2nd September 2021 at 16:15.
Arx1meD is offline   Reply With Quote
Old 2nd September 2021, 16:33   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,886
Quote:
Originally Posted by Arx1meD View Post
Then you assign chroma the string:
Nothing wrong with that, it was a bool, and then a string, [EDIT: is always bool before that point, and always string after that point in script]
just makes checking of function call easier [with a bool arg <no check needed at all>, instead of checking valid chroma arg as string].

But dont need eg
Code:
 chroma  = (base.IsRgb || chroma==true) ? "process" : "copy"
and instead of
Code:
Defined(msk)==false
Maybe
Code:
!Defined(msk)
Comparing with Global variables "true" and "false" is slow, and simply not needed when both chroma [at that point in script] is already a bool, and so is result of Defined().
Test of Bool True or False is done by parser and fast, whereas comparison with true or false globals is slow (has to find value of variable named "True" or "False" in Globals variable name table, after first searching Local variables name table).
True/False assigned to global vars early on in Avisynth startup, and so right at the end of Global variable list.

Above does not really matter, unless called many times from within runtime script. [EDIT: Also, I think name table access sped up some in AVS+]
__________________
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; 2nd September 2021 at 16:49.
StainlessS is offline   Reply With Quote
Old 2nd September 2021, 20:22   #5  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,317
Quote:
Originally Posted by Arx1meD View Post
Hi Reel.Deel
I noticed an error in your script:
In the OverlayPlus function, the "chroma" option is defined as bool:

Then you assign chroma the string:
It just converts true or false to "process" and "copy" to feed mt_merge's chroma parameter . Similar to what you did in your script:

Code:
chrom   = blend_rgb || chroma ? "process" : "copy"
Quote:
Originally Posted by StainlessS View Post
and instead of
Code:
Defined(msk)==false
Maybe
Code:
!Defined(msk)
I will probably do some cosmetics later. But I guess it's just me but I like putting true or false, it makes it easier for me to follow.
Reel.Deel is offline   Reply With Quote
Old 2nd September 2021, 20:31   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,886
Quote:
makes it easier for me to follow.
Is a bit like if(true==true), but I have been known to do it too, is nothing terribly wrong about it
__________________
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; 2nd September 2021 at 20:44.
StainlessS is offline   Reply With Quote
Old 10th September 2021, 20:18   #7  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,317
I updated OverlayPlus, see first post. It includes a bug fix, added a chroma placement parameter, support for all interleaved colorspaces and a few other other minor things. OverlayPlus now accepts mismatched colorspaces as long as they are in the same color family. For example the base clip can be RGB32 and the overlay RGBP8 or vice versa. Or in YUV the base clip can be YUVA420P8 and the overlay clip can be YUV420P8, or base can be YUY2 and overlay YV16. If applicable, the alpha channel is discarded from the overlay and mask clip, only the base clip alpha channel is copied. Mask can be any colorspace if mask_first_plane=true, if not it must be the same as the base with or without an alpha channel..... Enjoy
Reel.Deel is offline   Reply With Quote
Old 27th September 2021, 09:28   #8  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,317
I updated OverlayPlus, see first post. It includes a bug fix and some optimizations to try to increase speed. The cropping and padding stage is skipped when not needed and a single frame mask is used when a mask clip is not defined. From my test this increased the speed over 100fps on SD resolution and used less memory overall. Aside from that, now an RGB or YUV444 mask can be used and interchanged when the base clip is RGB or YUV. And last but not least the chroma parameter now defaults to false for YUV clips. Next version will have an RGB mode for YUV colorspaces, just undecided what to do with YUV420 or YUV422, downscale the luma channel to the size of the chroma or upscale the chroma to the luma....


I hope these changes makes the speed more comparable to ex_blend or Overlay_MTools :
Code:
# 100% ex_blend(a,mode="multiply")
#  92% Overlay_MTools(mode="multiply")             # only in PC range
#  56% OverlayPlus(a,mode="multiply",chroma=false) # only in PC range
#  56% Overlay(mode="multiply")                    # only in PC range
@Dogway

What colorspace and dimensions did you use for that benchmark?
Reel.Deel is offline   Reply With Quote
Old 27th September 2021, 17:04   #9  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 1,638
I use 1080p@16-bit, with chroma false in 420.
I just retested latest version and is pretty much on par with ex_blend() within the margins of error.
Code:
OverlayPlus(a,mode="multiply",chroma=false) # 315
ex_blend(a,mode="multiply") # 319
__________________
[i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub
Dogway is offline   Reply With Quote
Old 27th September 2021, 20:10   #10  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,113
I see there is a bug in mt_merge chroma copy when luma is true?
pinterf is offline   Reply With Quote
Old 27th September 2021, 21:08   #11  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,317
Quote:
Originally Posted by Dogway View Post
I use 1080p@16-bit, with chroma false in 420.
I just retested latest version and is pretty much on par with ex_blend() within the margins of error.
Code:
OverlayPlus(a,mode="multiply",chroma=false) # 315
ex_blend(a,mode="multiply") # 319
Thank you for testing it again. I'm glad my changes increased the speed.

Quote:
Originally Posted by pinterf View Post
I see there is a bug in mt_merge chroma copy when luma is true?
Yes. I initially reported it here but I think it was overlooked and then I forgot to follow up. So whenever luma=true it always processes the chroma planes, regardless of what chroma/u/v are set to. One can argue if you set luma=true you intend to process the chroma planes also but then u=2, v=3 is not possible since with luma=true it processes both planes. I don't know if this is the intended behavior but I think chroma/u/v should have priority. You can see what I'm talking about by setting luma to true and then false.

Code:
base  = Blankclip(color=$FFFFFF, pixel_type="RGBP8")
base2 = Blankclip(color_yuv=$FF8080, pixel_type="YUV444P8")
over  = Colorbars(pixel_type="RGBP8")
over2 = Colorbars(pixel_type="YUV444P8")
mask  = Blankclip(color=$000000, pixel_type="RGBP8").Subtitle("AviSynth", size=150, align=5, text_color=$FFFFFF)
masky = mask.ShowRed("Y8")
mask2 = YToUV(masky,masky,masky)

# RGB
#mt_merge(base, over, mask, chroma="copy", luma=true)

#YUV
#mt_merge(base2, over2, mask2, chroma="copy", luma=false)
mt_merge(base2, over2, mask2, u=2, v=3, luma=true)
Edit:
I went back and read the old readme and I guess that is the intended behavior:

Quote:
merge clip1 and clip2 according to the mask. If "luma" is true, only the luma
mask plane is used, and both chroma planes are processed with it - without needing
to specify u=v=3 or chroma="process"
Quote:
Changed from alpha 21 to alpha 22 :
* added : bool "luma" parameter to mt_merge, which makes it use the luma mask for
all three planes, and which forces chroma modes to "process" ( u=v=3 )
I can't find any evidence in the source code but I don't why I was under the impression that luma defaults to true (only thing I found). So this is a false alarm and not a bug but the intended behavior. Bummer.

Edit 2:
Added luma parameter notes in the wiki page (luma, u/v, and chroma parameters), if something is wrong please let me know.

Last edited by Reel.Deel; 28th September 2021 at 11:21.
Reel.Deel 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 02:18.


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