Log in

View Full Version : chroma interlacing problem - scripting help needed


mASSIVe
10th February 2006, 20:55
this picture shows the problem pretty good: chroma interlacing (after ivtc obviously, and yes the whole thing is like this: in a pattern of every 5 frames 2 are broken, one is a duplicate and gets decimated, the other is the 'problematic' one)
http://www.massi-san.de/pictures/forum/dch-original-small.png

a rather good way to counter this has been sangnom(0/1, 18), with the correct field-order...
http://www.massi-san.de/pictures/forum/dch-correctorder-small.png

...but choosing the wrong order is almost counterproductive...
http://www.massi-san.de/pictures/forum/dch-wrongorder-small.png

this wouldn't be such a big problem...if it wouldn't affect ~10000 frames. so how do i automate this?

i don't think there is pattern on when what order is the correct/better order. is it possible to compare two frames (after applying sangnom with either field-order on them) and then choose the better one? (doesn't have to be 100% correct each time, but in most cases it should be). any other solution?

and how do i make it only apply on the broken frames? broken frames are always combed, and are always the frame after the one that gets decimated. i don't really want to manually select every broken frame (using custom list in yatta for example).

my avisynth scripting skills and lack of overall understanding of the matter don't really help...so please be easy on me.

any help/advice is highly appreciated! thx!


the whole thing...
http://www.massi-san.de/pictures/forum/dch-yatta_small.jpg (http://www.massi-san.de/pictures/forum/dch-yatta.jpg)

scharfis_brain
10th February 2006, 21:04
provide an unprocessed sample clip showing that problem.
also provide the script you used.

mASSIVe
10th February 2006, 21:21
just the plain yatta generated .avs (filtering isn't the concern atm, just the mentioned problem)
loadPlugin("C:\encoding\avisynth\plugins\fieldhint.dll")
loadPlugin("C:\encoding\avisynth\plugins\decomb.dll")
loadPlugin("C:\encoding\avisynth\plugins\DGDecode.dll")

import("C:\encoding\avisynth\plugins\sangnom_list.avs")

function Preset0(clip c) {
#Name: Default
c
return last
}

function Preset1(clip c) {
#Name: fade
c
return last
}

dgdecode_Mpeg2Source("E:\encodes\desperatehousewifes\desperate.d2v")

FieldHint(ovr="E:\encodes\desperatehousewifes\desperate.d2v.fh.txt")
FieldDeinterlace(blend=false,dthreshold=7)

PresetClip0=Preset0()
PresetClip1=Preset1()
PresetClip0.Trim(0,2129)+PresetClip1.Trim(2130,2157)+PresetClip0.Trim(2158,2430)+PresetClip1.Trim(2431,3297)+PresetClip0.Trim(3298,51870)

FreezeFrame(1139,1139,1138)
FreezeFrame(2146,2146,2145)

Decimate(cycle=5,quality=3,ovr="E:\encodes\desperatehousewifes\desperate.d2v.dec.txt")

sangnom_list(7268, 0) #right now this was manually added to show the effect, but having more than just a couple of those in the .avs makes it go nuts (out of memory error). sangnom seems to be the culprit...so a different way of implementing is needed.

Lanczos4Resize(640,480)

mostly stolen from another script...and 'improved' to make it work for my purposes...
function sangnom_list(clip clip, int frame, int "order"){

order = default(order, 0)
replacedchroma = (order == 1) ? clip.sangnom(1,18)
\ : clip.sangnom(0,18)

sangnom_clip = mergechroma(clip,replacedchroma).trim(frame,frame)

new = clip.isYUY2() ? sangnom_clip :
\ clip.isYV12() ? sangnom_clip.converttoYV12() :
\ clip.isRGB24() ? sangnom_clip.converttoRGB24() :
\ sangnom_clip.converttoRGB32()

final = (frame == 1) ? clip.trim(0,1).deleteframe(1) + new + clip.trim(frame+1,0) :
\ (frame == clip.framecount) ? clip.trim(0,frame-1) + new :
\ clip.trim(0,frame-1) + new + clip.trim(frame+1,0)

assert(clip.framecount == final.framecount, "sangnom_list: warning! wrong framecount! beat the author for stealing parts of this script... z0mg...")

return final }

~10mb sample .vob
dch-sample.vob (http://www.massi-san.de/encoding/dch-sample.vob)

scharfis_brain
10th February 2006, 22:00
the chroma is double field blended due to wrong chroma downsampling within the encoder. There are a LOT of DVDs showing that error out there.

But the chroma planes are far too bad as there are possibilities to recover them.
But at least the occuring residual stripes are removable at the cost of loss in chroma detail and ghosting:

tfm(pp=0)
mergechroma(blur(0,1))
tdecimate()

mASSIVe
10th February 2006, 22:28
that doesn't work as well as sangnom with the correct order though.

still would like to use my sangnom approach...if it could be somehow be less manual... :(