aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Texture/BitArrayStream.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-12-03 00:38:47 -0200
committerGitHub <noreply@github.com>2018-12-03 00:38:47 -0200
commitc86aacde76b5f8e503e2b412385c8491ecc86b3b (patch)
tree8e4737422fba15199c1a6ce7c6345996c0e907b5 /Ryujinx.Graphics/Texture/BitArrayStream.cs
parentad00fd02442cf9c0f00c4562635738042b521efa (diff)
NVDEC implementation using FFmpeg (#443)
* Initial nvdec implementation using FFmpeg * Fix swapped channels on the video decoder and the G8R8 texture format * Fix texture samplers not being set properly (regression) * Rebased * Remove unused code introduced on the rebase * Add support for RGBA8 output format on the video image composer * Correct spacing * Some fixes for rebase and other tweaks * Allow size mismatch on frame copy * Get rid of GetHostAddress calls on VDec
Diffstat (limited to 'Ryujinx.Graphics/Texture/BitArrayStream.cs')
-rw-r--r--Ryujinx.Graphics/Texture/BitArrayStream.cs121
1 files changed, 0 insertions, 121 deletions
diff --git a/Ryujinx.Graphics/Texture/BitArrayStream.cs b/Ryujinx.Graphics/Texture/BitArrayStream.cs
deleted file mode 100644
index 2a8ed091..00000000
--- a/Ryujinx.Graphics/Texture/BitArrayStream.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-using System;
-using System.Collections;
-
-namespace Ryujinx.Graphics.Texture
-{
- public class BitArrayStream
- {
- public BitArray BitsArray;
-
- public int Position { get; private set; }
-
- public BitArrayStream(BitArray BitArray)
- {
- BitsArray = BitArray;
- Position = 0;
- }
-
- public short ReadBits(int Length)
- {
- int RetValue = 0;
- for (int i = Position; i < Position + Length; i++)
- {
- if (BitsArray[i])
- {
- RetValue |= 1 << (i - Position);
- }
- }
-
- Position += Length;
- return (short)RetValue;
- }
-
- public int ReadBits(int Start, int End)
- {
- int RetValue = 0;
- for (int i = Start; i <= End; i++)
- {
- if (BitsArray[i])
- {
- RetValue |= 1 << (i - Start);
- }
- }
-
- return RetValue;
- }
-
- public int ReadBit(int Index)
- {
- return Convert.ToInt32(BitsArray[Index]);
- }
-
- public void WriteBits(int Value, int Length)
- {
- for (int i = Position; i < Position + Length; i++)
- {
- BitsArray[i] = ((Value >> (i - Position)) & 1) != 0;
- }
-
- Position += Length;
- }
-
- public byte[] ToByteArray()
- {
- byte[] RetArray = new byte[(BitsArray.Length + 7) / 8];
- BitsArray.CopyTo(RetArray, 0);
- return RetArray;
- }
-
- public static int Replicate(int Value, int NumberBits, int ToBit)
- {
- if (NumberBits == 0) return 0;
- if (ToBit == 0) return 0;
-
- int TempValue = Value & ((1 << NumberBits) - 1);
- int RetValue = TempValue;
- int ResLength = NumberBits;
-
- while (ResLength < ToBit)
- {
- int Comp = 0;
- if (NumberBits > ToBit - ResLength)
- {
- int NewShift = ToBit - ResLength;
- Comp = NumberBits - NewShift;
- NumberBits = NewShift;
- }
- RetValue <<= NumberBits;
- RetValue |= TempValue >> Comp;
- ResLength += NumberBits;
- }
- return RetValue;
- }
-
- public static int PopCnt(int Number)
- {
- int Counter;
- for (Counter = 0; Number != 0; Counter++)
- {
- Number &= Number - 1;
- }
- return Counter;
- }
-
- public static void Swap<T>(ref T lhs, ref T rhs)
- {
- T Temp = lhs;
- lhs = rhs;
- rhs = Temp;
- }
-
- // Transfers a bit as described in C.2.14
- public static void BitTransferSigned(ref int a, ref int b)
- {
- b >>= 1;
- b |= a & 0x80;
- a >>= 1;
- a &= 0x3F;
- if ((a & 0x20) != 0) a -= 0x40;
- }
- }
-}