Questions tagged [nv12-nv21]

Use for questions relating to the NV12 and NV21 YUV formats. Also known as YCbCr.

NV12 and NV21

NV12 and NV21 are standards for YUV420 elements ordering.

libyuv description:

NV12 is a biplanar format with a full sized Y plane followed by a single chroma plane with weaved U and V values. NV21 is the same but with weaved V and U values. The 12 in NV12 refers to 12 bits per pixel. NV12 has a half width and half height chroma channel, and therefore is a 420 subsampling.

In context of NV12/NV21, YUV format is mainly referred to as YCbCr.

NV12 and NV21 are detailed by FOURCC standard:

VideoLAN description: NV12/NV21

Microsoft description: NV12

NV12 element ordering example (each element is one byte): YYYYYY
YYYYYY
UVUVUV

NV12

NV21 element ordering example:
YYYYYY
YYYYYY
VUVUVU

33 questions
35
votes
2 answers

Confusion on YUV NV21 conversion to RGB

According to http://developer.android.com/reference/android/graphics/ImageFormat.html#NV21, NV21 is the default used format. There are quite a number of code on web regarding YUV NV21 to RGB conversion. However, when I go through the code, I doubt…
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
15
votes
1 answer

Image formats NV12 storage in memory

I am totally understand about the size of the NV12 format as described in question NV12 format and UV plane Now I am reading from two sources about the storage of UV plane in this format: one is…
Manish Kumar
  • 1,419
  • 3
  • 17
  • 36
9
votes
3 answers

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…
Madu
  • 4,849
  • 9
  • 44
  • 78
8
votes
1 answer

How to convert sRGB to NV12 format using NumPy?

NV12 format defines specific color channels ordering of YUV color space with 420 subsampling. NV12 format is mostly used in video encoding/decoding pipeline. libyuv description of NV12: NV12 is a biplanar format with a full sized Y plane…
Rotem
  • 30,366
  • 4
  • 32
  • 65
7
votes
1 answer

NV21 format and odd image dimensions

I have been working for some time with NV21 images in Android and I have been tracking a bug that might be caused by incorrect indexing bytes in an NV21 image. The image in the answer of this question has a nice overview of how the Y, U and V bytes…
silvaren
  • 730
  • 6
  • 14
5
votes
1 answer

How to convert RGB to NV12 color space using IPP

Video encoders like Intel® Media SDK require NV12 video input format. NV12 format is YUV 4:2:0 format ordered in memory with a Y plane first, followed by packed chroma samples in interleaved UV plane. Example: YYYYYY YYYYYY UVUVUV RGB color…
Rotem
  • 30,366
  • 4
  • 32
  • 65
4
votes
0 answers

Android : how to convert back openCV Mat to byte array NV21?

On Android , I use MediaCodec to create mp4 video file from captured images. I am getting the OpenCV Mat data using Image i = reader.acquireLatestImage(); ByteBuffer byteBuffer = i.getPlanes()[0].getBuffer(); byte[] bytes = new…
kfir
  • 635
  • 8
  • 27
4
votes
1 answer

How to convert RGBA to NV12 using OpenGL?

I need to convert RGBA to NV12 using OpenGL shader as encoder input. Already have render two different fragment shaders, both textures are from one camera . Using v4l2 to get the camera image(YUV). Then, convert YUV to RGB let OpenGL render. The…
Julia Ding
  • 173
  • 16
3
votes
1 answer

How to convert 8 bits Grayscale image to NV12 (limited range) color space using IPP

Video encoders like Intel® Media SDK do not accept 8 bits Grayscale image as input format. 8 bits Grayscale format applies one byte per pixel in range [0, 255]. 8 bits YUV format in the context of the question applies YCbCr (BT.601 or…
Rotem
  • 30,366
  • 4
  • 32
  • 65
2
votes
1 answer

How to do fast memory copy from YUV_420_888 to NV21

Refer to this post, I want to write a method converting android YUV_420_888 to nv21. A more general implementation is needed although image from camera2 API is default NV21 in disguise. It is as follows: class NV21Image{ public byte[] y; public…
Finley
  • 795
  • 1
  • 8
  • 26
2
votes
1 answer

How does the canvas drawImage function convert YUV to sRGB

I work with webcodecs and have found that when I manually convert an NV12 format to an RGB format, I get slightly different values than if I simply write the VideoFrame to a canvas and read the imageData. The ImageData from the Canvas [87, 87, 39,…
2
votes
1 answer

Converting image from YV12 to NV12 with OpenCV

I have a webcam from which I read frames in NV12 format. I convert the frames to RGB, then to YV12, and my goal is to convert them back to NV12, for verification purposes. I am doing something like this: cv::cvtColor(InputFrame, InputRGB,…
b20000
  • 995
  • 1
  • 12
  • 30
2
votes
1 answer

How to convert Bitmap to nv21 byte[] array in android

I I have tried this method to convert but result image is getting currupted ByteArrayOutputStream outputStream=new ByteArrayOutputStream(); scaled.compress(Bitmap.CompressFormat.JPEG,100, outputStream); byte [] bytes…
Santhosh M
  • 21
  • 3
2
votes
2 answers

NV12 Format support in Bitmapimage C#

Does BitmapImage or WriteableBitmapImage supports NV12 format. or Can we create a BitmapImage or WriteableBitmapImage from a byte array which is arranged in NV12 format? Thanks
Madu
  • 4,849
  • 9
  • 44
  • 78
1
vote
1 answer

Capture full-range/lossless rgb frame from capture card that supports NV12 and YUYV output

I am trying to make a program which captures an image, then i need to compare captured image and the input data which i displayed, both should matc pixel by pixel Here are the details of my capture card $ v4l2-ctl --list-formats-ext -d…
1
2 3