I am trying to integrate LibVLCSharp in to my game engine built using MonoGame.
I have gotten it to render and gotten decent results using
_mediaPlayer.SetVideoFormat("RGBA", _width, _height, stride);
_mediaPlayer.SetVideoCallbacks(LockCb, null, DisplayCb);
Unfortunately, it's not quite good enough. Until now I have been using another library for videos called Theora Playback Library (https://www.cateia.com/libtheoraplayer/wiki/index.php?title=Main_Page). With it we are getting very smooth video playback, but we are trying to move our engine to 64bit and this library doesn't have that capability.
Looking at the source for TPL, I see it is decoding video frames to I420 buffers then converting them to RGBA. I wanted to see if doing the same thing with LibVLCSharp would improve playback performance but I've hit a snag.
The buffer for a I420 frame requires 3 picture buffers but the delegate signature for LibVLCVideoFormatCb doesn't appear to allow you to define that.
The libVLC documentation says that both lines and pitches are tables that should allow you to set the pitch and lines for each picture buffer
pitches: table of scanline pitches in bytes for each pixel plane (the table is allocated by LibVLC) [OUT]
lines: table of scanlines count for each plane [OUT]
but in LibVLCSharp pitches and lines are both uint so I can only set 1 value when I need to set 3.
public delegate uint LibVLCVideoFormatCb(
ref IntPtr opaque,
IntPtr chroma,
ref uint width,
ref uint height,
ref uint pitches,
ref uint lines);
Is there a way to define the format of an I420 buffer with the existing signature or is there another way entirely to get the decoded I420 frame data for each frame that I'm not doing?