From 6aa8d71588af4615019cd91b8a31f69dbfaa815d Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Wed, 28 Jun 2023 09:26:39 +0200 Subject: [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 * 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 * 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 --- src/Ryujinx.Graphics.Nvdec.Vp9/Idct.cs | 112 ++++++++++++++++----------------- 1 file changed, 53 insertions(+), 59 deletions(-) (limited to 'src/Ryujinx.Graphics.Nvdec.Vp9/Idct.cs') diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/Idct.cs b/src/Ryujinx.Graphics.Nvdec.Vp9/Idct.cs index 9fa5842a..1ee7f68b 100644 --- a/src/Ryujinx.Graphics.Nvdec.Vp9/Idct.cs +++ b/src/Ryujinx.Graphics.Nvdec.Vp9/Idct.cs @@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 private struct Transform2D { - public Transform1D Cols, Rows; // Vertical and horizontal + public Transform1D Cols, Rows; // Vertical and horizontal public Transform2D(Transform1D cols, Transform1D rows) { @@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 private struct HighbdTransform2D { - public HighbdTransform1D Cols, Rows; // Vertical and horizontal + public HighbdTransform1D Cols, Rows; // Vertical and horizontal public HighbdTransform2D(HighbdTransform1D cols, HighbdTransform1D rows) { @@ -32,12 +32,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 } } - private static readonly Transform2D[] Iht4 = new Transform2D[] - { - new Transform2D(Idct4, Idct4), // DCT_DCT = 0 - new Transform2D(Iadst4, Idct4), // ADST_DCT = 1 - new Transform2D(Idct4, Iadst4), // DCT_ADST = 2 - new Transform2D(Iadst4, Iadst4) // ADST_ADST = 3 + private static readonly Transform2D[] _iht4 = { + new(Idct4, Idct4), // DCT_DCT = 0 + new(Iadst4, Idct4), // ADST_DCT = 1 + new(Idct4, Iadst4), // DCT_ADST = 2 + new(Iadst4, Iadst4), // ADST_ADST = 3 }; public static void Iht4x416Add(ReadOnlySpan input, Span dest, int stride, int txType) @@ -51,9 +50,9 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 // Inverse transform row vectors for (i = 0; i < 4; ++i) { - Iht4[txType].Rows(input, outptr); - input = input.Slice(4); - outptr = outptr.Slice(4); + _iht4[txType].Rows(input, outptr); + input = input[4..]; + outptr = outptr[4..]; } // Inverse transform column vectors @@ -64,7 +63,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 tempIn[j] = output[j * 4 + i]; } - Iht4[txType].Cols(tempIn, tempOut); + _iht4[txType].Cols(tempIn, tempOut); for (j = 0; j < 4; ++j) { dest[j * stride + i] = ClipPixelAdd(dest[j * stride + i], BitUtils.RoundPowerOfTwo(tempOut[j], 4)); @@ -72,12 +71,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 } } - private static readonly Transform2D[] Iht8 = new Transform2D[] - { - new Transform2D(Idct8, Idct8), // DCT_DCT = 0 - new Transform2D(Iadst8, Idct8), // ADST_DCT = 1 - new Transform2D(Idct8, Iadst8), // DCT_ADST = 2 - new Transform2D(Iadst8, Iadst8) // ADST_ADST = 3 + private static readonly Transform2D[] _iht8 = { + new(Idct8, Idct8), // DCT_DCT = 0 + new(Iadst8, Idct8), // ADST_DCT = 1 + new(Idct8, Iadst8), // DCT_ADST = 2 + new(Iadst8, Iadst8), // ADST_ADST = 3 }; public static void Iht8x864Add(ReadOnlySpan input, Span dest, int stride, int txType) @@ -87,14 +85,14 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 Span outptr = output; Span tempIn = stackalloc int[8]; Span tempOut = stackalloc int[8]; - Transform2D ht = Iht8[txType]; + Transform2D ht = _iht8[txType]; // Inverse transform row vectors for (i = 0; i < 8; ++i) { ht.Rows(input, outptr); - input = input.Slice(8); - outptr = outptr.Slice(8); + input = input[8..]; + outptr = outptr[8..]; } // Inverse transform column vectors @@ -113,12 +111,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 } } - private static readonly Transform2D[] Iht16 = new Transform2D[] - { - new Transform2D(Idct16, Idct16), // DCT_DCT = 0 - new Transform2D(Iadst16, Idct16), // ADST_DCT = 1 - new Transform2D(Idct16, Iadst16), // DCT_ADST = 2 - new Transform2D(Iadst16, Iadst16) // ADST_ADST = 3 + private static readonly Transform2D[] _iht16 = { + new(Idct16, Idct16), // DCT_DCT = 0 + new(Iadst16, Idct16), // ADST_DCT = 1 + new(Idct16, Iadst16), // DCT_ADST = 2 + new(Iadst16, Iadst16), // ADST_ADST = 3 }; public static void Iht16x16256Add(ReadOnlySpan input, Span dest, int stride, int txType) @@ -128,14 +125,14 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 Span outptr = output; Span tempIn = stackalloc int[16]; Span tempOut = stackalloc int[16]; - Transform2D ht = Iht16[txType]; + Transform2D ht = _iht16[txType]; // Rows for (i = 0; i < 16; ++i) { ht.Rows(input, outptr); - input = input.Slice(16); - outptr = outptr.Slice(16); + input = input[16..]; + outptr = outptr[16..]; } // Columns @@ -283,12 +280,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 } } - private static readonly HighbdTransform2D[] HighbdIht4 = new HighbdTransform2D[] - { - new HighbdTransform2D(HighbdIdct4, HighbdIdct4), // DCT_DCT = 0 - new HighbdTransform2D(HighbdIadst4, HighbdIdct4), // ADST_DCT = 1 - new HighbdTransform2D(HighbdIdct4, HighbdIadst4), // DCT_ADST = 2 - new HighbdTransform2D(HighbdIadst4, HighbdIadst4) // ADST_ADST = 3 + private static readonly HighbdTransform2D[] _highbdIht4 = { + new(HighbdIdct4, HighbdIdct4), // DCT_DCT = 0 + new(HighbdIadst4, HighbdIdct4), // ADST_DCT = 1 + new(HighbdIdct4, HighbdIadst4), // DCT_ADST = 2 + new(HighbdIadst4, HighbdIadst4), // ADST_ADST = 3 }; public static void HighbdIht4x416Add(ReadOnlySpan input, Span dest, int stride, int txType, int bd) @@ -302,9 +298,9 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 // Inverse transform row vectors. for (i = 0; i < 4; ++i) { - HighbdIht4[txType].Rows(input, outptr, bd); - input = input.Slice(4); - outptr = outptr.Slice(4); + _highbdIht4[txType].Rows(input, outptr, bd); + input = input[4..]; + outptr = outptr[4..]; } // Inverse transform column vectors. @@ -315,7 +311,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 tempIn[j] = output[j * 4 + i]; } - HighbdIht4[txType].Cols(tempIn, tempOut, bd); + _highbdIht4[txType].Cols(tempIn, tempOut, bd); for (j = 0; j < 4; ++j) { dest[j * stride + i] = HighbdClipPixelAdd(dest[j * stride + i], BitUtils.RoundPowerOfTwo(tempOut[j], 4), bd); @@ -323,12 +319,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 } } - private static readonly HighbdTransform2D[] HighIht8 = new HighbdTransform2D[] - { - new HighbdTransform2D(HighbdIdct8, HighbdIdct8), // DCT_DCT = 0 - new HighbdTransform2D(HighbdIadst8, HighbdIdct8), // ADST_DCT = 1 - new HighbdTransform2D(HighbdIdct8, HighbdIadst8), // DCT_ADST = 2 - new HighbdTransform2D(HighbdIadst8, HighbdIadst8) // ADST_ADST = 3 + private static readonly HighbdTransform2D[] _highIht8 = { + new(HighbdIdct8, HighbdIdct8), // DCT_DCT = 0 + new(HighbdIadst8, HighbdIdct8), // ADST_DCT = 1 + new(HighbdIdct8, HighbdIadst8), // DCT_ADST = 2 + new(HighbdIadst8, HighbdIadst8), // ADST_ADST = 3 }; public static void HighbdIht8x864Add(ReadOnlySpan input, Span dest, int stride, int txType, int bd) @@ -338,14 +333,14 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 Span outptr = output; Span tempIn = stackalloc int[8]; Span tempOut = stackalloc int[8]; - HighbdTransform2D ht = HighIht8[txType]; + HighbdTransform2D ht = _highIht8[txType]; // Inverse transform row vectors. for (i = 0; i < 8; ++i) { ht.Rows(input, outptr, bd); - input = input.Slice(8); - outptr = output.Slice(8); + input = input[8..]; + outptr = output[8..]; } // Inverse transform column vectors. @@ -364,12 +359,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 } } - private static readonly HighbdTransform2D[] HighIht16 = new HighbdTransform2D[] - { - new HighbdTransform2D(HighbdIdct16, HighbdIdct16), // DCT_DCT = 0 - new HighbdTransform2D(HighbdIadst16, HighbdIdct16), // ADST_DCT = 1 - new HighbdTransform2D(HighbdIdct16, HighbdIadst16), // DCT_ADST = 2 - new HighbdTransform2D(HighbdIadst16, HighbdIadst16) // ADST_ADST = 3 + private static readonly HighbdTransform2D[] _highIht16 = { + new(HighbdIdct16, HighbdIdct16), // DCT_DCT = 0 + new(HighbdIadst16, HighbdIdct16), // ADST_DCT = 1 + new(HighbdIdct16, HighbdIadst16), // DCT_ADST = 2 + new(HighbdIadst16, HighbdIadst16), // ADST_ADST = 3 }; public static void HighbdIht16x16256Add(ReadOnlySpan input, Span dest, int stride, int txType, int bd) @@ -379,14 +373,14 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 Span outptr = output; Span tempIn = stackalloc int[16]; Span tempOut = stackalloc int[16]; - HighbdTransform2D ht = HighIht16[txType]; + HighbdTransform2D ht = _highIht16[txType]; // Rows for (i = 0; i < 16; ++i) { ht.Rows(input, outptr, bd); - input = input.Slice(16); - outptr = output.Slice(16); + input = input[16..]; + outptr = output[16..]; } // Columns @@ -440,7 +434,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 // DC only DCT coefficient if (eob == 1) { - vpx_Highbdidct8x8_1_add_c(input, dest, stride, bd); + Vpx_Highbdidct8x8_1_add_c(input, dest, stride, bd); } else if (eob <= 12) { -- cgit v1.2.3