NV12 format and UV plane

Madu picture Madu · Jul 5, 2013 · Viewed 9.6k times · Source

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.

Answer

Fredrik Pihl picture Fredrik Pihl · Jul 7, 2013

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...