aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Nvdec/Image/SurfaceCommon.cs
blob: 14bc113f59227450f1df6dafedd47c34be9ee18c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using Ryujinx.Graphics.Texture;
using Ryujinx.Graphics.Video;
using System;

namespace Ryujinx.Graphics.Nvdec.Image
{
    static class SurfaceCommon
    {
        public static int GetBlockLinearSize(int width, int height, int bytesPerPixel)
        {
            return SizeCalculator.GetBlockLinearTextureSize(width, height, 1, 1, 1, 1, 1, bytesPerPixel, 2, 1, 1).TotalSize;
        }

        public static void Copy(ISurface src, ISurface dst)
        {
            src.YPlane.AsSpan().CopyTo(dst.YPlane.AsSpan());
            src.UPlane.AsSpan().CopyTo(dst.UPlane.AsSpan());
            src.VPlane.AsSpan().CopyTo(dst.VPlane.AsSpan());
        }

        public unsafe static Span<byte> AsSpan(this Plane plane)
        {
            return new Span<byte>((void*)plane.Pointer, plane.Length);
        }
    }
}