Log in

View Full Version : Chroma Blending


Overdrive80
3rd September 2014, 20:22
Hi all, I am trying deinterlace a NTSC source but I get video with this artefact:

http://i57.tinypic.com/r6zabt.png
http://i62.tinypic.com/2afxruf.png

My code used is:

DGDecode_mpeg2source("E:\Dragon Ball\DB_5\026\VideoFile.d2v", info=3)

assumebff()

tfm(order=0,pp=6,mode=4).tdecimate(mode=1)

How could I fix it? Example video (m2v): Example video (https://www.dropbox.com/s/obus84oyz0aox2a/Video_example.demuxed.m2v?dl=0)

Thanks in advance.

nekosama
3rd September 2014, 21:17
That's ghosting, there isn't really much you can do about it other than weakening the ghosting using mdegrain2 (or 3).

This is caused by temporal post-procesing done by the studio.

Don't try to force it with something destructive like ghostbusters (also yuy2 only) because that won't end well.

Icould also just be totally wrong and it could just be a simple case of blends (seeing as chroma is affected too.

Overdrive80
3rd September 2014, 21:27
If I use separatefields, this artefact still is it but all blending frames can be replaced for backward and forward frame.

Is there any filter that do it?? I have trying srestore but dont work.

nekosama
3rd September 2014, 21:44
Yes then they're just plain blends, honestly I'm not experienced enough with blends to give proper advice on how to take care of them.
But I can direct you to combmask (https://github.com/chikuzen/CombMask/tree/master/avisynth) which (like the name states) makes a mask of the comb based on the isCombed() algo.
Combmask allong with daa3 should do a better job than pp=6 in tfm (so I suggest u set it to 0 and let daa3 do the work).
Also I don't think there's such filter out there that replaces the combed frames with the last or next frame as it could lead to some nasty errors.

Overdrive80
3rd September 2014, 22:44
had try this:

DGDecode_mpeg2source("E:\Dragon Ball\DB_5\026\VideoFile.d2v", info=3)

assumebff()

tfm(order=0,pp=0,mode=5).tdecimate(mode=1)

video=last

mask=video.combmask()

last=video.mcdaa3()

mt_merge(last, video, mask)

Chrome blending still is it.

http://i58.tinypic.com/k209xf.png

asarian
3rd September 2014, 22:46
Are you sure the ghosting is in the source, and not the result of some temporal frame-inaccuracy or some such? For test, I'd try this too:

SetMemoryMax(768)

SetMTMode(5,4)

DGDecode_mpeg2source("E:\Dragon Ball\DB_5\026\VideoFile.d2v", info=3)

SetMTMode(3)

assumebff()

tfm(order=0,pp=6,mode=4).tdecimate(mode=1)

P.S. Ppl always tell me to use SetMTMode(2), but honestly, I find SetMTMode(3) to be much more stable (be it somewhat slower).

Overdrive80
3rd September 2014, 23:19
With this I get same result that shows here (http://forum.doom9.org/showpost.php?p=1692365&postcount=5)

DGDecode_mpeg2source("E:\Dragon Ball\DB_5\026\VideoFile.d2v", info=3)

assumebff()

TFM(mode=4).Tdecimate().Vinverse()


@asarian
The code that you post is same than my first post.

foxyshadis
3rd September 2014, 23:56
This is what happens when you treat interlaced chroma as progressive. I've tried lots of fixes, and unfortunately, I can't get SRestore's double-blend detection to work on this at all. You can manually fix the chroma, since the framerate is so low, but that's a real pain. The luma is completely untouched by blending, so that's a relief at least.

The combing isn't a problem at all, the fields aren't combed at all, just the chroma in many is blended. It's a bad IVTC on the studio side.

Overdrive80
4th September 2014, 00:20
Honestly, I dont know how manually fix it. I tried minimize the impact of this artifact withi this code:

DGDecode_mpeg2source("E:\Dragon Ball\DB_5\026\VideoFile.d2v", info=3)

assumebff()

TFM(mode=4).Tdecimate(mode=1).Vinverse()

Mergechroma(awarpsharp2(depth=16,thresh=255,blur=3,chroma=6).aWarpSharp2(depth=-4,chroma=2).MergeLuma(blur(0.1)).aWarpSharp2(depth=16,chroma=6))
fft3dfilter(sigma=2,plane=3,degrid=1)

Even so, remains of chroma blending.

bxyhxyh
4th September 2014, 06:00
If you're using TFM(), no need to call AssumeBFF or AssumeTFF. Order argument set it.

DGDecode_mpeg2source("E:\Dragon Ball\DB_5\026\VideoFile.d2v", info=3)
TFM(chroma=true) # Sample you posted was TFF
srestore(omode=4)
TDecimate(chroma=false,mode=1)

Try this. Can't remove all blends, but better than nothing.

It works good on one blended frame.
Can't fix two consistent blended frames but TDecimate(chroma=false,mode=1) do the trick, which decimates one of two blended frames.

EDIT: If you set chroma=true on TDecimate, those 2 blended frames won't be decimated.
EDIT: You may want to change thresh value of srestore() for more accurate blend detection. I think default value works ok.

feisty2
4th September 2014, 10:30
chroma blend
you need to deblend chroma planes
and sync luma to chroma with masktools

feisty2
4th September 2014, 11:09
luma = tfm(pp=0, slow=2)
chroma = vinverse().Srestore(omode="PP3", cache=10)

# manual sync: figure out which frame (previous,current aka p,c) of 'chroma' clip is most similar to current frame of 'luma' clip

# 46*log(|x-y|+1) uses the full [0,255]-range and scales little differences better than |x-y|*2
diffp = mt_lutxy(luma,chroma.selectevery(1,-1),"x y - abs 1 + log 46 *")
diffc = mt_lutxy(luma,chroma, "x y - abs 1 + log 46 *")

# average difference between compared frames
mp = mt_lutf(diffp,diffp,"avg",expr="x")
mc = mt_lutf(diffc,diffc,"avg",expr="x")

# build conditional masks based on the caculated comparisons
maskp = mt_lutxy(mp,mc,"x y < 255 0 ?")

# finally merge the luma of the tfm with the chroma of the srestore clip accordingly to the binary mask
MergeChroma(luma,chroma).mt_merge(chroma.selectevery(1,-1),maskp,luma=true,Y=2,U=3,V=3)

Overdrive80
4th September 2014, 18:14
@Feisty2 At your feet!!! Your script is great and works nice. I would like to have such insight about avisynth as you for understanding the code. Thank you so much.

EDIT: For Decimate I use decimate(cycle=5,quality=0), and result video is incredible.

foxyshadis
4th September 2014, 22:07
luma = tfm(pp=0, slow=2)
chroma = vinverse().Srestore(omode="PP3", cache=10)

# manual sync: figure out which frame (previous,current aka p,c) of 'chroma' clip is most similar to current frame of 'luma' clip

# 46*log(|x-y|+1) uses the full [0,255]-range and scales little differences better than |x-y|*2
diffp = mt_lutxy(luma,chroma.selectevery(1,-1),"x y - abs 1 + log 46 *")
diffc = mt_lutxy(luma,chroma, "x y - abs 1 + log 46 *")

# average difference between compared frames
mp = mt_lutf(diffp,diffp,"avg",expr="x")
mc = mt_lutf(diffc,diffc,"avg",expr="x")

# build conditional masks based on the caculated comparisons
maskp = mt_lutxy(mp,mc,"x y < 255 0 ?")

# finally merge the luma of the tfm with the chroma of the srestore clip accordingly to the binary mask
MergeChroma(luma,chroma).mt_merge(chroma.selectevery(1,-1),maskp,luma=true,Y=2,U=3,V=3)

Wow, nice. I never got srestore to do anything in double-blend mode, it always picked the wrong frames, even when I used dclip=UToY().fft3dfilter(). In normal mode, it always picked one of the two correctly, but that's not enough. Surprised it worked for you!

Comparing the luma and chroma edges to match frames is absolutely brilliant though.

asarian
4th September 2014, 22:51
Comparing the luma and chroma edges to match frames is absolutely brilliant though.

Yup, I recently had the privilege of reaping the benefits of his genius too. :)

poisondeathray
5th September 2014, 00:18
http://forum.doom9.org/showthread.php?p=1582950#post1582950

feisty2
5th September 2014, 00:25
oop, I didn't write these codes, copied from somewhere I forgot, thx for the link poisondeathray :)