Surface.cs
 1  using Ryujinx.Graphics.Nvdec.FFmpeg.Native;
 2  using Ryujinx.Graphics.Video;
 3  using System;
 4  
 5  namespace Ryujinx.Graphics.Nvdec.FFmpeg
 6  {
 7      unsafe class Surface : ISurface
 8      {
 9          public AVFrame* Frame { get; }
10  
11          public int RequestedWidth { get; }
12          public int RequestedHeight { get; }
13  
14          public Plane YPlane => new((IntPtr)Frame->Data[0], Stride * Height);
15          public Plane UPlane => new((IntPtr)Frame->Data[1], UvStride * UvHeight);
16          public Plane VPlane => new((IntPtr)Frame->Data[2], UvStride * UvHeight);
17  
18          public FrameField Field => Frame->InterlacedFrame != 0 ? FrameField.Interlaced : FrameField.Progressive;
19  
20          public int Width => Frame->Width;
21          public int Height => Frame->Height;
22          public int Stride => Frame->LineSize[0];
23          public int UvWidth => (Width + 1) >> 1;
24          public int UvHeight => (Height + 1) >> 1;
25          public int UvStride => Frame->LineSize[1];
26  
27          public Surface(int width, int height)
28          {
29              RequestedWidth = width;
30              RequestedHeight = height;
31  
32              Frame = FFmpegApi.av_frame_alloc();
33          }
34  
35          public void Dispose()
36          {
37              FFmpegApi.av_frame_unref(Frame);
38              FFmpegApi.av_free(Frame);
39          }
40      }
41  }