Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th January 2005, 23:34   #1  |  Link
Cyberia
Moderator
 
Cyberia's Avatar
 
Join Date: Nov 2002
Location: Inside
Posts: 718
Colorspace packing formats

Could someone briefly explain what the various packing formats for colorspace are and how they relate to the colorspaces themselves?

ie: What are 4:4:4, 4:2:2, 4:2:0 formats? How do they relate to colorspaces like RGB32, YUV2 or YV12?
Cyberia is offline   Reply With Quote
Old 10th January 2005, 00:04   #2  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,312
http://www.avisynth.org/ColorSpaces
http://www.avisynth.org/Sampling
and all links in http://www.avisynth.org/PlanarImageFormat
Wilbert is offline   Reply With Quote
Old 10th January 2005, 00:07   #3  |  Link
stickboy
AviSynth Enthusiast
 
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,268
RGB and YUV are colorspaces.

RGB32 is a specific format for RGB, where it uses 1 byte for red, 1 byte for green, 1 byte for blue, and 1 byte that's unused (or is sometimes used for alpha).

YUY2 and YV12 are specific formats of YUV. YUY2 uses 4:2:2 subsampling, consuming an average of 16 bits per pixel, and YV12 uses 4:2:0, consuming an average of 12 bits per pixel.

Explanation of subsampling formats:
Chroma Subsampling Standards
stickboy is offline   Reply With Quote
Old 10th January 2005, 00:12   #4  |  Link
Cyberia
Moderator
 
Cyberia's Avatar
 
Join Date: Nov 2002
Location: Inside
Posts: 718
Ah, got it. Thanks
Cyberia is offline   Reply With Quote
Old 10th January 2005, 12:07   #5  |  Link
Schlumpf
Registered User
 
Join Date: Oct 2001
Posts: 62
Since we're already on that topic...
I have some more dumb questions that have been nagging me for some time now.
In RGB I know that each channel can take a variety of 256 values in total, hence the resulting 8 bit.
In YUV each channel is represented with a value from 0-4 like in 4:4:4 , 4:2:2 , etc. Obviously the 4 does not represent the maximum of bits it can hold, since only 16 possible values for a channel would result in quite a poor picture... So what does this 4 stand for?
And YUY2 is 16 bit, okay. That makes sense, when we say that 4*2*2 = 16, but why is YV12 (4:2:0) 12 bits then?
Oh, and my last question has a bit to do with my bad memory...don't know if I recall it correctly, but in a former in-depth discussion of DVD-Video, it was stated that DVDs don't exactly use YV12 but rather a 4:2:0 colorspace with the chroma channels switched (UYUY ? ) Was that correct? And if yes, I obviously had never trouble in dealing with DVDs + Avisynth, so does Avisynth handle this conversion internally or any of the plugins I use to import DVD-footage?
Hope I made some sense.
Schlumpf is offline   Reply With Quote
Old 10th January 2005, 12:28   #6  |  Link
stephanV
gone
 
Join Date: Apr 2004
Posts: 1,709
The 4:4:4, 4:2:2, etc notations do not stand for the amount of bits per channel used. All channels in the YUV colorspace use 8 bits. Those numbers refer to the horizontal and vertical downsampling that is used for the chroma.

YUV 4:4:4 has no downsampling
YUV 4:2:2 has the chroma downsampled in a 2:1 ratio vertically and but not horizontally
YUV 4:2:0 (YV12) has a 2:1 downsampling for chroma, both vertically and horizontally.

so to calculate the average bits per pixel of YV12 we need to take a square block of 4 pixels (2x2). Such a block will contain 4 values for the luma (Y) and 1 value for the chroma (U+V). Each channel is 8 bit therefor the total amount of bits is 4*8 + 8 + 8 = 48 bits for 4 pixels

this results in an average bits per pixel of 12.

in the links from Wilbert you should be able to find more info.

Quote:
don't know if I recall it correctly, but in a former in-depth discussion of DVD-Video, it was stated that DVDs don't exactly use YV12 but rather a 4:2:0 colorspace with the chroma channels switched (UYUY ? ) Was that correct? And if yes, I obviously had never trouble in dealing with DVDs + Avisynth, so does Avisynth handle this conversion internally or any of the plugins I use to import DVD-footage?
I'm not sure if this is the case, buit if it is the conversion is handled by the decoder, not AVIsynth.

Last edited by stephanV; 10th January 2005 at 12:30.
stephanV is offline   Reply With Quote
Old 10th January 2005, 13:07   #7  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,312
Quote:
I'm not sure if this is the case, buit if it is the conversion is handled by the decoder, not AVIsynth.
It's stored as I420, which is YV12 with the U and V planes being switched. For YV12 we have Y plane | V plane | U plane, and for I420 Y plane | U plane | V plane. This conversion is done by mpeg2dec3.

Speaking about color formats. Do anyone of you know what 4:1:0 means? We were discussing this somewhere else, and looking at some indeo (which seems to be the only codec which uses YUV 4:1:0) screenshots we concluded that chroma is shared by 4x4 luma pixels. But, I'm not sure how to conclude from the notation 4:1:0?

