Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Source/ZenLib/BitStream_Fast.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class BitStream_Fast
0x1f, 0x3f, 0x7f, 0xff,
};

if (HowMany==0 || HowMany>8)
return 0;

if (HowMany<=(Buffer_Size%8))
{
Buffer_Size-=HowMany;
Expand Down Expand Up @@ -117,6 +120,9 @@ class BitStream_Fast
0x1fff, 0x3fff, 0x7fff, 0xffff,
};

if (HowMany==0 || HowMany>16)
return 0;

if (HowMany<=(Buffer_Size%8))
{
Buffer_Size-=HowMany;
Expand Down Expand Up @@ -164,6 +170,9 @@ class BitStream_Fast
0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff,
};

if (HowMany==0 || HowMany>32)
return 0;

if (HowMany<=(Buffer_Size%8))
{
Buffer_Size-=HowMany;
Expand Down Expand Up @@ -263,6 +272,9 @@ class BitStream_Fast
0x1f, 0x3f, 0x7f, 0xff,
};

if (HowMany==0 || HowMany>8)
return 0;

if (HowMany<=(Buffer_Size%8))
return (LastByte>>((Buffer_Size-HowMany)%8))&Mask[HowMany];

Expand Down Expand Up @@ -295,6 +307,9 @@ class BitStream_Fast
0x1fff, 0x3fff, 0x7fff, 0xffff,
};

if (HowMany==0 || HowMany>16)
return 0;

if (HowMany<=(Buffer_Size%8))
return (LastByte>>((Buffer_Size-HowMany)%8))&Mask[HowMany];

Expand Down Expand Up @@ -341,6 +356,9 @@ class BitStream_Fast
0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff,
};

if (HowMany==0 || HowMany>32)
return 0;

if (HowMany<=(Buffer_Size%8))
return (LastByte>>((Buffer_Size-HowMany)%8))&Mask[HowMany];

Expand Down
18 changes: 17 additions & 1 deletion Source/ZenLib/BitStream_LE.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class BitStream_LE : public BitStream
0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff,
};

if (HowMany==0 || HowMany>32)
return 0;

unsigned long m=Mask[HowMany];

HowMany+=endbit;
Expand Down Expand Up @@ -103,6 +107,18 @@ class BitStream_LE : public BitStream

void Skip(size_t bits)
{
if (bits==0)
return;
if (bits>32) //Get is only for <=32 bits
{
do {
Get(32);
bits-=32;
} while (bits>32);
if (bits)
Get(bits);
return;
}
Get(bits);
}

Expand All @@ -114,7 +130,7 @@ class BitStream_LE : public BitStream
void Byte_Align()
{
if (endbit)
Get(endbit);
Get(8-endbit);
};

size_t Offset_Get()
Expand Down
Loading