Posts for nanogyth

1 2
8 9 10
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
You could trying something like this. You'd have to play around with font/size to find something you like. (you could do some pointresizing if you want it even blockier.)
src=clip

blankclip(src)
subtitle("hello world!",halo_color=$FF000000,text_color=$00FFFFFF,align=5,\
font="Fixedsys",size=24)
mask=levels(0,1,1,0,255)

layer(src,mask.mask(mask))
#this will let you change the color of the text. layer(src, blankclip(src,color=$00FFFF).mask(mask)) #adjusting the 127/128 values will change how much of the antialiasing it keeps. mask=levels(127,1,128,0,255) #using this will give less smooth anti-aliasing mask=levels(0,1,192,0,3).levels(0,1,3,0,255)
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
IMO pixels should be treated as square. My reasoning on this is that a CRT can stretch a pixel into a rectangle, no problem. But to do the same digitally you need to map those rectangular pixels onto a square grid. For most games that translation takes away more than it adds IMO.
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
This does some stuff right, like catching stuff that is blinking at a 2 frame rate. But mostly it looks worse.
clip_c
assumefps(60)
converttorgb32

e0=selectevery(4,0)
o1=selectevery(4,1)
e2=selectevery(4,2)
o3=selectevery(4,3)

mask=ng_mask(o1,e2,o3)

i2 = layer(o1,o3.mask(mask))

interleave(e0,i2)

function ng_mask(clip a, clip b, clip c){
    a=a.converttoyv24
    b=b.converttoyv24
    c=c.converttoyv24

    dd=dad(a,b,c)

    y=dd.converttoy8
    u=dd.uToY8
    v=dd.vToY8

    uv=mt_lutxy(u,v,"x y + 2 /")
    mask=mt_lutxy(y,uv,"x y + 256 > 255 0 ?")
    return mask.converttorgb32
}

function dad(clip a, clip b, clip c){
    ab=ab_dif(a,b)
    bc=ab_dif(b,c)
    return mt_lutxy(ab,bc,"x y - 2 / 128 +") #(x-y)/2 +128
}

function ab_dif(clip a, clip b){
    return mt_lutxy(a,b,expr="x y - abs")
}
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
lol so I made a really-slow somewhat-blurry. selectevery(4,0,3)
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
http://www.youtube.com/watch?v=d03CnBzfK-o http://www.youtube.com/watch?v=4td9d64eYJk http://www.youtube.com/watch?v=cz8lJcufRdE
clip_a=FFVideoSource("sm/sm.avi")
clip_b=ffvideosource("sm/1-sf2ceua-unaltered.mp4")
clip_c=directshowsource("sm/roadrunner_fast_and_flickering_section_noaudio.avi")
clip_d=ffvideosource("sm/#2223 - cpadolf's SNES Super Metroid ''any%, glitched''.avi")

clip_b
assumefps(60)
PointResize(Width * 2, Height * 2)
convertToyv12

i2=smoothOverlay(selectevery(4,1),halfwink,motionMask)

interleave(selectevery(4,0),i2)

#PointResize(Width / 2, Height / 2)

function smoothOverlay(clip a, clip b, clip mask){
    step1=overlay(a,b,mask=mask.mt_expand.mt_expand,opacity=.5)
    return overlay(step1,b,mask=mask)
}

function motionMask(clip c){
    pc=c.mt_motion(thT=255)
    oepc=pc.selectevery(4,2)
    eopc=pc.selectevery(4,3)
    oopc=c.selectodd.mt_motion(thT=255).selectevery(2,1)

    mask=mt_logic(oepc, eopc, mode="or")
    return mt_logic(mask, oopc, mode="or")
}

function halfwink(clip c){
    inter=c.convertToyuy2.selectodd.separatefields.trim(1,0).weave
    deinter=inter.qtgmc.selectevery(4,1)
    return deinter.convertToyv12
}
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
Here is a conceptually simpler idea, using Vit's excellent deinterlacer, qtgmc, to create the blended frames.
ConvertToRGB32
PointResize(Width * 2, Height * 2)

