diff options
| author | gdk <gab.dark.100@gmail.com> | 2019-10-13 03:02:07 -0300 |
|---|---|---|
| committer | Thog <thog@protonmail.com> | 2020-01-09 02:13:00 +0100 |
| commit | 1876b346fea647e8284a66bb6d62c38801035cff (patch) | |
| tree | 6eeff094298cda84d1613dc5ec0691e51d7b35f1 /Ryujinx.Graphics/VDec/BitStreamWriter.cs | |
| parent | f617fb542a0e3d36012d77a4b5acbde7b08902f2 (diff) | |
Initial work
Diffstat (limited to 'Ryujinx.Graphics/VDec/BitStreamWriter.cs')
| -rw-r--r-- | Ryujinx.Graphics/VDec/BitStreamWriter.cs | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/Ryujinx.Graphics/VDec/BitStreamWriter.cs b/Ryujinx.Graphics/VDec/BitStreamWriter.cs deleted file mode 100644 index db2d39e5..00000000 --- a/Ryujinx.Graphics/VDec/BitStreamWriter.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.IO; - -namespace Ryujinx.Graphics.VDec -{ - class BitStreamWriter - { - private const int BufferSize = 8; - - private Stream _baseStream; - - private int _buffer; - private int _bufferPos; - - public BitStreamWriter(Stream baseStream) - { - _baseStream = baseStream; - } - - public void WriteBit(bool value) - { - WriteBits(value ? 1 : 0, 1); - } - - public void WriteBits(int value, int valueSize) - { - int valuePos = 0; - - int remaining = valueSize; - - while (remaining > 0) - { - int copySize = remaining; - - int free = GetFreeBufferBits(); - - if (copySize > free) - { - copySize = free; - } - - int mask = (1 << copySize) - 1; - - int srcShift = (valueSize - valuePos) - copySize; - int dstShift = (BufferSize - _bufferPos) - copySize; - - _buffer |= ((value >> srcShift) & mask) << dstShift; - - valuePos += copySize; - _bufferPos += copySize; - remaining -= copySize; - } - } - - private int GetFreeBufferBits() - { - if (_bufferPos == BufferSize) - { - Flush(); - } - - return BufferSize - _bufferPos; - } - - public void Flush() - { - if (_bufferPos != 0) - { - _baseStream.WriteByte((byte)_buffer); - - _buffer = 0; - _bufferPos = 0; - } - } - } -}
\ No newline at end of file |
