2018-12-02 18:38:47 -08:00
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.VDec
|
|
|
|
{
|
|
|
|
class VpxBitStreamWriter : BitStreamWriter
|
|
|
|
{
|
2019-03-03 17:45:25 -08:00
|
|
|
public VpxBitStreamWriter(Stream baseStream) : base(baseStream) { }
|
2018-12-02 18:38:47 -08:00
|
|
|
|
2019-03-03 17:45:25 -08:00
|
|
|
public void WriteU(int value, int valueSize)
|
2018-12-02 18:38:47 -08:00
|
|
|
{
|
2019-03-03 17:45:25 -08:00
|
|
|
WriteBits(value, valueSize);
|
2018-12-02 18:38:47 -08:00
|
|
|
}
|
|
|
|
|
2019-03-03 17:45:25 -08:00
|
|
|
public void WriteS(int value, int valueSize)
|
2018-12-02 18:38:47 -08:00
|
|
|
{
|
2019-03-03 17:45:25 -08:00
|
|
|
bool sign = value < 0;
|
2018-12-02 18:38:47 -08:00
|
|
|
|
2019-03-03 17:45:25 -08:00
|
|
|
if (sign)
|
2018-12-02 18:38:47 -08:00
|
|
|
{
|
2019-03-03 17:45:25 -08:00
|
|
|
value = -value;
|
2018-12-02 18:38:47 -08:00
|
|
|
}
|
|
|
|
|
2019-03-03 17:45:25 -08:00
|
|
|
WriteBits((value << 1) | (sign ? 1 : 0), valueSize + 1);
|
2018-12-02 18:38:47 -08:00
|
|
|
}
|
|
|
|
|
2019-03-03 17:45:25 -08:00
|
|
|
public void WriteDeltaQ(int value)
|
2018-12-02 18:38:47 -08:00
|
|
|
{
|
2019-03-03 17:45:25 -08:00
|
|
|
bool deltaCoded = value != 0;
|
2018-12-02 18:38:47 -08:00
|
|
|
|
2019-03-03 17:45:25 -08:00
|
|
|
WriteBit(deltaCoded);
|
2018-12-02 18:38:47 -08:00
|
|
|
|
2019-03-03 17:45:25 -08:00
|
|
|
if (deltaCoded)
|
2018-12-02 18:38:47 -08:00
|
|
|
{
|
2019-03-03 17:45:25 -08:00
|
|
|
WriteBits(value, 4);
|
2018-12-02 18:38:47 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|