// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using osu.Framework.Graphics.Textures; using osuTK.Graphics.ES30; using FFmpeg.AutoGen; using osu.Framework.Graphics.Primitives; using SixLabors.ImageSharp.PixelFormats; namespace osu.Framework.Graphics.Video { public sealed unsafe class VideoTextureUpload : ITextureUpload { public readonly AVFrame* Frame; private readonly FFmpegFuncs.AvFrameFreeDelegate freeFrameDelegate; public ReadOnlySpan Data => ReadOnlySpan.Empty; public int Level => 0; public RectangleI Bounds { get; set; } public PixelFormat Format => PixelFormat.Red; /// /// Sets the frame containing the data to be uploaded. /// /// The frame to upload. /// A function to free the frame on disposal. internal VideoTextureUpload(AVFrame* frame, FFmpegFuncs.AvFrameFreeDelegate freeFrameDelegate) { Frame = frame; this.freeFrameDelegate = freeFrameDelegate; } #region IDisposable Support public void Dispose() { fixed (AVFrame** ptr = &Frame) freeFrameDelegate(ptr); } #endregion } }