GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LDT / V0-5-0 > encdec / linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

HDD.c File Reference

Implementation ofthe routines to decode a distribution of symbols previously encoded using HDE_encodeSS. More...

#include "LDT/HDD.h"
#include "LDT/HUFF.h"
#include "LDT/BFU.h"
#include "ffs.h"
#include "PBI/Endianness.h"
#include "dprintf.h"

Classes

struct  _HDD
union  _DeltaInfo_bf
 Union of the delta information word as (signed) bit fields. More...
union  _DeltaInfo
 Union of the delta information word as an interpretted 32-bit integer and its (signed) bit fields. More...

Defines

#define _CV_TO_CODETREE(_0, _1, _2)   ((_2 << 4) | (_1 << 2) | (_0 << 0))
#define _CODES(_c0, _c1, _c2)   ((_c2 << 4) | (_c1 << 2) | (_c0 << 0))

Typedefs

typedef struct _HDD HDD
typedef struct
_DeltaInfo_bf 
DeltaInfo_bf
 Typedef for union _DeltaInfo_bf.
typedef union _DeltaInfo DeltaInfo
 Typedef for union _DeltaInfo.

Functions

static __inline BFU unpack_short (BFU bfu, const unsigned int *src, int *val)
static __inline BFU unpack_nshort (BFU bfu, const unsigned int *src, int *val)
static __inline BFU unpack_ushort (BFU bfu, const unsigned int *src, unsigned int *val)
static __inline BFU unpack_delta_min_max_seed (BFU bfu, const unsigned int *src, int *delta_min, int *delta_max, unsigned int *seed)
static __inline void fill_code_lens (unsigned char *lens, int nlens, unsigned int seed, int delta)
 Routine to form the code length when all the deltas are the same.
static __inline BFU unpack_code_lens1 (unsigned char *lens, int nlens, unsigned int seed, int min, const unsigned int *src, unsigned int max, BFU bfu)
 Optimized routine to unpack the deltas and form the code length array when the deltas are all 0s or 1s.
static __inline BFU unpack_code_lens2 (unsigned char *lens, int nlens, unsigned int seed, int min, const unsigned int *src, unsigned int max, BFU bfu)
 Optimized routine to unpack the deltas and form the code length array when the deltas ranges is 2 (0,1,2).
static __inline BFU unpack_code_lensN (unsigned char *lens, int nlens, unsigned int seed, int delta_min, int delta_max, const unsigned int *src, unsigned int max, BFU bfu, HUFF_dtable *dtable)
 Generic routine to unpack the deltas and form the code length array when the deltas are themselves encoded as a Huffman table The routines unpack_deltas1 and deltas2 are used when the range of the huffman encoding table is only 1 (2 symbols) or 2 (3 symbols) In these cases, a more optimal scheme, tailored to these small tables is used.
static __inline BFU unpack_code_lens (unsigned char *lens, int nlens, const unsigned int *src, unsigned int max, BFU bfu, HUFF_dtable *dtable)
 Dispatch routine to unpack the deltas and form the code length array when the deltas are themselves encoded as a Huffman table.
static __inline BFU unpack_syms (signed short int *syms, int nsyms, const HUFF_dtable *dtable, int nlens, int min, unsigned int nunderflow, unsigned int noverflow, const unsigned int *src, unsigned int max_pos, BFU bfu)
 Restores the differences between the original PHA value and its pedestal.
unsigned int HDD_sizeof (unsigned int nhuff)
 Returns the size, in bytes, for a handle to hold a Huffman distribution of huffman_bins.
void * HDD_construct (HDD *hdd, unsigned int nhuff)
 Constructs (initializes) the specified HDD structure.
unsigned int HDD_tableDecode (HDD *hdd, const unsigned int *src, unsigned int pos, unsigned int max_pos)
 Unpacks the table encoded with HDE_tableEncode.
