View Single Post
Old 28th October 2021, 10:18   #9  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by johnmeyer View Post
Yes.

https://forum.doom9.org/showthread.p...24#post1409324

I completely changed the detection logic not only because his wasn't very good, but also because there was no way to display the detection metrics. If you can't display them, you can't tune the script.
I was playing with this (above Didee link mod) a few weeks back (I think I left it in working order, but not sure),

Code:
# DeDecimateNtsc24BackTo30.avsi

Function DeDecimateNtsc24BackTo30(clip c,Bool "ShowDot") {
/*
    DeDecimateNtsc24BackTo30.avsi : Mod to Script function by StainlessS. Original script by Didee @ https://forum.doom9.org/showthread.php?p=1409324#post1409324
    required, AVS v2.60/+, Pinterf mt_masktools, Pinterf mvtools2, Pinterf tivtc.

    Source should be NTSC_FILM(23.976p) that has been decimated from original PROGRESSIVE_NTSC_STANDARD(29.97p).
*/
    c    myName="DeDecimateNtsc24BackTo30: "
    ShowDot = Default(ShowDot,False)                                                                          # shows a "dot" on the interpolated frames of the result
    o  = assumefps(1.0)                                                                                       # Avoid frame doubling rounding issues, due to weird NTSC framerates.
    ox = o.width() oy=o.height()
    Assert(!c.IsRGB && c.IsPlanar,myname+"Planar YUV only")
    try { bpc=c.BitsPerComponent } catch(msg) { bpc=8 }
    Assert(8 <= bpc <= 16,myname+"8 to 16 bit only")

    super  = (showdot ? o.subtitle(".") : o).MSuper(pel=2,hpad=16,vpad=16)
    bvec   = MAnalyse(super, overlap=4, isb = true,  search=4, dct=5)
    fvec   = MAnalyse(super, overlap=4, isb = false, search=4, dct=5)
    double = o.MFlowFps(super, bvec, fvec, num=2, den=1, blend=false)                                         # Result will be 2.0 FPS, and FrameCount=(c.FrameCount*2)-1. Dont Blend at SceneChange.

    shftn = BitLShift(1, bpc-8)
    cs256 = BitLShift(256,shftn)
    cs255 = cs256-1
    cs128 = BitLShift(128,shftn)
    cs32  = BitLShift(32,shftn)

    d2n_yexpr="x " + String(cs128) + " - abs " + String(cs32) + " / 1 2.0 / ^ " + String(cs128) + " *"        # [8-Bit]:- rpn="x 128 - abs 32 / 1 2.0 / ^ 128 *" : Infix="( (abs(x-128)/32) ^ (1/2.0) ) * 128"

    diff2next = mt_makediff(o,o.selectevery(1,1)).mt_lut(d2n_yexpr,U=-(cs128),V=-(cs128))
    diff2next = mt_lutf(diff2next,diff2next,yexpr="x",mode="average").pointresize(32,32)
    diff2next = interleave(diff2next.selectevery(4,0).tsg(2),diff2next.selectevery(4,1).tsg(2),
        \  diff2next.selectevery(4,2).tsg(2),diff2next.selectevery(4,3).tsg(2))


    maximum = diff2next.mt_logic(diff2next.selectevery(1,-3),"max")
        \  .mt_logic(diff2next.selectevery(1,-2),"max")
        \  .mt_logic(diff2next.selectevery(1,-1),"max")
        \  .mt_logic(diff2next.selectevery(1, 1),"max")
        \  .mt_logic(diff2next.selectevery(1, 2),"max")
        \  .mt_logic(diff2next.selectevery(1, 3),"max")

    ismax_yexpr = "x y < 0 " + String(cs255) + " ?"                                                           # [8-Bit]:- rpn = "x y < 0 255 ?" : Infix = "(x < y) ? 0 : 255"

    ismax = mt_lutxy(diff2next,maximum,ismax_yexpr,U=-(cs128),V=-(cs128)).pointresize(ox,oy)
    themask = interleave(o.mt_lut("0"),ismax)
    interleave(o,o).mt_merge(double,themask,luma=true,U=3,V=3)                                                # Process U and V

    tdecimate(mode=1,cycleR=3,cycle=8)                                                                        # Decimate 3 out of 8 = 18 out of 48 (leaving 24 from 48)
    assumefps(30000,1001)                                                                                     # Back to NTSC_Video
    return last
}

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

# tsg by Didee @ https://forum.doom9.org/showthread.php?p=1409324#post1409324
#  ssS: Looks like some kind of limited Gausian Temporal Soften.
#       TemporalSoften (clip, int radius, int luma_threshold, int chroma_threshold, int "scenechange", int "mode")
#       Radius=1=Adjacent_frames, Luma_threshold=255=no limit, chroma_threshold=0=dont process, scenechange=255=ignore, mode=2=ISSE
function tsg(clip c, int t) { c
t<5?last:last.temporalsoften(1,255,0,255,2).merge(last,0.25)
t<4?last:last.temporalsoften(1,255,0,255,2).merge(last,0.25)
t<3?last:last.temporalsoften(1,255,0,255,2).merge(last,0.25)
t<2?last:last.temporalsoften(1,255,0,255,2).merge(last,0.25)
t<1?last:last.temporalsoften(1,255,0,255,2).merge(last,0.25) }
EDITED: [there were two instances where I had not changed csLev128 to cs128]

EDIT: 8 -> 16 bit depth.
__________________
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; 28th October 2021 at 18:34.
StainlessS is offline   Reply With Quote