Log in

View Full Version : "Convert" using Avisynth. Weird seemingly incorrect results


Jeremy Duncan
14th March 2008, 20:55
Example

http://aycu15.webshots.com/image/46934/2000886508290967074_th.jpg (http://allyoucanupload.webshots.com/v/2000886508290967074)

In the example.
There is three layers showing different contrast.
The top layer is without using avisynth.
The middle layer is using avisynth and this code:
ConvertToRGB(matrix="pc.601")
chromaresample="Lanczos"

The third layer is using avisynth and this code:
ConvertToRGB()
chromaresample="Lanczos"

-Now I'm confused as to why the top two layers in the example show different contrast.
Both of them are using pc.601 levels, so why is the avisynth convert one so different from not using convert to get pc.601 levels?

Maybe it's a bug.

I'm using:
AviSynth_070919
mplayerc_20080308
ffdshow_rev1897_20080313_clsid

ffdshow settings
Codecs tab
Set Mpeg2 to Libmpeg2, and check "DVD decoding".
Set Avisynth to Avisynth, Raw video to All supported

Avisynth tab
YV12 checked,
Add FFdshow Video source checked,
3:2 Pulldown box: ignore Pulldown checked,
Check Buffer back/Ahead: 1, 15

ConvertToRGB(matrix="pc.601")
chromaresample="Lanczos"

Subtitles tab, Unchecked
Uncheck "Decode closed captions"
Uncheck "Accept embedded subs"
Uncheck "Accept SSA, ASS, ASS2 Subtitle (experimental)
Vobsub subpage, uncheck Vobsub Enable.

Resize & aspect tab
Multiply by:
1.780 (for 1280x720 16:9 aspect ratio)
2.668 (for 1920x1080 16:9 aspect ratio)
Process Pixel aspect ratio internally checked
No aspect ratio correction checked
Lanczos
Taps: 2
Luma Sharpen: 0.00
Accurate rounding checked

Queue & Output tab
Queue output samples checked

Output tab
rgb32 checked

media player classic settings
Click the View button. Check only the top three in the drop down list.
Click options.

Click the output tab, and set it to VMR9 (Windowed), vmr9 mixer checked, bicubix 0.60.

Click the Audio Switcher Tab, Slide the bar to the far right.

Click the External Filters Tab.
Click the Add Filter Button.
FFdshow Audio decoder
FFdshow video decoder

2Bdecided
17th March 2008, 10:34
When going from YUV (e.g. YV12) to RGB, the luma range 16-235 should normally be expanded to 0-255.

Using the "PC" conversion, rather than the "Rec" conversion prevents this expansion from happening.

It's normal for the "PC" conversion to make whites darker and blacks lighter than the "Rec" conversion.

It looks like other conversions could be happening elsewhere.

Are you sure your input is correct (i.e. the levels are what they claim to be)?

Cheers,
David.

Jeremy Duncan
18th March 2008, 22:47
In that contrast pattern, using the regular default in converttorgb. I can see the +2 and + 5 disappear as soon as avisynth convert is used!
So the levels are ruined when converttorgb is used at default without using pc.601.

When not using avisynth in ffdshow I can see +2 and +5 in the contrast pattern fine.

IanB
19th March 2008, 03:03
@Jeremy Duncan,

Reread 2Bdecided's post, you need to understand the levels range of your source material and the levels requirments of your viewing environment. When you fully understand both you will also be able to understand the significance of using matrix="PC.601" verus matrix="Rec601".

Use ColorYUV(Analyze=True), RGBAdjust(Analyze=True) and Histogram() to help you see and understand the actual values involved.

Nothing mentioned in this post is weird or ruined, you are just not using the tools at your disposal appropriately.

Jeremy Duncan
20th March 2008, 20:54
IanB,

I can see that using Convert, the levels are changed to tv levels.
They are Changed.
+2 +5 cannot be seen regardless of how much I adjust the contrast on the monitor.

Not using convert and I get 0-255 levels.

I can get 0-255 levels using convert if I use pc.601.

These are the facts.
I'm probably not going throught the steps nessessary to see the brilliance in this.

scharfis_brain
20th March 2008, 21:08
they are changed to conform the YUV spec for video.

2Bdecided
21st March 2008, 15:54
In compliant video, below 16 is "blacker than black", above 235 is "whiter than white" - these meaningless colours should be removed when expanding the range for PC display.

