Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 Doom9's Forum Motion-adaptive higher quality conversions to interlaced 4:2:0
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 25th November 2020, 13:10 #1  |  Link DTL Registered User   Join Date: Jul 2018 Posts: 62 Motion-adaptive higher quality conversions to interlaced 4:2:0 As I see build-in standard conversions to 4:2:0 color formats are simple enough (like averaging 2 neibour samples) and also for interlaced processing it looks like makes only field-based processing. So at interlaced 4:2:0 we got 1/4 of vertical color resolution all over the frame - in moving and in static areas. If disable interlaced color processing we got color artifacts at moving areas. So I think the motion-adaptive conversion script or may be even complied function (plugin) may be developed. For higher quality samples processing I currently make 2 functions: for progressive and for interlaced processing - they uses resize-downsample functions instead of just neibour samples averaging. Also with parametrized resizers the sharpness of color channels may be adjusted if needed. Code: ```function RGB24ToYUV420p8_prog(clip c, float fp) { source=ConvertToYV24(c) U8 = source.UToY8() V8 = source.VToY8() Y8 = source.ConvertToY() U8=SinPowResizeMT(U8,U8.width/2, U8.height/2,p=fp) V8=SinPowResizeMT(V8,V8.width/2, V8.height/2,p=fp) return CombinePlanes(Y8, U8, V8, planes="YUV", source_planes="YYY", pixel_type="YUV420P8") } function RGB24ToYUV420p8_intrl(clip c, float fp) { source=ConvertToYV24(c) source=SeparateFields(source) U8 = source.UToY8() V8 = source.VToY8() Y8 = source.ConvertToY() U8=SinPowResizeMT(U8,U8.width/2, U8.height/2,p=fp) V8=SinPowResizeMT(V8,V8.width/2, V8.height/2,p=fp) ret=CombinePlanes(Y8, U8, V8, planes="YUV", source_planes="YYY", pixel_type="YUV420P8") return Weave(ret) }``` But it is not motion-adaptive processing. I think may be use some mask tools close to typical motion-adaptive deinterlacers to combine static and motion areas from 2 types of processing. Can anyone point me to working motion mask generation pluging or script (possibly not required tons of plugins installed like in QTGMC script) ? Attempt of using MMask from mvtools2 not completely successive - it either do not detect motion or detect it in all frame. May be needed to tweak 'kind' and 'ml' parameters or additional enchanting of mask produced by MMask. It looks so: Code: ```function RGB24ToYUV420p8_intrl_ma(clip c, float fp) { source=ConvertToYV24(c) source_fields=SeparateFields(source) super=MSuper(source_fields, pel=1) vectors = MAnalyse(super) moves_mask = MMask(source_fields, vectors, kind=1,ml=50) moves_mask = Tweak(moves_mask,cont=10) U8_fields = source_fields.UToY8() V8_fields = source_fields.VToY8() Y8_fields = source_fields.ConvertToY() U8_fields = SinPowResizeMT(U8_fields,U8_fields.width/2, U8_fields.height/2,p=fp) V8_fields = SinPowResizeMT(V8_fields,V8_fields.width/2, V8_fields.height/2,p=fp) ret_fields = CombinePlanes(Y8_fields, U8_fields, V8_fields, planes="YUV", source_planes="YYY", pixel_type="YUV420P8") ret_fields = Weave(ret_fields) moves_mask = Weave(moves_mask) U8 = source.UToY8() V8 = source.VToY8() Y8 = source.ConvertToY() U8=SinPowResizeMT(U8,U8.width/2, U8.height/2,p=fp) V8=SinPowResizeMT(V8,V8.width/2, V8.height/2,p=fp) ret_frames=CombinePlanes(Y8, U8, V8, planes="YUV", source_planes="YYY", pixel_type="YUV420P8") return Overlay(ret_fields,ret_frames,mask=moves_mask) }``` Current testing script for simulation partly motion at the left side and static at the right: Code: ```LoadPlugin("ResampleMT.dll") LoadPlugin("yadif.dll") LoadPlugin("mvtools2.dll") function RGB24ToYUV420p8_intrl_ma(clip c, float fp) { source=ConvertToYV24(c) source_fields=SeparateFields(source) super=MSuper(source_fields, pel=1) vectors = MAnalyse(super) moves_mask = MMask(source_fields, vectors, kind=1,ml=50) moves_mask = Tweak(moves_mask,cont=10) U8_fields = source_fields.UToY8() V8_fields = source_fields.VToY8() Y8_fields = source_fields.ConvertToY() U8_fields = SinPowResizeMT(U8_fields,U8_fields.width/2, U8_fields.height/2,p=fp) V8_fields = SinPowResizeMT(V8_fields,V8_fields.width/2, V8_fields.height/2,p=fp) ret_fields = CombinePlanes(Y8_fields, U8_fields, V8_fields, planes="YUV", source_planes="YYY", pixel_type="YUV420P8") ret_fields = Weave(ret_fields) moves_mask = Weave(moves_mask) U8 = source.UToY8() V8 = source.VToY8() Y8 = source.ConvertToY() U8=SinPowResizeMT(U8,U8.width/2, U8.height/2,p=fp) V8=SinPowResizeMT(V8,V8.width/2, V8.height/2,p=fp) ret_frames=CombinePlanes(Y8, U8, V8, planes="YUV", source_planes="YYY", pixel_type="YUV420P8") return Overlay(ret_fields,ret_frames,mask=moves_mask) } ImageReader("01.png") SinPowResizeMT(width/10,height/10,p=3.2) left=Crop(0,0,width/2,height) right=Crop(width/2,0,width/2,height) left=SeparateFields(left) left_e=SelectEven(left) left_o=SelectOdd(left) left_e=Crop(left_e,0,0,left_e.width-5,left_e.height) left_e=AddBorders(left_e,5,0,0,0) left=Interleave(left_o,left_e) left=Weave(left) StackHorizontal(left,right) src_yv12=ConvertToYV12(interlaced=true) RGB24ToYUV420p8_intrl_ma(last, 2.7) yadif(mode=1) SincLin2ResizeMT(width*8,height*8,taps=20) /* src_yv12=yadif(src_yv12, mode=1) SincLin2ResizeMT(src_yv12,width*8,height*8,taps=20) */ Subtitle("RGB24ToYUV420p8_intrl_ma")``` And results in attach. It shows how vertical color resolution better at static areas in compare with full-frame ConvertToYV12(interlaced=true) but masking still feeds some frame-based processed data at moving areas and cause some color-ghosting. Unfortunately avisynth+ may be with ResampleMT works buggy todays at me so some buggy blue-yellow horizontal lines added at the bottom. Last edited by DTL; 29th November 2020 at 19:19.
 29th November 2020, 15:55 #2  |  Link DTL Registered User   Join Date: Jul 2018 Posts: 62 Using some 4:2:2 sat feed capture from torrent of Eurovision 2019 made a bit tweaks to motion searching. Current version: Code: ```function RGB24ToYUV420p8_intrl_ma(clip c, float fp) { source=ConvertToYV24(c) source_fields=SeparateFields(source) super=MSuper(source_fields, pel=1) vectors = MAnalyse(super) moves_mask = MMask(source_fields, vectors, kind=0,ml=25) moves_mask = Tweak(moves_mask,cont=10) U8_fields = source_fields.UToY8() V8_fields = source_fields.VToY8() Y8_fields = source_fields.ConvertToY() U8_fields = SinPowResizeMT(U8_fields,U8_fields.width/2, U8_fields.height/2,p=fp) V8_fields = SinPowResizeMT(V8_fields,V8_fields.width/2, V8_fields.height/2,p=fp) ret_fields = CombinePlanes(Y8_fields, U8_fields, V8_fields, planes="YUV", source_planes="YYY", pixel_type="YUV420P8") ret_fields = Weave(ret_fields) moves_mask = Weave(moves_mask) U8 = source.UToY8() V8 = source.VToY8() Y8 = source.ConvertToY() U8=SinPowResizeMT(U8,U8.width/2, U8.height/2,p=fp) V8=SinPowResizeMT(V8,V8.width/2, V8.height/2,p=fp) ret_frames=CombinePlanes(Y8, U8, V8, planes="YUV", source_planes="YYY", pixel_type="YUV420P8") return Overlay(ret_frames,ret_fields,mask=moves_mask) } function YV16ToYUV420p8_intrl_ma(clip c, float fp) { source=c source_fields=SeparateFields(source) super=MSuper(source_fields, pel=1) vectors = MAnalyse(super) moves_mask = MMask(source_fields, vectors, kind=0,ml=25) moves_mask = Tweak(moves_mask,cont=10) U8_fields = source_fields.UToY8() V8_fields = source_fields.VToY8() Y8_fields = source_fields.ConvertToY() U8_fields = SinPowResizeMT(U8_fields,U8_fields.width, U8_fields.height/2,p=fp) V8_fields = SinPowResizeMT(V8_fields,V8_fields.width, V8_fields.height/2,p=fp) ret_fields = CombinePlanes(Y8_fields, U8_fields, V8_fields, planes="YUV", source_planes="YYY", pixel_type="YUV420P8") ret_fields = Weave(ret_fields) moves_mask = Weave(moves_mask) U8 = source.UToY8() V8 = source.VToY8() Y8 = source.ConvertToY() U8=SinPowResizeMT(U8,U8.width, U8.height/2,p=fp) V8=SinPowResizeMT(V8,V8.width, V8.height/2,p=fp) ret_frames=CombinePlanes(Y8, U8, V8, planes="YUV", source_planes="YYY", pixel_type="YUV420P8") return Overlay(ret_frames,ret_fields,mask=moves_mask) }``` Frames compare with built-in ConvertToYV12(interlaced=true) function: direct full image 1920:1080 https://i6.imageban.ru/out/2020/11/2...946c6750d1.png https://i4.imageban.ru/out/2020/11/2...01bb1f898e.png https://i2.imageban.ru/out/2020/11/2...f92b1ffb9f.png https://i2.imageban.ru/out/2020/11/2...71678824f6.png http://www.framecompare.com/screensh...rison/KKYYPNNX Screenshots deinterlaced with simple yadif(mode=1). At static areas at horizontal color transitions it shows how sharpness increases. But at moving areas it still pases-through some blended fields parts. Need more correct mask of moving areas generation. Last edited by DTL; 29th November 2020 at 19:20.
1st December 2020, 18:41   #3  |  Link
jpsdr
Registered User

Join Date: Oct 2002
Location: France
Posts: 1,864
Quote:
 Originally Posted by DTL Unfortunately avisynth+ may be with ResampleMT works buggy todays at me so some buggy blue-yellow horizontal lines added at the bottom.
You mean that if in your script you replace SinPowResizeMT by GaussResize, you don't have these lines ?
What avs+ version ?
__________________
My github.

2nd December 2020, 23:34   #4  |  Link
DTL
Registered User

Join Date: Jul 2018
Posts: 62
Quote:
 Originally Posted by jpsdr You mean that if in your script you replace SinPowResizeMT by GaussResize, you don't have these lines ? What avs+ version ?
The source of bug was found and workarounded by pinterf - https://forum.doom9.org/showthread.p...29#post1929529 . It looks common for most avisynth versions. Waiting for next release with workaround included.