Surface.cs 1.3 KB

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