mirror of
https://github.com/Gericom/FastVideoDSEncoder.git
synced 2025-06-18 10:45:33 -04:00
31 lines
696 B
C#
31 lines
696 B
C#
using System.Collections.Generic;
|
|
|
|
namespace Gericom.FastVideoDS.Frames
|
|
{
|
|
public class FramePool
|
|
{
|
|
private readonly Queue<Rgb555Frame> _pool = new();
|
|
|
|
public readonly int Width;
|
|
public readonly int Height;
|
|
|
|
public FramePool(int width, int height)
|
|
{
|
|
Width = width;
|
|
Height = height;
|
|
}
|
|
|
|
public RefFrame AcquireFrame()
|
|
{
|
|
if (!_pool.TryDequeue(out var frame))
|
|
frame = new Rgb555Frame(Width, Height);
|
|
|
|
return new RefFrame(this, frame);
|
|
}
|
|
|
|
public void ReleaseFrame(RefFrame frame)
|
|
{
|
|
_pool.Enqueue(frame.Frame);
|
|
}
|
|
}
|
|
} |