Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
VideoDecodeBuffer.cs
1using System.Runtime.InteropServices;
2
3namespace Gondwana.Video;
4
5// One allocation per negotiated format, owned until LibVLC calls format cleanup.
6internal sealed unsafe class VideoDecodeBuffer : IDisposable
7{
8 internal int Width { get; }
9 internal int Height { get; }
10 internal int Stride { get; }
11 internal int Lines { get; }
12 internal IntPtr Pixels { get; private set; }
13 internal VideoDecodeBuffer(int width, int height)
14 {
15 if (width <= 0 || height <= 0) throw new ArgumentOutOfRangeException(nameof(width));
16 Width = width;
17 Height = height;
18 Stride = checked((checked(width * 4) + 31) & ~31);
19 Lines = checked((height + 31) & ~31);
20 int bytes = checked(Stride * Lines);
21 Pixels = (IntPtr)NativeMemory.AlignedAlloc((nuint)bytes, 32);
22 if (Pixels == IntPtr.Zero) throw new OutOfMemoryException();
23 NativeMemory.Clear((void*)Pixels, (nuint)bytes);
24 }
25
29 public void Dispose()
30 {
31 if (Pixels == IntPtr.Zero) return;
32 NativeMemory.AlignedFree((void*)Pixels);
33 Pixels = IntPtr.Zero;
34 }
35}