Log in

View Full Version : Bad Chroma Upsampling


ice_uk99
18th August 2004, 08:43
Hi everybody. I didn't really know where to put this thread, so I chose AviSynth, since I suspect it's the cause of my problem.

I've ran into this issue while encoding a PAL DVD (The Matrix) and namely "bad chroma upsampling". The thing is, I did not upsample the film neither in DGDecode nor in my AviSynth script or VirtualDubMod.

This is really strange, unless AviSynth (i'm running version 2.54), VirtualDubMod (set on "fast recompress") or DGDecode do some colourspace conversions somewhere. As far as I know, XviD natively works in YV12 colourspace, so I can't think of any culprits.

Here's my script:

LoadPlugin("C:\PROGRA~1\GORDIA~1\DGDecode.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\WarpSharp.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\VagueDenoiser.dll")

Import("C:\PROGRA~1\GORDIA~1\SharpTools-v0.3.avs")

mpeg2source("C:\DVD\THE_MATRIX\VIDEO_TS\The Matrix.d2v",idct=7)

crop(0,78,720,420)

SharpResize(720,288)

clip=last
clip1=clip.VagueDenoiser(threshold=0.25, method=1, nsteps=6, chroma=false)
clip2=clip.VagueDenoiser(threshold=0.75, method=1, nsteps=6, chroma=true)
clip1.mergechroma(clip2)

I didn't attach screenshots of the bug, because I think that you all know what the bug looks like. If you don't, I'll send some screenshots to you.

I've removed VagueDenoise and SharpResizer, which needed YV12 anyway, and converted to YUY2 and this fixed it. Oh yeah, I have a GeForce2 MX (motherboard chipset), although that shouldn't matter when encoding. Is there any way of getting the right colours besides converting to YUY2, as I need YV12 for SharpResize?

I've noticed this has been endlessly discussed on doom9, but I couldn't find a solution to the problem on these forums. I've also checked out this thread, though, and didn't find a solution. instead, I got some nice interlacing info from it: http://forum.doom9.org/showthread.php?threadid=46007&highlight=bad+chroma+upsampling

Does this happen on interlaced or on progressive films only, because I've got "2001: A Space Odyssey" (PAL aswell), which BitrateView reports it as being progressive (as opposed to my copy of "The Matrix" which it says it's interlaced), and in the scene where Bowman deactivates HAL, this bug is very obvious and it ruins the whole sequence.

sh0dan
18th August 2004, 09:09
Ok - here are some pointers.

Bad chroma happends when you convert from interlaced YV12 to mostly any other format and the converter thinks the material is progressive.
Or, the other way around, if material is progressive, and upsampled as interlaced. This is however not as bad as the other way around.

When vdub PREVIEWS your material, it will need to have material as RGB. Since AviSynth delivers YV12 it asks the codec (mostly XviD or DivX) to convert YV12 to RGB. The codec however does ALWAYS upsample progressive. Hence you will get artifacts in vdub preview on interlaced YV12 material. This is however not present in the YV12 material - to confirm this, let AviSynth do the conversion by adding ConvertToRGB(interlaced=true) at the end of your script.

So when you hand interlaced YV12 material to XviD you are handing it correct material. However a lot of thing can also go wrong after that (ie. colorspace conversions).

- XviD usually uses YUY2 for DirectShow overlays - does XviD correctly decode interlaced encoded material?
- When viewing the file in vdub, we are back in RGB mode. Does Xvid upsample correctly here, when it knows the material is interlaced?

One way to find out. Open the XviD in AviSynth, ConvertToRGB(interlaced=true).

yaz
18th August 2004, 11:10
dunno it helps or not but ... cropping to non-mod4 (like yours) makes me 'chroma troubles' always. even if it's resized to a mod4 res afterwards. try a mod4 crop (wont hurt anything) or remark that line out for a try.
the bests
y
whooff ... what a way of smoothing chroma :-))

ice_uk99
18th August 2004, 14:09
First of all, thanks for the replies.

I've tried the following (by the way, I'm using Koepi's XviD 1.0.1):

- opened the .AVI in VirtualDubMod >> bad upsampling;
- added ConvertToRGB(interlaced=true) to my script and opened it in VirtualDubMod >> bad upsampling;
- played the .AVI with Crystal Player 1.8: with overlay on >> bad upsampling / with overlay off (HWCodec) >> bad upsampling;
- commented all other lines in the script (even the crop and resize) except the source and opened it in VirtualDubMod (with and without ConvertToRGB) >> bad upsampling;
- put all the lines back in and added .ConvertToYUY2() and the end of mpeg2source, and opened it again with VirtualDubMod >> correct upsampling.

What am I doing wrong here?

sh0dan
18th August 2004, 17:54
ok - I think you are talking about something else than bad chroma upsampling.

