[Ryujinx.Graphics.Nvdec.Vp9] Address dotnet-format issues (#5371)

* dotnet format style --severity info

Some changes were manually reverted.

* dotnet format analyzers --serverity info

Some changes have been minimally adapted.

* Restore a few unused methods and variables

* Silence dotnet format IDE0060 warnings

* Address or silence dotnet format IDE1006 warnings

* Address most dotnet format whitespace warnings

* Apply dotnet format whitespace formatting

A few of them have been manually reverted and the corresponding warning was silenced

* Add comments to disabled warnings

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* Address IDE0251 warnings

* Address a few disabled IDE0060 warnings

* Silence IDE0060 in .editorconfig

* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"

This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.

* dotnet format whitespace after rebase

* Fix empty lines before return

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Add trailing commas, remove redundant code and remove static modifier from Surface.HighBd

* Fix naming rule violations

* Fix naming rule violations

* Fix empty line before return

* Fix comment style

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Remove comment alignment

* Address review feedback

* Separate comments by 2 spaces and fix other formatting issues

* Make HighBd an auto-property

* Replace if-chain with if-else-chain

* Fix new naming rule violations

---------

Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
TSRBerry
2023-06-28 09:26:39 +02:00
committed by GitHub
parent 9becbd7d72
commit 6aa8d71588
41 changed files with 1240 additions and 1207 deletions

View File

@@ -117,6 +117,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if (Sse41.IsSupported && UseIntrinsics && xStepQ4 == 1 << SubpelBits)
{
ConvolveHorizSse41(src, srcStride, dst, dstStride, xFilters, x0Q4, w, h);
return;
}
@@ -261,6 +262,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if (Avx2.IsSupported && UseIntrinsics && yStepQ4 == 1 << SubpelBits)
{
ConvolveVertAvx2(src, srcStride, dst, dstStride, yFilters, y0Q4, w, h);
return;
}
@@ -776,7 +778,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Debug.Assert(yStepQ4 <= 32);
Debug.Assert(xStepQ4 <= 32);
HighbdConvolveHoriz(src - srcStride * (SubpelTaps / 2 - 1), srcStride, temp, 64, filter, x0Q4, xStepQ4, w, intermediateHeight, bd);
HighbdConvolveHoriz(src - srcStride * (SubpelTaps / 2 - 1), srcStride, temp, 64, filter, x0Q4, xStepQ4, w, intermediateHeight, bd);
HighbdConvolveVert(temp + 64 * (SubpelTaps / 2 - 1), 64, dst, dstStride, filter, y0Q4, yStepQ4, w, h, bd);
}
@@ -811,7 +813,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
int h,
int bd)
{
HighbdConvolveAvgHoriz(src, srcStride, dst, dstStride, filter, x0Q4, xStepQ4, w, h, bd);
HighbdConvolveAvgHoriz(src, srcStride, dst, dstStride, filter, x0Q4, xStepQ4, w, h, bd);
}
public static unsafe void HighbdConvolve8Vert(

View File

@@ -227,7 +227,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
private static unsafe void D135Predictor(byte* dst, int stride, int bs, byte* above, byte* left)
{
int i;
byte* border = stackalloc byte[32 + 32 - 1]; // outer border from bottom-left to top-right
byte* border = stackalloc byte[32 + 32 - 1]; // outer border from bottom-left to top-right
// Dst(dst, stride, bs, bs - 2)[0], i.e., border starting at bottom-left
for (i = 0; i < bs - 2; ++i)
@@ -607,13 +607,13 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Dst(dst, stride, 1, 0) = Dst(dst, stride, 0, 2) = Avg2(b, c);
Dst(dst, stride, 2, 0) = Dst(dst, stride, 1, 2) = Avg2(c, d);
Dst(dst, stride, 3, 0) = Dst(dst, stride, 2, 2) = Avg2(d, e);
Dst(dst, stride, 3, 2) = Avg2(e, f); // Differs from vp8
Dst(dst, stride, 3, 2) = Avg2(e, f); // Differs from vp8
Dst(dst, stride, 0, 1) = Avg3(a, b, c);
Dst(dst, stride, 1, 1) = Dst(dst, stride, 0, 3) = Avg3(b, c, d);
Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 3) = Avg3(c, d, e);
Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 3) = Avg3(d, e, f);
Dst(dst, stride, 3, 3) = Avg3(e, f, g); // Differs from vp8
Dst(dst, stride, 3, 3) = Avg3(e, f, g); // Differs from vp8
}
public static unsafe void D63ePredictor4x4(byte* dst, int stride, byte* above, byte* left)
@@ -655,7 +655,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Dst(dst, stride, 3, 0) = Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 2) = Dst(dst, stride, 0, 3) = Avg3(d, e, f);
Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 2) = Dst(dst, stride, 1, 3) = Avg3(e, f, g);
Dst(dst, stride, 3, 2) = Dst(dst, stride, 2, 3) = Avg3(f, g, h);
Dst(dst, stride, 3, 3) = h; // differs from vp8
Dst(dst, stride, 3, 3) = h; // differs from vp8
}
public static unsafe void D45ePredictor4x4(byte* dst, int stride, byte* above, byte* left)
@@ -935,7 +935,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
private static unsafe void HighbdD135Predictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
{
int i;
ushort* border = stackalloc ushort[32 + 32 - 1]; // Outer border from bottom-left to top-right
ushort* border = stackalloc ushort[32 + 32 - 1]; // Outer border from bottom-left to top-right
// Dst(dst, stride, bs, bs - 2)[0], i.e., border starting at bottom-left
for (i = 0; i < bs - 2; ++i)
@@ -1281,13 +1281,13 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Dst(dst, stride, 1, 0) = Dst(dst, stride, 0, 2) = Avg2(b, c);
Dst(dst, stride, 2, 0) = Dst(dst, stride, 1, 2) = Avg2(c, d);
Dst(dst, stride, 3, 0) = Dst(dst, stride, 2, 2) = Avg2(d, e);
Dst(dst, stride, 3, 2) = Avg2(e, f); // Differs from vp8
Dst(dst, stride, 3, 2) = Avg2(e, f); // Differs from vp8
Dst(dst, stride, 0, 1) = Avg3(a, b, c);
Dst(dst, stride, 1, 1) = Dst(dst, stride, 0, 3) = Avg3(b, c, d);
Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 3) = Avg3(c, d, e);
Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 3) = Avg3(d, e, f);
Dst(dst, stride, 3, 3) = Avg3(e, f, g); // Differs from vp8
Dst(dst, stride, 3, 3) = Avg3(e, f, g); // Differs from vp8
}
public static unsafe void HighbdD45Predictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
@@ -1306,7 +1306,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Dst(dst, stride, 3, 0) = Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 2) = Dst(dst, stride, 0, 3) = Avg3(d, e, f);
Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 2) = Dst(dst, stride, 1, 3) = Avg3(e, f, g);
Dst(dst, stride, 3, 2) = Dst(dst, stride, 2, 3) = Avg3(f, g, h);
Dst(dst, stride, 3, 3) = h; // Differs from vp8
Dst(dst, stride, 3, 3) = h; // Differs from vp8
}
public static unsafe void HighbdD117Predictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)