If you have non-compliant video, with real content above 235 or below 16, then you need to do something smarter and preserve it - this could mean using the PC.601 matrix, but there are other options (e.g. levels). It depends what you want to do.

You haven't actually said what you're trying to acheive, so it's difficult to help further.

Cheers,
David.

IanB
23rd March 2008, 06:31
They are Changed.Yes! that is the purpose of the filters.

1. State the parameters of your video.

2. State your objective.

Jeremy Duncan
24th March 2008, 02:39
My parameters of the video is 0-255 levels in sddvd ntsc movies.

I would post a small d2v of that contrast pattern, but it's not good for the owner of this site: calibrate.tv
Might cost him a customer that just wanted that pattern.

My objective is to go from yv 12 to rgb32.
yv 12 chroma is less than is present in rgb 32.
So I wanted to make this conversion to get that chroma back, before resizing with lanczos in ffdshow.

The added chroma would theoretically add more detail OR better color.
I'm not sure which, since this whole plan wasn't mine, but vpopovich's in the avsforum.
If I get better color and more detail from the added chroma from the conversion to rgb32 then I would be laughing. :cool:

IanB
24th March 2008, 07:18
Okay, IFF! your stream is YUV format and IFF! the Y levels are 0-255 then use ConvertToRGB32(matrix="PC.601") or "PC.709", this is what these matrices are intended for.

Use Info() to confirm the pixel type of your stream.

Use ColorYUV(Analyze=True) to confirm the range of your Y, U and V levels.

Use Tweak(Sat=?, coring=False) to boost the amplitude of your U and V levels if they are lower than you want.

So you probably want something like this :-...
# Info() # Uncomment to check format
Tweak(Sat=1.14, coring=False) # 14% UV boost.
# ColorYUV(Analyze=True) # Uncomment to check YUV levels
ConvertToRGB32(Matix="PC.601")
# RGBAdjust(Analyze=True) # Uncomment to check RGB levelsYou have over 600 posts, I am surprised you are having such difficulty searching these forums and reading the documentation to achieve what appears to be a simple levels adjustment of a non-standard clip.

Jeremy Duncan
25th March 2008, 03:43
IanB,

If I wanted to use tweak(), and be told I was using 0-255 I would have done those things.

The entire reason for the thread was I was unsure about the results I was getting using convert.

Still makes no sense to me why I get these results.
But I conceed that your right and I'm wrong.
I'll just carry on.

:thanks:

Jeremy Duncan
25th March 2008, 04:11
Here's the test results Ianb asked for.

http://rapidshare.com/files/102136081/New_Folder.zip.html

2Bdecided
25th March 2008, 12:56
My parameters of the video is 0-255 levels in sddvd ntsc movies.As several people have tried to tell you, the correct levels are 16-235 - and now you've confirmed the source is an SD DVD, "NTSC", that's even more certain.

Test patterns often include the full range (1-254 or 0-255), but real content should not. There are some incorrectly encoded DVDs which include blacker-than-black, and lots of home movies include whiter-than-white - but most commercial content is encoded correctly on the DVD.

Do not try to keep luma values that are not used, you will reduce the dynamic range and produce a dull looking picture.

Can you provide a link to the guide you are trying to follow? Maybe there is a setting somewhere else that change the range which means what you are doing actually makes sense within the workflow as a whole.

Cheers,
David.

IanB
25th March 2008, 13:29
I am at a total loss trying to understand what your real issue is here. :confused:

Yes you have a 2 hours YV12 stream 720x480 @ 25FPS.

Yes frame 2029 of some clip, I assume is the same as above, has 12 <= Y <= 143 and negligable chroma. Most of the dark pixels are at 15, yes the peak black is at 12 but it is less than 0.5% of the dark pixels.

The RGB image has the dark areas as not pure black.

Is this really a genuine PC.601 source or just a badly captured Rec601 that need some care and feeding with Levels and/or Tweak.

And yes you could care and feed it to either PC (PC.601) or TV (Rec601) levels as long as you are consistant with your subsequent processing.

Jeremy Duncan
26th March 2008, 19:01
The test results were taken from the movie The Transporter.

And they were direct from the disk using ffdshow and mpc.

These new test results are from the new movie I Am Legend.

http://rapidshare.com/files/102565589/Coloryuv.zip.html

Here's one. All three are in the rapidshare link.

