Log in

View Full Version : A script I improve simply may be better than Decimate?


irlnic
1st March 2022, 14:30
There is the original script.https://forum.doom9.org/showthread.php?p=1582950#post1582950
Thank Sp00kyFox!It's based on his script.

luma = tfm(pp=0, slow=2)
chroma = vinverse().Srestore(omode="PP3", cache=4)

# 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
p = MergeChroma(luma,chroma).mt_merge(chroma.selectevery(1,-1),maskp,luma=true,Y=2,U=3,V=3)
#irlnic:the result is interlaced frames are replaced by previous frames

#the following are what I write
#replace interlaced frames with next frames in the clip
n = p.selectevery(1,1)
n = ConditionalFilter(src,n,p,"IscombedTIVTC","=","true")

#delete surplus frames by pattern of telecine I find
Interleave(p,n)
SelectEvery(5 ,0,1,2,3)
SelectEvery(2 ,0)


Sent my appreciation to Doom9's Forum!It works well for me!I will be glad if it can help some people!

Ceppo
1st March 2022, 15:42
Can you explain the idea. I lack some filter so I can't test it. Also, a sample source and the filtered one would be nice.

StainlessS
1st March 2022, 17:22
I lack some filter so I can't test it.

chroma = vinverse2().Srestore(omode="PP3", cache=4)
diffp = mt_lutxy(luma,chroma.selectevery(1,-1),"x y - abs 1 + log 46 *")

You probably lack "luma" clip too, as it seems to be gotten by some kind of magic.
Maybe post the full script irlnic.

EDIT: Also irlnic, wrap code in code tags, looks better, [retains indent formatting] ie,


some code stuff.


looks like

some code stuff.

and forum TAB step setting is 8, [I use TAB step = 4 in windows text editor and have to convert to SPACE's to look correct on forum]

and welcome to the forum.

irlnic
1st March 2022, 17:39
Can you explain the idea. I lack some filter so I can't test it. Also, a sample source and the filtered one would be nice.
Well,I'm not very good at English writing,but I have a try.If I can't explan it very well,please forgive me.

There is the original script.https://forum.doom9.org/showthread.php?t=165357

After I used Sp00kyFox's script(I don't know how it work),I found the result is interlaced frames are replaced by previous frames(because of selectevery(1,-1)).

At the same time,I might find regularity of telecine as well.

then I write

n = p.selectevery(1,1)
n = ConditionalFilter(b,n,p,"IscombedTIVTC","=","true")

to replace interlaced frames with next frames.

by using the regularity,I write

Interleave(p,n)
SelectEvery(5 ,0,1,2,3)
SelectEvery(2 ,0)

It's also the core of my idea.
It's not very easy for me to explan what is the regularity in English,but I think you can get it after reading this part and apply it to a sample source on the paper.

All in all, except 3:2 pull down,all interlaced frames are surplus.all I want to do is to delete them directly.Luckily,"3:2 pull down" can be solved by Sp00kyFox's script.

irlnic
1st March 2022, 18:12
chroma = vinverse2().Srestore(omode="PP3", cache=4)
diffp = mt_lutxy(luma,chroma.selectevery(1,-1),"x y - abs 1 + log 46 *")

You probably lack "luma" clip too, as it seems to be gotten by some kind of magic.
Maybe post the full script irlnic.

EDIT: Also irlnic, wrap code in code tags, looks better, [retains indent formatting] ie,


some code stuff.


looks like

some code stuff.

and forum TAB step setting is 8, [I use TAB step = 4 in windows text editor and have to convert to SPACE's to look correct on forum]

and welcome to the forum.

Thank you very much for your advice and warm welcome!I'm really new there.I have also seen many your replies,from which I have learned much!Thank you for that as well!Give my best respect to you!

Ceppo
1st March 2022, 20:34
Sorry irlnic, I didn't notice it was your first post/message. Well welcome! :)
You probably lack "luma" clip too, as it seems to be gotten by some kind of magic.
I was just too lazy to download srestore :)

Anyway, irlnic, max tomorrow and I will give you my feedback.

It's not very easy for me to explan what is the regularity in English
Maybe you mean pattern?

EDIT:
BTW do you have a small sample with field blending on chroma? I don't have any and the original script is meant for that and yours seems too.

kedautinh12
2nd March 2022, 00:40
Just copy/paste :D
https://github.com/realfinder/AVS-Stuff/blob/Community/avs%202.5%20and%20up/Srestore.avsi

irlnic
2nd March 2022, 04:31
Maybe you mean pattern?

Yeah,I think "pattern" is accurate expression.


BTW do you have a small sample with field blending on chroma?I don't have any.

Sorry...I deleted relevant source weeks ago...
But this isn't problem of source.It occurs after TFM.There are some similar threads you can find in the forum.