aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs')
-rw-r--r--src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
index d5b51bc2..7f34faa5 100644
--- a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
+++ b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
@@ -11,11 +11,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types
public ArrayPtr<byte> UBuffer;
public ArrayPtr<byte> VBuffer;
- public unsafe Plane YPlane => new Plane((IntPtr)YBuffer.ToPointer(), YBuffer.Length);
- public unsafe Plane UPlane => new Plane((IntPtr)UBuffer.ToPointer(), UBuffer.Length);
- public unsafe Plane VPlane => new Plane((IntPtr)VBuffer.ToPointer(), VBuffer.Length);
+ public readonly unsafe Plane YPlane => new((IntPtr)YBuffer.ToPointer(), YBuffer.Length);
+ public readonly unsafe Plane UPlane => new((IntPtr)UBuffer.ToPointer(), UBuffer.Length);
+ public readonly unsafe Plane VPlane => new((IntPtr)VBuffer.ToPointer(), VBuffer.Length);
- public FrameField Field => FrameField.Progressive;
+ public readonly FrameField Field => FrameField.Progressive;
public int Width { get; }
public int Height { get; }
@@ -27,29 +27,31 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types
public int UvAlignedWidth { get; }
public int UvAlignedHeight { get; }
public int UvStride { get; }
- public bool HighBd => false;
+
+ public bool HighBd { get; }
private readonly IntPtr _pointer;
public Surface(int width, int height)
{
- const int border = 32;
- const int ssX = 1;
- const int ssY = 1;
- const bool highbd = false;
+ HighBd = false;
+
+ const int Border = 32;
+ const int SsX = 1;
+ const int SsY = 1;
int alignedWidth = (width + 7) & ~7;
int alignedHeight = (height + 7) & ~7;
- int yStride = ((alignedWidth + 2 * border) + 31) & ~31;
- int yplaneSize = (alignedHeight + 2 * border) * yStride;
- int uvWidth = alignedWidth >> ssX;
- int uvHeight = alignedHeight >> ssY;
- int uvStride = yStride >> ssX;
- int uvBorderW = border >> ssX;
- int uvBorderH = border >> ssY;
+ int yStride = ((alignedWidth + 2 * Border) + 31) & ~31;
+ int yplaneSize = (alignedHeight + 2 * Border) * yStride;
+ int uvWidth = alignedWidth >> SsX;
+ int uvHeight = alignedHeight >> SsY;
+ int uvStride = yStride >> SsX;
+ int uvBorderW = Border >> SsX;
+ int uvBorderH = Border >> SsY;
int uvplaneSize = (uvHeight + 2 * uvBorderH) * uvStride;
- int frameSize = (highbd ? 2 : 1) * (yplaneSize + 2 * uvplaneSize);
+ int frameSize = (HighBd ? 2 : 1) * (yplaneSize + 2 * uvplaneSize);
IntPtr pointer = Marshal.AllocHGlobal(frameSize);
_pointer = pointer;
@@ -58,23 +60,23 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types
AlignedWidth = alignedWidth;
AlignedHeight = alignedHeight;
Stride = yStride;
- UvWidth = (width + ssX) >> ssX;
- UvHeight = (height + ssY) >> ssY;
+ UvWidth = (width + SsX) >> SsX;
+ UvHeight = (height + SsY) >> SsY;
UvAlignedWidth = uvWidth;
UvAlignedHeight = uvHeight;
UvStride = uvStride;
- ArrayPtr<byte> NewPlane(int start, int size, int border)
+ ArrayPtr<byte> NewPlane(int start, int size, int planeBorder)
{
- return new ArrayPtr<byte>(pointer + start + border, size - border);
+ return new ArrayPtr<byte>(pointer + start + planeBorder, size - planeBorder);
}
- YBuffer = NewPlane(0, yplaneSize, (border * yStride) + border);
+ YBuffer = NewPlane(0, yplaneSize, (Border * yStride) + Border);
UBuffer = NewPlane(yplaneSize, uvplaneSize, (uvBorderH * uvStride) + uvBorderW);
VBuffer = NewPlane(yplaneSize + uvplaneSize, uvplaneSize, (uvBorderH * uvStride) + uvBorderW);
}
- public void Dispose()
+ public readonly void Dispose()
{
Marshal.FreeHGlobal(_pointer);
}