interleave(selectevery(4,0),halfwink)

function halfwink(clip c){
    c=c.convertToYuy2(matrix="PC.601")
    inter=c.selectodd.separatefields.trim(1,0).weave
    deinter=inter.qtgmc.selectevery(4,1)
    return deinter.ConvertToRGB32( matrix="PC.601" )
}
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
Would it be possible to tell the emulator to make all the blinking sprites be visible on the even frames? (or blink at a on-on-off-off cadence?)
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
Vit wrote:
Poor motion matches are caused by objects appearing or disappearing or by objects changing their shape, look or color radically from one frame to the next.
Yes, that was exactly what I was using it to look for. The problem was that it matched a whole lot of other stuff too, lol.
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
Here is another version, hopefully useful to someone. So, we can see in the odd to odd transition there are pixel changes, but only complex motion in the platform.
function momix(clip c){

    #E   e   E
    #  o ^ o   o
    o1=c.selectevery(4,1)
    e2=c.selectevery(4,2)
    o3=c.selectevery(4,3)

    move=c.moveit
    oddMove=c.selectodd.moveit

    #e e e
    # o^o o
    oe=move.selectevery(4,1)
    eo=move.selectevery(4,2)
    oo=oddMove.selecteven

    return stackvertical(\
        stackhorizontal(oe, e2, eo),\
        stackhorizontal(o1, oo, o3))
}

function moveIt(clip c,int "ml"){
    ml=default(ml,100)
    c=c.ConvertToYv12 #.colorYUV(autogain=true)

    super=MSuper(c)
    fvec =MAnalyse(super, isb=false, truemotion=false)
    bvec =MAnalyse(super, isb=true , truemotion=false)
    fmask=Mmask(c,fvec,kind=1,ml=ml).mt_binarize
    bmask=Mmask(c,bvec,kind=1,ml=ml).mt_binarize

    To=fmask.trim(1,0)
    From=bmask
    move=c.mt_motion(thT=255).trim(1,0)

    return mergeRGB(to,move,from)
}
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
I'm currently working on some visualization to help figure out why artifacts happen. The results are worse than previous because the masks are so sharp.
FFVideoSource("sm.avi")
ConvertToRGB32
HalfWink(debug=true)

function HalfWink(clip c, bool "debug"){
    debug=default(debug,false)

    #The clip is made of even/odd frames and the simplest way to reduce
    #framerate would be to just take the even frames. But some clips have
    #blinking/shaking that alternates frame to frame. That could make a
    #"transparent" object solid or disappear entirely. Or lock a shaking
    #scene in a single position.

    #e e e
    # o^o o
    #Every other even frame is taken as is. The other even frame is used
    #as much as it can be. A mask is made of the blinking and the shaking.
    #Those parts of the frame are simply replaced with data from one of the
    #odd frames. NO BLENDING!!!

    e0=c.selectevery(4,0)
    o1=c.selectevery(4,1)
    e2=c.selectevery(4,2)
    o3=c.selectevery(4,3)

    e2fix=overlay(e2,o1,mask=BlinkShake(c))

    DebugMask=stackvertical(\
        stackhorizontal(o1,e2,o3),\
        stackhorizontal(Shaking(c,debug=true),e2fix,Blinking(c,debug=true)))

    return debug ? DebugMask : interleave(e0,e2fix)
}

function BlinkShake(clip c){
    return mt_logic(Blinking(c),Shaking(c),mode="or")
}

