Example 2.13. V4L2_PIX_FMT_YUYV 4 × 4 pixelimagehtml
start + 0:linux |
Y'00spa |
Cb00.net |
Y'01htm |
Cr00blog |
Y'02ip |
Cb01get |
Y'03string |
Cr01it |
start + 8: |
Y'10 |
Cb10 |
Y'11 |
Cr10 |
Y'12 |
Cb11 |
Y'13 |
Cr11 |
start + 16: |
Y'20 |
Cb20 |
Y'21 |
Cr20 |
Y'22 |
Cb21 |
Y'23 |
Cr21 |
start + 24: |
Y'30 |
Cb30 |
Y'31 |
Cr30 |
Y'32 |
Cb31 |
Y'33 |
Cr31 |
YUV422碼流存放位置
(轉自http://www.chineselinuxuniversity.net/kerneldocs/media/V4L2-PIX-FMT-YUYV.html)
Example 2.18. V4L2_PIX_FMT_YUV420 4 × 4 pixelimage
start + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
start + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
start + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
start + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
start + 16: |
Cb00 |
Cb01 |
|
|
start + 18: |
Cb10 |
Cb11 |
|
|
start + 20: |
Cr00 |
Cr01 |
|
|
start + 22: |
Cr10 |
Cr11 |
|
|
|
|
|
|
|
YUV420碼流存放位置
(轉自http://www.chineselinuxuniversity.net/kerneldocs/media/re18.html該處是YVU420)
這裏要順帶提一下YUV444,既無損YUV色彩空間.一個Y帶一個Cb一個Cr,即YCbCr.
YUV422採樣即從YUV444基礎上,從第一個Y開始只保留Cb,剔去Cr,第二個Y只保留Cr剔去Cb…...這樣交替採樣,長度大小爲width*height*2,Y:U:V=4:2:2,一個色彩份量佔一個字節.
而YUV420即從YUV422基礎上進行隔行採樣,例如第一行只保留Cb,第二行只保留Cr……這樣交替進行,Y:U:V=4:2:0並非沒有V份量,也能夠是Y:U:V=4:0:2.相信這樣你們容易理解.最後在這個基礎上,把Y,U,V三種份量打包排列,即如上圖,長度大小爲width*height*3/2.
說了這麼多,是時候貼上具體代碼.