casacore
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
dyscostman::BytePacker Class Reference

Class for bit packing of values into bytes. More...

#include <bytepacker.h>

Static Public Member Functions

static void pack (unsigned bitCount, unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Call a pack..() function for a given bit count.
 
static void unpack (unsigned bitCount, unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Call an unpack..() function for a given bit count.
 
static void pack2 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=2.
 
static void unpack2 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack2().
 
static void pack3 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=3.
 
static void unpack3 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack3().
 
static void pack4 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=4.
 
static void unpack4 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack4().
 
static void pack6 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=6.
 
static void unpack6 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack6().
 
static void pack8 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=8.
 
static void unpack8 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack8().
 
static void pack10 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=10.
 
static void unpack10 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack10().
 
static void pack12 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=12.
 
static void unpack12 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack12().
 
static void pack16 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=16.
 
static void unpack16 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack16().
 
static size_t bufferSize (size_t nSymbols, size_t nBits)
 

Detailed Description

Class for bit packing of values into bytes.

Contains several methods that can pack and unpack an array of unsigned values into a bit-packed array, using as few bytes as possible. The number of bits used is fixed for all values in the array. All methods assume that the specified output array has at least enough space to store the packed / unpacked data. When packing, the amount of space needed is ceil(symbolCount / bitCount).

The pack() and unpack() methods can call the method with given bitcount at runtime. If the bitcount is known at compile time, one of the other methods can be used. For each of these calls, the input symbols are assumed to occupy at most the given number of bits. The number of bytes written during pack operations is ceil(symbolCount * bitCount / 8). unpack operations will write symbolCount symbols into the output buffer.

Definition at line 26 of file bytepacker.h.

Member Function Documentation

◆ bufferSize()

static size_t dyscostman::BytePacker::bufferSize ( size_t  nSymbols,
size_t  nBits 
)
inlinestatic

Definition at line 148 of file bytepacker.h.

◆ pack()

void dyscostman::BytePacker::pack ( unsigned  bitCount,
unsigned char *  dest,
const unsigned *  symbolBuffer,
size_t  symbolCount 
)
inlinestatic

Call a pack..() function for a given bit count.

Will forward the pack operation to the one for the given bit count.

Parameters
bitCountthe number of bits to use per symbol
destoutput buffer (see class desc for size)
symbolBufferthe input buffer
symbolCountnumber of symbols in symbolBuffer.

Definition at line 153 of file bytepacker.h.

References pack10(), pack12(), pack16(), pack2(), pack3(), pack4(), pack6(), and pack8().

◆ pack10()

void dyscostman::BytePacker::pack10 ( unsigned char *  dest,
const unsigned *  symbolBuffer,
size_t  symbolCount 
)
inlinestatic

Pack the symbols from symbolBuffer into the destination array using bitCount=10.

++symbolBuffer; ++pos;

Definition at line 567 of file bytepacker.h.

Referenced by pack().

◆ pack12()

void dyscostman::BytePacker::pack12 ( unsigned char *  dest,
const unsigned *  symbolBuffer,
size_t  symbolCount 
)
inlinestatic

Pack the symbols from symbolBuffer into the destination array using bitCount=12.

Definition at line 670 of file bytepacker.h.

Referenced by pack().

◆ pack16()

void dyscostman::BytePacker::pack16 ( unsigned char *  dest,
const unsigned *  symbolBuffer,
size_t  symbolCount 
)
inlinestatic

Pack the symbols from symbolBuffer into the destination array using bitCount=16.

Definition at line 718 of file bytepacker.h.

Referenced by pack().

◆ pack2()

void dyscostman::BytePacker::pack2 ( unsigned char *  dest,
const unsigned *  symbolBuffer,
size_t  symbolCount 
)
inlinestatic

Pack the symbols from symbolBuffer into the destination array using bitCount=2.

Definition at line 220 of file bytepacker.h.

Referenced by pack().

◆ pack3()

void dyscostman::BytePacker::pack3 ( unsigned char *  dest,
const unsigned *  symbolBuffer,
size_t  symbolCount 
)
inlinestatic

Pack the symbols from symbolBuffer into the destination array using bitCount=3.

Definition at line 286 of file bytepacker.h.

Referenced by pack().

◆ pack4()

void dyscostman::BytePacker::pack4 ( unsigned char *  dest,
const unsigned *  symbolBuffer,
size_t  symbolCount 
)
inlinestatic

Pack the symbols from symbolBuffer into the destination array using bitCount=4.

Definition at line 433 of file bytepacker.h.

Referenced by pack().

◆ pack6()

void dyscostman::BytePacker::pack6 ( unsigned char *  dest,
const unsigned *  symbolBuffer,
size_t  symbolCount 
)
inlinestatic

Pack the symbols from symbolBuffer into the destination array using bitCount=6.

++symbolBuffer; ++pos;

Definition at line 462 of file bytepacker.h.

Referenced by pack().

◆ pack8()

void dyscostman::BytePacker::pack8 ( unsigned char *  dest,
const unsigned *  symbolBuffer,
size_t  symbolCount 
)
inlinestatic

Pack the symbols from symbolBuffer into the destination array using bitCount=8.

Definition at line 556 of file bytepacker.h.

Referenced by pack().

◆ unpack()

void dyscostman::BytePacker::unpack ( unsigned  bitCount,
unsigned *  symbolBuffer,
unsigned char *  packedBuffer,
size_t  symbolCount 
)
inlinestatic

Call an unpack..() function for a given bit count.

Will forward the unpack operation to the one for the given bit count.

Parameters
bitCountthe number of bits used per symbol
symbolBufferoutput buffer
packedBufferthe input buffer with the packed symbols
symbolCountnumber of symbols that will be unpacked into symbolBuffer.

Definition at line 186 of file bytepacker.h.

References unpack10(), unpack12(), unpack16(), unpack2(), unpack3(), unpack4(), unpack6(), and unpack8().

◆ unpack10()

void dyscostman::BytePacker::unpack10 ( unsigned *  symbolBuffer,
unsigned char *  packedBuffer,
size_t  symbolCount 
)
inlinestatic

Reverse of pack10().

Will write symbolCount items into the symbolBuffer.

Definition at line 619 of file bytepacker.h.

Referenced by unpack().

◆ unpack12()

void dyscostman::BytePacker::unpack12 ( unsigned *  symbolBuffer,
unsigned char *  packedBuffer,
size_t  symbolCount 
)
inlinestatic

Reverse of pack12().

Will write symbolCount items into the symbolBuffer.

Definition at line 695 of file bytepacker.h.

Referenced by unpack().

◆ unpack16()

void dyscostman::BytePacker::unpack16 ( unsigned *  symbolBuffer,
unsigned char *  packedBuffer,
size_t  symbolCount 
)
inlinestatic

Reverse of pack16().

Will write symbolCount items into the symbolBuffer.

Definition at line 725 of file bytepacker.h.

Referenced by unpack().

◆ unpack2()

void dyscostman::BytePacker::unpack2 ( unsigned *  symbolBuffer,
unsigned char *  packedBuffer,
size_t  symbolCount 
)
inlinestatic

Reverse of pack2().

Will write symbolCount items into the symbolBuffer.

Definition at line 253 of file bytepacker.h.

Referenced by unpack().

◆ unpack3()

void dyscostman::BytePacker::unpack3 ( unsigned *  symbolBuffer,
unsigned char *  packedBuffer,
size_t  symbolCount 
)
inlinestatic

Reverse of pack3().

Will write symbolCount items into the symbolBuffer.

Definition at line 355 of file bytepacker.h.

Referenced by unpack().

◆ unpack4()

void dyscostman::BytePacker::unpack4 ( unsigned *  symbolBuffer,
unsigned char *  packedBuffer,
size_t  symbolCount 
)
inlinestatic

Reverse of pack4().

Will write symbolCount items into the symbolBuffer.

Definition at line 447 of file bytepacker.h.

Referenced by unpack().

◆ unpack6()

void dyscostman::BytePacker::unpack6 ( unsigned *  symbolBuffer,
unsigned char *  packedBuffer,
size_t  symbolCount 
)
inlinestatic

Reverse of pack6().

Will write symbolCount items into the symbolBuffer.

Definition at line 510 of file bytepacker.h.

Referenced by unpack().

◆ unpack8()

void dyscostman::BytePacker::unpack8 ( unsigned *  symbolBuffer,
unsigned char *  packedBuffer,
size_t  symbolCount 
)
inlinestatic

Reverse of pack8().

Will write symbolCount items into the symbolBuffer.

Definition at line 561 of file bytepacker.h.

Referenced by unpack().


The documentation for this class was generated from the following file: