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 3rd June 2015, 14:58   #21  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Still mobile.
See s_exlogo thread for a walk hrough.
Maybe don't need use s_exlogo though,your choice.
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 27th April 2016, 22:31   #22  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
@Hello_Hello,

Sorry, I seem to have missed this post (#20) and was about to delete stuff related to it.

Quote:
PS StainlessS,
Could I get you to assume I'm Avisynth stupid and elaborate on what you meant by the following. Being Avisynth stupid I'm not sure I understand what you meant. Do you mean to somehow do this when encoding and removing the logo?
Thanks.

"By the way, I think the script makes global changes to clip (not just logo area) might want to chop out area of interest and
process just that and omit two colorspace conversions to boot (for most of the frame)."
I meant that the filter alters the entire clip (converting to RGB and back again), so I would preferably crop out an area around
the logo, fix that, and then put it back, (Crop, Overlay or preferably StackH/V). In this manner, only the logo area suffers
two colorspace conversions (I'm not sure how much of the frame is affected by Overlay, hopefully no unnecessary conversions
if already YUV).
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 2nd January 2017, 16:40   #23  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Fixed InPaintFunc bug in RepairEdge Mask. (result of a bug fix in avs v2.6 Levels, produced bug in InPaintFunc)

Below Repair Edge mask now works as intended (did look exactly same as Repair Mask)


InpaintFunc.avs Part 1 of 2.
Code:
#____________________________________________________________________________________
#       _____                   _       _   ______
#      |_   _|                 (_)     | | |  ____|
#        | |  _ __  _ __   __ _ _ _ __ | |_| |__ _   _ _ __   ___
#        | | | '_ \| '_ \ / _` | | '_ \| __|  __| | | | '_ \ / __|
#       _| |_| | | | |_) | (_| | | | | | |_| |  | |_| | | | | (__
#      |_____|_| |_| .__/ \__,_|_|_| |_|\__|_|   \__,_|_| |_|\___|
#                  | |
#                  |_|
#_____________________________________________________________________________________



#  InpaintFunc is a new delogo function using AVSInpaint.dll an AviSynth C plugin developed by AMSS.
#See thread : http://forum.doom9.org/showthread.php?t=133682 to download this plugin and get
#more information about it. Just an advertise : AVSInpaint plugin is rather slow so be patient ;-)


#_______________________________________________________________________________________
#
#    History :
#_______________________________________________________________________________________


# Actual revision : InpaintFunc v1.12

# Author          : Reuf Toc

# Requirement     : AVSInpaint.dll


# Changes         :

#Rev 1.00 :  First release 2008/01/30
#Rev 1.01 :  Added debug for "mode". Removed two useless operations.
#Rev 1.02 :  Added "Speed" parameter.
#Rev 1.03 :  Fixed bug in PAR calculation. Fixed bug with non-RGB32 mask.
#Rev 1.10 :  Fixed bug due to overlay. Added post-processing + a lot of things.
#Rev 1.11 :  Added Show parameter and InpaintAssist function. Process in RGB24 instead of RGB32.
#Rev 1.12 :  Fixed bug in "loc" calculation
#Rev 1.13 :  Fixed bug for .ebmp creation (did not happen in several cases)
#Rev 1.14 :  Fixed RepairEdge bug resulting from a bug fix in Levels for RGB (http://forum.doom9.org/showthread.php?t=159652) [StainlessS).

#______________________________________________________________________________________
#
#    About Inpainting :
#______________________________________________________________________________________


#  Image Inpainting is the art of restoring destroyed parts of an image by using information
#of valid parts of the image in a way, so that the human eye does not recognize the damaged
#areas (at least not at a first sight). In video processing image inpainting is often applied
#to videos in order to remove TV station logos.


#______________________________________________________________________________________
#
#    Function parameters :
#______________________________________________________________________________________




# =======================================================
#                   InpaintAssist
# =======================================================


# This subfunction can be used to help you in order to set your own crop values to isolate the logo to remove. With HD footage, the delogo
# process is slow due to the resolution (especialy for analysis) and to maximize speed, it is adviced to reduce the size of the cropped clip
# by setting your own crop values.


# If you don't specify a loc value, this function will display your clip divised in 9 parts (the nine loc preset of InpaintFunc) with the crop values for each one in order
# to give you an idea about the values to use.

# After that step, you can enter your own loc values and check they are correct. The selected area will be hightlighted.
# Keep in mind you have to keep a little border around the logo since inpainting use nearby pixels to compute the hidden ones.

# string "loc"    : Select the part of the picture where is the logo to remove. Same as InpaintFunc loc parameter

# String "alignment"   : Alignment of the text. "Top", "Center" and "Bottom" are allowed



# =======================================================
#                   InpaintFunc
# =======================================================



#  Given this function use AVSInpaint.dll and given AVSInpaint is an avisynth C plugin
#don't forget to add loadCplugin("xxx\AVSInpaint.dll") in your script before calling this function !!!




# String "loc"      :  Select the part of the picture where is the logo to remove.
#                     See the table :


#              ______________           ______________
#              | TL | TC |TR |          | X1 | X2 |X3 |
#              |____|____|___|          |____|____|___|
#              | ML | MC |MR |    or    | Y1 | Y2 |Y3 |
#              |____|____|___|          |____|____|___|
#              | BL | BC |BR |          | Z1 | Z2 |Z3 |
#              |____|____|___|          |____|____|___|


#                      If the logo you want to remove is in the top right corner, then you can choose
#                     either loc="TR" or loc="x3".

#                      If you don't want to use one of these preset, you can enter manually the crop values to isolate the logo.
#                     example : loc = "0,300,-440,-20". Spaces are not allowed in "loc" parameter. You can use function
#                     InpaintAssist to help you to set crop values.




# String "mask"     :  Path to the mask of the logo. The mask is a black and white picture. Parties where the logo
#                     is are white, the others are black.

#                     example : mask="C:\my_mask.bmp"



# String "mode"     :  3 Choices (default both) :

#                     -Deblend : If the logo is transparent, use this mode.
#                     -Inpaint : If the logo is opaque, use this mode.
#                     -Both    : If the logo is both opaque and transparent, use this mode.



# Float "AR"        :  The Sample Aspect Ratio of your video. E.g. : 16/9, 4/3...  (Default 1.0).
#                     This value is used to calculate the PAR of your video. If you don't set this parameter, then
#                     PAR will be set to 1:1. It's not really important if you don't set this value.
#                     When you set the AR, take care to add ".0" to your values if you use exact value (16/9 or 4/3).
#                     example : AR=16.0/9.0 or AR=4.0/3.0



# Int "Speed"       :  With this parameter you can speed up this function by trimming the clip analyzed by
#                     AnalyseLogo. A value of 20 means that 100% of clip will be analyzed. With a value of
#                     1, only 5% will be analyzed. (min value 1, max value 20, default 5)


# Int "PPMode"      :  If you want to apply post-processing, 3 modes are available. Default is 0 (disabled)
#                     -Mode 1 : Blur all the area where logo was present.
#                     -Mode 2 : Blur all the area where logo was present using TemporalSoften and SpatialSoften.
#                     -Mode 3 : Blur only the edge of logo area using TemporalSoften and SpatialSoften..


# Int "PP"          :  Strength of the post-processing. Default is 50 (min value 0, max value 100)
#                     A 0 value will disable post processing, 100 will process at full strength.

# Bool "Reset"      :  InpaintFunc contain a feature that allow to not compute logo analysis when it was already done.
#                     By setting Reset to true, logo analysis is always computed. Default is false.

# Float "radius"    :  Radius around a damaged pixel from where values are taken when the pixel is inpainted.
#                     Bigger values prevent inpainting in the wrong direction, but also create more blur.

# Float "sharpness" : Higher values can prevent blurring caused by high Radius values.

# Float "preblur"   : Standard deviation of the blur which is applied to the image before the structure tensor is computed.
#                     Higher values help connecting isophotes which have been cut by the inpainting region, but also
#                     increase CPU usage. PreBlur=0.0 disables pre-blurring.


# Float "postblur"  : Standard deviation of the blur which is applied to the structure tensors before they are used
#                     to determine the inpainting direction. Higher values help gather more directional information when
#                     there are only few valid pixels available, but increases CPU usage.


# Bool "show"       : Allow the user to see the differents steps of the delogoing. Are displayed the source, the
#                     repaired, the repaired post-processed, the mask, the repair masks (edge and global), the color
#                     mask, the alpha mask and the inpaint mask.




#______________________________________________________________________________________

#    Function :
#______________________________________________________________________________________


function InpaintFunc( clip clp, string "mask", string "loc", float "AR", string "mode", int "speed",
\                     int "pp", int "ppmode", bool "reset", float "radius", float "sharpness", float "preblur",
\                     float"postblur", bool "show")

{

    mask        = default (mask         , ""    )
    loc         = default (loc          , ""    )
    AR          = default (AR           , 1.0   )
    mode        = default (mode         , "both")
    speed       = default (speed        , 5     )
    pp          = default (pp           , 50    )
    ppmode      = default (ppmode       , 0     )
    reset       = default (reset        , false )
    radius      = default (radius       , 8.0   )
    sharpness   = default (sharpness    , 75.0  )
    preblur     = default (preblur      , 8.0   )
    postblur    = default (postblur     , 4.0   )
    show        = default (show         , false )




    # debug
    # =====


    x           = width   (clp)
    y           = height  (clp)
    pp          = (pp >= 100) ? 255 : (pp <= 0) ? 0 : int(pp*255/100)
    RGB         = isRGB(clp)
    RGB24       = isRGB24(clp)
    RGB32       = isRGB32(clp)
    YUY2        = isYUY2(clp)
    cropval     = (StrLen(loc)  != 2  )  ? true : false
    spd         = (speed        != 20 )  ? true : false
    PAR         = (AR           != 1.0)  ? float( y) / float( x) * AR : 1.0
    bugloc      = (loc          == "" )  ? true : false
    bugmode     = (mode         != "inpaint" && mode != "deblend" && mode != "both") ? true : false
    bugspeed    = (speed        <= 0 || speed >= 21) ? true : false


    assert        ( findstr(loc," ")  == 0      , """Space character is not allowed in string "loc"."""")
    assert        ( mask              != ""     , """You have to define a mask (string "mymask")""")
    assert        ( bugloc            == false  , """You must define "Loc".""")
    assert        ( bugmode           == false  , """This mode doesn't exist. Change "mode" value.""")
    assert        ( bugspeed          == false  , """"Speed" value must be between 1 and 20.""")



    # calculation of crop values
    # ==========================


    null = (cropval == false ) ? eval("""

    a           = (Rightstr(loc,1) == "L" || Rightstr(loc,1) == "1") ? 0 : (Rightstr(loc,1) == "C" || Rightstr(loc,1) == "2")  ? round((x*1/6))*2  : round((x*1/3))*2
    b           = (leftstr(loc,1)  == "T" || leftstr(loc,1)  == "X") ? 0 : (leftstr(loc,1)  == "M" || leftstr(loc,1)  == "Y")  ? round((y*1/6))*2  : round((y*1/3))*2
    c           = (Rightstr(loc,1) == "R" || Rightstr(loc,1) == "3") ? 0 : (Rightstr(loc,1) == "C" || Rightstr(loc,1) == "2")  ? -round((x*1/6))*2  : -round((x*1/3))*2
    d           = (leftstr(loc,1)  == "B" || leftstr(loc,1)  == "Z") ? 0 : (leftstr(loc,1)  == "M" || leftstr(loc,1)  == "Y")  ? -round((y*1/6))*2  : -round((y*1/3))*2

                  """) : eval("""

    long        = StrLen(loc)

    posvirg1    = findstr(loc, ",")
    posvirg2    = findstr(rightstr(loc,long-posvirg1), ",")
    posvirg2    = posvirg2+posvirg1
    posvirg3    = findstr(rightstr(loc,long-posvirg2), ",")
    posvirg3    = posvirg3  + posvirg2

    a           = int(value(leftstr(loc,posvirg1-1)))
    b           = int(value(leftstr(rightstr(loc,long-posvirg1),posvirg2-posvirg1-1)))
    c           = int(value(leftstr(rightstr(loc,long-posvirg2),posvirg3-posvirg2-1)))
    d           = int(value(rightstr(loc,long-posvirg3)))
    """)


    # crop of the part of the image where is the logo + mask creation
    # ================================================================


    cropped     = clp.crop(a,b,c,d)
    in          = (RGB32 == true) ? cropped : cropped.converttoRGB24()
    in2         = (spd   == true) ? in.SelectRangeEvery (every=20, length=speed) : in

    Masque      = imagesource(mask,start=0,end=1).converttoRGB32
    Masque      = Masque.crop(a,b,c,d).levels(127,1,128,0,255)
    Masque      = Masque.mask(Masque)

    BlendedMask = Masque.DirtyBlur().levels(0,1,75,0,255)
    BlendedMask = BlendedMask.mask(BlendedMask)
    RepairMask  = BlendedMask.levels(0,1,255,0,pp)
    #RepairEdge  = Masque.DirtyBlur().levels(0,1,255,0,900)                 # ssS fix (removed)
    RepairEdge  = Masque.DirtyBlur().IPF_Mask()                             # ssS fix (added)
    RepairEdge  = RepairEdge.DirtyBlur().levels(0,1,75,0,pp)


    # check for an existing computed mask. If it doesn't exist or if reset = true --> computation
    # ===========================================================================================


    ID          = mask + "InpaintFunc" + string(a) + string(b) + string(c) + string(d) + string(speed)

    Logo        = (reset == true) ? eval("""

                  in2.analyzelogo(Masque).trim(0,-1).converttoRGB32
                  imagewriter(ID,0,1,"ebmp")

                  """) : eval("""

                  try

                  {imagesource(ID + "%06d.ebmp",0,0)}
                  catch (dummy)

                  {in2.analyzelogo(Masque).trim(0,-1).converttoRGB32
                  imagewriter(ID,0,1,"ebmp")      }""")


    # Creation of the masks used for DeblendLogo and InpaintLogo
    # ==========================================================


    LogoColor   = Logo.Crop(0,0,0,Logo.Height/2).converttoRGB24

    LogoAlpha   = Logo.Crop(0,Logo.Height/2,0,0)
    Logoalpha   = LogoAlpha.mask(LogoAlpha)

    LogoInpaint = LogoAlpha.mask(masque.dirtyblur().levels(0,1,32,0,255))


    # InpaintLogo and DeblendLogo are applied depending on the value of "mode"
    # ==========================================================================


    repaired    = (mode ==  "both")   ?
    \             in.DeblendLogo(LogoColor,LogoAlpha).
    \             InpaintLogo(LogoInpaint,radius=radius,sharpness=sharpness,preblur=preblur,postblur=postblur,PixelAspect=PAR).converttorgb32:
    \             (mode == "deblend") ?
    \             in.DeblendLogo(Logocolor,Logoalpha).converttorgb32 :
    \             in.InpaintLogo(LogoInpaint,radius=radius,sharpness=sharpness,preblur=preblur,postblur=postblur,PixelAspect=PAR).converttorgb32


    # Finalization of the repaired with post-processing
    # ==========================================================
EDIT: 2 modded sections marked in Blue
__________________
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; 8th December 2019 at 11:37.
StainlessS is offline   Reply With Quote
Old 2nd January 2017, 16:41   #24  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
InpaintFunc.avs Part 2 of 2.
Code:

    repairedpp  = (ppmode == 1) ? repaired.layer(repaired.DirtyBlur( ).mask(RepairMask))              :
    \             (ppmode == 2) ? repaired.layer(repaired.DirtyBlur(2).mask(RepairMask))              :
    \             (ppmode == 3) ? repaired.layer(repaired.DirtyBlur(2).DirtyBlur().mask(RepairEdge))  : repaired


    output      = in.converttorgb32.Layer(repairedpp.Mask(BlendedMask))


    # Overlay of the cleaned portion over the original clip
    # =====================================================


    (show == true) ? Eval("""

    cropped     = cropped.subtitle("source").converttoRGB32
    masque      = masque.subtitle("mask")

    repairmask  = repairmask.subtitle("repair mask")
    repairedge  = repairedge.subtitle("repair edge")

    Logoalpha   = Logoalpha.subtitle("Logo alpha")
    Logocolor   = Logocolor.subtitle("Logo color").converttoRGB32
    Logoinpaint = Logoinpaint.subtitle("Logo inpaint")

    repaired    = repaired.subtitle("repaired")
    repairedpp  = repairedpp.subtitle("repaired pp")

    l1          = Stackhorizontal(cropped,repaired,repairedpp)
    l2          = Stackhorizontal(masque,repairmask,repairedge)
    l3          = Stackhorizontal(logocolor,logoalpha,logoinpaint)

    stackvertical (l1,l2,l3)
    return spline36resize(last,width(last),height(last))

    """) : Eval("""


    clp         = (RGB32 == true) ? clp : clp.converttoRGB32
    fullclip    = clp.layer(output,x=a, y=b)
    fullclip    = (RGB == true) ? (RGB32 == true) ? fullclip : fullclip.converttoRGB24() : (YUY2 == true) ? fullclip.converttoYUY2() : fullclip.converttoYV12()
    return fullclip
    """)

}


#==========================================================================================================
#==========================================================================================================
#==========================================================================================================


function InpaintAssist ( clip clp, string "loc", string "alignment") {


    loc         = default (loc,  "")
    x           = width   (clp)
    y           = height  (clp)
    alignment        = default (alignment, "top")
    align       = (alignment == "top") ? 8 : (alignment == "center") ? 5 : (alignment == "bottom") ? 2 :8
    framecount  = framecount(clp)


    # I "Loc" parameter is not specified, split the clip in 9 parts et show crop value for each part
    # ==============================================================================================


    loc == ""     ? Eval("""

    white       = blankclip(width=round(x/3),height=round(y/3),color=$FFFFFF,length=framecount)
    black       = blankclip(width=round(x/3),height=round(y/3),color=$000000,length=framecount)

    l1          = stackhorizontal(white,black,white)
    l2          = stackhorizontal(black,white,black)
    background  = stackvertical(l1,l2,l1).converttoRGB32.spline36resize(x,y)
    clp         = clp.converttoRGB32

    a1          = string(0)
    a2          = string(round((x*1/6))*2)
    a3          = string(round((x*1/3))*2)

    b1          = string(0)
    b2          = string(round((y*1/6))*2)
    b3          = string(round((y*1/3))*2)

    ca1         = string(-round((x*1/3))*2)
    ca2         = string(-round((x*1/6))*2)
    ca3         = string(0)

    d1          = string(-round((y*1/3))*2)
    d2          = string(-round((y*1/6))*2)
    d3          = string(0)

    c1          = clp.crop(0               , 0          , -round((x*1/3))*2, -round((y*1/3))*2)
    \             .subtitle("TL (" + a1 + ","  + b1 + ","  + ca1 + ","  + d1+ ")",align=8)
    c2          = clp.crop(round((x*1/6))*2, 0          , -round((x*1/6))*2, -round((y*1/3))*2)
    \             .subtitle("TC (" + a2 + ","  + b1 + ","  + ca2 + ","  + d1+ ")",align=8)
    c3          = clp.crop(round((x*1/3))*2, 0          , 0                , -round((y*1/3))*2)
    \             .subtitle("TR (" + a3 + ","  + b1 + ","  + ca3 + ","  + d1+ ")",align=8)

    c4          = clp.crop(0               , round((y*1/6))*2 , -round((x*1/3))*2, -round((y*1/6))*2)
    \             .subtitle("ML (" + a1 + ","  + b2 + ","  + ca1 + ","  + d2+ ")",align=8)
    c5          = clp.crop(round((x*1/6))*2, round((y*1/6))*2 , -round((x*1/6))*2, -round((y*1/6))*2)
    \             .subtitle("MC (" + a2 + ","  + b2 + ","  + ca2 + ","  + d2+ ")",align=8)
    c6          = clp.crop(round((x*1/3))*2, round((y*1/6))*2 , 0                , -round((y*1/6))*2)
    \             .subtitle("MR (" + a3 + ","  + b2 + ","  + ca3 + ","  + d2+ ")",align=8)

    c7          = clp.crop(0               , round((y*1/3))*2, -round((x*1/3))*2,  0)
    \             .subtitle("BL (" + a1 + ","  + b3 + ","  + ca1 + ","  + d3+ ")",align=8)
    c8          = clp.crop(round((x*1/6))*2, round((y*1/3))*2, -round((x*1/6))*2,  0)
    \             .subtitle("BC (" + a2 + ","  + b3 + ","  + ca2 + ","  + d3+ ")",align=8)
    c9          = clp.crop(round((x*1/3))*2, round((y*1/3))*2, 0                ,  0)
    \             .subtitle("BR (" + a3 + ","  + b3 + ","  + ca3 + ","  + d3+ ")",align=8)

    output      = stackvertical(stackhorizontal(c1,c2,c3), stackhorizontal(c4,c5,c6), stackhorizontal(c7,c8,c9))
    output      = output.spline36resize(x,y)
    clip1       = background.layer(output.mask(blankclip(output,color=$DEDEDE)))


    """) : nop


    # If "Loc" is specified, hightlight the part choosen by user
    # ==========================================================


    (strlen(loc) == 2) ? Eval("""

    a           = (Rightstr(loc,1) == "L" || Rightstr(loc,1) == "1") ? 0 : (Rightstr(loc,1) == "C" || Rightstr(loc,1) == "2")  ? round((x*1/6))*2  : round((x*1/3))*2
    b           = (leftstr(loc,1)  == "T" || leftstr(loc,1)  == "X") ? 0 : (leftstr(loc,1)  == "M" || leftstr(loc,1)  == "Y")  ? round((y*1/6))*2  : round((y*1/3))*2
    c           = (Rightstr(loc,1) == "R" || Rightstr(loc,1) == "3") ? 0 : (Rightstr(loc,1) == "C" || Rightstr(loc,1) == "2")  ? -round((x*1/6))*2  : -round((x*1/3))*2
    d           = (leftstr(loc,1)  == "B" || leftstr(loc,1)  == "Z") ? 0 : (leftstr(loc,1)  == "M" || leftstr(loc,1)  == "Y")  ? -round((y*1/6))*2  : -round((y*1/3))*2

                 """) : (strlen(loc) != 0) ? eval("""

    long        = StrLen(loc)
    posvirg1    = findstr(loc, ",")
    posvirg2    = findstr(rightstr(loc,long-posvirg1), ",")
    posvirg2    = posvirg2+posvirg1
    posvirg3    = findstr(rightstr(loc,long-posvirg2), ",")
    posvirg3    = posvirg3  + posvirg2

    a           = int(value(leftstr(loc,posvirg1-1)))
    b           = int(value(leftstr(rightstr(loc,long-posvirg1),posvirg2-posvirg1-1)))
    c           = int(value(leftstr(rightstr(loc,long-posvirg2),posvirg3-posvirg2-1)))
    d           = int(value(rightstr(loc,long-posvirg3)))

                  """) : nop


    (loc != "") ? eval("""

    hightlight  = blankclip(width=x-a+c,height=y-b+d,color=$96ff2d).converttoRGB32
    clip2       = clp.converttoRGB32.layer(hightlight.Mask(blankclip(hightlight, color=$444444)),x=a,y=b)
    return        clip2.subtitle("Crop value : "  + string(a) +", " +string(b) +", " +string(c) +", " +string(d), align=align, size=20  )

                  """) : clip1


    return last
}


#==========================================================================================================
#==========================================================================================================
#==========================================================================================================



function dirtyblur(clip clp, int "mode") {
    mode = default (mode, 1)

    o    = (mode == 1) ? clp.blur(1.58).GeneralConvolution (matrix="40 75 40 75 100 75 40 75 40").blur(1.58).blur(1.58).blur(1.58) :
    \                    clp.converttoYUY2.temporalsoften(1,64,64,mode=2,scenechange=6).spatialsoften(2,255,255).converttoRGB32

    return o
}

Function IPF_Mask(clip c) { # ssS fix (added), Correction for fixed Levels bug. Returns RGB32
    c.ShowGreen(pixel_type="YV12").Mt_Lut(Mt_Polish("(x >= 164) ? 0 : x"))
    Return MergeRGB(Last,Last,Last).Levels(0,1.0,255,0,900)
}
EDIT: Single modded section Marked in Blue at end of script.
__________________
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 January 2017 at 19:26.
StainlessS is offline   Reply With Quote
Old 2nd January 2017, 19:13   #25  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Thanks for the update.
hello_hello is offline   Reply With Quote
Old 2nd January 2017, 19:21   #26  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Your Welcome HH, note, can also use in v2.58, (v2.58 does not suffer from the bug anyway).
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 2nd January 2017, 21:32   #27  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
OK HH, here you go, (was actually quite simple).
Suggest you investigate using specific loc setting eg InPaintFunc("D:\Z\Test.BMP",loc="1580,0,0,-850") #Top RHS

InPaintFunc.avs v1.15, Part 1 of 2.
Code:
#____________________________________________________________________________________
#       _____                   _       _   ______
#      |_   _|                 (_)     | | |  ____|
#        | |  _ __  _ __   __ _ _ _ __ | |_| |__ _   _ _ __   ___
#        | | | '_ \| '_ \ / _` | | '_ \| __|  __| | | | '_ \ / __|
#       _| |_| | | | |_) | (_| | | | | | |_| |  | |_| | | | | (__
#      |_____|_| |_| .__/ \__,_|_|_| |_|\__|_|   \__,_|_| |_|\___|
#                  | |
#                  |_|
#_____________________________________________________________________________________



#  InpaintFunc is a new delogo function using AVSInpaint.dll an AviSynth C plugin developed by AMSS.
#See thread : http://forum.doom9.org/showthread.php?t=133682 to download this plugin and get
#more information about it. Just an advertise : AVSInpaint plugin is rather slow so be patient ;-)


#_______________________________________________________________________________________
#
#    History :
#_______________________________________________________________________________________


# Actual revision : InpaintFunc v1.12

# Author          : Reuf Toc

# Requirement     : AVSInpaint.dll


# Changes         :

#Rev 1.00 :  First release 2008/01/30
#Rev 1.01 :  Added debug for "mode". Removed two useless operations.
#Rev 1.02 :  Added "Speed" parameter.
#Rev 1.03 :  Fixed bug in PAR calculation. Fixed bug with non-RGB32 mask.
#Rev 1.10 :  Fixed bug due to overlay. Added post-processing + a lot of things.
#Rev 1.11 :  Added Show parameter and InpaintAssist function. Process in RGB24 instead of RGB32.
#Rev 1.12 :  Fixed bug in "loc" calculation
#Rev 1.13 :  Fixed bug for .ebmp creation (did not happen in several cases)
#Rev 1.14 :  Fixed RepairEdge bug resulting from a bug fix in Levels for RGB (http://forum.doom9.org/showthread.php?t=159652) [StainlessS).
#Rev 1.15 :  Affect loc area only [StainlessS).

#______________________________________________________________________________________
#
#    About Inpainting :
#______________________________________________________________________________________


#  Image Inpainting is the art of restoring destroyed parts of an image by using information
#of valid parts of the image in a way, so that the human eye does not recognize the damaged
#areas (at least not at a first sight). In video processing image inpainting is often applied
#to videos in order to remove TV station logos.


#______________________________________________________________________________________
#
#    Function parameters :
#______________________________________________________________________________________




# =======================================================
#                   InpaintAssist
# =======================================================


# This subfunction can be used to help you in order to set your own crop values to isolate the logo to remove. With HD footage, the delogo
# process is slow due to the resolution (especialy for analysis) and to maximize speed, it is adviced to reduce the size of the cropped clip
# by setting your own crop values.


# If you don't specify a loc value, this function will display your clip divised in 9 parts (the nine loc preset of InpaintFunc) with the crop values for each one in order
# to give you an idea about the values to use.

# After that step, you can enter your own loc values and check they are correct. The selected area will be hightlighted.
# Keep in mind you have to keep a little border around the logo since inpainting use nearby pixels to compute the hidden ones.

# string "loc"    : Select the part of the picture where is the logo to remove. Same as InpaintFunc loc parameter

# String "alignment"   : Alignment of the text. "Top", "Center" and "Bottom" are allowed



# =======================================================
#                   InpaintFunc
# =======================================================



#  Given this function use AVSInpaint.dll and given AVSInpaint is an avisynth C plugin
#don't forget to add loadCplugin("xxx\AVSInpaint.dll") in your script before calling this function !!!




# String "loc"      :  Select the part of the picture where is the logo to remove.
#                     See the table :


#              ______________           ______________
#              | TL | TC |TR |          | X1 | X2 |X3 |
#              |____|____|___|          |____|____|___|
#              | ML | MC |MR |    or    | Y1 | Y2 |Y3 |
#              |____|____|___|          |____|____|___|
#              | BL | BC |BR |          | Z1 | Z2 |Z3 |
#              |____|____|___|          |____|____|___|


#                      If the logo you want to remove is in the top right corner, then you can choose
#                     either loc="TR" or loc="x3".

#                      If you don't want to use one of these preset, you can enter manually the crop values to isolate the logo.
#                     example : loc = "0,300,-440,-20". Spaces are not allowed in "loc" parameter. You can use function
#                     InpaintAssist to help you to set crop values.




# String "mask"     :  Path to the mask of the logo. The mask is a black and white picture. Parties where the logo
#                     is are white, the others are black.

#                     example : mask="C:\my_mask.bmp"



# String "mode"     :  3 Choices (default both) :

#                     -Deblend : If the logo is transparent, use this mode.
#                     -Inpaint : If the logo is opaque, use this mode.
#                     -Both    : If the logo is both opaque and transparent, use this mode.



# Float "AR"        :  The Sample Aspect Ratio of your video. E.g. : 16/9, 4/3...  (Default 1.0).
#                     This value is used to calculate the PAR of your video. If you don't set this parameter, then
#                     PAR will be set to 1:1. It's not really important if you don't set this value.
#                     When you set the AR, take care to add ".0" to your values if you use exact value (16/9 or 4/3).
#                     example : AR=16.0/9.0 or AR=4.0/3.0



# Int "Speed"       :  With this parameter you can speed up this function by trimming the clip analyzed by
#                     AnalyseLogo. A value of 20 means that 100% of clip will be analyzed. With a value of
#                     1, only 5% will be analyzed. (min value 1, max value 20, default 5)


# Int "PPMode"      :  If you want to apply post-processing, 3 modes are available. Default is 0 (disabled)
#                     -Mode 1 : Blur all the area where logo was present.
#                     -Mode 2 : Blur all the area where logo was present using TemporalSoften and SpatialSoften.
#                     -Mode 3 : Blur only the edge of logo area using TemporalSoften and SpatialSoften..


# Int "PP"          :  Strength of the post-processing. Default is 50 (min value 0, max value 100)
#                     A 0 value will disable post processing, 100 will process at full strength.

# Bool "Reset"      :  InpaintFunc contain a feature that allow to not compute logo analysis when it was already done.
#                     By setting Reset to true, logo analysis is always computed. Default is false.

# Float "radius"    :  Radius around a damaged pixel from where values are taken when the pixel is inpainted.
#                     Bigger values prevent inpainting in the wrong direction, but also create more blur.

# Float "sharpness" : Higher values can prevent blurring caused by high Radius values.

# Float "preblur"   : Standard deviation of the blur which is applied to the image before the structure tensor is computed.
#                     Higher values help connecting isophotes which have been cut by the inpainting region, but also
#                     increase CPU usage. PreBlur=0.0 disables pre-blurring.


# Float "postblur"  : Standard deviation of the blur which is applied to the structure tensors before they are used
#                     to determine the inpainting direction. Higher values help gather more directional information when
#                     there are only few valid pixels available, but increases CPU usage.


# Bool "show"       : Allow the user to see the differents steps of the delogoing. Are displayed the source, the
#                     repaired, the repaired post-processed, the mask, the repair masks (edge and global), the color
#                     mask, the alpha mask and the inpaint mask.




#______________________________________________________________________________________

#    Function :
#______________________________________________________________________________________


function InpaintFunc( clip clp, string "mask", string "loc", float "AR", string "mode", int "speed",
\                     int "pp", int "ppmode", bool "reset", float "radius", float "sharpness", float "preblur",
\                     float"postblur", bool "show")

{

    mask        = default (mask         , ""    )
    loc         = default (loc          , ""    )
    AR          = default (AR           , 1.0   )
    mode        = default (mode         , "both")
    speed       = default (speed        , 5     )
    pp          = default (pp           , 50    )
    ppmode      = default (ppmode       , 0     )
    reset       = default (reset        , false )
    radius      = default (radius       , 8.0   )
    sharpness   = default (sharpness    , 75.0  )
    preblur     = default (preblur      , 8.0   )
    postblur    = default (postblur     , 4.0   )
    show        = default (show         , false )




    # debug
    # =====


    x           = width   (clp)
    y           = height  (clp)
    pp          = (pp >= 100) ? 255 : (pp <= 0) ? 0 : int(pp*255/100)
    RGB         = isRGB(clp)
    RGB24       = isRGB24(clp)
    RGB32       = isRGB32(clp)
    YUY2        = isYUY2(clp)
    cropval     = (StrLen(loc)  != 2  )  ? true : false
    spd         = (speed        != 20 )  ? true : false
    PAR         = (AR           != 1.0)  ? float( y) / float( x) * AR : 1.0
    bugloc      = (loc          == "" )  ? true : false
    bugmode     = (mode         != "inpaint" && mode != "deblend" && mode != "both") ? true : false
    bugspeed    = (speed        <= 0 || speed >= 21) ? true : false


    assert        ( findstr(loc," ")  == 0      , """Space character is not allowed in string "loc"."""")
    assert        ( mask              != ""     , """You have to define a mask (string "mymask")""")
    assert        ( bugloc            == false  , """You must define "Loc".""")
    assert        ( bugmode           == false  , """This mode doesn't exist. Change "mode" value.""")
    assert        ( bugspeed          == false  , """"Speed" value must be between 1 and 20.""")



    # calculation of crop values
    # ==========================


    null = (cropval == false ) ? eval("""

    a           = (Rightstr(loc,1) == "L" || Rightstr(loc,1) == "1") ? 0 : (Rightstr(loc,1) == "C" || Rightstr(loc,1) == "2")  ? round((x*1/6))*2  : round((x*1/3))*2
    b           = (leftstr(loc,1)  == "T" || leftstr(loc,1)  == "X") ? 0 : (leftstr(loc,1)  == "M" || leftstr(loc,1)  == "Y")  ? round((y*1/6))*2  : round((y*1/3))*2
    c           = (Rightstr(loc,1) == "R" || Rightstr(loc,1) == "3") ? 0 : (Rightstr(loc,1) == "C" || Rightstr(loc,1) == "2")  ? -round((x*1/6))*2  : -round((x*1/3))*2
    d           = (leftstr(loc,1)  == "B" || leftstr(loc,1)  == "Z") ? 0 : (leftstr(loc,1)  == "M" || leftstr(loc,1)  == "Y")  ? -round((y*1/6))*2  : -round((y*1/3))*2

                  """) : eval("""

    long        = StrLen(loc)

    posvirg1    = findstr(loc, ",")
    posvirg2    = findstr(rightstr(loc,long-posvirg1), ",")
    posvirg2    = posvirg2+posvirg1
    posvirg3    = findstr(rightstr(loc,long-posvirg2), ",")
    posvirg3    = posvirg3  + posvirg2

    a           = int(value(leftstr(loc,posvirg1-1)))
    b           = int(value(leftstr(rightstr(loc,long-posvirg1),posvirg2-posvirg1-1)))
    c           = int(value(leftstr(rightstr(loc,long-posvirg2),posvirg3-posvirg2-1)))
    d           = int(value(rightstr(loc,long-posvirg3)))
    """)


    # crop of the part of the image where is the logo + mask creation
    # ================================================================


    cropped     = clp.crop(a,b,c,d)
    in          = (RGB32 == true) ? cropped : cropped.converttoRGB24()
    in2         = (spd   == true) ? in.SelectRangeEvery (every=20, length=speed) : in

    Masque      = imagesource(mask,start=0,end=0).converttoRGB32           # ssS, Changed End=1 to End=0
    Masque      = Masque.crop(a,b,c,d).levels(127,1,128,0,255)
    Masque      = Masque.mask(Masque)

    BlendedMask = Masque.DirtyBlur().levels(0,1,75,0,255)
    BlendedMask = BlendedMask.mask(BlendedMask)
    RepairMask  = BlendedMask.levels(0,1,255,0,pp)
    #RepairEdge  = Masque.DirtyBlur().levels(0,1,255,0,900)                 # ssS fix (removed)
    RepairEdge  = Masque.DirtyBlur().IPF_Mask()                             # ssS fix (added)
    RepairEdge  = RepairEdge.DirtyBlur().levels(0,1,75,0,pp)


    # check for an existing computed mask. If it doesn't exist or if reset = true --> computation
    # ===========================================================================================


    ID          = mask + "InpaintFunc" + string(a) + string(b) + string(c) + string(d) + string(speed)

    Logo        = (reset == true) ? eval("""

                  in2.analyzelogo(Masque).trim(0,-1).converttoRGB32
                  imagewriter(ID,0,1,"ebmp")

                  """) : eval("""

                  try

                  {imagesource(ID + "%06d.ebmp",0,0)}
                  catch (dummy)

                  {in2.analyzelogo(Masque).trim(0,-1).converttoRGB32
                  imagewriter(ID,0,1,"ebmp")      }""")


    # Creation of the masks used for DeblendLogo and InpaintLogo
    # ==========================================================


    LogoColor   = Logo.Crop(0,0,0,Logo.Height/2).converttoRGB24

    LogoAlpha   = Logo.Crop(0,Logo.Height/2,0,0)
    Logoalpha   = LogoAlpha.mask(LogoAlpha)

    LogoInpaint = LogoAlpha.mask(masque.dirtyblur().levels(0,1,32,0,255))


    # InpaintLogo and DeblendLogo are applied depending on the value of "mode"
    # ==========================================================================


    repaired    = (mode ==  "both")   ?
    \             in.DeblendLogo(LogoColor,LogoAlpha).
    \             InpaintLogo(LogoInpaint,radius=radius,sharpness=sharpness,preblur=preblur,postblur=postblur,PixelAspect=PAR).converttorgb32:
    \             (mode == "deblend") ?
    \             in.DeblendLogo(Logocolor,Logoalpha).converttorgb32 :
    \             in.InpaintLogo(LogoInpaint,radius=radius,sharpness=sharpness,preblur=preblur,postblur=postblur,PixelAspect=PAR).converttorgb32


    # Finalization of the repaired with post-processing
    # ==========================================================
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 2nd January 2017, 21:33   #28  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
InPaintFunc.avs v1.15, Part 2 of 2.
Code:
    repairedpp  = (ppmode == 1) ? repaired.layer(repaired.DirtyBlur( ).mask(RepairMask))              :
    \             (ppmode == 2) ? repaired.layer(repaired.DirtyBlur(2).mask(RepairMask))              :
    \             (ppmode == 3) ? repaired.layer(repaired.DirtyBlur(2).DirtyBlur().mask(RepairEdge))  : repaired


    output      = in.converttorgb32.Layer(repairedpp.Mask(BlendedMask))


    # Overlay of the cleaned portion over the original clip
    # =====================================================


    (show == true) ? Eval("""

    cropped     = cropped.subtitle("source").converttoRGB32
    masque      = masque.subtitle("mask")

    repairmask  = repairmask.subtitle("repair mask")
    repairedge  = repairedge.subtitle("repair edge")

    Logoalpha   = Logoalpha.subtitle("Logo alpha")
    Logocolor   = Logocolor.subtitle("Logo color").converttoRGB32
    Logoinpaint = Logoinpaint.subtitle("Logo inpaint")

    repaired    = repaired.subtitle("repaired")
    repairedpp  = repairedpp.subtitle("repaired pp")

    l1          = Stackhorizontal(cropped,repaired,repairedpp)
    l2          = Stackhorizontal(masque,repairmask,repairedge)
    l3          = Stackhorizontal(logocolor,logoalpha,logoinpaint)

    stackvertical (l1,l2,l3)
    return spline36resize(last,width(last),height(last))

    """) : Eval("""

#    v1.15, removed below, ssS
#    clp         = (RGB32 == true) ? clp : clp.converttoRGB32
#    fullclip    = clp.layer(output,x=a, y=b)
#    fullclip    = (RGB == true) ? (RGB32 == true) ? fullclip : fullclip.converttoRGB24() : (YUY2 == true) ? fullclip.converttoYUY2() : fullclip.converttoYV12()
#    return fullclip

    fullclip    = clp.Overlay(output,x=a, y=b)      # v1.15, Affect only loc area. ssS.
    return fullclip

    """)

}


#==========================================================================================================
#==========================================================================================================
#==========================================================================================================


function InpaintAssist ( clip clp, string "loc", string "alignment") {


    loc         = default (loc,  "")
    x           = width   (clp)
    y           = height  (clp)
    alignment        = default (alignment, "top")
    align       = (alignment == "top") ? 8 : (alignment == "center") ? 5 : (alignment == "bottom") ? 2 :8
    framecount  = framecount(clp)


    # I "Loc" parameter is not specified, split the clip in 9 parts et show crop value for each part
    # ==============================================================================================


    loc == ""     ? Eval("""

    white       = blankclip(width=round(x/3),height=round(y/3),color=$FFFFFF,length=framecount)
    black       = blankclip(width=round(x/3),height=round(y/3),color=$000000,length=framecount)

    l1          = stackhorizontal(white,black,white)
    l2          = stackhorizontal(black,white,black)
    background  = stackvertical(l1,l2,l1).converttoRGB32.spline36resize(x,y)
    clp         = clp.converttoRGB32

    a1          = string(0)
    a2          = string(round((x*1/6))*2)
    a3          = string(round((x*1/3))*2)

    b1          = string(0)
    b2          = string(round((y*1/6))*2)
    b3          = string(round((y*1/3))*2)

    ca1         = string(-round((x*1/3))*2)
    ca2         = string(-round((x*1/6))*2)
    ca3         = string(0)

    d1          = string(-round((y*1/3))*2)
    d2          = string(-round((y*1/6))*2)
    d3          = string(0)

    c1          = clp.crop(0               , 0          , -round((x*1/3))*2, -round((y*1/3))*2)
    \             .subtitle("TL (" + a1 + ","  + b1 + ","  + ca1 + ","  + d1+ ")",align=8)
    c2          = clp.crop(round((x*1/6))*2, 0          , -round((x*1/6))*2, -round((y*1/3))*2)
    \             .subtitle("TC (" + a2 + ","  + b1 + ","  + ca2 + ","  + d1+ ")",align=8)
    c3          = clp.crop(round((x*1/3))*2, 0          , 0                , -round((y*1/3))*2)
    \             .subtitle("TR (" + a3 + ","  + b1 + ","  + ca3 + ","  + d1+ ")",align=8)

    c4          = clp.crop(0               , round((y*1/6))*2 , -round((x*1/3))*2, -round((y*1/6))*2)
    \             .subtitle("ML (" + a1 + ","  + b2 + ","  + ca1 + ","  + d2+ ")",align=8)
    c5          = clp.crop(round((x*1/6))*2, round((y*1/6))*2 , -round((x*1/6))*2, -round((y*1/6))*2)
    \             .subtitle("MC (" + a2 + ","  + b2 + ","  + ca2 + ","  + d2+ ")",align=8)
    c6          = clp.crop(round((x*1/3))*2, round((y*1/6))*2 , 0                , -round((y*1/6))*2)
    \             .subtitle("MR (" + a3 + ","  + b2 + ","  + ca3 + ","  + d2+ ")",align=8)

    c7          = clp.crop(0               , round((y*1/3))*2, -round((x*1/3))*2,  0)
    \             .subtitle("BL (" + a1 + ","  + b3 + ","  + ca1 + ","  + d3+ ")",align=8)
    c8          = clp.crop(round((x*1/6))*2, round((y*1/3))*2, -round((x*1/6))*2,  0)
    \             .subtitle("BC (" + a2 + ","  + b3 + ","  + ca2 + ","  + d3+ ")",align=8)
    c9          = clp.crop(round((x*1/3))*2, round((y*1/3))*2, 0                ,  0)
    \             .subtitle("BR (" + a3 + ","  + b3 + ","  + ca3 + ","  + d3+ ")",align=8)

    output      = stackvertical(stackhorizontal(c1,c2,c3), stackhorizontal(c4,c5,c6), stackhorizontal(c7,c8,c9))
    output      = output.spline36resize(x,y)
    clip1       = background.layer(output.mask(blankclip(output,color=$DEDEDE)))


    """) : nop


    # If "Loc" is specified, hightlight the part choosen by user
    # ==========================================================


    (strlen(loc) == 2) ? Eval("""

    a           = (Rightstr(loc,1) == "L" || Rightstr(loc,1) == "1") ? 0 : (Rightstr(loc,1) == "C" || Rightstr(loc,1) == "2")  ? round((x*1/6))*2  : round((x*1/3))*2
    b           = (leftstr(loc,1)  == "T" || leftstr(loc,1)  == "X") ? 0 : (leftstr(loc,1)  == "M" || leftstr(loc,1)  == "Y")  ? round((y*1/6))*2  : round((y*1/3))*2
    c           = (Rightstr(loc,1) == "R" || Rightstr(loc,1) == "3") ? 0 : (Rightstr(loc,1) == "C" || Rightstr(loc,1) == "2")  ? -round((x*1/6))*2  : -round((x*1/3))*2
    d           = (leftstr(loc,1)  == "B" || leftstr(loc,1)  == "Z") ? 0 : (leftstr(loc,1)  == "M" || leftstr(loc,1)  == "Y")  ? -round((y*1/6))*2  : -round((y*1/3))*2

                 """) : (strlen(loc) != 0) ? eval("""

    long        = StrLen(loc)
    posvirg1    = findstr(loc, ",")
    posvirg2    = findstr(rightstr(loc,long-posvirg1), ",")
    posvirg2    = posvirg2+posvirg1
    posvirg3    = findstr(rightstr(loc,long-posvirg2), ",")
    posvirg3    = posvirg3  + posvirg2

    a           = int(value(leftstr(loc,posvirg1-1)))
    b           = int(value(leftstr(rightstr(loc,long-posvirg1),posvirg2-posvirg1-1)))
    c           = int(value(leftstr(rightstr(loc,long-posvirg2),posvirg3-posvirg2-1)))
    d           = int(value(rightstr(loc,long-posvirg3)))

                  """) : nop


    (loc != "") ? eval("""

    hightlight  = blankclip(width=x-a+c,height=y-b+d,color=$96ff2d).converttoRGB32
    clip2       = clp.converttoRGB32.layer(hightlight.Mask(blankclip(hightlight, color=$444444)),x=a,y=b)
    return        clip2.subtitle("Crop value : "  + string(a) +", " +string(b) +", " +string(c) +", " +string(d), align=align, size=20  )

                  """) : clip1


    return last
}


#==========================================================================================================
#==========================================================================================================
#==========================================================================================================



function dirtyblur(clip clp, int "mode") {
    mode = default (mode, 1)

    o    = (mode == 1) ? clp.blur(1.58).GeneralConvolution (matrix="40 75 40 75 100 75 40 75 40").blur(1.58).blur(1.58).blur(1.58) :
    \                    clp.converttoYUY2.temporalsoften(1,64,64,mode=2,scenechange=6).spatialsoften(2,255,255).converttoRGB32

    return o
}

Function IPF_Mask(clip c) { # ssS fix (added), Correction for fixed Levels bug. Returns RGB32
    c.ShowGreen(pixel_type="YV12").Mt_Lut(Mt_Polish("(x >= 164) ? 0 : x"))
    Return MergeRGB(Last,Last,Last).Levels(0,1.0,255,0,900)
}
Mod in blue
__________________
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 January 2017 at 21:35.
StainlessS is offline   Reply With Quote
Old 22nd June 2019, 20:41   #29  |  Link
VoodooFX
Banana User
 
VoodooFX's Avatar
 
Join Date: Sep 2008
Posts: 985
Can someone check if InpaintFunc.avs(1.13-1.15) crash AviSynth+? "Inpaint" mode works ok, "Deblend" and "Both" modes instantly crash AviSynth+.
No problems with AviSynth 2.6.

Report from AVSMeter:
AviSynth+ 0.1 (r2772, MT, i386) (0.1.0.0)
Exception 0xC0000005 [STATUS_ACCESS_VIOLATION]
Module: C:\Windows\SysWOW64\VCRUNTIME140.dll
Address: 0x72DC282E

Last edited by VoodooFX; 22nd June 2019 at 20:44.
VoodooFX is offline   Reply With Quote
Old 22nd June 2019, 20:43   #30  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by VoodooFX View Post
Can someone check if InpaintFunc.avs (all versions) crash AviSynth+? "Inpaint" mode works ok, "Deblend" and "Both" modes instantly crash AviSynth+.
No problems with AviSynth 2.6.

Report from AVSMeter:
AviSynth+ 0.1 (r2772, MT, i386) (0.1.0.0)
Exception 0xC0000005 [STATUS_ACCESS_VIOLATION]
Module: C:\Windows\SysWOW64\VCRUNTIME140.dll
Address: 0x72DC282E
Post your script.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 22nd June 2019, 20:45   #31  |  Link
VoodooFX
Banana User
 
VoodooFX's Avatar
 
Join Date: Sep 2008
Posts: 985
How to quickly test it:
1) video file (short!)
2) bmp file (RGB24, same resolution as video, all solid black and small solid white "blob" at top-left corner.
3) InpaintFunc.avs and AVSInpaint.dll ( http://avisynth.nl/index.php/InpaintFunc )
4) script:
LoadCplugin("C:\AVSInpaint.dll")
Import("C:\InpaintFunc.avs")
InpaintFunc(mask="c:\test.bmp", loc="tl",mode="Inpaint",speed=1)

Last edited by VoodooFX; 22nd June 2019 at 21:13. Reason: typo
VoodooFX is offline   Reply With Quote
Old 22nd June 2019, 20:58   #32  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by VoodooFX View Post
How to quickly test it:
1) video file (short!)
2) bmp file (RGB24, same resolution as video, all solid black and small solid white "blob" at top-left corner.
3) Inpaint.avs and AVSInpaint.dll ( http://avisynth.nl/index.php/InpaintFunc )
4) script:
LoadCplugin("C:\AVSInpaint.dll")
Import("C:\InpaintFunc.avs")
InpaintFunc(mask="c:\test.bmp", loc="tl",mode="Inpaint",speed=1)
I can reproduce this, VDub also reports an access violation. However, my culprit is avisynth.dll, not VCRUNTIME140.dll.

