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