View File

@@ -35,6 +35,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
// of this range for invalid/corrupt VP9 streams.
Debug.Assert(short.MinValue <= input);
Debug.Assert(input <= short.MaxValue);
return input;
}
@@ -70,6 +71,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
public static byte ClipPixelAdd(byte dest, long trans)
{
trans = WrapLow(trans);
return BitUtils.ClipPixel(dest + (int)trans);
}
@@ -77,6 +79,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
public static ushort HighbdClipPixelAdd(ushort dest, long trans, int bd)
{
trans = HighbdWrapLow(trans, bd);
return BitUtils.ClipPixelHighbd(dest + (int)trans, bd);
}
@@ -84,6 +87,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
private static long DctConstRoundShift(long input)
{
long rv = BitUtils.RoundPowerOfTwo(input, DctConstBits);
return rv;
}
@@ -115,8 +119,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
op[1] = WrapLow(b1);
op[2] = WrapLow(c1);
op[3] = WrapLow(d1);
ip = ip.Slice(4);
op = op.Slice(4);
ip = ip[4..];
op = op[4..];
}
Span<int> ip2 = output;
@@ -138,8 +142,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[stride * 2] = ClipPixelAdd(dest[stride * 2], WrapLow(c1));
dest[stride * 3] = ClipPixelAdd(dest[stride * 3], WrapLow(d1));
ip2 = ip2.Slice(1);
dest = dest.Slice(1);
ip2 = ip2[1..];
dest = dest[1..];
}
}
@@ -167,8 +171,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[stride * 1] = ClipPixelAdd(dest[stride * 1], e1);
dest[stride * 2] = ClipPixelAdd(dest[stride * 2], e1);
dest[stride * 3] = ClipPixelAdd(dest[stride * 3], e1);
ip2 = ip2.Slice(1);
dest = dest.Slice(1);
ip2 = ip2[1..];
dest = dest[1..];
}
}
@@ -182,7 +186,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if ((x0 | x1 | x2 | x3) == 0)
{
output.Slice(0, 4).Fill(0);
output[..4].Clear();
return;
}
@@ -247,8 +252,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
for (i = 0; i < 4; ++i)
{
Idct4(input, outptr);
input = input.Slice(4);
outptr = outptr.Slice(4);
input = input[4..];
outptr = outptr[4..];
}
// Columns
@@ -282,7 +287,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[1] = ClipPixelAdd(dest[1], a1);
dest[2] = ClipPixelAdd(dest[2], a1);
dest[3] = ClipPixelAdd(dest[3], a1);
dest = dest.Slice(stride);
dest = dest[stride..];
}
}
@@ -300,7 +305,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if ((x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7) == 0)
{
output.Slice(0, 8).Fill(0);
output[..8].Clear();
return;
}
@@ -434,8 +440,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
for (i = 0; i < 8; ++i)
{
Idct8(input, outptr);
input = input.Slice(8);
outptr = outptr.Slice(8);
input = input[8..];
outptr = outptr[8..];
}
// Then transform columns
@@ -464,15 +470,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Span<int> tempIn = stackalloc int[8];
Span<int> tempOut = stackalloc int[8];
output.Fill(0);
output.Clear();
// First transform rows
// Only first 4 row has non-zero coefs
for (i = 0; i < 4; ++i)
{
Idct8(input, outptr);
input = input.Slice(8);
outptr = outptr.Slice(8);
input = input[8..];
outptr = outptr[8..];
}
// Then transform columns
@@ -506,7 +512,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[i] = ClipPixelAdd(dest[i], a1);
}
dest = dest.Slice(stride);
dest = dest[stride..];
}
}
@@ -533,7 +539,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if ((x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 | x13 | x14 | x15) == 0)
{
output.Slice(0, 16).Fill(0);
output[..16].Clear();
return;
}
@@ -860,8 +867,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
for (i = 0; i < 16; ++i)
{
Idct16(input, outptr);
input = input.Slice(16);
outptr = outptr.Slice(16);
input = input[16..];
outptr = outptr[16..];
}
// Then transform columns
@@ -889,15 +896,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Span<int> tempIn = stackalloc int[16];
Span<int> tempOut = stackalloc int[16];
output.Fill(0);
output.Clear();
// First transform rows. Since all non-zero dct coefficients are in
// upper-left 8x8 area, we only need to calculate first 8 rows here.
for (i = 0; i < 8; ++i)
{
Idct16(input, outptr);
input = input.Slice(16);
outptr = outptr.Slice(16);
input = input[16..];
outptr = outptr[16..];
}
// Then transform columns
@@ -925,15 +932,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Span<int> tempIn = stackalloc int[16];
Span<int> tempOut = stackalloc int[16];
output.Fill(0);
output.Clear();
// First transform rows. Since all non-zero dct coefficients are in
// upper-left 4x4 area, we only need to calculate first 4 rows here.
for (i = 0; i < 4; ++i)
{
Idct16(input, outptr);
input = input.Slice(16);
outptr = outptr.Slice(16);
input = input[16..];
outptr = outptr[16..];
}
// Then transform columns
@@ -967,7 +974,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[i] = ClipPixelAdd(dest[i], a1);
}
dest = dest.Slice(stride);
dest = dest[stride..];
}
}
@@ -1365,11 +1372,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
}
else
{
outptr.Slice(0, 32).Fill(0);
outptr[..32].Clear();
}
input = input.Slice(32);
outptr = outptr.Slice(32);
input = input[32..];
outptr = outptr[32..];
}
// Columns
@@ -1397,15 +1404,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Span<int> tempIn = stackalloc int[32];
Span<int> tempOut = stackalloc int[32];
output.Fill(0);
output.Clear();
// Rows
// Only upper-left 16x16 has non-zero coeff
for (i = 0; i < 16; ++i)
{
Idct32(input, outptr);
input = input.Slice(32);
outptr = outptr.Slice(32);
input = input[32..];
outptr = outptr[32..];
}
// Columns
@@ -1433,15 +1440,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Span<int> tempIn = stackalloc int[32];
Span<int> tempOut = stackalloc int[32];
output.Fill(0);
output.Clear();
// Rows
// Only upper-left 8x8 has non-zero coeff
for (i = 0; i < 8; ++i)
{
Idct32(input, outptr);
input = input.Slice(32);
outptr = outptr.Slice(32);
input = input[32..];
outptr = outptr[32..];
}
// Columns
@@ -1476,7 +1483,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[i] = ClipPixelAdd(dest[i], a1);
}
dest = dest.Slice(stride);
dest = dest[stride..];
}
}
@@ -1508,8 +1515,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
op[1] = HighbdWrapLow(b1, bd);
op[2] = HighbdWrapLow(c1, bd);
op[3] = HighbdWrapLow(d1, bd);
ip = ip.Slice(4);
op = op.Slice(4);
ip = ip[4..];
op = op[4..];
}
ReadOnlySpan<int> ip2 = output;
@@ -1531,8 +1538,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[stride * 2] = HighbdClipPixelAdd(dest[stride * 2], HighbdWrapLow(c1, bd), bd);
dest[stride * 3] = HighbdClipPixelAdd(dest[stride * 3], HighbdWrapLow(d1, bd), bd);
ip2 = ip2.Slice(1);
dest = dest.Slice(1);
ip2 = ip2[1..];
dest = dest[1..];
}
}
@@ -1560,8 +1567,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[stride * 1] = HighbdClipPixelAdd(dest[stride * 1], e1, bd);
dest[stride * 2] = HighbdClipPixelAdd(dest[stride * 2], e1, bd);
dest[stride * 3] = HighbdClipPixelAdd(dest[stride * 3], e1, bd);
ip2 = ip2.Slice(1);
dest = dest.Slice(1);
ip2 = ip2[1..];
dest = dest[1..];
}
}
@@ -1576,13 +1583,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if (DetectInvalidHighbdInput(input, 4) != 0)
{
Debug.Assert(false, "invalid highbd txfm input");
output.Slice(0, 4).Fill(0);
output[..4].Clear();
return;
}
if ((x0 | x1 | x2 | x3) == 0)
{
output.Slice(0, 4).Fill(0);
output[..4].Clear();
return;
}
@@ -1619,7 +1628,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if (DetectInvalidHighbdInput(input, 4) != 0)
{
Debug.Assert(false, "invalid highbd txfm input");
output.Slice(0, 4).Fill(0);
output[..4].Clear();
return;
}
@@ -1653,8 +1663,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
for (i = 0; i < 4; ++i)
{
HighbdIdct4(input, outptr, bd);
input = input.Slice(4);
outptr = outptr.Slice(4);
input = input[4..];
outptr = outptr[4..];
}
// Columns
@@ -1688,7 +1698,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[1] = HighbdClipPixelAdd(dest[1], a1, bd);
dest[2] = HighbdClipPixelAdd(dest[2], a1, bd);
dest[3] = HighbdClipPixelAdd(dest[3], a1, bd);
dest = dest.Slice(stride);
dest = dest[stride..];
}
}
@@ -1707,13 +1717,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if (DetectInvalidHighbdInput(input, 8) != 0)
{
Debug.Assert(false, "invalid highbd txfm input");
output.Slice(0, 8).Fill(0);
output[..8].Clear();
return;
}
if ((x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7) == 0)
{
output.Slice(0, 8).Fill(0);
output[..8].Clear();
return;
}
@@ -1786,7 +1798,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if (DetectInvalidHighbdInput(input, 8) != 0)
{
Debug.Assert(false, "invalid highbd txfm input");
output.Slice(0, 8).Fill(0);
output[..8].Clear();
return;
}
@@ -1845,8 +1858,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
for (i = 0; i < 8; ++i)
{
HighbdIdct8(input, outptr, bd);
input = input.Slice(8);
outptr = outptr.Slice(8);
input = input[8..];
outptr = outptr[8..];
}
// Then transform columns
@@ -1874,15 +1887,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Span<int> tempIn = stackalloc int[8];
Span<int> tempOut = stackalloc int[8];
output.Fill(0);
output.Clear();
// First transform rows
// Only first 4 row has non-zero coefs
for (i = 0; i < 4; ++i)
{
HighbdIdct8(input, outptr, bd);
input = input.Slice(8);
outptr = outptr.Slice(8);
input = input[8..];
outptr = outptr[8..];
}
// Then transform columns
@@ -1901,7 +1914,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
}
}
public static void vpx_Highbdidct8x8_1_add_c(ReadOnlySpan<int> input, Span<ushort> dest, int stride, int bd)
public static void Vpx_Highbdidct8x8_1_add_c(ReadOnlySpan<int> input, Span<ushort> dest, int stride, int bd)
{
int i, j;
long a1;
@@ -1916,7 +1929,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[i] = HighbdClipPixelAdd(dest[i], a1, bd);
}
dest = dest.Slice(stride);
dest = dest[stride..];
}
}
@@ -1940,16 +1953,19 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
int x13 = input[12];
int x14 = input[1];
int x15 = input[14];
if (DetectInvalidHighbdInput(input, 16) != 0)
{
Debug.Assert(false, "invalid highbd txfm input");
output.Slice(0, 16).Fill(0);
output[..16].Clear();
return;
}
if ((x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 | x13 | x14 | x15) == 0)
{
output.Slice(0, 16).Fill(0);
output[..16].Clear();
return;
}
@@ -2105,7 +2121,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if (DetectInvalidHighbdInput(input, 16) != 0)
{
Debug.Assert(false, "invalid highbd txfm input");
output.Slice(0, 16).Fill(0);
output[..16].Clear();
return;
}
@@ -2283,8 +2300,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
for (i = 0; i < 16; ++i)
{
HighbdIdct16(input, outptr, bd);
input = input.Slice(16);
outptr = outptr.Slice(16);
input = input[16..];
outptr = outptr[16..];
}
// Then transform columns
@@ -2312,15 +2329,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Span<int> tempIn = stackalloc int[16];
Span<int> tempOut = stackalloc int[16];
output.Fill(0);
output.Clear();
// First transform rows. Since all non-zero dct coefficients are in
// upper-left 8x8 area, we only need to calculate first 8 rows here.
for (i = 0; i < 8; ++i)
{
HighbdIdct16(input, outptr, bd);
input = input.Slice(16);
outptr = outptr.Slice(16);
input = input[16..];
outptr = outptr[16..];
}
// Then transform columns
@@ -2336,7 +2353,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
for (j = 0; j < 16; ++j)
{
destT[i] = HighbdClipPixelAdd(destT[i], BitUtils.RoundPowerOfTwo(tempOut[j], 6), bd);
destT = destT.Slice(stride);
destT = destT[stride..];
}
}
}
@@ -2350,15 +2367,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Span<int> tempIn = stackalloc int[16];
Span<int> tempOut = stackalloc int[16];
output.Fill(0);
output.Clear();
// First transform rows. Since all non-zero dct coefficients are in
// upper-left 4x4 area, we only need to calculate first 4 rows here.
for (i = 0; i < 4; ++i)
{
HighbdIdct16(input, outptr, bd);
input = input.Slice(16);
outptr = outptr.Slice(16);
input = input[16..];
outptr = outptr[16..];
}
// Then transform columns
@@ -2392,7 +2409,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[i] = HighbdClipPixelAdd(dest[i], a1, bd);
}
dest = dest.Slice(stride);
dest = dest[stride..];
}
}
@@ -2406,7 +2423,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if (DetectInvalidHighbdInput(input, 32) != 0)
{
Debug.Assert(false, "invalid highbd txfm input");
output.Slice(0, 32).Fill(0);
output[..32].Clear();
return;
}
@@ -2797,11 +2815,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
}
else
{
outptr.Slice(0, 32).Fill(0);
outptr[..32].Clear();
}
input = input.Slice(32);
outptr = outptr.Slice(32);
input = input[32..];
outptr = outptr[32..];
}
// Columns
@@ -2829,15 +2847,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Span<int> tempIn = stackalloc int[32];
Span<int> tempOut = stackalloc int[32];
output.Fill(0);
output.Clear();
// Rows
// Only upper-left 16x16 has non-zero coeff
for (i = 0; i < 16; ++i)
{
HighbdIdct32(input, outptr, bd);
input = input.Slice(32);
outptr = outptr.Slice(32);
input = input[32..];
outptr = outptr[32..];
}
// Columns
@@ -2853,7 +2871,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
for (j = 0; j < 32; ++j)
{
destT[i] = HighbdClipPixelAdd(destT[i], BitUtils.RoundPowerOfTwo(tempOut[j], 6), bd);
destT = destT.Slice(stride);
destT = destT[stride..];
}
}
}
@@ -2867,15 +2885,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Span<int> tempIn = stackalloc int[32];
Span<int> tempOut = stackalloc int[32];
output.Fill(0);
output.Clear();
// Rows
// Only upper-left 8x8 has non-zero coeff
for (i = 0; i < 8; ++i)
{
HighbdIdct32(input, outptr, bd);
input = input.Slice(32);
outptr = outptr.Slice(32);
input = input[32..];
outptr = outptr[32..];
}
// Columns
@@ -2910,7 +2928,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
dest[i] = HighbdClipPixelAdd(dest[i], a1, bd);
}
dest = dest.Slice(stride);
dest = dest[stride..];
}
}
}