Works fine with classic Avisynth 2.6. You should post this in the AVS+ thread.

Edit: Apparently there's a fix from StainlessS, just read a few posts above.
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 22nd June 2019 at 21:12.
Groucho2004 is offline   Reply With Quote
Old 22nd June 2019, 21:17   #33  |  Link
VoodooFX
Banana User
 
VoodooFX's Avatar
 
Join Date: Sep 2008
Posts: 985
Both v1.14 & v1.15 StainlessS scripts crash too.
VoodooFX is offline   Reply With Quote
Old 23rd June 2019, 17:59   #34  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
ImageSource is a built-in Avisynth function, isn't it?

Using Avisynth 2.6 it works fine, but when I try to open the same script with MeGUI and it's portable Avisynth+ (on XP).

InpaintFunc(mask="d:\test.bmp", loc="TL",mode="Inpaint",speed=1)

hello_hello is offline   Reply With Quote
Old 23rd June 2019, 18:56   #35  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by hello_hello View Post
ImageSource is a built-in Avisynth function, isn't it?

Using Avisynth 2.6 it works fine, but when I try to open the same script with MeGUI and it's portable Avisynth+ (on XP).

InpaintFunc(mask="d:\test.bmp", loc="TL",mode="Inpaint",speed=1)

In AVS+, ImageSource() was transferred to a plugin ("ImageSeq.dll").
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 23rd June 2019, 20:18   #36  |  Link
VoodooFX
Banana User
 
