Surface.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using FFmpeg.AutoGen;
  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 int Width => Frame->width;
  15. public int Height => Frame->height;
  16. public int Stride => Frame->linesize[0];
  17. public int UvWidth => (Frame->width + 1) >> 1;
  18. public int UvHeight => (Frame->height + 1) >> 1;
  19. public int UvStride => Frame->linesize[1];
  20. public Surface(int width, int height)
  21. {
  22. RequestedWidth = width;
  23. RequestedHeight = height;
  24. Frame = ffmpeg.av_frame_alloc();
  25. }
  26. public void Dispose()
  27. {
  28. ffmpeg.av_frame_unref(Frame);
  29. ffmpeg.av_free(Frame);
  30. }
  31. }
  32. }