Fix Bitstream reader - 8byte reads

This commit is contained in:
Juergen Tem 2018-05-12 02:56:55 +02:00
parent 53a7e2e5bf
commit ea25445244
No known key found for this signature in database
GPG Key ID: 0A9625B1654DCE28

View File

@ -177,15 +177,25 @@ namespace BDInfo
{
var pos = _stream.Position;
var shift = 56;
long data = 0;
for (var i = 0; i < 8; i++)
var shift = 24;
var data = 0;
for (var i = 0; i < 4; i++)
{
if (pos + i >= _bufferLength) break;
data += (_stream.ReadByte() << shift);
shift -= 8;
}
var vector = new BitArray(new []{(int)(data >> 32), (int)data});
shift = 24;
var data2 = 0;
for (var i = 0; i < 4; i++)
{
if (pos + i >= _bufferLength) break;
data2 += (_stream.ReadByte() << shift);
shift -= 8;
}
var vector = new BitArray(new []{data2, data});
ulong value = 0;
for (var i = _skipBits; i < _skipBits + bits; i++)
@ -213,7 +223,8 @@ namespace BDInfo
public void BSSkipNextByte()
{
BSSkipBits(8 - _skipBits);
if (_skipBits > 0)
BSSkipBits(8 - _skipBits);
}
public void BSSkipBytes(int bytes)
@ -257,5 +268,10 @@ namespace BDInfo
{
return (_stream.Length - _stream.Position)*8 - _skipBits;
}
public long DataBitStreamRemainBytes()
{
return (_stream.Length - _stream.Position);
}
}
}