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

2

14

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?

India answered 5/10, 2012 at 15:1 Comment(0)
W
6

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.

Watchful answered 18/10, 2012 at 13:5 Comment(1)
Thanks! That is what I was looking for. I wonder why VideoLAN doesn't just expose that function in LibVLC...India
C
0

The setup callback (2nd parameter of libvlc_video_set_format_callbacks(), of type libvlc_video_format_cb) allows you to read and, optionally, change the video format.

If this callback gets a format that it doesn't understand, it can just change it to one that it knows.

Claw answered 17/10, 2012 at 21:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.