unsigned int HDD_symbolsDecodeS (HDD *hdd, const unsigned int *src, unsigned int pos, unsigned int max_pos, short *syms, unsigned int nsyms)
 Unpacks the distribution encoded with HDD_symbolsEncodeS.
unsigned int HDD_decodeS (HDD *hdd, const unsigned int *src, unsigned int pos, unsigned int max_pos, short *syms, unsigned int nsyms)
 Unpacks the distribution encoded with HDD_encodeSS.


Detailed Description

Implementation ofthe routines to decode a distribution of symbols previously encoded using HDE_encodeSS.

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: HDD.c,v 1.10 2010/08/23 16:32:41 saxton Exp $

Typedef Documentation

DeltaInfo_bf

Typedef for union _DeltaInfo_bf.

The advantage of defining these structures is that it allows the compiler to sign-extend the bit fields where needed.


Function Documentation

static __inline BFU fill_code_lens ( unsigned char *  lens,
int  nlens,
unsigned int  seed,
int  delta 
) [static]

Routine to form the code length when all the deltas are the same.

Parameters:
lens The array of code lengths to fill in
nlens The number of lengths to fill in
seed The starting value to integrate the deltas from
delta The delta length

void* HDD_construct ( HDD *  hdd,
unsigned int  nhuff 
)

Constructs (initializes) the specified HDD structure.

Returns:
The next address after this structure.
Parameters:
hdd The HDD control structure to construct
nhuff The maximum number of Huffman encoding bins that this control structure is meant to support.
The size of this structure should be acquired by a call to HDD_sizeof. The parameter huffman_nbins must be the same in the call to HDD_sizeof and HDD_construct.

unsigned int HDD_decodeS ( HDD *  hdd,
const unsigned int *  src,
unsigned int  pos,
unsigned int  max_pos,
short *  syms,
unsigned int  nsyms 
)

Unpacks the distribution encoded with HDD_encodeSS.

Returns:
The next bit position to read.
Parameters:
hdd The decode handle
src The source stream
pos The current bit read position
max_pos The maximum bit position, i.e. do not read past this point
syms The array to receive the decoded symbols
nsyms The number of symbols to decode

unsigned int HDD_sizeof ( unsigned int  nhuff  ) 

Returns the size, in bytes, for a handle to hold a Huffman distribution of huffman_bins.

Parameters:
nhuff The maximum number of Huffman codes
For the most part, this only provides a working area. On host-based workstations with expandable stacks, this memory would go on the stack, except for the fact that it is variable length.

unsigned int HDD_symbolsDecodeS ( HDD *  hdd,
const unsigned int *  src,
unsigned int  pos,
unsigned int  max_pos,
short *  syms,
unsigned int  nsyms 
)

Unpacks the distribution encoded with HDD_symbolsEncodeS.

Returns:
The next bit position to read.
Parameters:
hdd The decode handle
src The source stream
pos The current bit read position
max_pos The maximum bit position, i.e. do not read past this point
syms The array to receive the decoded symbols
nsyms The number of symbols to decode

unsigned int HDD_tableDecode ( HDD *  hdd,
const unsigned int *  src,
unsigned int  pos,
unsigned int  max_pos 
)

Unpacks the table encoded with HDE_tableEncode.

Returns:
The next bit position to read.
Parameters:
hdd The decode handle
src The source stream
pos The current bit read position
max_pos The maximum bit position, i.e. do not read past this point

static __inline BFU unpack_code_lens ( unsigned char *  lens,
int  nlens,
const unsigned int *  src,
unsigned int  max,
BFU  bfu,
HUFF_dtable dtable 
) [static]

Dispatch routine to unpack the deltas and form the code length array when the deltas are themselves encoded as a Huffman table.

Returns:
The updated bit position and current deblocked 32-bit buffer
Parameters:
lens The array of code lengths to fill in
nlens The number of lengths to fill in
src The data source, i.e. the bit stream
max The maximum bit position
bfu The current bit position and temporary buffer
dtable Temporary storage to hold the huffman decode table for the lengths