function Shaking(clip c, bool "debug"){
    debug=default(debug,false)
    c=c.ConvertToYv12 #.colorYUV(autogain=true)

    #Shaking is the background moving at a regular rate.

    #E   e   E
    #  o ^ o   o

    move=c.mt_motion
    oe=move.selectevery(4,2)
    eo=move.selectevery(4,3)
    oo=c.selectodd.mt_motion.selectodd

    #Motion will be seen between oe AND eo, AND NOT oo

    Shaking=mt_logic(mt_logic(oe,eo,mode="and"),oo.mt_invert,mode="and")

    DebugMask=mergeRGB(oe,eo,oo.mt_invert)
    return debug ? DebugMask : Shaking
}

function Blinking(clip c, bool "debug"){
    debug=default(debug,false)
    c=c.ConvertToYv12 #.colorYUV(autogain=true)

    #Blinking is an object that appears/disappears from the scene.
    #If the object is blinking it will show crazy high motion since it doesn't
    #exist frame to frame. Use mvtools to detect motion.
    #Look for motion to and from. The vectors aren't symetric because it is
    #easier to match the background than an object.
    #The motion must be forward AND backward or it isn't a one-frame blink.

    super=MSuper(c)
    fvec =MAnalyse(super, isb=false, truemotion=false)
    bvec =MAnalyse(super, isb=true , truemotion=false)
    fmask=Mmask(c,fvec,kind=1).mt_binarize
    bmask=Mmask(c,bvec,kind=1).mt_binarize

    #f   f   f   f
    #  b   b   b   b

    #f b f b f b f b
    #f(bf)(bf)(bf)(bf)(b
    #       >2<

    masks=interleave(fmask,bmask)

    To=masks.selectevery(2,1)
    From=masks.selectevery(2,2)
    ToFrom=mt_logic(To,From,mode="or")

    tfForward=ToFrom.selectevery(4,1)
    tfBackward=ToFrom.selectevery(4,2)
    Blinking=mt_logic(tfForward,tfBackward,mode="and")

    DebugMask=mergeRGB(tfForward,tfBackward,blankclip(tfForward))
    return debug ? DebugMask : Blinking
}
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
StreetFighter2 Ok, I think I'm done. Looks at the motion vectors to and from in the forward and backwards direction.
function HalfWink(clip c, int "ml"){
    ml = Default(ml, 100)
    c

    #e e e
    # o o o
    #The clip is made of even/odd frames and the simplest way to reduce
    #framerate would be to just take the even frames. But some clips have
    #blinking that alternates frame to frame. That could make a "transparent"
    #object solid or disappear entirely.

    #E   e   E
    #  o I o   o
    #This function takes every other even frame and a frame interpolated
    #from the odd frames. There are even times when it is appropriate to
    #use some of the skipped even frame.

    e0=selectevery(4,0)
    e2=selectevery(4,2)
    OddBlend=selectodd.convertfps(c).selectevery(4,1)
    interleave(e0,overlay(OddBlend,e2,mask=BlinkMask(c,ml=ml)))
}

function BlinkMask(clip c, int "ml"){
    ml = Default(ml, 100)
    c.ConvertToYv12.colorYUV(autogain=true)

    #oo is the part of the odd frame that is moving.
    #If it isn't moving it doesn't need to be replaced.

    OddMoving=selectodd.mt_motion(thT=255).selectodd

    #Use mvtools to detect motion.
    #If the object is blinking it will show crazy high motion since it doesn't
    #exist frame to frame.

    super=MSuper()
    fvec =MAnalyse(super, isb=false, truemotion=false)
    bvec =MAnalyse(super, isb=true , truemotion=false)
    fmask=Mmask(last,fvec,kind=1,ml=ml).mt_binarize
    bmask=Mmask(last,bvec,kind=1,ml=ml).mt_binarize

    #mask is the part of the even frame that IS moving in both the forward and
    #backwards direction. If it isn't moving in BOTH directions then it isn't
    #blinking and we CAN!!! use it.

    #f   f   f   f
    #  b   b   b   b

    masks=interleave(fmask,bmask)

    #f b f b f b f b

    tf=mt_logic(masks.selectevery(2,1),masks.selectevery(2,2),mode="or").mt_expand.mt_expand

    #f(bf)(bf)(bf)(bf)(b

    Blinking=mt_logic(tf.selectevery(4,1),tf.selectevery(4,2),mode="and")

    #       >2<

    NotBlinking=Blinking.mt_invert

    mt_logic(OddMoving,NotBlinking,mode="and").mt_expand.mt_expand
}
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
creaothceann wrote:
New function on doom9: http://forum.doom9.org/showthread.php?p=1524289#post1524289 Unfortunately it seems to not detect much of Samus' arm-pumping, at least with the tweaking as-is.
We ended up with similar functions. What is the arm-pumping? Part of the running animation?
FFVideoSource("sm.avi")
ConvertToRGB32
HalfWink

