wanton
20th May 2003, 17:59
I'm writing this because i think many people won't know how yv12 version of mpeg2dec.dll decodes to yv12. If you have 29.97fps mpeg-2 material then you use force film for normal movie that is 100% FILM it's good chance video probably encoded with progressive_frame on meaning yuv data comes out as normal YV12 progressive data. But if you don't have force film one those extra frames made by repeat first field flags in mpeg2 data allways are in interlaced YV12...meaning if you don't use force film there will be wrong chroma decoding for those extra frames. In anime many video is encoded as hybrid with real NTSC and FILM data mixed together so YV12 data isn't very practical to use with those since you get lot of wrong chroma decoding since avisynth doesn't have any kind of flags for YV12 data if it's interlaced or not. Only way this would work is that every frame had an interlaced flags.
But that also has it's problem if you use something like decomb since it assumes you are using interlaced YV12. Author original of original DVD2AVI made DVD2AVI just because of flaskmpeg decoded chroma wrong for interlaced frames here is a link
http://arbor.ee.ntu.edu.tw/~jackei/dvd2avi/interlace/
You can test this yourself. Don't use Force film for pure film material and you can see that interlaced frames has wrong chroma. If you are an programmer you might want to check original mpeg2dec.dll sourcecode since you can see there that it converts chroma diffrently from YV12->YUY2 depending if frame has progressive_frame flag on or not.
If you material is true film and you use force film it's should be fine or material is truly interlaced mpeg-2 then you might want to do
ConvertToYUY2( interlaced=true )
ConvertToYV12()
to turn interlaced YV12 to progressive one if you want to encoded to example XVID since it assumes progressive YV12 input like probably everything else too since i think YV12 format in general is progressive format atleast in AVI's since you can't specify anywhere it to be interlaced atleast in microsoft site YV12 seems to specified as progressive one only. Also there should be any quality loss if you encode mpeg-2 file with YV12 progressive converted to YUY2 and then back to YV12 if you encode progressive material (example 23.976fps with pulldown).
And last note...i bet most YV12 filters asume progressive YV12 since avisynth doesn't specify if it's interlaced or not and most filters don't have setting to use interlaced video. Since if something assumes progressive chroma and it's actually interlaced one then filter gets wrong chroma value for every second line.
What i would suggest for hybrid material like anime is to use YUY2 version of mpeg2dec.dll and do decomb and then use ConvertToYV12 after it to run filters and such. Because frames are combined to progressive you can use normal ConvertToYV12() to turn them to progressive YV12 to use directly with XVID example.
If you use avi source then you probably doesn't have to worry at all since if they are decoded to YV12 they are in progressive YV12 mode allready.
I made this text because after transfering from avisynth 2.0 to 2.5 i had hard time with hybrid anime material so this might help other people. Now i think i should go and compile my self an old MPEG2DEC.DLL with YUY2 support to use with this kind of material.
Ofcourse it would be better if author of MPEG2DEC3 would add YUY2 decoding support since it has lot of nice options.
P.S. Didn't much check what i wrote so i hope you people got the idea :)
But that also has it's problem if you use something like decomb since it assumes you are using interlaced YV12. Author original of original DVD2AVI made DVD2AVI just because of flaskmpeg decoded chroma wrong for interlaced frames here is a link
http://arbor.ee.ntu.edu.tw/~jackei/dvd2avi/interlace/
You can test this yourself. Don't use Force film for pure film material and you can see that interlaced frames has wrong chroma. If you are an programmer you might want to check original mpeg2dec.dll sourcecode since you can see there that it converts chroma diffrently from YV12->YUY2 depending if frame has progressive_frame flag on or not.
If you material is true film and you use force film it's should be fine or material is truly interlaced mpeg-2 then you might want to do
ConvertToYUY2( interlaced=true )
ConvertToYV12()
to turn interlaced YV12 to progressive one if you want to encoded to example XVID since it assumes progressive YV12 input like probably everything else too since i think YV12 format in general is progressive format atleast in AVI's since you can't specify anywhere it to be interlaced atleast in microsoft site YV12 seems to specified as progressive one only. Also there should be any quality loss if you encode mpeg-2 file with YV12 progressive converted to YUY2 and then back to YV12 if you encode progressive material (example 23.976fps with pulldown).
And last note...i bet most YV12 filters asume progressive YV12 since avisynth doesn't specify if it's interlaced or not and most filters don't have setting to use interlaced video. Since if something assumes progressive chroma and it's actually interlaced one then filter gets wrong chroma value for every second line.
What i would suggest for hybrid material like anime is to use YUY2 version of mpeg2dec.dll and do decomb and then use ConvertToYV12 after it to run filters and such. Because frames are combined to progressive you can use normal ConvertToYV12() to turn them to progressive YV12 to use directly with XVID example.
If you use avi source then you probably doesn't have to worry at all since if they are decoded to YV12 they are in progressive YV12 mode allready.
I made this text because after transfering from avisynth 2.0 to 2.5 i had hard time with hybrid anime material so this might help other people. Now i think i should go and compile my self an old MPEG2DEC.DLL with YUY2 support to use with this kind of material.
Ofcourse it would be better if author of MPEG2DEC3 would add YUY2 decoding support since it has lot of nice options.
P.S. Didn't much check what i wrote so i hope you people got the idea :)