Last edited by Wilbert; 10th January 2005 at 13:13.
Wilbert is offline   Reply With Quote
Old 10th January 2005, 13:42   #8  |  Link
stephanV
gone
 
Join Date: Apr 2004
Posts: 1,709
I have trouble understanding the notation too but i have came to the following conclusion

the first 2 numbers (for example 4:2) give the horizontal resolution ratio of the chroma. In case of YUY2 and YV12 this is both 2:1 (= 4:2). The 3rd number says something about the vertical resolution of the chroma. However the use of it is rather weird, but I've came to the following conclusion:

- If the 3rd number is equal to the 2nd number, the vertical chroma resolution is untouched (as in 4:4:4, 4:2:2 and 4:1:1).
- If the 3rd number is 0 the vertical chroma resolution is equal to the horizontal chroma resolution.

considering 4:1:0, the horizontal chroma downsampling would have a ratio of 4:1 and the vertical downsampling equals that (because of the 0). So this would confirm your guess about Indeo.

I havent any source for this to confirm my findings but it is the only way I can make sense out of the numbers.

[edit]from my conclusion, you could say that 4:4:4 is the same as 4:4:0... although that probably doesnt excist

[edit2]It is my personal believe that 4:2:4 would be a better notation for YUY2 and 4:2:2 for YV12... then the ratio ( : ) sign actually makes sense... there should be some reason for the notation we have now though, although its probably not a logical one.

Last edited by stephanV; 10th January 2005 at 13:57.
stephanV is offline   Reply With Quote
Old 10th January 2005, 14:13   #9  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,312
Quote:
- If the 3rd number is equal to the 2nd number, the vertical chroma resolution is untouched (as in 4:4:4, 4:2:2 and 4:1:1).

- If the 3rd number is 0 the vertical chroma resolution is equal to the horizontal chroma resolution.
Yes, it also came to this conclusion until I saw your following remark.

Quote:
[edit]from my conclusion, you could say that 4:4:4 is the same as 4:4:0... although that probably doesnt excist
Hmm

But that interpretation (if indeed true in some form) is very restrictive. Suppose we make a codec where the chroma is shared between 2x4 pixels. What notation would you use? 4:1:1/2 or something like that
Wilbert is offline   Reply With Quote
Old 10th January 2005, 14:31   #10  |  Link
stephanV
gone
 
Join Date: Apr 2004
Posts: 1,709
well, i've thought about this too

I think a 2x4 sharing of chroma is a very unlikely situation considering it is easier to give up horizontal resolution before vertical due to difficulties with interlaced video.

although, this would still leave a question like: how do we describe 4x2 block? the first numbers should be 4:1 but then... 2? i dont know of anything that uses this... you might though.

im finding the use of the number 0 in what appears to be a ratio of some sort rather confusing, but again, this is the only way i can make sense of it... if you know something better or have a different idea, please share!
stephanV is offline   Reply With Quote
Old 10th January 2005, 17:27   #11  |  Link
fccHandler
Registered Jedi
 
Join Date: Jan 2003
Location: Georgia, U.S.A.
Posts: 734
The numbering scheme dates back to the 1980's I think, but their historical usage seems a bit obscure today. I did find some interesting explanations on the web:

http://www.tvtechnology.com/features...07.10.02.shtml
http://forum.matrox.com/rt2000/Forum8/HTML/000052.html
__________________
May the FOURCC be with you...
fccHandler is offline   Reply With Quote
Old 10th January 2005, 18:01   #12  |  Link
stephanV
gone
 
Join Date: Apr 2004
Posts: 1,709
heh

thx
stephanV is offline   Reply With Quote
Old 10th January 2005, 18:10   #13  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,312
I've read similar links. But I'm not very impressed by the first link (it thinks that DV sampling and MPEG-2 sampling are the same, MPEG-1 sampling is described wrong too).

If such links say something about 4:1:0 (see second link for example), they say the following

Quote:
An important point to note is that if the two schemes 4:2:0 and 4:1:1 are cascaded the result will be 4:1:0 the worst possible solution.
To me this means that chroma is shared between 4x2 pixels. But, this is clearly false if you look at Indeo screenshots. Perhaps Indeo didn't understand what 4:1:0 means, I don't know ...

@stephanV,

Quote:
although, this would still leave a question like: how do we describe 4x2 block? the first numbers should be 4:1 but then... 2? i dont know of anything that uses this... you might though.
No I don't.

Quote:
if you know something better or have a different idea, please share!
I don't have anything better
Wilbert is offline   Reply With Quote
Old 11th January 2005, 03:56   #14  |  Link
fccHandler
Registered Jedi
 
