View Full Version : Wrong YUY2 Codec causes colourspace errors on AVISynth scripts feeding TMPGEnc


acanthis
24th June 2002, 21:08
Some time ago I suddenly found that feeding TMPGEnc with an AVISynth script resulted in what looked like a colourspace conversion error; as if the video had been badly dithered down from 24 bit to 8 bit!

This was another one of those classic "it worked last week, but now it doesn't and I don't know when it stopped working" situations.

At the time I couldn't find the cause, so I resolved to putting ConvertToRGB at the bottom of every script; this fixed it. Today, I finally tracked it down.

The culprit turned out to be those awfully nice people over at the Microsoft Corporation. More specifically, a natty little file by the name of MSYUV.DLL. This goes under the description "Microsoft UYVY Decompressor", and I *think* it gets installed by Windows Media Plodder version 7; it seems to be a standard part of XP Pro.

Anyway, the problem (for me) was that Microsoft had decided to register this codec as the YUY2 decompressor (AVISynth works in YUY2 mode). This is probably perfectly harmless, and in fact it only affected TMPGEnc. However, I fixed my colourspace problem by going into the registry and changing the driver setting for VIDC.YUY2 so that HUFFYUV handled YUY2 decoding.

Here's the .reg file for Win2K/XP ...

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32]
"VIDC.YUY2"="huffyuv.dll"

This does result in seeing two entires for HUFFYUV when you call up the Video Compression dialogue for VirtualDub (one for YUY2 and one for HFYU), but at least it fixed my problem.

Has anyone else ever encountered this? Did you find another fix? Is there a better way?

TactX
24th June 2002, 22:35
Well, your fix does work :)
But adding ConvertToRGB works too. There is no difference in speed since it will be converted to RGB in both cases, either by Avisynth or by HuffYuv.

acanthis
24th June 2002, 23:11
Originally posted by TactX
Well, your fix does work :)
But adding ConvertToRGB works too. There is no difference in speed since it will be converted to RGB in both cases, either by Avisynth or by HuffYuv.

Hmmmn. But is it the same, though? And doesn't this mean that either the Microsoft codec is incorrectly converting YUY2 to RGB, or that AVISynth or TMPGEnc is doing something wrong? Doesn't HUFFYUV pass through YUY2 to an application that can read it without converting it to RGB unless "Always suggest RGB Format for Output" is set? and don't MPEG encoders work best in the YUY colourspace?

Actually, it wasn't speed I was concerned about; I just don't like suddenly finding that something has stopped working for no apparent reason. I have to know why - and what a surprise to find that Microsoft are involved in it somewhere :)

Uli
25th June 2002, 10:07
This DLL comes with DirectX 8.1.

greetz, Uli

Gazza
26th July 2002, 04:02
This is interesting. A couple of days ago I started to get errors when viewing avi or ogm files. bsplayer or zoomplayer (and dvd2avi for that matter) informed me that my hardware was unable to process yuv and I should switch to rgb. I hadn't seen this problem before.

It just so happens that I have recently installed DirectX8.1. I didn't think this caused any issues but then my problems started to appear a couple of days ago. Maybe there is a link?

I am a little stuck with fixing my problem so any advise/guidance from the experts would be most appreciated. Should I go back to previous Directx version? Or mess around in the registry?

Thanks in advance.

Gazza

Gazza
29th July 2002, 03:51
I tried changing msyuv.dll to huffyuv.dll as suggested but still got the same problem. There must be something else that is impacting. Anyone got any ideas on what I could try next? I'm a little in-experianced in this area.

Thanks in advance

Gazza

Didée
29th July 2002, 07:54
@ Gazza

(Just another) shot in the dark:

try re-installing the drivers of your graphics card. This helped in many cases, since a directX-installation is likely to overwrite some files it shouldn´t ...
Don´t know for 8.1 (since shipping with XP), but older versions even wanted to replace your complete graphics driver setup with some basic ones that directX thought it should be ... brrrr!

In any case, re-installing your latest drivers on-top shoudn´t harm. It can only get better.

lovelegend
29th July 2002, 08:56
@Gazza
I haven't tried changing the registry but I tried adding the command ConvertToRGB() and it worked...
Another way I've just found out is using CCE instead of TMPGEnc...

Gazza
30th July 2002, 04:43
To all who provided suggestions, etc. Thanks for your help and advice but unfortunately my problem didn't go away. So I am going to rebuild (a long time overdue) and return back to normality.

Again, thanks for your suggestions.

Gazza

Koepi
30th July 2002, 05:51
Hm, I got inspired by this, and as we're all lazy you might wanna checkout the attachment to this post :)

(Ok, until the mod approves the attachment: it's an easy installer which comes along with huffyuv.dll to make it _really_ easy..)

Regards,
Koepi

EDIT: had to upload the attachment again (hopefully it really overwrites the old one) as the old one didn't work properly. This installer does in fact install huffyuv (and can properly uninstall it again :) ) and registers all colourspaces registered to msyuv.dll to huffyuv.dll. Since I use that some of my capturing problems are gone, too! :)

frank
31st July 2002, 20:05
YUV and YUY2 are not the same!
neuron2 (Donald Graft) wrote in an earlier post:
The YUV you get from DVDs has the following byte ordering
U Y1 V Y2
whereas YUY2 (huffyuv) has
Y1 U Y2 VMicro$oft has mismatched something. :rolleyes:

MPEG2DEC.DLL converts to YUY2.
Look at this thread:New IVTC for AVIsynth (http://forum.doom9.org/showthread.php?s=&threadid=14011&highlight=New+IVTC) page 3

trbarry
31st July 2002, 21:40
The YUV you get from DVDs has the following byte ordering
U Y1 V Y2

DVD's are in planar 4:2:0 format and aren't YUYanything. But if you are talking about the YUY2 coming out of DVD2AVI then I'm pretty sure it is Y1 U Y2 V, in storage, but sometimes confusing because that byte order will be reversed when loaded into an MMX register.

- Tom

lovelegend
31st July 2002, 23:43
Originally posted by trbarry


DVD's are in planar 4:2:0 format and aren't YUYanything. But if you are talking about the YUY2 coming out of DVD2AVI then I'm pretty sure it is Y1 U Y2 V, in storage, but sometimes confusing because that byte order will be reversed when loaded into an MMX register.

- Tom

@@..... You just made me more confused.... LOL

Richard Berg
1st August 2002, 02:57
YUV is a colorspace. YUY2 & YV12 (& UYVY & a host of other nasty incompatible formats) are byte formats for storing 16-bit YUV pixels subsampled in various ways.

Gazza
2nd August 2002, 04:30
In my previous message I said I was going to re-build and in effect remove Directx8.1. However, I got in touch with the manufacturer of my computer. It turns out that my problems (ie unable to convert yuv color space during replay of avi's) was in fact due to having M$ Netmeeting active on my desktop. Once this was de-activated everything has returned to normal.

I'm posting this as a hint if others hit on the same frustrating problems I have in the last couple of weeks.

Gazza