Surface.cs 975 B

123456789101112131415161718192021222324252627282930313233
  1. using FFmpeg.AutoGen;
  2. using Ryujinx.Graphics.Video;
  3. using System;
  4. namespace Ryujinx.Graphics.Nvdec.H264
  5. {
  6. unsafe class Surface : ISurface
  7. {
  8. public AVFrame* Frame { get; }
  9. public Plane YPlane => new Plane((IntPtr)Frame->data[0], Stride * Height);
  10. public Plane UPlane => new Plane((IntPtr)Frame->data[1], UvStride * UvHeight);
  11. public Plane VPlane => new Plane((IntPtr)Frame->data[2], UvStride * UvHeight);
  12. public int Width => Frame->width;
  13. public int Height => Frame->height;
  14. public int Stride => Frame->linesize[0];
  15. public int UvWidth => (Frame->width + 1) >> 1;
  16. public int UvHeight => (Frame->height + 1) >> 1;
  17. public int UvStride => Frame->linesize[1];
  18. public Surface()
  19. {
  20. Frame = ffmpeg.av_frame_alloc();
  21. }
  22. public void Dispose()
  23. {
  24. ffmpeg.av_frame_unref(Frame);
  25. ffmpeg.av_free(Frame);
  26. }
  27. }
  28. }