YUV420P & YV12

YUV

YUV is a color space typically used as part of a color image pipeline. It encodes a color image or video taking human perception into account, allowing reduced bandwidth for chrominance components, thereby typically enabling transmission errors or compression artifacts to be more efficiently masked by the human perception than using a "direct" RGB-representation.

  • YUV是一種色彩空間模型.
  • YUV比RGB更節(jié)省帶寬.

The Y′UV model defines a color space in terms of one luma (Y′) and two chrominance (UV) components.
The Y′UV color model is used in the PAL and SECAM composite color video standards.
Previous black-and-white systems used only luma (Y′) information.
Color information (U and V) was added separately via a sub-carrier so that a black-and-white receiver would still be able to receive and display a color picture transmission in the receiver's native black-and-white format.

  • YUV也是為了兼容黑白電視等, 黑白電視只顯示Y分量(亮度)即可.

YUV420P & YV12

  • YUV420P

Y′UV420p is a planar format, meaning that the Y′, U, and V values are grouped together instead of interspersed(分散).
The reason for this is that by grouping the U and V values together, the image becomes much more compressible. When given an array of an image in the Y′UV420p format, all the Y′ values come first, followed by all the U values, followed finally by all the V values.

存放順序: Y->U->V.

  • YV12

The Y′V12 format is essentially the same as Y′UV420p, but it has the U and V data switched: the Y′ values are followed by the V values, with the U values last. As long as care is taken to extract U and V values from the proper locations, both Y′UV420p and Y′V12 can be processed using the same algorithm.

All of the Y samples appear first in memory as an array of unsigned char values. This array is followed immediately by all of the V (Cr) samples. The stride of the V plane is half the stride of the Y plane, and the V plane contains half as many lines as the Y plane. The V plane is followed immediately by all of the U (Cb) samples, with the same stride and number of lines as the V plane (Figure 12).
Figure 12:


YV12

存放順序: Y->V->U.
YUV420P & YV12可用相同的算法進(jìn)行處理.

As with most Y′UV formats, there are as many Y′ values as there are pixels. Where X equals the height multiplied by the width, the first X indices in the array are Y′ values that correspond to each individual pixel. However, there are only one fourth as many U and V values. The U and V values correspond to each 2 by 2 block of the image, meaning each U and V entry applies to four pixels. After the Y′ values, the next X/4 indices are the U values for each 2 by 2 block, and the next X/4 indices after that are the V values that also apply to each 2 by 2 block.

As shown in the above image, the Y′, U and V components in Y′UV420 are encoded separately in sequential blocks. A Y′ value is stored for every pixel, followed by a U value for each 2×2 square block of pixels, and finally a V value for each 2×2 block. Corresponding Y′, U and V values are shown using the same color in the diagram above. Read line-by-line as a byte stream from a device, the Y′ block would be found at position 0, the U block at position x×y (6×4 = 24 in this example) and the V block at position x×y + (x×y)/4 (here, 6×4 + (6×4)/4 = 30).

每個(gè)像素點(diǎn)會(huì)存儲(chǔ)一個(gè)Y值.
圖中的Y1 Y2 Y7 Y8 + U1 + V1是一組.
可以看出采樣點(diǎn)比例其實(shí)是4:1:1. (其實(shí)叫420是歷史原因)

References:
https://en.wikipedia.org/wiki/YUV#cite_note-13
https://en.wikipedia.org/wiki/YUV
https://msdn.microsoft.com/en-us/library/aa904813

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末菌湃,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子智玻,更是在濱河造成了極大的恐慌萌京,老刑警劉巖祈噪,帶你破解...
    沈念sama閱讀 217,826評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件熊昌,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡嗓节,警方通過查閱死者的電腦和手機(jī)勿锅,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,968評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門帕膜,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人溢十,你說我怎么就攤上這事垮刹。” “怎么了张弛?”我有些...
    開封第一講書人閱讀 164,234評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵荒典,是天一觀的道長。 經(jīng)常有香客問我吞鸭,道長寺董,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,562評(píng)論 1 293
  • 正文 為了忘掉前任刻剥,我火速辦了婚禮遮咖,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘造虏。我一直安慰自己御吞,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,611評(píng)論 6 392
  • 文/花漫 我一把揭開白布漓藕。 她就那樣靜靜地躺著陶珠,像睡著了一般。 火紅的嫁衣襯著肌膚如雪享钞。 梳的紋絲不亂的頭發(fā)上揍诽,一...
    開封第一講書人閱讀 51,482評(píng)論 1 302
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼寝姿。 笑死交排,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的饵筑。 我是一名探鬼主播,決...
    沈念sama閱讀 40,271評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼处坪,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼根资!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起同窘,我...
    開封第一講書人閱讀 39,166評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤玄帕,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后想邦,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體裤纹,經(jīng)...
    沈念sama閱讀 45,608評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,814評(píng)論 3 336
  • 正文 我和宋清朗相戀三年丧没,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了鹰椒。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,926評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡呕童,死狀恐怖漆际,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情夺饲,我是刑警寧澤奸汇,帶...
    沈念sama閱讀 35,644評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站往声,受9級(jí)特大地震影響擂找,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜浩销,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,249評(píng)論 3 329
  • 文/蒙蒙 一贯涎、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧撼嗓,春花似錦柬采、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,866評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至斑芜,卻和暖如春肩刃,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,991評(píng)論 1 269
  • 我被黑心中介騙來泰國打工盈包, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留沸呐,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,063評(píng)論 3 370
  • 正文 我出身青樓呢燥,卻偏偏與公主長得像崭添,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子叛氨,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,871評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容