View File

@@ -15,6 +15,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
int p = (int)(((ulong)num * 256 + (den >> 1)) / den);
// (p > 255) ? 255 : (p < 1) ? 1 : p;
int clippedProb = p | ((255 - p) >> 23) | (p == 0 ? 1 : 0);
return (byte)clippedProb;
}
}
@@ -26,10 +27,9 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
}
// MODE_MV_MAX_UPDATE_FACTOR (128) * count / MODE_MV_COUNT_SAT;
private static readonly uint[] CountToUpdateFactor = new uint[]
{
private static readonly uint[] _countToUpdateFactor = {
0, 6, 12, 19, 25, 32, 38, 44, 51, 57, 64,
70, 76, 83, 89, 96, 102, 108, 115, 121, 128
70, 76, 83, 89, 96, 102, 108, 115, 121, 128,
};
private const int ModeMvCountSat = 20;
@@ -44,8 +44,9 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
else
{
uint count = Math.Min(den, ModeMvCountSat);
uint factor = CountToUpdateFactor[(int)count];
uint factor = _countToUpdateFactor[(int)count];
byte prob = GetProb(ct0, den);
return WeightedProb(preProb, prob, (int)factor);
}
}
@@ -62,6 +63,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
int r = tree[i + 1];
uint rightCount = (r <= 0) ? counts[-r] : TreeMergeProbsImpl((uint)r, tree, preProbs, counts, probs);
probs[(int)(i >> 1)] = ModeMvMergeProbs(preProbs[(int)(i >> 1)], leftCount, rightCount);
return leftCount + rightCount;
}

