PDA

View Full Version : YUY2 broken in latest Avisynth release?


bobokonijn
20th January 2006, 08:17
Hello all,

I've noticed that function ConvertTuYUY2() results in clips that have irregular, "stepped" luminance histograms, so observed when I open the AVS file with virtualdub. ConvertToRGB32() does not have this problem. Is something broken?

sh0dan
20th January 2006, 11:15
Moved to Dev.

Could you supply a bit more info?

The algorithm for conversion hasn't changed since v2.0.something.

Mug Funky
20th January 2006, 13:52
i think it may be virtualdub's issue - i've noticed that levels adjustments in Virtualdub (although very close) don't match exactly with those made in avisynth. perhaps it does it's own RGB conversion when it constructs the histogram?

there's a native avisynth histogram function that you could try...

@ sh0dan:

just a matter of a couple of white gaps in the histogram as displayed by virtualdub.

IanB
20th January 2006, 14:22
At a guess, bobokonijn has probably noticed the quantization when converting [16..235] YUY2 data into [0..255] RGB data. There are only 220 discrete values of luminance and 225 discrete values for each chrominance channel, giving 11,137,500 possible discrete values. For RGB there are 256^3=16,777,216 possible discrete values.

Also only about 50% of the 11,137,500 values can actually map into the RGB colour space. For Y=235, U=V=128 the mapping equations give R=G=B=255, likewise for Y=16, U=V=128 gives R=G=B=0. At these extremes U and V can only ever be 128 all other values lead to R, G and/or B values greater then 255 or less the 0. Only at Y=126 can the U and V values project there maximium scope.

To help convince ones self put the YUV to RGB formulae into spread sheet and explore the results, it's quite amazing how incompatible the 2 colour spaces actually are, yet our eyes cannot discern anything amiss.

bobokonijn
21st January 2006, 10:08
I just did the following:

OpenDMLSource("d:\myfile.avi")
ConvertToYUY2()

and opened the resulting avs in an older virtualdub version that doesn't support the YV12 color model.

There I added the "levels" filter just to watch the histogram, not to change anything. I do this always to determine the correct black and white levels because my capturing card has a lousy AGC.

The histogram was extremely irregular.

When I use ConvertToRGB32() instead, the histogram is smooth as silk
but the processing is slower.

sh0dan
21st January 2006, 13:38
When you use ConvertToYUY2(), vdub converts the video back to RGB for display. This is either done by vdub or a codec, so AviSynth is not involved.

For adjusting levels within AviSynth visually, you can use:
OpenDMLSource("d:\myfile.avi")
ConvertToYUY2()
Levels(0,1.0,255,0,255)
Histogram("levels")

bobokonijn
31st January 2006, 17:16
Please try the following:


OpenDMLSource("d:\myfile.avi")
ConvertToYUY2()
ConvertToRGB32()

and load the AVS file in Virtualdub. Then load the Levels filter in Virtualdub just to watch the histogram (don't change anything).


Then repeat the same thing, leaving out step (2).

See the difference?