misc: chore: VP9 project cleanup
Target-typed new, remove var usage, use collection expressions, rename many fields & properties to match C# standard
This commit is contained in:
@@ -59,9 +59,9 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
{
|
||||
switch (maxTxSize)
|
||||
{
|
||||
case TxSize.Tx8x8: return fc.Tx8x8Prob[ctx].AsSpan();
|
||||
case TxSize.Tx16x16: return fc.Tx16x16Prob[ctx].AsSpan();
|
||||
case TxSize.Tx32x32: return fc.Tx32x32Prob[ctx].AsSpan();
|
||||
case TxSize.Tx8X8: return fc.Tx8x8Prob[ctx].AsSpan();
|
||||
case TxSize.Tx16X16: return fc.Tx16x16Prob[ctx].AsSpan();
|
||||
case TxSize.Tx32X32: return fc.Tx32x32Prob[ctx].AsSpan();
|
||||
default:
|
||||
Debug.Assert(false, "Invalid maxTxSize.");
|
||||
return ReadOnlySpan<byte>.Empty;
|
||||
@@ -72,9 +72,9 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
{
|
||||
switch (maxTxSize)
|
||||
{
|
||||
case TxSize.Tx8x8: return counts.Tx8x8[ctx].AsSpan();
|
||||
case TxSize.Tx16x16: return counts.Tx16x16[ctx].AsSpan();
|
||||
case TxSize.Tx32x32: return counts.Tx32x32[ctx].AsSpan();
|
||||
case TxSize.Tx8X8: return counts.Tx8x8[ctx].AsSpan();
|
||||
case TxSize.Tx16X16: return counts.Tx16x16[ctx].AsSpan();
|
||||
case TxSize.Tx32X32: return counts.Tx32x32[ctx].AsSpan();
|
||||
default:
|
||||
Debug.Assert(false, "Invalid maxTxSize.");
|
||||
return Span<uint>.Empty;
|
||||
@@ -86,10 +86,10 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
int ctx = xd.GetTxSizeContext();
|
||||
ReadOnlySpan<byte> txProbs = GetTxProbs(ref cm.Fc.Value, maxTxSize, ctx);
|
||||
TxSize txSize = (TxSize)r.Read(txProbs[0]);
|
||||
if (txSize != TxSize.Tx4x4 && maxTxSize >= TxSize.Tx16x16)
|
||||
if (txSize != TxSize.Tx4X4 && maxTxSize >= TxSize.Tx16X16)
|
||||
{
|
||||
txSize += r.Read(txProbs[1]);
|
||||
if (txSize != TxSize.Tx8x8 && maxTxSize >= TxSize.Tx32x32)
|
||||
if (txSize != TxSize.Tx8X8 && maxTxSize >= TxSize.Tx32X32)
|
||||
{
|
||||
txSize += r.Read(txProbs[2]);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
TxMode txMode = cm.TxMode;
|
||||
BlockSize bsize = xd.Mi[0].Value.SbType;
|
||||
TxSize maxTxSize = Luts.MaxTxSizeLookup[(int)bsize];
|
||||
if (allowSelect && txMode == TxMode.TxModeSelect && bsize >= BlockSize.Block8x8)
|
||||
if (allowSelect && txMode == TxMode.TxModeSelect && bsize >= BlockSize.Block8X8)
|
||||
{
|
||||
return ReadSelectedTxSize(ref cm, ref xd, maxTxSize, ref r);
|
||||
}
|
||||
@@ -276,7 +276,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
}
|
||||
|
||||
// Fractional part
|
||||
fr = r.ReadTree(Luts.MvFPTree, class0 ? fc.Class0Fp[mvcomp][d].AsSpan() : fc.Fp[mvcomp].AsSpan());
|
||||
fr = r.ReadTree(Luts.MvFpTree, class0 ? fc.Class0Fp[mvcomp][d].AsSpan() : fc.Fp[mvcomp].AsSpan());
|
||||
|
||||
// High precision part (if hp is not used, the default value of the hp is 1)
|
||||
hp = usehp ? r.Read(class0 ? fc.Class0Hp[mvcomp] : fc.Hp[mvcomp]) : 1;
|
||||
@@ -415,7 +415,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
|
||||
switch (bsize)
|
||||
{
|
||||
case BlockSize.Block4x4:
|
||||
case BlockSize.Block4X4:
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
mi.Bmi[i].Mode = ReadIntraModeY(ref cm, ref xd, ref r, 0);
|
||||
@@ -423,11 +423,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
|
||||
mi.Mode = mi.Bmi[3].Mode;
|
||||
break;
|
||||
case BlockSize.Block4x8:
|
||||
case BlockSize.Block4X8:
|
||||
mi.Bmi[0].Mode = mi.Bmi[2].Mode = ReadIntraModeY(ref cm, ref xd, ref r, 0);
|
||||
mi.Bmi[1].Mode = mi.Bmi[3].Mode = mi.Mode = ReadIntraModeY(ref cm, ref xd, ref r, 0);
|
||||
break;
|
||||
case BlockSize.Block8x4:
|
||||
case BlockSize.Block8X4:
|
||||
mi.Bmi[0].Mode = mi.Bmi[1].Mode = ReadIntraModeY(ref cm, ref xd, ref r, 0);
|
||||
mi.Bmi[2].Mode = mi.Bmi[3].Mode = mi.Mode = ReadIntraModeY(ref cm, ref xd, ref r, 0);
|
||||
break;
|
||||
@@ -595,7 +595,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
int miRow,
|
||||
int miCol,
|
||||
int block,
|
||||
int isSub8x8)
|
||||
int isSub8X8)
|
||||
{
|
||||
ref Array4<sbyte> refSignBias = ref cm.RefFrameSignBias;
|
||||
int i, refmvCount = 0;
|
||||
@@ -612,7 +612,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
mvRefList.Slice(0, Constants.MaxMvRefCandidates).Fill(new Mv());
|
||||
|
||||
i = 0;
|
||||
if (isSub8x8 != 0)
|
||||
if (isSub8X8 != 0)
|
||||
{
|
||||
// If the size < 8x8 we get the mv from the bmi substructure for the
|
||||
// nearest two blocks.
|
||||
@@ -770,7 +770,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
return refmvCount;
|
||||
}
|
||||
|
||||
private static void AppendSub8x8ForIdx(
|
||||
private static void AppendSub8X8ForIdx(
|
||||
ref Vp9Common cm,
|
||||
ref MacroBlockD xd,
|
||||
Span<Position> mvRefSearch,
|
||||
@@ -779,7 +779,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
int refr,
|
||||
int miRow,
|
||||
int miCol,
|
||||
ref Mv bestSub8x8)
|
||||
ref Mv bestSub8X8)
|
||||
{
|
||||
Span<Mv> mvList = stackalloc Mv[Constants.MaxMvRefCandidates];
|
||||
ref ModeInfo mi = ref xd.Mi[0].Value;
|
||||
@@ -794,22 +794,22 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
switch (block)
|
||||
{
|
||||
case 0:
|
||||
bestSub8x8 = mvList[refmvCount - 1];
|
||||
bestSub8X8 = mvList[refmvCount - 1];
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
if (bMode == PredictionMode.NearestMv)
|
||||
{
|
||||
bestSub8x8 = bmi[0].Mv[refr];
|
||||
bestSub8X8 = bmi[0].Mv[refr];
|
||||
}
|
||||
else
|
||||
{
|
||||
bestSub8x8 = new Mv();
|
||||
bestSub8X8 = new Mv();
|
||||
for (int n = 0; n < refmvCount; ++n)
|
||||
{
|
||||
if (Unsafe.As<Mv, int>(ref bmi[0].Mv[refr]) != Unsafe.As<Mv, int>(ref mvList[n]))
|
||||
{
|
||||
bestSub8x8 = mvList[n];
|
||||
bestSub8X8 = mvList[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -819,7 +819,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
case 3:
|
||||
if (bMode == PredictionMode.NearestMv)
|
||||
{
|
||||
bestSub8x8 = bmi[2].Mv[refr];
|
||||
bestSub8X8 = bmi[2].Mv[refr];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -828,12 +828,12 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
candidates[1] = bmi[0].Mv[refr];
|
||||
candidates[2] = mvList[0];
|
||||
candidates[3] = mvList[1];
|
||||
bestSub8x8 = new Mv();
|
||||
bestSub8X8 = new Mv();
|
||||
for (int n = 0; n < 2 + Constants.MaxMvRefCandidates; ++n)
|
||||
{
|
||||
if (Unsafe.As<Mv, int>(ref bmi[2].Mv[refr]) != Unsafe.As<Mv, int>(ref candidates[n]))
|
||||
{
|
||||
bestSub8x8 = candidates[n];
|
||||
bestSub8X8 = candidates[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -889,7 +889,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
if (cm.Seg.IsSegFeatureActive(mi.SegmentId, SegLvlFeatures.Skip) != 0)
|
||||
{
|
||||
mi.Mode = PredictionMode.ZeroMv;
|
||||
if (bsize < BlockSize.Block8x8)
|
||||
if (bsize < BlockSize.Block8X8)
|
||||
{
|
||||
xd.ErrorInfo.Value.InternalError(CodecErr.UnsupBitstream,
|
||||
"Invalid usage of segement feature on small blocks");
|
||||
@@ -898,7 +898,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bsize >= BlockSize.Block8x8)
|
||||
if (bsize >= BlockSize.Block8X8)
|
||||
{
|
||||
mi.Mode = ReadInterMode(ref cm, ref xd, ref r, interModeCtx);
|
||||
}
|
||||
@@ -932,20 +932,20 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
? ReadSwitchableInterpFilter(ref cm, ref xd, ref r)
|
||||
: cm.InterpFilter;
|
||||
|
||||
if (bsize < BlockSize.Block8x8)
|
||||
if (bsize < BlockSize.Block8X8)
|
||||
{
|
||||
int num4x4W = 1 << xd.BmodeBlocksWl;
|
||||
int num4x4H = 1 << xd.BmodeBlocksHl;
|
||||
int num4X4W = 1 << xd.BmodeBlocksWl;
|
||||
int num4X4H = 1 << xd.BmodeBlocksHl;
|
||||
int idx, idy;
|
||||
PredictionMode bMode = 0;
|
||||
Array2<Mv> bestSub8x8 = new();
|
||||
const uint invalidMv = 0x80008000;
|
||||
Array2<Mv> bestSub8X8 = new();
|
||||
const uint InvalidMv = 0x80008000;
|
||||
// Initialize the 2nd element as even though it won't be used meaningfully
|
||||
// if isCompound is false.
|
||||
Unsafe.As<Mv, uint>(ref bestSub8x8[1]) = invalidMv;
|
||||
for (idy = 0; idy < 2; idy += num4x4H)
|
||||
Unsafe.As<Mv, uint>(ref bestSub8X8[1]) = InvalidMv;
|
||||
for (idy = 0; idy < 2; idy += num4X4H)
|
||||
{
|
||||
for (idx = 0; idx < 2; idx += num4x4W)
|
||||
for (idx = 0; idx < 2; idx += num4X4W)
|
||||
{
|
||||
int j = (idy * 2) + idx;
|
||||
bMode = ReadInterMode(ref cm, ref xd, ref r, interModeCtx);
|
||||
@@ -954,24 +954,24 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
{
|
||||
for (refr = 0; refr < 1 + isCompound; ++refr)
|
||||
{
|
||||
AppendSub8x8ForIdx(ref cm, ref xd, mvRefSearch, bMode, j, refr, miRow, miCol,
|
||||
ref bestSub8x8[refr]);
|
||||
AppendSub8X8ForIdx(ref cm, ref xd, mvRefSearch, bMode, j, refr, miRow, miCol,
|
||||
ref bestSub8X8[refr]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Assign(ref cm, ref xd, bMode, ref mi.Bmi[j].Mv, ref bestRefMvs, ref bestSub8x8,
|
||||
if (!Assign(ref cm, ref xd, bMode, ref mi.Bmi[j].Mv, ref bestRefMvs, ref bestSub8X8,
|
||||
isCompound, allowHp, ref r))
|
||||
{
|
||||
xd.Corrupted |= true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (num4x4H == 2)
|
||||
if (num4X4H == 2)
|
||||
{
|
||||
mi.Bmi[j + 2] = mi.Bmi[j];
|
||||
}
|
||||
|
||||
if (num4x4W == 2)
|
||||
if (num4X4W == 2)
|
||||
{
|
||||
mi.Bmi[j + 1] = mi.Bmi[j];
|
||||
}
|
||||
@@ -1084,7 +1084,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
|
||||
switch (bsize)
|
||||
{
|
||||
case BlockSize.Block4x4:
|
||||
case BlockSize.Block4X4:
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
mi.Value.Bmi[i].Mode =
|
||||
@@ -1093,13 +1093,13 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||
|
||||
mi.Value.Mode = mi.Value.Bmi[3].Mode;
|
||||
break;
|
||||
case BlockSize.Block4x8:
|
||||
case BlockSize.Block4X8:
|
||||
mi.Value.Bmi[0].Mode = mi.Value.Bmi[2].Mode =
|
||||
ReadIntraMode(ref r, GetYModeProbs(ref cm.Fc.Value, mi, aboveMi, leftMi, 0));
|
||||
mi.Value.Bmi[1].Mode = mi.Value.Bmi[3].Mode = mi.Value.Mode =
|
||||
ReadIntraMode(ref r, GetYModeProbs(ref cm.Fc.Value, mi, aboveMi, leftMi, 1));
|
||||
break;
|
||||
case BlockSize.Block8x4:
|
||||
case BlockSize.Block8X4:
|
||||
mi.Value.Bmi[0].Mode = mi.Value.Bmi[1].Mode =
|
||||
ReadIntraMode(ref r, GetYModeProbs(ref cm.Fc.Value, mi, aboveMi, leftMi, 0));
|
||||
mi.Value.Bmi[2].Mode = mi.Value.Bmi[3].Mode = mi.Value.Mode =
|
||||
|
||||
Reference in New Issue
Block a user