[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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 1240 additions and 1207 deletions

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..];
}
}
}