function HalfWink(clip c){
    c

    #e e e
    # o o o
    #The clip is made of even/odd frames and the simplest way to reduce
    #framerate would be to just take the even frames. But some clips have
    #blinking that alternates frame to frame. That could make a "transparent"
    #object solid or disappear entirely.

    #E   e   E
    #  o I o   o
    #This function takes every other even frame and a frame interpolated
    #from the odd frames. There are even times when it is appropriate to
    #use some of the skipped even frame.

    e0=selectevery(4,0)
    e2=selectevery(4,2)
    OddBlend=selectodd.convertfps(c).selectevery(4,1)
    interleave(e0,overlay(OddBlend,e2,mask=BlinkMask(c)))
}

function BlinkMask(clip c){
    c.ConvertToYv12

    #oo is the part of the odd frame that is moving.
    #If it isn't moving it doesn't need to be replaced.

    OddMoving=selectodd.mt_motion(thT=255).selectodd

    #Use mvtools to detect motion.
    #If the object is blinking it will show crazy high motion since it doesn't
    #exist frame to frame.

    super=MSuper()
    fvec =MAnalyse(super, isb=false, truemotion=false)
    bvec =MAnalyse(super, isb=true , truemotion=false)
    fmask=Mmask(last,fvec,kind=1,ml=130).mt_binarize
    bmask=Mmask(last,bvec,kind=1,ml=130).mt_binarize

    #mask is the part of the even frame that IS moving in both the forward and
    #backwards direction. If it isn't moving in BOTH directions then it isn't
    #blinking and we CAN!!! use it.

    Blinking=mt_logic(fmask,bmask,mode="and").selectevery(4,2).mt_expand.mt_expand
    NotBlinking=Blinking.mt_invert

    mt_logic(OddMoving,NotBlinking,mode="and").mt_expand.mt_expand
}
RoadRunner StreetFighter
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
Ok, I think I fixed it up pretty well, disappearing lady near the end, but otherwise pretty smooth. I've given up on motion compensation for the moment. The places it would be used usually look better blended anyway. And this way the pixels can stay in rgb32. The yv12 is only used to make the mask. Might not even need to resize at all now. http://www.youtube.com/watch?v=bU-OnJzjQu8
assumefps(60)
PointResize(Width * 2, Height * 2)
source=last

ConvertToYv12

super=MSuper()
fvec =MAnalyse(super, isb=false, truemotion=false)
bvec =MAnalyse(super, isb=true , truemotion=false)
fmask=Mmask(last,fvec,kind=1,ml=130).mt_binarize
bmask=Mmask(last,bvec,kind=1,ml=130).mt_binarize
mask=mt_logic(fmask,bmask,mode="and").selectevery(4,2).mt_expand.mt_expand

oo=selectodd.mt_motion(thT=255).selectodd
mask2=mt_logic(oo,mask.mt_invert,mode="and").mt_expand.mt_expand

source.converttorgb32

e0=selectevery(4,0)
e2=selectevery(4,2)
i2=selectodd.convertfps(60).selectevery(4,1)