static __inline BFU unpack_code_lens1 ( unsigned char *  lens,
int  nlens,
unsigned int  seed,
int  min,
const unsigned int *  src,
unsigned int  max,
BFU  bfu 
) [static]

Optimized routine to unpack the deltas and form the code length array when the deltas are all 0s or 1s.

Returns:
The updated bit position and current deblocked 32-bit buffer
Parameters:
lens The array of code lengths to fill in
nlens The number of lengths to fill in
seed The starting value to integrate the deltas from
min The minimum delta, this is almost certainly 0, but..
src The data source, i.e. the bit stream
max The maximum bit position
bfu The current bit position and temporary buffer
This routine starts at the mid point and works its way first down to the code length 0, then restarts and works its way up to the last code length. In each case the deltas are integrated starting with the seed value

static __inline BFU unpack_code_lens2 ( unsigned char *  lens,
int  nlens,
unsigned int  seed,
int  min,
const unsigned int *  src,
unsigned int  max,
BFU  bfu 
) [static]

Optimized routine to unpack the deltas and form the code length array when the deltas ranges is 2 (0,1,2).

Returns:
The updated bit position and current deblocked 32-bit buffer
Parameters:
lens The array of code lengths to fill in
nlens The number of lengths to fill in
seed The starting value to integrate the deltas from
min The minimum delta, this is almost certainly -1 or 0
src The data source, i.e. the bit stream
max The maximum bit position
bfu The current bit position and temporary buffer
This routine starts at the mid point and works its way first down to the code length 0, then restarts and works its way up to the last code length. In each case the deltas are integrated starting with the seed value

static __inline BFU unpack_code_lensN ( unsigned char *  lens,
int  nlens,
unsigned int  seed,
int  delta_min,
int  delta_max,
const unsigned int *  src,
unsigned int  max,
BFU  bfu,
HUFF_dtable dtable 
) [static]

Generic routine to unpack the deltas and form the code length array when the deltas are themselves encoded as a Huffman table The routines unpack_deltas1 and deltas2 are used when the range of the huffman encoding table is only 1 (2 symbols) or 2 (3 symbols) In these cases, a more optimal scheme, tailored to these small tables is used.

Returns:
The updated bit position and current deblocked 32-bit buffer
Parameters:
lens The array of code lengths to fill in
nlens The number of lengths to fill in
delta_min The minimum delta value
delta_max The maximum delta value
seed The starting value to integrate the deltas from
src The data source, i.e. the bit stream
max The maximum bit position
bfu The current bit position and temporary buffer
dtable Temporary storage to hold the huffman decode table for the lengths. While this is returned to the caller, its purpose, to extract the lengths of the codes, has already been served.

static __inline BFU unpack_syms ( signed short int *  syms,
int  nsyms,
const HUFF_dtable dtable,
int  nlens,
int  min,
unsigned int  nunderflow,
unsigned int  noverflow,
const unsigned int *  src,
unsigned int  max_pos,
BFU  bfu 
) [static]

Restores the differences between the original PHA value and its pedestal.

Returns:
The updated bit position and current deblocked 32-bit buffer
Parameters:
syms The array of symbol values, corresponding to the difference between the PHA value and its pedestal to be filled in
nsyms The number of symbols to decode
dtable The decoding table
nlens The number of code lengths
min The minimum symbol value. This is the biase that most be added to all symbols when they are decoded. It restores the symbol to its original value.
nunderflow The number of bins below the first HUFFman bin to be decoded
noverflow The number of bins above the last HUFFman bin to be decoded
src The data source, i.e. the bit stream
max_pos The maximum bit position
bfu The current bit position and temporary buffer


Generated on Mon Aug 23 09:43:46 2010 by  doxygen 1.5.3