VoodooFX's Avatar
 
Join Date: Sep 2008
Posts: 985
Quote:
Originally Posted by hello_hello View Post
ImageSource is a built-in Avisynth function, isn't it?

Using Avisynth 2.6 it works fine, but when I try to open the same script with MeGUI and it's portable Avisynth+ (on XP).

InpaintFunc(mask="d:\test.bmp", loc="TL",mode="Inpaint",speed=1)

I noticed that ImageSource & ImageWriter doesn't work with portable MeGUI's avs+ without manually loading ImageSeq.dll. You should ask why it is not auto-loaded in MeGUI's thread.
VoodooFX is offline   Reply With Quote
Old 24th June 2019, 06:40   #37  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by VoodooFX View Post
I noticed that ImageSource & ImageWriter doesn't work with portable MeGUI's avs+ without manually loading ImageSeq.dll. You should ask why it is not auto-loaded in MeGUI's thread.
I did check the Avisynth Wiki but didn't see any mention of it being a separate dll for Avisynth+. I don't know if it's a good idea to put it in the Avisynth 2.6 auto-loading plugin folder.

I added
LoadPlugin("C:\Program Files\MeGUI\tools\avs\plugins\ImageSeq.dll")
to the script and it still opened fine with the installed Avisynth 2.6.
When I tried to open it with MeGUI and the portable Avisynth+ it was okay for mode="InPaint" but MeGUI crashed when I tried mode="both".

