aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Nvdec.Vp9/Types/Segmentation.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-07-12 00:07:01 -0300
committerGitHub <noreply@github.com>2020-07-12 05:07:01 +0200
commit4d02a2d2c0451b4de1f6de3bbce54c457cacebe2 (patch)
tree120fe4fb8cfa1ac1c6ef4c97d92be47e955e8c0f /Ryujinx.Graphics.Nvdec.Vp9/Types/Segmentation.cs
parent38b26cf4242999fa7d8c550993ac0940cd03d55f (diff)
New NVDEC and VIC implementation (#1384)
* Initial NVDEC and VIC implementation * Update FFmpeg.AutoGen to 4.3.0 * Add nvdec dependencies for Windows * Unify some VP9 structures * Rename VP9 structure fields * Improvements to Video API * XML docs for Common.Memory * Remove now unused or redundant overloads from MemoryAccessor * NVDEC UV surface read/write scalar paths * Add FIXME comments about hacky things/stuff that will need to be fixed in the future * Cleaned up VP9 memory allocation * Remove some debug logs * Rename some VP9 structs * Remove unused struct * No need to compile Ryujinx.Graphics.Host1x with unsafe anymore * Name AsyncWorkQueue threads to make debugging easier * Make Vp9PictureInfo a ref struct * LayoutConverter no longer needs the depth argument (broken by rebase) * Pooling of VP9 buffers, plus fix a memory leak on VP9 * Really wish VS could rename projects properly... * Address feedback * Remove using * Catch OperationCanceledException * Add licensing informations * Add THIRDPARTY.md to release too Co-authored-by: Thog <me@thog.eu>
Diffstat (limited to 'Ryujinx.Graphics.Nvdec.Vp9/Types/Segmentation.cs')
-rw-r--r--Ryujinx.Graphics.Nvdec.Vp9/Types/Segmentation.cs71
1 files changed, 71 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Nvdec.Vp9/Types/Segmentation.cs b/Ryujinx.Graphics.Nvdec.Vp9/Types/Segmentation.cs
new file mode 100644
index 00000000..53d1f2cc
--- /dev/null
+++ b/Ryujinx.Graphics.Nvdec.Vp9/Types/Segmentation.cs
@@ -0,0 +1,71 @@
+using Ryujinx.Common.Memory;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+namespace Ryujinx.Graphics.Nvdec.Vp9.Types
+{
+ internal struct Segmentation
+ {
+ private static readonly int[] SegFeatureDataSigned = new int[] { 1, 1, 0, 0 };
+ private static readonly int[] SegFeatureDataMax = new int[] { QuantCommon.MaxQ, Vp9.LoopFilter.MaxLoopFilter, 3, 0 };
+
+ public bool Enabled;
+ public bool UpdateMap;
+ public byte UpdateData;
+ public byte AbsDelta;
+ public bool TemporalUpdate;
+
+ public Array8<Array4<short>> FeatureData;
+ public Array8<uint> FeatureMask;
+ public int AqAvOffset;
+
+ public static byte GetPredProbSegId(ref Array3<byte> segPredProbs, ref MacroBlockD xd)
+ {
+ return segPredProbs[xd.GetPredContextSegId()];
+ }
+
+ public void ClearAllSegFeatures()
+ {
+ MemoryMarshal.CreateSpan(ref FeatureData[0][0], 8 * 4).Fill(0);
+ MemoryMarshal.CreateSpan(ref FeatureMask[0], 8).Fill(0);
+ AqAvOffset = 0;
+ }
+
+ internal void EnableSegFeature(int segmentId, SegLvlFeatures featureId)
+ {
+ FeatureMask[segmentId] |= 1u << (int)featureId;
+ }
+
+ internal static int FeatureDataMax(SegLvlFeatures featureId)
+ {
+ return SegFeatureDataMax[(int)featureId];
+ }
+
+ internal static int IsSegFeatureSigned(SegLvlFeatures featureId)
+ {
+ return SegFeatureDataSigned[(int)featureId];
+ }
+
+ internal void SetSegData(int segmentId, SegLvlFeatures featureId, int segData)
+ {
+ Debug.Assert(segData <= SegFeatureDataMax[(int)featureId]);
+ if (segData < 0)
+ {
+ Debug.Assert(SegFeatureDataSigned[(int)featureId] != 0);
+ Debug.Assert(-segData <= SegFeatureDataMax[(int)featureId]);
+ }
+
+ FeatureData[segmentId][(int)featureId] = (short)segData;
+ }
+
+ internal int IsSegFeatureActive(int segmentId, SegLvlFeatures featureId)
+ {
+ return Enabled && (FeatureMask[segmentId] & (1 << (int)featureId)) != 0 ? 1 : 0;
+ }
+
+ internal short GetSegData(int segmentId, SegLvlFeatures featureId)
+ {
+ return FeatureData[segmentId][(int)featureId];
+ }
+ }
+}