Loading...
Searching...
No Matches
bytepacker.h
Go to the documentation of this file.
#ifndef DYSCO_BYTE_PACKER_H
#define DYSCO_BYTE_PACKER_H
#include <cstdint>
#include <stdexcept>
namespace dyscostman {
class BytePacker {
public:
static void pack(unsigned bitCount, unsigned char *dest,
const unsigned *symbolBuffer, size_t symbolCount);
static void unpack(unsigned bitCount, unsigned *symbolBuffer,
unsigned char *packedBuffer, size_t symbolCount);
static void pack2(unsigned char *dest, const unsigned *symbolBuffer,
size_t symbolCount);
static void unpack2(unsigned *symbolBuffer, unsigned char *packedBuffer,
size_t symbolCount);
static void pack3(unsigned char *dest, const unsigned *symbolBuffer,
size_t symbolCount);
static void unpack3(unsigned *symbolBuffer, unsigned char *packedBuffer,
size_t symbolCount);
static void pack4(unsigned char *dest, const unsigned *symbolBuffer,
size_t symbolCount);
static void unpack4(unsigned *symbolBuffer, unsigned char *packedBuffer,
size_t symbolCount);
static void pack6(unsigned char *dest, const unsigned *symbolBuffer,
size_t symbolCount);
static void unpack6(unsigned *symbolBuffer, unsigned char *packedBuffer,
size_t symbolCount);
static void pack8(unsigned char *dest, const unsigned *symbolBuffer,
size_t symbolCount);
static void unpack8(unsigned *symbolBuffer, unsigned char *packedBuffer,
size_t symbolCount);
static void pack10(unsigned char *dest, const unsigned *symbolBuffer,
size_t symbolCount);
static void unpack10(unsigned *symbolBuffer, unsigned char *packedBuffer,
size_t symbolCount);
static void pack12(unsigned char *dest, const unsigned *symbolBuffer,
size_t symbolCount);
static void unpack12(unsigned *symbolBuffer, unsigned char *packedBuffer,
size_t symbolCount);
static void pack16(unsigned char *dest, const unsigned *symbolBuffer,
size_t symbolCount);
static void unpack16(unsigned *symbolBuffer, unsigned char *packedBuffer,
size_t symbolCount);
static size_t bufferSize(size_t nSymbols, size_t nBits) {
return (nSymbols * nBits + 7) / 8;
}
};
inline void BytePacker::pack(unsigned int bitCount, unsigned char *dest,
const unsigned int *symbolBuffer,
size_t symbolCount) {
switch (bitCount) {
case 2:
pack2(dest, symbolBuffer, symbolCount);
break;
case 3:
pack3(dest, symbolBuffer, symbolCount);
break;
case 4:
pack4(dest, symbolBuffer, symbolCount);
break;
case 6:
pack6(dest, symbolBuffer, symbolCount);
break;
case 8:
pack8(dest, symbolBuffer, symbolCount);
break;
case 10:
pack10(dest, symbolBuffer, symbolCount);
break;
case 12:
pack12(dest, symbolBuffer, symbolCount);
break;
case 16:
pack16(dest, symbolBuffer, symbolCount);
break;
default:
throw std::runtime_error("Unsupported packing size");
}
}
inline void BytePacker::unpack(unsigned int bitCount,
unsigned int *symbolBuffer,
unsigned char *packedBuffer,
size_t symbolCount) {
switch (bitCount) {
case 2:
unpack2(symbolBuffer, packedBuffer, symbolCount);
break;
case 3:
unpack3(symbolBuffer, packedBuffer, symbolCount);
break;
case 4:
unpack4(symbolBuffer, packedBuffer, symbolCount);
break;
case 6:
unpack6(symbolBuffer, packedBuffer, symbolCount);
break;
case 8:
unpack8(symbolBuffer, packedBuffer, symbolCount);
break;
case 10:
unpack10(symbolBuffer, packedBuffer, symbolCount);
break;
case 12:
unpack12(symbolBuffer, packedBuffer, symbolCount);
break;
case 16:
unpack16(symbolBuffer, packedBuffer, symbolCount);
break;
default:
throw std::runtime_error("Unsupported unpacking size");
}
}
inline void BytePacker::pack2(unsigned char *dest,
const unsigned int *symbolBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 4;
for (size_t i = 0; i != limit; i++) {
*dest = (*symbolBuffer); // bits 1-2 into 1-2
++symbolBuffer;
*dest |= (*symbolBuffer) << 2; // bits 1-2 into 3-4
++symbolBuffer;
*dest |= (*symbolBuffer) << 4; // bits 1-2 into 5-6
++symbolBuffer;
*dest |= (*symbolBuffer) << 6; // bits 1-2 into 7-8
++symbolBuffer;
++dest;
}
size_t pos = limit * 4;
if (pos != symbolCount) {
*dest = (*symbolBuffer); // bits 1-2 into 1-2
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= (*symbolBuffer) << 2; // bits 1-2 into 3-4
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= (*symbolBuffer) << 4; // bits 1-2 into 5-6
}
}
}
}
inline void BytePacker::unpack2(unsigned *symbolBuffer,
unsigned char *packedBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 4;
for (size_t i = 0; i != limit; i++) {
*symbolBuffer = *packedBuffer & 0x03; // bits 1-2 into 1-2
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x0C) >> 2; // bits 3-4 into 1-2
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x30) >> 4; // bits 5-6 into 1-2
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0xC0) >> 6; // bits 7-8 into 1-2
++symbolBuffer;
++packedBuffer;
}
size_t pos = limit * 4;
if (pos != symbolCount) {
*symbolBuffer = *packedBuffer & 0x03; // bits 1-2 into 1-2
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x0C) >> 2; // bits 3-4 into 1-2
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x30) >> 4; // bits 5-6 into 1-2
}
}
}
}
inline void BytePacker::pack3(unsigned char *dest, const unsigned *symbolBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 8;
for (size_t i = 0; i != limit; i++) {
*dest = *symbolBuffer; // 1. Bit 1-3 into 1-3
++symbolBuffer;
*dest |= (*symbolBuffer) << 3; // 2. Bits 1-3 into 4-6
++symbolBuffer;
*dest |= ((*symbolBuffer) & 0x3) << 6; // 3. Bits 1-2 into 7-8
++dest;
*dest = ((*symbolBuffer) & 0x4) >> 2; // 3b. Bit 3 into 1
++symbolBuffer;
*dest |= (*symbolBuffer) << 1; // 4. Bits 1-3 into 2-4
++symbolBuffer;
*dest |= (*symbolBuffer) << 4; // 5. Bits 1-3 into 5-7
++symbolBuffer;
*dest |= ((*symbolBuffer) & 0x1) << 7; // 6. Bit 1 into 8
++dest;
*dest = ((*symbolBuffer) & 0x6) >> 1; // 6b. Bits 2-3 into 1-2
++symbolBuffer;
*dest |= (*symbolBuffer) << 2; // 7. Bits 1-3 into bits 3-5
++symbolBuffer;
*dest |= (*symbolBuffer) << 5; // 8. Bits 1-3 into bits 6-8
++symbolBuffer;
++dest;
}
size_t pos = limit * 8;
if (pos != symbolCount) {
*dest = *symbolBuffer; // 1. Bit 1-3 into 1-3
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= (*symbolBuffer) << 3; // 2. Bits 1-3 into 4-6
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= ((*symbolBuffer) & 0x3) << 6; // 3. Bits 1-2 into 7-8
++dest;
*dest = ((*symbolBuffer) & 0x4) >> 2; // Bit 3 into 1
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= (*symbolBuffer) << 1; // 4. Bits 1-3 into 2-4
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= (*symbolBuffer) << 4; // 5. Bits 1-3 into 5-7
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= ((*symbolBuffer) & 0x1) << 7; // 6. Bit 1 into 8
++dest;
*dest = ((*symbolBuffer) & 0x6) >> 1; // Bits 2-3 into 1-2
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= (*symbolBuffer) << 2; // 7. Bits 1-3 into bits 3-5
}
}
}
}
}
}
}
}
inline void BytePacker::unpack3(unsigned *symbolBuffer,
unsigned char *packedBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 8;
for (size_t i = 0; i != limit; i++) {
*symbolBuffer = (*packedBuffer) & 0x07; // 1. Bits 1-3 into 1-3
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x38) >> 3; // 2. Bits 4-6 into 1-3
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0xC0) >> 6; // 3. Bits 7-8 into 1-2
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x01) << 2; // 3b. Bit 1 into 3
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x0e) >> 1; // 4. Bit 2-4 into 1-3
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x70) >> 4; // 5. Bit 5-7 into 1-3
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x80) >> 7; // 6. Bit 8 into 1
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x03) << 1; // 6b. Bit 1-2 into 2-3
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x1c) >> 2; // 7. Bit 3-5 into 1-3
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0xe0) >> 5; // 8. Bit 6-8 into 1-3
++symbolBuffer;
++packedBuffer;
}
size_t pos = limit * 8;
if (pos != symbolCount) {
*symbolBuffer = (*packedBuffer) & 0x07; // 1. Bits 1-3 into 1-3
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x38) >> 3; // 2. Bits 4-6 into 1-3
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0xC0) >> 6; // 3. Bits 7-8 into 1-2
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x01) << 2; // 3b. Bit 1 into 3
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x0e) >> 1; // 4. Bit 2-4 into 1-3
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer =
((*packedBuffer) & 0x70) >> 4; // 5. Bit 5-7 into 1-3
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0x80) >> 7; // 6. Bit 8 into 1
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x03)
<< 1; // 6b. Bit 1-2 into 2-3
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer =
((*packedBuffer) & 0x1c) >> 2; // 7. Bit 3-5 into 1-3
}
}
}
}
}
}
}
}
inline void BytePacker::pack4(unsigned char *dest,
const unsigned int *symbolBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 2;
for (size_t i = 0; i != limit; i++) {
*dest = (*symbolBuffer); // bits 1-4 into 1-4
++symbolBuffer;
*dest |= (*symbolBuffer) << 4; // bits 1-4 into 5-8
++symbolBuffer;
++dest;
}
if (limit * 2 != symbolCount) *dest = (*symbolBuffer); // bits 1-4 into 1-4
}
inline void BytePacker::unpack4(unsigned *symbolBuffer,
unsigned char *packedBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 2;
for (size_t i = 0; i != limit; i++) {
*symbolBuffer = *packedBuffer & 0x0F; // bits 1-4 into 1-4
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0xF0) >> 4; // bits 5-8 into 1-4
++symbolBuffer;
++packedBuffer;
}
if (limit * 2 != symbolCount)
*symbolBuffer = *packedBuffer & 0x0F; // bits 1-4 into 1-4
}
inline void BytePacker::pack6(unsigned char *dest, const unsigned *symbolBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 4;
for (size_t i = 0; i != limit; i++) {
*dest = *symbolBuffer; // Bit 1-6 into 1-6
++symbolBuffer;
*dest |= (*symbolBuffer & 3) << 6; // Bits 1-2 into 7-8
++dest;
*dest = (*symbolBuffer & 60) >> 2; // Bits 3-6 into 1-4
++symbolBuffer;
*dest |= (*symbolBuffer & 15) << 4; // Bits 1-4 into 5-8
++dest;
*dest = (*symbolBuffer & 48) >> 4; // Bits 5-6 into 1-2
++symbolBuffer;
*dest |= *symbolBuffer << 2; // Bits 1-6 into bits 3-8
++symbolBuffer;
++dest;
}
size_t pos = limit * 4;
if (pos != symbolCount) {
*dest = *symbolBuffer; // Bit 1-6 into 1-6
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= (*symbolBuffer & 3) << 6; // Bits 1-2 into 7-8
++dest;
*dest = (*symbolBuffer & 60) >> 2; // Bits 3-6 into 1-4
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= (*symbolBuffer & 15) << 4; // Bits 1-4 into 5-8
++dest;
*dest = (*symbolBuffer & 48) >> 4; // Bits 5-6 into 1-2
//++symbolBuffer; ++pos;
}
}
}
}
inline void BytePacker::unpack6(unsigned *symbolBuffer,
unsigned char *packedBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 4;
for (size_t i = 0; i != limit; i++) {
*symbolBuffer = (*packedBuffer) & 63; // Bits 1-6 into 1-6
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 192) >> 6; // Bits 7-8 into 1-2
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 15) << 2; // Bits 1-4 into 3-6
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 240) >> 4; // Bits 5-8 into 1-4
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 3) << 4; // Bits 1-2 into 5-6
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 252) >> 2; // Bits 3-8 into 1-6
++packedBuffer;
++symbolBuffer;
}
size_t pos = limit * 4;
if (pos != symbolCount) {
*symbolBuffer = (*packedBuffer) & 63; // Bits 1-6 into 1-6
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 192) >> 6; // Bits 7-8 into 1-2
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 15) << 2; // Bits 1-4 into 3-6
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 240) >> 4; // Bits 5-8 into 1-4
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 3) << 4; // Bits 1-2 into 5-6
}
}
}
}
inline void BytePacker::pack8(unsigned char *dest, const unsigned *symbolBuffer,
size_t symbolCount) {
for (size_t i = 0; i != symbolCount; ++i) dest[i] = symbolBuffer[i];
}
inline void BytePacker::unpack8(unsigned *symbolBuffer,
unsigned char *packedBuffer,
size_t symbolCount) {
for (size_t i = 0; i != symbolCount; ++i) symbolBuffer[i] = packedBuffer[i];
}
inline void BytePacker::pack10(unsigned char *dest,
const unsigned int *symbolBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 4;
for (size_t i = 0; i != limit; i++) {
*dest = (*symbolBuffer & 0x0FF); // Bit 1-8 into 1-8
++dest;
*dest = (*symbolBuffer & 0x300) >> 8; // Bits 9-10 into 1-2
++symbolBuffer;
*dest |= (*symbolBuffer & 0x03F) << 2; // Bits 1-6 into 3-8
++dest;
*dest = (*symbolBuffer & 0x3C0) >> 6; // Bits 7-10 into 1-4
++symbolBuffer;
*dest |= (*symbolBuffer & 0x00F) << 4; // Bits 1-4 into 5-8
++dest;
*dest = (*symbolBuffer & 0x3F0) >> 4; // Bits 5-10 into bits 1-6
++symbolBuffer;
*dest |= (*symbolBuffer & 0x003) << 6; // Bits 1-2 into 7-8
++dest;
*dest = (*symbolBuffer & 0x3FC) >> 2; // Bits 3-10 into bits 1-8
++symbolBuffer;
++dest;
}
size_t pos = limit * 4;
if (pos != symbolCount) {
*dest = (*symbolBuffer & 0x0FF); // Bit 1-8 into 1-8
++dest;
*dest = (*symbolBuffer & 0x300) >> 8; // Bits 9-10 into 1-2
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= (*symbolBuffer & 0x03F) << 2; // Bits 1-6 into 3-8
++dest;
*dest = (*symbolBuffer & 0x3C0) >> 6; // Bits 7-10 into 1-4
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*dest |= (*symbolBuffer & 0x00F) << 4; // Bits 1-4 into 5-8
++dest;
*dest = (*symbolBuffer & 0x3F0) >> 4; // Bits 5-10 into bits 1-6
//++symbolBuffer; ++pos;
}
}
}
}
inline void BytePacker::unpack10(unsigned int *symbolBuffer,
unsigned char *packedBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 4;
for (size_t i = 0; i != limit; i++) {
*symbolBuffer = *packedBuffer; // Bits 1-8 into 1-8
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x03) << 8; // Bits 1-2 into 9-10
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0xFC) >> 2; // Bits 3-8 into 1-6
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x0F) << 6; // Bits 1-4 into 7-10
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0xF0) >> 4; // Bits 5-8 into 1-4
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x3F) << 4; // Bits 1-6 into 5-10
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0xC0) >> 6; // Bits 7-8 into 1-2
++packedBuffer;
*symbolBuffer |= (*packedBuffer) << 2; // Bits 1-8 into 3-10
++packedBuffer;
++symbolBuffer;
}
size_t pos = limit * 4;
if (pos != symbolCount) {
*symbolBuffer = *packedBuffer; // Bits 1-8 into 1-8
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x03) << 8; // Bits 1-2 into 9-10
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0xFC) >> 2; // Bits 3-8 into 1-6
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x0F) << 6; // Bits 1-4 into 7-10
++pos;
if (pos != symbolCount) {
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0xF0) >> 4; // Bits 5-8 into 1-4
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x3F) << 4; // Bits 1-6 into 5-10
}
}
}
}
inline void BytePacker::pack12(unsigned char *dest,
const unsigned int *symbolBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 2;
for (size_t i = 0; i != limit; i++) {
*dest = (*symbolBuffer) & 0x0FF; // bits 1-8 into 1-8
++dest;
*dest = ((*symbolBuffer) & 0xF00) >> 8; // bits 9-12 into 1-4
++symbolBuffer;
*dest |= ((*symbolBuffer) & 0x00F) << 4; // bits 1-4 into 5-8
++dest;
*dest = ((*symbolBuffer) & 0xFF0) >> 4; // bits 5-12 into 1-8
++symbolBuffer;
++dest;
}
if (limit * 2 != symbolCount) {
*dest = (*symbolBuffer) & 0x0FF; // bits 1-8 into 1-8
++dest;
*dest = ((*symbolBuffer) & 0xF00) >> 8; // bits 9-12 into 1-4
}
}
inline void BytePacker::unpack12(unsigned int *symbolBuffer,
unsigned char *packedBuffer,
size_t symbolCount) {
const size_t limit = symbolCount / 2;
for (size_t i = 0; i != limit; i++) {
*symbolBuffer = *packedBuffer; // bits 1-8 into 1-8
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x0F) << 8; // bits 1-4 into 9-12
++symbolBuffer;
*symbolBuffer = ((*packedBuffer) & 0xF0) >> 4; // bits 5-8 into 1-4
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0xFF) << 4; // bits 1-8 into 5-12
++packedBuffer;
++symbolBuffer;
}
if (limit * 2 != symbolCount) {
*symbolBuffer = *packedBuffer; // bits 1-8 into 1-8
++packedBuffer;
*symbolBuffer |= ((*packedBuffer) & 0x0F) << 8; // bits 1-4 into 9-12
}
}
inline void BytePacker::pack16(unsigned char *dest,
const unsigned *symbolBuffer,
size_t symbolCount) {
for (size_t i = 0; i != symbolCount; ++i)
reinterpret_cast<uint16_t *>(dest)[i] = symbolBuffer[i];
}
inline void BytePacker::unpack16(unsigned *symbolBuffer,
unsigned char *packedBuffer,
size_t symbolCount) {
for (size_t i = 0; i != symbolCount; ++i)
symbolBuffer[i] = reinterpret_cast<uint16_t *>(packedBuffer)[i];
}
} // namespace dyscostman
#endif
dyscostman::BytePacker
Class for bit packing of values into bytes.
Definition bytepacker.h:26
dyscostman::BytePacker::unpack4
static void unpack4(unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
Reverse of pack4().
Definition bytepacker.h:447
dyscostman::BytePacker::unpack12
static void unpack12(unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
Reverse of pack12().
Definition bytepacker.h:695
dyscostman::BytePacker::pack2
static void pack2(unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
Pack the symbols from symbolBuffer into the destination array using bitCount=2.
Definition bytepacker.h:220
dyscostman::BytePacker::bufferSize
static size_t bufferSize(size_t nSymbols, size_t nBits)
Definition bytepacker.h:148
dyscostman::BytePacker::pack8
static void pack8(unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
Pack the symbols from symbolBuffer into the destination array using bitCount=8.
Definition bytepacker.h:556
dyscostman::BytePacker::pack4
static void pack4(unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
Pack the symbols from symbolBuffer into the destination array using bitCount=4.
Definition bytepacker.h:433
dyscostman::BytePacker::pack3
static void pack3(unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
Pack the symbols from symbolBuffer into the destination array using bitCount=3.
Definition bytepacker.h:286
dyscostman::BytePacker::pack16
static void pack16(unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
Pack the symbols from symbolBuffer into the destination array using bitCount=16.
Definition bytepacker.h:718
dyscostman::BytePacker::pack10
static void pack10(unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
Pack the symbols from symbolBuffer into the destination array using bitCount=10.
Definition bytepacker.h:567
dyscostman::BytePacker::unpack6
static void unpack6(unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
Reverse of pack6().
Definition bytepacker.h:510
dyscostman::BytePacker::unpack3
static void unpack3(unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
Reverse of pack3().
Definition bytepacker.h:355
dyscostman::BytePacker::unpack
static void unpack(unsigned bitCount, unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
Call an unpack..() function for a given bit count.
Definition bytepacker.h:186
dyscostman::BytePacker::pack6
static void pack6(unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
Pack the symbols from symbolBuffer into the destination array using bitCount=6.
Definition bytepacker.h:462
dyscostman::BytePacker::unpack2
static void unpack2(unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
Reverse of pack2().
Definition bytepacker.h:253
dyscostman::BytePacker::pack12
static void pack12(unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
Pack the symbols from symbolBuffer into the destination array using bitCount=12.
Definition bytepacker.h:670
dyscostman::BytePacker::unpack16
static void unpack16(unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
Reverse of pack16().
Definition bytepacker.h:725
dyscostman::BytePacker::unpack10
static void unpack10(unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
Reverse of pack10().
Definition bytepacker.h:619
dyscostman::BytePacker::pack
static void pack(unsigned bitCount, unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
Call a pack..() function for a given bit count.
Definition bytepacker.h:153
dyscostman::BytePacker::unpack8
static void unpack8(unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
Reverse of pack8().
Definition bytepacker.h:561
dyscostman
Definition bytepacker.h:7