http://fileserver6.jpghosting.com/images/Coloryuv_9aa8cc6a800b0c820374f75613e5b563.jpg

scharfis_brain
26th March 2008, 19:18
all the images were convertet to RGB.
when converting a movie (usually YV12) to RGB, the luma range becomes stretched from 16...235 (YV12) to 0...255 (RGB).

Jeremy Duncan
26th March 2008, 21:33
This is using only this code.

Info() # Uncomment to check format
Tweak(Sat=1.14, coring=False) # 14% UV boost.
# ColorYUV(Analyze=True) # Uncomment to check YUV levels

http://fileserver6.jpghosting.com/images/ColorYUV_720cfd607c16964014404409f0970efc.jpg
http://fileserver6.jpghosting.com/images/Info_7a872223d119e2f5b9c7b0e91ed4e7d5.jpg

Using the movie The Matrix.
From the disk, using ffdshow and mpc.

Jeremy Duncan
26th March 2008, 21:39
In ffdshow.
My input is yv12, output rgb32.
Avisynth is on top - it uses only yv12 - buffer 1, 15,
then subtitles tab,
then resize tab.

In mpc, I set output to vmr9 windowed, bicubic 0.60, vmr9 mixer checked.

ffdshow version: Link (http://downloads.sourceforge.net/ffdshow-tryout/ffdshow_rev1897_20080313_clsid.exe?modtime=1205419400&big_mirror=0)
mpc version: Link (http://downloads.sourceforge.net/guliverkli2/mplayerc_20080127.zip?modtime=1201469670&big_mirror=0)

scharfis_brain
26th March 2008, 21:47
would you please try dgindex/dgdecode instead of ffdshow?

Jeremy Duncan
26th March 2008, 21:54
Here is one takes with the same settings as in post # 18.

http://fileserver6.jpghosting.com/images/ColorYUV_92673da1ae887e162eeae09d7dc21a7f.jpg

Only output is yv12 instead of rgb32.

Jeremy Duncan
26th March 2008, 21:55
would you please try dgindex/dgdecode instead of ffdshow?

Alright. brb.

ARDA
26th March 2008, 22:00
Try without Tweak and compare results with the same frames.

Regards ARDA

Jeremy Duncan
26th March 2008, 22:05
Here you go, scharfis.

http://fileserver6.jpghosting.com/images/dgindex_1a617652c0be233f101c161e26ebffe1.jpg

Jeremy Duncan
26th March 2008, 22:30
Try without Tweak and compare results with the same frames.

Regards ARDA

With Tweak
http://fileserver6.jpghosting.com/images/ColorYUV_92673da1ae887e162eeae09d7dc21a7f.jpg

Without tweak
http://fileserver6.jpghosting.com/images/ColorYUV_105e998d9bedf276453ab78a2aa7ff84.jpg

Same settings as post 18, but yv12 output.

Here's the code i used.
# Info() # Uncomment to check format
ColorYUV(Analyze=True) # Uncomment to check YUV levels

ARDA
26th March 2008, 23:06
It was just a way to reduce variables.

Possibilities

a) Decode process is sending luma expanded to 0 255 to avisynth.
b) Source has lumas in that range.
c) ColorYUV(Analyze=True) is giving false results. I doubt

I can't guess anyother situation. Maybe anyone can see other option.

scharfis_brain
26th March 2008, 23:08
use histogram() before colorYUV() to ensure that its not only the black bars instad of the actual image content, that are dropping the black to 0

Jeremy Duncan
26th March 2008, 23:59
use histogram() before colorYUV() to ensure that its not only the black bars instad of the actual image content, that are dropping the black to 0

http://fileserver6.jpghosting.com/images/coloryuv_644505139c9a18f48fb66c91cbc1592e.jpg

histogram()
ColorYUV(Analyze=True) # Uncomment to check YUV levels

Same settings as in post 18, but yv12 output.

scharfis_brain
27th March 2008, 00:05
the black bars are limited at 16.
I guess that the black 0 is due to compression rounding errors.

Jeremy Duncan
27th March 2008, 00:10
the black bars are limited at 16.
I guess that the black 0 is due to compression rounding errors.

So, it's really 16-235. And this means I don't need pc.601?

scharfis_brain
27th March 2008, 00:31
yeah.

Jeremy Duncan
27th March 2008, 01:14
yeah.

That's great news.

I would like to thank all you kind people in helping me with this problem I was having, and showing great patience with me in working this out.

:)