View Full Version : Colorspace packing formats
Cyberia
9th January 2005, 23:34
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?
Wilbert
10th January 2005, 00:04
http://www.avisynth.org/ColorSpaces
http://www.avisynth.org/Sampling
and all links in http://www.avisynth.org/PlanarImageFormat
stickboy
10th January 2005, 00:07
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 (http://www.mir.com/DMG/chroma.html)
Cyberia
10th January 2005, 00:12
Ah, got it. Thanks
Schlumpf
10th January 2005, 12:07
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.
stephanV
10th January 2005, 12:28
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.
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. :)
Wilbert
10th January 2005, 13:07
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?
stephanV
10th January 2005, 13:42
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. :)
Wilbert
10th January 2005, 14:13
- 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.
[edit]from my conclusion, you could say that 4:4:4 is the same as 4:4:0... although that probably doesnt excist
Hmm :confused:
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 :)
stephanV
10th January 2005, 14:31
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! :)
fccHandler
10th January 2005, 17:27
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/Tech-Corner/f-RH-4.2.2-07.10.02.shtml
http://forum.matrox.com/rt2000/Forum8/HTML/000052.html
stephanV
10th January 2005, 18:01
heh
thx :)
Wilbert
10th January 2005, 18:10
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
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,
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.
if you know something better or have a different idea, please share!
I don't have anything better :)
fccHandler
11th January 2005, 03:56
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.
Wilbert
11th January 2005, 09:52
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.
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.
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
11th January 2005, 09:53
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.
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.
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 :)
fccHandler
11th January 2005, 17:21
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.
scharfis_brain
11th January 2005, 23:50
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...
Leak
11th January 2005, 23:53
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)
scharfis_brain
12th January 2005, 00:21
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.
Leak
12th January 2005, 00:26
Originally posted by scharfis_brain
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.
Aren't we talking about consumer-grade, not professional DV cams here? Saves you the colorspace format conversion if you want to output a RF signal... :p
(Yeah, it's getting late, and I'm getting dumb. Deal with it. :))
np: K-Taro Takanami - Play In The Early Afternoon (Chobits Original Soundtrack 001)
Wilbert
12th January 2005, 01:03
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.
Weird. I didn't believe this at first, because i thought SECAM is "4:2:2" too (meaning luma = 13.5 MHz and both chroma channels = 6.75 Mhz). But when I was reading "Video Demystified by Keith Jack", I saw that scharfis_brain is right. I still don't understand it. Has SECAM less chroma than PAL/NTSC :confused:
Note, it is actually not alternating U and V, but alternating Db and Dr (which are scaled versions of U and V).
so noone in production works with composite video signals like SECAM, PAL or NTSC. It's all YUV.
Well, PAL is YUV, NTSC is YIQ (the IQ and UV planes are rotations of each other) and SECAM is YDbDr.
scharfis_brain
12th January 2005, 06:35
Well, PAL is YUV, NTSC is YIQ (the IQ and UV planes are rotations of each other) and SECAM is YDbDr.
This is what the encoder will make out of the YUV that is used while the production.
So, one can 'easily' use common eqipment for all TV-Standards, because it is only the encoder, that has to care about chroma, modulation and such things.
Weird. I didn't believe this at first, because i thought SECAM is "4:2:2" too (meaning luma = 13.5 MHz and both chroma channels = 6.75 Mhz). But when I was reading "Video Demystified by Keith Jack", I saw that scharfis_brain is right. I still don't understand it. Has SECAM less chroma than PAL/NTSC
Not really true.
Fully implemented PAL-Decoders will drop the vertical chroma resolution down to the SECAM level.
This is, what the delay-line does!
But some TV-Cards didn't use that 'feature' of PAL
So one was getting the full 4:2:2 resolution at the cost of PAL-lines when phase-errors occured.
only NTSC is able to transfer full vertical chroma detail at the cost of miscoloration.
hanfrunz
19th January 2005, 21:12
Hello everyone,
everybody, who is realy interested in digital video should read this book:
http://www.amazon.com/exec/obidos/tg/detail/-/1558607927/qid=1106165382/sr=8-1/ref=pd_csp_1/102-8262083-1756945?v=glance&s=books&n=507846
I read a lot of books about video, but this is the only one i trust. Charles Poynton realy knows his stuff!!!
So get it!
hanfrunz
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.