Post screenshot/or small clips.

Regarding your script:

mpeg2source("C:\DVD\THE_MATRIX\VIDEO_TS\The Matrix.d2v",idct=7)

1) Is your source interlaced or progressive?

SharpResize(720,288)

2) If your material is interlaced all your problems are here. Never resize interlaced material without fieldseparating.

- If your source is interlaced, the problem is that you process it as progressive. If your source is progressive you cannot have bad chroma upsampling, and it is something else, which is why you should post screenshots.

ice_uk99
18th August 2004, 20:16
OK, here is a screenshot of the bug:

http://www.geocities.com/ice_mindbase/02_enlarged_xvid.PNG

And the DVD capture would look like this:

http://www.geocities.com/ice_mindbase/01_dvd.PNG

The DVD is reported by DGDecode as being interlaced.

scharfis_brain
18th August 2004, 20:31
hm.. seems like normal YV12 to me.
nothing special about it.

the stairstepping is normal with YV12 (due to chroma-subsampling)

Si
18th August 2004, 20:48
As a matter of interest, what part (time) of the film is this shot from and I'll check it out on my DVD
regards
Simon

scharfis_brain
19th August 2004, 05:11
I see you always try to do interlaced upsampling.
why this?


1) is the film itself interlaced?
2) is the mpeg encoded interlaced (DVD2AVI reports interlaced)

use only interlaced upsampling if you can see combs on moving object, everytime else uses progressive upsampling!!!
Even if the source is enceoded interlaced, but its content is progressive

ice_uk99
19th August 2004, 07:49
Si this is from chapter 18, "Running silent and deep." at approximately 0:57:42, when Tank says "power offline... EMP armed and ready". Those are pictures of the EMP knob.

scharfis_brain, could you tell me how to do progressive upsampling, because there are no interlaced artifacts in the film.

scharfis_brain
19th August 2004, 15:59
coverttoyuy2(interlaced=false) or converttorgb(interlaced=false)


equals to


coverttoyuy2() or converttorgb()


which produces progressive upsampling

ice_uk99
19th August 2004, 18:31
Isn't there another way to do this? I want to stick to YV12.

scharfis_brain
19th August 2004, 20:02
huh?

upsampling to ??? (insert the colorspace you like here) makes you leaving the YV12.

nontheless the word is called
UP - SAMPLING
UP -> more -> YUY2 has more chroma information than YV12

SAMPLING -> generating the missing data (creates MORE data) in a visual (smooth non-jaggy diagonals) and technical (proper interlaced/progressive handling) more or less pleasing way

so, now tell me, what do you want to do with your chroma?

everytime, you see your video, it is already converted to rgb24 or rgb32, cause it is either done withoin avisynth via converttorgb(...) or it is done by the YV12-decoder of your windows-system (which produces YV12 stairstepping!). yv12 cannot be displayed on CRTs/LCDs/Printers/TVs without being converted to at least YUY2 or RGB.

ice_uk99
19th August 2004, 21:22
I don't want to do any upsampling at all, I just want the stairstepping to go away.

sh0dan said that the film is encoded properly, and the stairstepping is produced when upsampling for display. Well, when I've tried avisynthing the DVD with converttorgb(interlaced=true), the stairstepping was still there. I've even tried avisynthing the AVI file with converttorgb and the effect was still there.

That only leaves the XviD codec as the cause of my problem. Right?

ice_uk99
20th August 2004, 06:45
I've done some testing yesterday, with both DivX and XviD, and they both show the same problem. While doing some searches on doom9, I've found a couple of threads with people having the same problem as me, the fault being the graphics card. It seems that my GeForce 2 MX (and nVidia cards, in general) don't upsample for display very well, thus creating this artifact.

It seems that XviD and AviSynth correctly encode and frameserve the film.

However, if my graphics card is to blame, then why is the DVD displayed correctly when played back?

ice_uk99
20th August 2004, 11:08
Solved it! It is only a playback issue indeed, and frameserving the AVI file with ConvertToRGB into VirtualDubMod removed the staristepping.

My only question now is: how can I upsample like that in an ordinary media player?

scharfis_brain
20th August 2004, 13:48
maybe using ffdshows internal avisynth interface while playback?

Mug Funky
20th August 2004, 15:48
my geforce 2 sucks balls for yv12 playback as well.

in addition, i get off-colour pixels appearing on every 16x16 block.

my advice is use directx7 or 9's Video Mixing Renderer for playback rather than the Overlay Mixer (probably the default).

you can select this in media player classic's output bit. choose VMR7 renderless, and tell it to render it as a 3d surface.

ice_uk99
20th August 2004, 18:05
Thanks guys. Actually, playing the film with ffdshow solved the problem (and without any of the workaround encoder bugs options enabled).