merge=overlay(i2,e2,mask=mask2)
interleave(e0,merge)
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
So, here is something. It fixes some of the problems I was having, but causes some other pretty serious ones. http://www.youtube.com/watch?v=SHv53ayuZ-0
assumefps(60)
PointResize(Width * 2, Height * 2)
ConvertToYv12

super=MSuper()
fvec =MAnalyse(super, isb=false, truemotion=false)
bvec =MAnalyse(super, isb=true , truemotion=false)

fmask=Mmask(last,fvec,kind=1,ml=130).mt_binarize
bmask=Mmask(last,bvec,kind=1,ml=130).mt_binarize

mask=mt_logic(fmask,bmask,mode="and").selectevery(4,2).mt_expand

e0=selectevery(4,0)
e2=selectevery(4,2)
i2=selectodd.convertfps(60).selectevery(4,1)

interleave(e0,mt_merge(e2,i2,mask,chroma="copy second"))
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
It seems like mvtools would be able to tell when an object popped in from nowhere/disappeared. Having a mask of that would be helpful. PS - what codec is the roadrunner clip in? ffvideosource green screened, directshowsource worked.
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
moozooh wrote:
Please include sections with 30 Hz arm-pumping and more complex background scrolling (ideally emergency countdown Ceres or some Norfair segment with heat haze) in your demonstrations. The current ones show way too little.
Yes, more samples would be welcome, I only have the one posted at doom9. One of the sonic levels would be nice. I think an important step forward is identifying where the actual blinking is occurring. Most of my gross motion prediction artifacts are in places that aren't blinking. Taking just the even frames causes problems for blinking, but is otherwise the right thing to do. So always take every other even frame (selectevery(4)), and then figure out which parts of the other even frame can be safely used and which parts need to be (and can be) interpolated from the odd frames.
e e e
 o o o

E   e   E

  o I o   o
There are three transitions I want to consider oe, eo, and oo.
  e
 / \
o - o
If all three are smooth transitions then the even frame can be used as is. If oe and eo are complex, but oo is smooth, then the interpolation should be used. If all three are complex then use the even frame, because the interpolation will be ugly. ??? THEN partyboy1a posted something with f1 and f2 blinking and it wrinkled my brain. =_=
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
partyboy1a wrote:
or if the motion estimation nanogyth posted didn't produce these bad artifacts...
You could just do blending for the odd frames.
Interleave(c.SelectEvery(4, 0),
\          c.SelectOdd.convertfps(60).SelectEvery(4, 1))
Less aggressive motion estimation settings should reduce artifacts while still showing some improvements. http://www.youtube.com/watch?v=EjDRm0CbILU
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
Warp wrote:
The video is private.
Sorry, misclicked unlisted, should work now.
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
http://www.youtube.com/watch?v=7dvTKkQaa0o http://www.mediafire.com/?yh13m7fhh3wxayj
start = FFVideoSource("sm.avi").assumefps(60).converttoyuy2

start
e=selecteven.dbz.selectevery(4,0)
o=selectodd.dbz.selectevery(4,1)

#stackhorizontal(e,o)
interleave(e,o)

stackhorizontal(start,last.changefps(60))

#b b b b b
# u u u u u

#BibiBibiB
# uIuiuIuiu

#http://avisynth.org.ru/mvtools/mvtools2.html
#
#AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
## assume progressive PAL 25 fps source
#super = MSuper(pel=2)
#backward_vec = MAnalyse(super, isb = true)
#forward_vec = MAnalyse(super, isb = false)
#MFlowFps(super, backward_vec, forward_vec, num=50, den=1, ml=100) # get 50 fps