Join Date: Jan 2003
Location: Georgia, U.S.A.
Posts: 734
Quote:
Originally posted by Wilbert
I've read similar links. But I'm not very impressed by the first link (it thinks that DV sampling and MPEG-2 sampling are the same, MPEG-1 sampling is described wrong too).
Hmm... The guy works for ABC, which is a big deal. He doesn't say that DV and MPEG-2 sampling are the same. He actually states that "some of the DV recording formats" use 4:1:1 sampling. But my understanding was that PAL DV uses the same 4:2:0 sampling as MPEG-2. (I think Ivo told me that once.)

The description of MPEG-1 sampling is not necessarily wrong if he's talking about interlaced sampling (although we know that MPEG-1 is strictly progressive). I do agree about one thing; the diagrams are pretty useless.
__________________
May the FOURCC be with you...
fccHandler is offline   Reply With Quote
Old 11th January 2005, 09:52   #15  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,312
Quote:
He doesn't say that DV and MPEG-2 sampling are the same. He actually states that "some of the DV recording formats" use 4:1:1 sampling.
Yes, that's correct.

Quote:
But my understanding was that PAL DV uses the same 4:2:0 sampling as MPEG-2. (I think Ivo told me that once.)
Yes, PAL DV uses 4:2:0 sampling. But that uses different sampling as MPEG-2. His figure 3 is how PAL-DV is sampled.

Quote:
The description of MPEG-1 sampling is not necessarily wrong if he's talking about interlaced sampling (although we know that MPEG-1 is strictly progressive).
Well, he talks about field based sampling. afaik the Cb and Cr samples have the same placement (indeed between the luma samples), not a different one as he suggests. The placement is between *four* luma samples and not between two as his diagram suggests.
Wilbert is offline   Reply With Quote
Old 11th January 2005, 09:53   #16  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,312
Quote:
He doesn't say that DV and MPEG-2 sampling are the same. He actually states that "some of the DV recording formats" use 4:1:1 sampling.
Yes, that's correct.

Quote:
But my understanding was that PAL DV uses the same 4:2:0 sampling as MPEG-2. (I think Ivo told me that once.)
Yes, PAL DV uses 4:2:0 sampling. But that uses a different sampling as MPEG-2. His figure 3 is how PAL-DV is sampled.

Quote:
The description of MPEG-1 sampling is not necessarily wrong if he's talking about interlaced sampling (although we know that MPEG-1 is strictly progressive).
Well, he talks about field based sampling. afaik the Cb and Cr samples have the same placement (indeed between the luma samples), not a different one as he suggests. The placement is between *four* luma samples and not between two as his diagram suggests.

edit: sorry for the double posting, something went wrong
Wilbert is offline   Reply With Quote
Old 11th January 2005, 17:21   #17  |  Link
fccHandler
Registered Jedi
 
Join Date: Jan 2003
Location: Georgia, U.S.A.
Posts: 734
Quote:
Originally posted by Wilbert
afaik the Cb and Cr samples have the same placement (indeed between the luma samples), not a different one as he suggests.
But maybe that's what the term "4:2:0" really means. For every 4 Y samples, there are either 2 Cr samples, or 2 Cb samples (but never both). Hence the zero component. The impression I get is that historically Cr and Cb were sampled at different locations when the term was coined.
__________________
May the FOURCC be with you...
fccHandler is offline   Reply With Quote
Old 11th January 2005, 23:50   #18  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,607
uhm. I've gotten some kind of flash in my mind while reading your post, fcchandler!

SECAM!

SECAM is a color-system that is based on the 625-lines 50 Hertz blackwhite television (the same like PAL is based on)

BUT SECAM is transferring its chroma components sequential, which means:
every even (big assumption!) line of a FIELD transfers the U
and every odd line of a FIELD transfers the V

this is exactly, how the chroma sampling of 'PAL'-DV works.

knows the devil why... I am afraid!

but maybe I am way to tired and throwed some (mis)information together...
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 11th January 2005, 23:53   #19  |  Link
Leak
ffdshow/AviSynth wrangler
 
Leak's Avatar
 
Join Date: Feb 2003
Location: Austria
Posts: 2,441
Quote:
Originally posted by scharfis_brain
this is exactly, how the chroma sampling of 'PAL'-DV works.

knows the devil why... I am afraid!
Developed mainly by French companies? They're using SECAM, after all...

np: Keishi Urata - Mischievous Voices (Texhnolyze OST The Man Of Men)
Leak is offline   Reply With Quote
Old 12th January 2005, 00:21   #20  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,607
I really doubt that. Both assumptions.
(But I am not absolutely sure about them)

SECAM is NOT a production format. It is a broadcast format.

This means: Production is done on very common 625-50 Equipment with 4:4:4 or at least 4:2:2 subsampling.
no color encoding scheme like pal or secam is used here.

the format-encoding (PAL,SECAM,NTSC) is the very last step of this

production -> storing -> delivering -> encoding & brodcasting

chain.

the encoding is done withing the broadcasting station.
or the signal comes preprocessed to the broadcasting station.
but the encoder is feed with a component YUV analogue signal.

so noone in production works with composite video signals like SECAM, PAL or NTSC.
It's all YUV.
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:08.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.