View File

@@ -6,8 +6,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
{
internal struct Reader
{
private static readonly byte[] Norm = new byte[]
{
private static readonly byte[] _norm = {
0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -17,7 +16,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
private const int BdValueSize = sizeof(ulong) * 8;
@@ -44,7 +43,8 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Count = -8;
Range = 255;
Fill();
return ReadBit() != 0; // Marker bit
return ReadBit() != 0; // Marker bit
}
}
@@ -65,7 +65,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
ulong bigEndianValues = BinaryPrimitives.ReadUInt64BigEndian(buffer);
nv = bigEndianValues >> (BdValueSize - bits);
count += bits;
buffer = buffer.Slice(bits >> 3);
buffer = buffer[(bits >> 3)..];
value = Value | (nv << (shift & 0x7));
}
else
@@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
{
count += 8;
value |= (ulong)buffer[0] << shift;
buffer = buffer.Slice(1);
buffer = buffer[1..];
shift -= 8;
}
}
@@ -98,7 +98,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
Count = count;
}
public bool HasError()
public readonly bool HasError()
{
// Check if we have reached the end of the buffer.
//
@@ -146,7 +146,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
}
{
int shift = Norm[range];
int shift = _norm[range];
range <<= shift;
value <<= shift;
count -= shift;
@@ -160,7 +160,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
public int ReadBit()
{
return Read(128); // vpx_prob_half
return Read(128); // vpx_prob_half
}
public int ReadLiteral(int bits)
@@ -181,7 +181,6 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
while ((i = tree[i + Read(probs[i >> 1])]) > 0)
{
continue;
}
return -i;
@@ -203,10 +202,10 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
if (value >= bigsplit)
{
range = range - split;
value = value - bigsplit;
range -= split;
value -= bigsplit;
{
int shift = Norm[range];
int shift = _norm[range];
range <<= shift;
value <<= shift;
count -= shift;
@@ -215,7 +214,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
}
range = split;
{
int shift = Norm[range];
int shift = _norm[range];
range <<= shift;
value <<= shift;
count -= shift;