function dbz(clip c)
{
    c
    super = MSuper(pel=2)
    backward_vec = MAnalyse(super, isb = true)
    forward_vec = MAnalyse(super, isb = false)
    MFlowFps(super, backward_vec, forward_vec, num=60, den=1, ml=100)
}
#e e e e e e # o o o o o o The 60Hz clip can be thought of as two separate clips (one with the blink object, one without) that have been interleaved to produce the blinking. Decimating by just taking the even frames doesn't work. So take every other even frame and try to interpolate the missing frame from the odd clip. #E e E e E e # oIoioIoioI Ideally the motion compensation works well and a nice sharp frame is produced. When the interpolation doesn't work it defaults to blending, which shouldn't be any worse than the other methods. Here is a highlight of the difference of interpolation versus blend. http://www.mediafire.com/?6py0sazeip6oiw5
start
e=selectevery(4)
o=selectodd.convertfps(60).selectevery(4,1)
o2=selectodd.dbz.selectevery(4,1)

#stackhorizontal(start,interleave(e,o).changefps(60),interleave(e,o2).changefps(60))
stackhorizontal(o.subtitle("blend"),o2.subtitle("interpolate"))
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
Do you have a copy before you yv12'd it? psxjin outputs rgb, right? You need to deinterlace before converting to planar. The screen warble at the end is probably just chroma ghosting.
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
Yes Does anyone have the PC version? The pixels would have to be square there, so it should be an easier target to aim at than analog captures.
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
http://lurkertech.com/lg/pixelaspect/#tellaspect Its not a source from Sony or Square saying that those frames output in a certain fashion, just the basic way analog video works and how the emulated picture lines up with the screen capture.
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
The 320x224 represent square pixels. The 368x224 don't, they have a pixel aspect ratio of 10/11 and take up a larger section of the screen. Basic overscan: http://www.lurkertech.com/lg/pixelaspect.html More technical: http://www.iki.fi/znark/video/conversion/ While the 368s have non-square pixels, trying to "square" them by resizing will lead to ugliness, most notably in the text. I think things will look the least distorted if everything is letterboxed to 224, the 368 is cropped to 352 and the 320 is pillarboxed to 352.
a=avisource("013_intro-320x216.avi").trim( 12,815) # battle
b=avisource("014_intro-368x224.avi").trim(  3,235) # reward
c=avisource("015_intro-320x224.avi").trim(202,437) # worldmap
d=avisource("016_intro-368x216.avi").trim(  5,360) # menu

a=a.addBorders(16,4,16,4)
b=b.crop(16,0,0,0)
c=c.addBorders(16,0,16,0)
d=d.addBorders(0,4,0,4).crop(10,0,-6,0)

a++b++c++d
selectevery(2).converttoyv12()
http://ia600608.us.archive.org/32/items/Ff8ScreencapSamples/p8.mp4
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
Dada wrote:
Could you also make a screenshot sampled at 720x480 of the regular gameplay so we can compare that too?
What constitutes regular gameplay? Running around in the garden? Here is what I measured. size [ center ] Battle -emu 320x216 [160,108] -cap 638x432 [359.5,243.5] Worldmap -emu 320x224 [160,112] -cap 638x448 [359.5,243.5] Reward -emu 351x202 [192,108.5] -cap 619x408 [360,237.5] Menu -emu 336x210 [192.5,110.5] -cap 590x422 [360.5,240.5] All the capture centers line up very well with the horizontal center of the screen. The data for the menus is centered at 192, which is half of the 384 mentioned in the other post. I'm not sure there is a good way to resize non-square pixels used for text at this small of a scale. Instead of one pixel wide white lines you end up with some 2-pixel wide grey blocks. Might look better to treat them as square and just throw out whatever isn't in the middle 320.
Experienced Forum User, Published Author, Player (65)
Joined: 4/21/2011
Posts: 232
natt wrote:
there are only 5 horizontal resolutions: 256, 320, 384, 512 or 640
Our 368 is the 384, they just didn't bother calculating the last 16 pixels in the line because it is overscanned offscreen on most TVs. The first 16 pixels are also usually blank, but if the cursor is at that edge of the screen it does extend into the cutoff zone.
1 2
8 9 10