So I assume it happens on XP too, but unfortunately I didn't discover anything new.

Edit: I tried the backup copy of an older ImageSeq.dll version in the MeGUI/avs/plugins folder, dated 2018/07/02, but the result was the same.

Edit: In case it hasn't been mentioned, InPaintFunc appears to create the ebmp file normally when using Avisynth+ (loading the script causes MeGUI to check it, which in turned causes the ebmp file to be created). It doesn't crash MeGUI until I try to preview the script after the ebmp file has been created.
I tried being more specific about the location of the logo with loc="0,0,-1604,-764" (1080p source, top left) but nothing changed.

Edit: In case it means something to someone, I commented out the InPaintFunc line, added the script to MeGUI's job queue, uncommented InPaintFunc and ran the job. The error appearing in MeGUI's log file was:
"Process exits with error: 0xC0000005 STATUS_ACCESS_VIOLATION (-1073741819)"

Last edited by hello_hello; 24th June 2019 at 07:53.
hello_hello is offline   Reply With Quote
Old 24th June 2019, 16:04   #38  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
0xC0000005 STATUS_ACCESS_VIOLATION

Often happens if code tries to access memory location 0, ie bug in dll.

EDIT: Yep, from Devs forum on same dll:- https://forum.doom9.org/showthread.p...29#post1877829
Quote:
Originally Posted by pinterf View Post
EDIT: The plugin somehow clears or is overwriting an existing framebuffer pointer?
The crash itself occurs at an internal RGB24-RGB32 conversion but since the destination frame does not exist (zero pointer) it will show "access violation".
I'll have a look at the dll source.
__________________
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; 24th June 2019 at 16:12.
StainlessS is offline   Reply With Quote
Old 24th June 2019, 16:12   #39  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
Obviously there was a bug, see test build here (also x64)
https://drive.google.com/open?id=1AQ...GX2ukXE4Uy7nWV
pinterf is offline   Reply With Quote
Old 25th June 2019, 05:57   #40  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by pinterf View Post
Obviously there was a bug, see test build here (also x64)
https://drive.google.com/open?id=1AQ...GX2ukXE4Uy7nWV
So far, so good here (XP).

Thank you very much!
hello_hello 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 18:55.


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