diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2020-07-12 00:07:01 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-12 05:07:01 +0200 |
| commit | 4d02a2d2c0451b4de1f6de3bbce54c457cacebe2 (patch) | |
| tree | 120fe4fb8cfa1ac1c6ef4c97d92be47e955e8c0f /Ryujinx.Graphics.Nvdec/VDec/VpxRangeEncoder.cs | |
| parent | 38b26cf4242999fa7d8c550993ac0940cd03d55f (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/VDec/VpxRangeEncoder.cs')
| -rw-r--r-- | Ryujinx.Graphics.Nvdec/VDec/VpxRangeEncoder.cs | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/Ryujinx.Graphics.Nvdec/VDec/VpxRangeEncoder.cs b/Ryujinx.Graphics.Nvdec/VDec/VpxRangeEncoder.cs deleted file mode 100644 index c854c9d9..00000000 --- a/Ryujinx.Graphics.Nvdec/VDec/VpxRangeEncoder.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System.IO; - -namespace Ryujinx.Graphics.VDec -{ - class VpxRangeEncoder - { - private const int HalfProbability = 128; - - private static readonly int[] NormLut = new int[] - { - 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - private Stream _baseStream; - - private uint _lowValue; - private uint _range; - private int _count; - - public VpxRangeEncoder(Stream baseStream) - { - _baseStream = baseStream; - - _range = 0xff; - _count = -24; - - Write(false); - } - - public void WriteByte(byte value) - { - Write(value, 8); - } - - public void Write(int value, int valueSize) - { - for (int bit = valueSize - 1; bit >= 0; bit--) - { - Write(((value >> bit) & 1) != 0); - } - } - - public void Write(bool bit) - { - Write(bit, HalfProbability); - } - - public void Write(bool bit, int probability) - { - uint range = _range; - - uint split = 1 + (((range - 1) * (uint)probability) >> 8); - - range = split; - - if (bit) - { - _lowValue += split; - range = _range - split; - } - - int shift = NormLut[range]; - - range <<= shift; - _count += shift; - - if (_count >= 0) - { - int offset = shift - _count; - - if (((_lowValue << (offset - 1)) >> 31) != 0) - { - long currentPos = _baseStream.Position; - - _baseStream.Seek(-1, SeekOrigin.Current); - - while (_baseStream.Position >= 0 && PeekByte() == 0xff) - { - _baseStream.WriteByte(0); - - _baseStream.Seek(-2, SeekOrigin.Current); - } - - _baseStream.WriteByte((byte)(PeekByte() + 1)); - - _baseStream.Seek(currentPos, SeekOrigin.Begin); - } - - _baseStream.WriteByte((byte)(_lowValue >> (24 - offset))); - - _lowValue <<= offset; - shift = _count; - _lowValue &= 0xffffff; - _count -= 8; - } - - _lowValue <<= shift; - - _range = range; - } - - private byte PeekByte() - { - byte value = (byte)_baseStream.ReadByte(); - - _baseStream.Seek(-1, SeekOrigin.Current); - - return value; - } - - public void End() - { - for (int index = 0; index < 32; index++) - { - Write(false); - } - } - } -}
\ No newline at end of file |
