casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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. More...
 
static void unpack (unsigned bitCount, unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Call an unpack..() function for a given bit count. More...
 
static void pack2 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=2. More...
 
static void unpack2 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack2(). More...
 
static void pack3 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=3. More...
 
static void unpack3 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack3(). More...
 
static void pack4 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=4. More...
 
static void unpack4 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack4(). More...
 
static void pack6 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=6. More...
 
static void unpack6 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack6(). More...
 
static void pack8 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=8. More...
 
static void unpack8 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack8(). More...
 
static void pack10 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=10. More...
 
static void unpack10 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack10(). More...
 
static void pack12 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=12. More...
 
static void unpack12 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack12(). More...
 
static void pack16 (unsigned char *dest, const unsigned *symbolBuffer, size_t symbolCount)
 Pack the symbols from symbolBuffer into the destination array using bitCount=16. More...
 
static void unpack16 (unsigned *symbolBuffer, unsigned char *packedBuffer, size_t symbolCount)
 Reverse of pack16(). More...
 
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 25 of file bytepacker.h.

Member Function Documentation

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

Definition at line 147 of file bytepacker.h.

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 152 of file bytepacker.h.

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

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 566 of file bytepacker.h.

Referenced by pack().

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 669 of file bytepacker.h.

Referenced by pack().

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 717 of file bytepacker.h.

Referenced by pack().

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 219 of file bytepacker.h.

Referenced by pack().

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 285 of file bytepacker.h.

Referenced by pack().

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 432 of file bytepacker.h.

Referenced by pack().

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 461 of file bytepacker.h.

Referenced by pack().

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 555 of file bytepacker.h.

Referenced by pack().

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 185 of file bytepacker.h.

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

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 618 of file bytepacker.h.

Referenced by unpack().

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 694 of file bytepacker.h.

Referenced by unpack().

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 724 of file bytepacker.h.

Referenced by unpack().

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 252 of file bytepacker.h.

Referenced by unpack().

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 354 of file bytepacker.h.

Referenced by unpack().

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 446 of file bytepacker.h.

Referenced by unpack().

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 509 of file bytepacker.h.

Referenced by unpack().

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 560 of file bytepacker.h.

Referenced by unpack().


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