Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NV12 format and UV plane

i am a little confused about the NV12 format. i am looking the this page to understand the format. What i currently understand is that if you have an image or video of 640 x 480 diminsion then the Y plane will be having 640 x 480 bytes and U and V both planes have 640/2 x 480/2. It does not mean that U plane have 640/2 x 480/2 and V plane have 640/2 x 480/2 both have only 640/2 x 480/2 bytes. so the total number of bytes in out buffer array will be. 2 is multiplied with (640/2) * (480/2) because uv plane will take two bytes.

byte [] myArray new byte[(640 * 480) + (2 * (640/2) * (480/2)) ];

so the question is that i am understanding it in a right way? and am i making the byte array in the format that specify the NV12 format.

like image 284
Madu Avatar asked Jul 05 '13 10:07

Madu


2 Answers

The NV12 format is subsampled as 4:2:0

420

The total size of a frame is W x H x 3 / 2 Where W is width and H is height.

1 frame in vga resolution is 460800 bytes, where

  • Y-part is 640x480 bytes
  • Cb-part is 640*480/4=76800 bytes
  • Cr-part is 640*480/4=76800 bytes

Hope this answers your question...

like image 99
Fredrik Pihl Avatar answered Nov 19 '22 21:11

Fredrik Pihl


To add to the first answer, the NV12 format interleaves the U and V chroma data.

For a 640x480 image frame, the NV12 representation consists of 720 rows of 640 bytes:

  • the first 480 rows each contain 640 luminance (Y) values.

  • the last 240 rows each contain 320 tuples of (U,V) values.

like image 41
Hugues Avatar answered Nov 19 '22 20:11

Hugues