Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I determine the number of planes and bytes per pixel of a certain chroma?

Tags:

c

video

vlc

libvlc

I am using LibVLC and want to render the video pixels in memory so I will be able to take a snapshot of a frame without getting the video drawn in a window (as is the default).

If I understand correctly, this can be achieved by calling libvlc_video_set_callbacks and libvlc_video_set_format_callbacks. In the first function I have to specify a callback of type libvlc_video_lock_cb, in which I will have to initialize one of three planes, which I understand are buffers in which pixels will be drawn.

My problem is that the number of bytes that is being used per pixel, as well as the number of planes that have to be initialized, depend on the video chroma. While I know how to obtain a four-letter identifier of this chroma, I have no idea how to obtain these particular properties of it; and without that information, I do not know what size the buffers I have to allocate need to be, and how many planes there are.

Does anyone know how to do this? Or am I understanding something incorrectly?

like image 990
AardvarkSoup Avatar asked Oct 05 '12 15:10

AardvarkSoup


1 Answers

As you noted, the bytes per pixel and number of planes are codec dependent. So one option is to hard code the values for the current options (GREY, I240, RV16, RV15, RV24, RV32, YUY2, YUYV, UYVY, I41N, I422, I420, I411, I410, MJPG) in your code.

Go to http://www.fourcc.org/ for detailed code/formats information.

You can also have a look at vlc_fourcc.h and fourcc.c from the VLC project. Specifically see the function vlc_fourcc_GetChromaDescription.

like image 153
amotzg Avatar answered Oct 23 '22 17:10

amotzg