aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Nvdec.Vp9/QuantCommon.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Graphics.Nvdec.Vp9/QuantCommon.cs')
-rw-r--r--src/Ryujinx.Graphics.Nvdec.Vp9/QuantCommon.cs45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/QuantCommon.cs b/src/Ryujinx.Graphics.Nvdec.Vp9/QuantCommon.cs
index 5c52c32f..ea858222 100644
--- a/src/Ryujinx.Graphics.Nvdec.Vp9/QuantCommon.cs
+++ b/src/Ryujinx.Graphics.Nvdec.Vp9/QuantCommon.cs
@@ -9,8 +9,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
public const int MinQ = 0;
public const int MaxQ = 255;
- private static readonly short[] DcQlookup = new short[]
- {
+ private static readonly short[] _dcQlookup = {
4, 8, 8, 9, 10, 11, 12, 12, 13, 14, 15, 16, 17, 18,
19, 19, 20, 21, 22, 23, 24, 25, 26, 26, 27, 28, 29, 30,
31, 32, 32, 33, 34, 35, 36, 37, 38, 38, 39, 40, 41, 42,
@@ -32,8 +31,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
1184, 1232, 1282, 1336,
};
- private static readonly short[] DcQlookup10 = new short[]
- {
+ private static readonly short[] _dcQlookup10 = {
4, 9, 10, 13, 15, 17, 20, 22, 25, 28, 31, 34, 37,
40, 43, 47, 50, 53, 57, 60, 64, 68, 71, 75, 78, 82,
86, 90, 93, 97, 101, 105, 109, 113, 116, 120, 124, 128, 132,
@@ -56,8 +54,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
3953, 4089, 4236, 4394, 4559, 4737, 4929, 5130, 5347,
};
- private static readonly short[] DcQlookup12 = new short[]
- {
+ private static readonly short[] _dcQlookup12 = {
4, 12, 18, 25, 33, 41, 50, 60, 70, 80, 91,
103, 115, 127, 140, 153, 166, 180, 194, 208, 222, 237,
251, 266, 281, 296, 312, 327, 343, 358, 374, 390, 405,
@@ -84,8 +81,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
19718, 20521, 21387,
};
- private static readonly short[] AcQlookup = new short[]
- {
+ private static readonly short[] _acQlookup = {
4, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
@@ -108,8 +104,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
1567, 1597, 1628, 1660, 1692, 1725, 1759, 1793, 1828,
};
- private static readonly short[] AcQlookup10 = new short[]
- {
+ private static readonly short[] _acQlookup10 = {
4, 9, 11, 13, 16, 18, 21, 24, 27, 30, 33, 37, 40,
44, 48, 51, 55, 59, 63, 67, 71, 75, 79, 83, 88, 92,
96, 100, 105, 109, 114, 118, 122, 127, 131, 136, 140, 145, 149,
@@ -132,8 +127,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
6268, 6388, 6512, 6640, 6768, 6900, 7036, 7172, 7312,
};
- private static readonly short[] AcQlookup12 = new short[]
- {
+ private static readonly short[] _acQlookup12 = {
4, 13, 19, 27, 35, 44, 54, 64, 75, 87, 99,
112, 126, 139, 154, 168, 183, 199, 214, 230, 247, 263,
280, 297, 314, 331, 349, 366, 384, 402, 420, 438, 456,
@@ -164,11 +158,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
{
switch (bitDepth)
{
- case BitDepth.Bits8: return DcQlookup[Math.Clamp(qindex + delta, 0, MaxQ)];
- case BitDepth.Bits10: return DcQlookup10[Math.Clamp(qindex + delta, 0, MaxQ)];
- case BitDepth.Bits12: return DcQlookup12[Math.Clamp(qindex + delta, 0, MaxQ)];
+ case BitDepth.Bits8:
+ return _dcQlookup[Math.Clamp(qindex + delta, 0, MaxQ)];
+ case BitDepth.Bits10:
+ return _dcQlookup10[Math.Clamp(qindex + delta, 0, MaxQ)];
+ case BitDepth.Bits12:
+ return _dcQlookup12[Math.Clamp(qindex + delta, 0, MaxQ)];
default:
Debug.Assert(false, "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12");
+
return -1;
}
}
@@ -177,11 +175,15 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
{
switch (bitDepth)
{
- case BitDepth.Bits8: return AcQlookup[Math.Clamp(qindex + delta, 0, MaxQ)];
- case BitDepth.Bits10: return AcQlookup10[Math.Clamp(qindex + delta, 0, MaxQ)];
- case BitDepth.Bits12: return AcQlookup12[Math.Clamp(qindex + delta, 0, MaxQ)];
+ case BitDepth.Bits8:
+ return _acQlookup[Math.Clamp(qindex + delta, 0, MaxQ)];
+ case BitDepth.Bits10:
+ return _acQlookup10[Math.Clamp(qindex + delta, 0, MaxQ)];
+ case BitDepth.Bits12:
+ return _acQlookup12[Math.Clamp(qindex + delta, 0, MaxQ)];
default:
Debug.Assert(false, "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12");
+
return -1;
}
}
@@ -192,12 +194,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
{
int data = seg.GetSegData(segmentId, SegLvlFeatures.SegLvlAltQ);
int segQIndex = seg.AbsDelta == Constants.SegmentAbsData ? data : baseQIndex + data;
+
return Math.Clamp(segQIndex, 0, MaxQ);
}
- else
- {
- return baseQIndex;
- }
+
+ return baseQIndex;
}
}
}