Further small cleaning.

This commit is contained in:
jmsgrogan 2023-01-16 12:05:36 +00:00
parent dba6a91ec1
commit c81db288b0
5 changed files with 13 additions and 11 deletions

View file

@ -30,8 +30,8 @@ void BitStream::write(uint32_t data)
void BitStream::writeWord(uint16_t data)
{
const auto byte0 = data >> 8;
const auto byte1 = (data << 8) >> 8;
const auto byte0 = static_cast<unsigned char>(data >> 8);
const auto byte1 = static_cast<unsigned char>((data << 8) >> 8);
writeByte(byte0);
writeByte(byte1);
}
@ -81,13 +81,13 @@ void BitStream::writeNBits(uint32_t data, unsigned length)
unsigned num_bytes = overshoot / 8;
for (unsigned idx=0; idx< num_bytes; idx++)
{
mCurrentByte = ByteUtils::getMBitsAtN(data, overshoot, idx*8 + num_left);
mCurrentByte = ByteUtils::getMBitsAtN(static_cast<unsigned char>(data), overshoot, idx*8 + num_left);
writeByte(mCurrentByte, false);
}
if (const auto remainder = overshoot % 8; remainder > 0)
{
mCurrentByte = ByteUtils::getMBitsAtN(data, remainder, num_bytes*8 + num_left);
mCurrentByte = ByteUtils::getMBitsAtN(static_cast<unsigned char>(data), remainder, num_bytes*8 + num_left);
mBitOffset = remainder;
}
else