GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LDT / V0-5-0 > encdec / sun-gcc
#include "LDT/HDE.h"
#include "LDT/HUFF.h"
#include "LDT/BFP.h"
#include "LDT/BA.h"
#include "ffs.h"
#include "dprintf.h"
#include "PBS/TMR.h"
#include <string.h>
Classes | |
struct | _HistLimits_f |
Min and Max indices of a region of the histogram. More... | |
union | _HistLimits |
Min and Max indices of a region of the histogram as a union between and uninterpretted 32-bit integer and its field representation. More... | |
struct | _HistCore_f |
Describes the result of the encoding selection process, giving the lower and upper bin limits along with the number of entries outside that region. More... | |
union | _HistCore |
The histogram core description as a union between an uninterpretted 32-bit representation and its field representation. More... | |
struct | _CodesSummary_f |
Lays out the structure of the return summary from codes_condition. More... | |
union | _CodesSummary |
Lays out the structure of the return summary from codes_condition as a union between an uninterpretted 32-bit representation and its field representation. More... | |
struct | _DeltasSummary_f |
Summarizes the parameters describing the delta code lengths array. More... | |
union | _DeltasSummary |
Summarizes the parameters describing the delta code lengths array as a union between an uninterpretted 32-bit number and its field representation. More... | |
Defines | |
#define | BA_32 |
#define | NULL ((void *)(0)) |
#define | _monitor_declare(statements) |
#define | _monitor_time(_mon, _idx) |
#define | _monitor(_var, val) |
#define | monitor_report(_mon) |
#define | _CODES(_l0, _c0, _l1, _c1, _l2, _c2) |
#define | TOUCH(_adr, _offset) |
Typedefs | |
typedef struct _HistLimits_f | HistLimits_f |
Typedef for struct _HistLimits. | |
typedef union _HistLimits | HistLimits |
Typedef for union _HistLimits. | |
typedef struct _HistCore_f | HistCore_f |
Typedef for struct _HistCore. | |
typedef union _HistCore | HistCore |
Typedef for union _HistCode. | |
typedef struct _CodesSummary_f | CodesSummary_f |
Typedef for struct _CodesStatus_f. | |
typedef union _CodesSummary | CodesSummary |
Typedef for union _CodesSummary. | |
typedef struct _DeltasSummary_f | DeltasSummary_f |
Typedef for struct _DeltasSummary_f. | |
typedef union _DeltasSummary | DeltasSummary |
Typedef for union _DeltasSummary. | |
Functions | |
static __inline unsigned int | hist_limits_findL (const unsigned int *hist, int cnt) |
Finds the indices of the smallest and largest non-zero entry in the specified histogram. | |
static __inline unsigned long long int | hist_selectL (const unsigned int *hist, int nentries, HistLimits limits, int nbins) |
Finds the nbits that encompass the largest number of entries for the specified histogram. | |
static __inline int | hist_copyL (unsigned int *dst, const unsigned int *src, int min, int max) |
Copies the core of the histogram (i.e. from the first non-zero element to the last non-zero element. | |
static __inline unsigned int | hist_limits_find (const unsigned short int *hist, int cnt) |
Finds the indices of the smallest and largest non-zero entry in the specified histogram. | |
static __inline unsigned long long int | hist_select (const unsigned short int *hist, int nentries, HistLimits limits, int nbins) |
Finds the nbits that encompass the largest number of entries for the specified histogram. | |
static __inline int | hist_copy (unsigned int *dst, const unsigned short int *src, int min, int max) |
Copies the core of the histogram (i.e. from the first non-zero element to the last non-zero element. | |
static __inline unsigned int | form_deltas (signed char *deltas, const HUFF_code *codes, int ncodes, int nseed, int seed) |
Forms the array code lengths deltas. | |
static __inline unsigned int | pack_short (unsigned int *buf, unsigned int pos, short int val) |
Packs the number of bits needed to contain the short integer and its value. | |
static __inline unsigned int | pack_seed_min_max (unsigned int *buf, unsigned int pos, int seed, int min, int max) |
static __inline void | hist_deltas (unsigned int *hist, int min, int nbins, const signed char *deltas, int ndeltas) |
Histograms the delta distribution. | |
static __inline unsigned int | pack_delta1 (unsigned int *buf, unsigned int pos, const signed char *deltas, int ndeltas, int min, int max_means_0) |
High efficiency routine to handle the case when all the deltas are 0 or 1. | |
static __inline unsigned int | pack_delta2 (unsigned int *buf, unsigned int pos, const signed char *deltas, int ndeltas, int min, int max_means_0) |
High efficiency routine to handle the case when all the delta range is only 2 (3 values). | |
static __inline unsigned int | pack_delta_huff (unsigned int *buf, unsigned int pos, const signed char *deltas, int ndeltas, int min, int max, int max_means_0) |
Packs the delta code lengths as a huffman table. | |
static __inline unsigned int | huff_table_encode (unsigned int *buf, unsigned int pos, CodesSummary cs, const HUFF_code *codes, const unsigned int *freq, signed char *deltas, int min, int max, unsigned int under, unsigned int over) |
Encodes the Huffman encoding table. | |
static __inline unsigned int | huff_symbols_encode (unsigned int *buf, unsigned int pos, const HUFF_code *codes, int min, int max, unsigned int nunderflow, unsigned int noverflow, int xsymbols, const short int *symbols, int nsymbols) |
Encodes the pedestal subtracted ADC values using the specified Huffman codes. | |
static __inline unsigned int | direct_symbols_encode (HDE *hde, unsigned int *buf, unsigned int pos, int min, int nbits, const short int *symbols, int nsymbols) |
Encodes the specified symbols symbols using the specified histogram of frequencies. Both the symbols and the histogram are presented as 16-bit values. | |
static __inline unsigned int | codes_condition (HUFF_code *codes, const unsigned int *freq, int ncodes) |
Conditions the code array by setting the code lengths of non-existent codes to the maximum code length + 1. | |
declare (static void print_nbits(const int *f, int cnt, int tot)) | |
unsigned int | HDE_sizeof (unsigned int nhuff) |
Returns the size, in bytes, for a handle to hold a Huffman distribution of huffman_bins. | |
void * | HDE_construct (HDE *hde, unsigned int nhuff) |
Constructs (initializes) the specified HDE structure. | |
void | HDE_tableConstructL (HDE *hde, unsigned int nhuff, const unsigned int *hist, int nbins, int nentries) |
Constructs HDE Huffman Table associated with the specified distribution. | |
unsigned int | HDE_tableEncode (HDE *hde, unsigned int *buf, unsigned int pos) |
Encodes a previously constructed table. | |
unsigned int | HDE_symbolsEncodeS (HDE *hde, unsigned int *buf, unsigned int pos, const short int *symbols, int nsymbols) |
Encodes the set of symbols using the encoding information in hde. This encoding information must have been previously setup using HDE_encodeTable. | |
unsigned int | HDE_encodeSS (HDE *hde, unsigned int *buf, unsigned int pos, unsigned int nhuff, const unsigned short int *hist, int nbins, const short int *symbols, int nsymbols) |
Encodes the specified symbols symbols using the specified histogram of frequencies. Both the symbols and the histogram are presented as 16-bit values. | |
const HDE_assay * | HDE_assayLocate (const HDE *hde) |
Returns a pointer to the publically defined piece of this structure. This can be a one-time call, i.e. for any given HDE structure, this routine always returns the same value. | |
void | HDE_histClearL (const HDE *hde, unsigned int *hist) |
Clears the histogram using the active bin range stored in the HDE_assay block of the HDE structure. | |
void | HDE_histClearS (const HDE *hde, unsigned short int *hist) |
Clears the histogram using the active bin range stored in the HDE_assay block of the HDE structure. |
CVS $Id: HDE.c,v 1.10 2010/08/06 19:18:20 saxton Exp $
#define _CODES | ( | _l0, | |||
_c0, | |||||
_l1, | |||||
_c1, | |||||
_l2, | |||||
_c2 | ) |
Value:
( \ (((_c2 << 2) | _l2) << 8) | \ (((_c1 << 2) | _l1) << 4) | \ (((_c0 << 2) | _l0) << 0) \ )
static __inline unsigned int codes_condition | ( | HUFF_code * | codes, | |
const unsigned int * | freq, | |||
int | ncodes | |||
) | [static] |
Conditions the code array by setting the code lengths of non-existent codes to the maximum code length + 1.
codes | The codes to condition | |
freq | The frequency distribution. Elements with 0 entries have their corresponding codes 'conditioned' | |
ncodes | The number of codes and also, by definition, the number elements in freq. |
unsigned int direct_symbols_encode | ( | HDE * | hde, | |
unsigned int * | buf, | |||
unsigned int | pos, | |||
int | min, | |||
int | nbits, | |||
const short int * | symbols, | |||
int | nsymbols | |||
) | [static] |
Encodes the specified symbols symbols using the specified histogram of frequencies. Both the symbols and the histogram are presented as 16-bit values.
hde | The HDE control structure | |
buf | The output buffer address | |
pos | The current write bit offset | |
min | The value of the smallest symbol | |
nbits | The number of bits needed to encode the widest symbol | |
symbols | The array of symbols | |
nsymbols | The number of symbols |
static __inline unsigned int form_deltas | ( | signed char * | deltas, | |
const HUFF_code * | codes, | |||
int | ncodes, | |||
int | nseed, | |||
int | seed | |||
) | [static] |
Forms the array code lengths deltas.
deltas | The array of deltas to be filled out | |
codes | The HUFF_man code array to be differinated | |
ncodes | The number of codes in codes | |
nseed | The seed bin | |
seed | The seed value |
Returns a pointer to the publically defined piece of this structure. This can be a one-time call, i.e. for any given HDE structure, this routine always returns the same value.
hde | The HDE control structure |
void* HDE_construct | ( | HDE * | hde, | |
unsigned int | nhuff | |||
) |
Constructs (initializes) the specified HDE structure.
hde | The HDE control structure to construct | |
nhuff | The maximum number of Huffman encoding bins that this control structure is meant to support. |
unsigned int HDE_encodeSS | ( | HDE * | hde, | |
unsigned int * | buf, | |||
unsigned int | pos, | |||
unsigned int | nhuff, | |||
const unsigned short int * | hist, | |||
int | nbins, | |||
const short int * | symbols, | |||
int | nsymbols | |||
) |
Encodes the specified symbols symbols using the specified histogram of frequencies. Both the symbols and the histogram are presented as 16-bit values.
hde | The HDE control structure | |
buf | The output buffer address | |
pos | The current write bit offset | |
nhuff | Provides a means to limit the size of the huffman encoding region to a region that is smaller than what was specified during the HDE construction (i.e. the nhuff parameter) The construction value is used, if this value is 0 or larger. | |
hist | The frequency histogram. The histogram is such that it extends -/+ nbins from this pointer. That is, this is the center of the histogram. | |
nbins | The half width of the histogram | |
symbols | The array of symbols | |
nsymbols | The number of symbols |
void HDE_histClearL | ( | const HDE * | hde, | |
unsigned int * | hist | |||
) |
Clears the histogram using the active bin range stored in the HDE_assay block of the HDE structure.
hde | The HDE control handle | |
hist | The histogram to clear |
void HDE_histClearS | ( | const HDE * | hde, | |
unsigned short int * | hist | |||
) |
Clears the histogram using the active bin range stored in the HDE_assay block of the HDE structure.
hde | The HDE control handle | |
hist | The histogram to clear |
unsigned int HDE_sizeof | ( | unsigned int | nhuff | ) |
Returns the size, in bytes, for a handle to hold a Huffman distribution of huffman_bins.
nhuff | The maximum size of the Huffman encoding area Suggested values are small powers of 2 like 32, 64, 128. Note also up to 3 bins may be used to hold describe the underflow, overflow and exception areas. Currently these 3 are mapped into 1 bin, but this may change in a future implementation |
unsigned int HDE_symbolsEncodeS | ( | HDE * | hde, | |
unsigned int * | buf, | |||
unsigned int | pos, | |||
const short int * | symbols, | |||
int | nsymbols | |||
) |
Encodes the set of symbols using the encoding information in hde. This encoding information must have been previously setup using HDE_encodeTable.
hde | The HDE control structure | |
symbols | The array of symbols | |
nsymbols | The number of symbols | |
buf | The output buffer address | |
pos | The current write bit offset |
void HDE_tableConstructL | ( | HDE * | hde, | |
unsigned int | nhuff, | |||
const unsigned int * | hist, | |||
int | nbins, | |||
int | nentries | |||
) |
Constructs HDE Huffman Table associated with the specified distribution.
hde | The HDE control structure | |
nhuff | Provides a means to limit the size of the huffman encoding region to a region that is smaller than what was specified during the HDE construction (i.e. the nhuff parameter) The construction value is used, if this value is 0 or larger. | |
hist | The frequency histogram. The histogram is such that it extends -/+ nbins from this pointer. That is, this is the center of the histogram. | |
nbins | The half width of the histogram | |
nentries | The number of entries in the histogram |
unsigned int HDE_tableEncode | ( | HDE * | hde, | |
unsigned int * | buf, | |||
unsigned int | pos | |||
) |
Encodes a previously constructed table.
hde | The HDE control structure | |
buf | The output buffer address | |
pos | The current write bit offset |
static __inline int hist_copy | ( | unsigned int * | dst, | |
const unsigned short int * | src, | |||
int | min, | |||
int | max | |||
) | [static] |
Copies the core of the histogram (i.e. from the first non-zero element to the last non-zero element.
dst | The destination histogram | |
src | The source histogram | |
min | The first non-zero histogram bin | |
max | The last non-zero histogram bin |
static __inline int hist_copyL | ( | unsigned int * | dst, | |
const unsigned int * | src, | |||
int | min, | |||
int | max | |||
) | [static] |
Copies the core of the histogram (i.e. from the first non-zero element to the last non-zero element.
dst | The destination histogram | |
src | The source histogram | |
min | The first non-zero histogram bin | |
max | The last non-zero histogram bin |
static __inline void hist_deltas | ( | unsigned int * | hist, | |
int | min, | |||
int | nbins, | |||
const signed char * | deltas, | |||
int | ndeltas | |||
) | [static] |
Histograms the delta distribution.
hist | The resulting histogram | |
min | The minimum bin number | |
nbins | The number of bins in the histogram | |
deltas | The deltas to histogram | |
ndeltas | The number of deltas to histogram |
static __inline unsigned int hist_limits_find | ( | const unsigned short int * | hist, | |
int | cnt | |||
) | [static] |
Finds the indices of the smallest and largest non-zero entry in the specified histogram.
hist | The target histogram | |
cnt | The total number of entries in the histogram |
static __inline unsigned int hist_limits_findL | ( | const unsigned int * | hist, | |
int | cnt | |||
) | [static] |
Finds the indices of the smallest and largest non-zero entry in the specified histogram.
hist | The target histogram | |
cnt | The total number of entries in the histogram |
static __inline unsigned long long int hist_select | ( | const unsigned short int * | hist, | |
int | nentries, | |||
HistLimits | limits, | |||
int | nbins | |||
) | [static] |
Finds the nbits that encompass the largest number of entries for the specified histogram.
hist | The target histogram | |
nentries | The total number of entries described by the limits | |
limits | The lower and upper bins of the histogram. These are the first and last bins with data | |
nbins | The width to select. |
static __inline unsigned long long int hist_selectL | ( | const unsigned int * | hist, | |
int | nentries, | |||
HistLimits | limits, | |||
int | nbins | |||
) | [static] |
Finds the nbits that encompass the largest number of entries for the specified histogram.
hist | The target histogram | |
nentries | The total number of entries described by the limits | |
limits | The lower and upper bins of the histogram. These are the first and last bins with data | |
nbins | The width to select. |
static __inline unsigned int huff_symbols_encode | ( | unsigned int * | buf, | |
unsigned int | pos, | |||
const HUFF_code * | codes, | |||
int | min, | |||
int | max, | |||
unsigned int | nunderflow, | |||
unsigned int | noverflow, | |||
int | xsymbols, | |||
const short int * | symbols, | |||
int | nsymbols | |||
) | [static] |
Encodes the pedestal subtracted ADC values using the specified Huffman codes.
buf | The output buffer | |
pos | The position of the next bit to fill | |
codes | The Huffman codes | |
min | The minimum symbol value for Huffman encoding | |
max | The maximum symbol value for Huffman encoding If 'p | |
nunderflow | The size of the underflow region | |
noverflow | The size of the overflow region | |
xsymbols | The number of symbols in the under/over flow regions | |
symbols | The symbols to encode | |
nsymbols | The number of symbols to encode |
static __inline unsigned int huff_table_encode | ( | unsigned int * | buf, | |
unsigned int | pos, | |||
CodesSummary | cs, | |||
const HUFF_code * | codes, | |||
const unsigned int * | freq, | |||
signed char * | deltas, | |||
int | min, | |||
int | max, | |||
unsigned int | under, | |||
unsigned int | over | |||
) | [static] |
Encodes the Huffman encoding table.
buf | The output buffer | |
pos | The position of the next bit to fill | |
cs | The code summary status | |
codes | The Huffman codes | |
freq | The frequency distribution. This is used to determine valid members. | |
deltas | Scratch area for the code length deltas | |
min | The minimum code index | |
max | The maximum code index | |
under | The number of bins in the underflow region | |
over | The number of bins in the overflow region |
static __inline unsigned int pack_delta1 | ( | unsigned int * | buf, | |
unsigned int | pos, | |||
const signed char * | deltas, | |||
int | ndeltas, | |||
int | min, | |||
int | max_means_0 | |||
) | [static] |
High efficiency routine to handle the case when all the deltas are 0 or 1.
buf | The output buffer | |
pos | The position of the next bit to fill | |
deltas | The deltas, by defintion, these must be 0 or 1 | |
ndeltas | The number of deltas | |
min | The minimum value | |
max_means_0 | If true, when the original code lengths restored from the deltas, the maximum code length really means 0 |
static __inline unsigned int pack_delta2 | ( | unsigned int * | buf, | |
unsigned int | pos, | |||
const signed char * | deltas, | |||
int | ndeltas, | |||
int | min, | |||
int | max_means_0 | |||
) | [static] |
High efficiency routine to handle the case when all the delta range is only 2 (3 values).
buf | The output buffer | |
pos | The position of the next bit to fill | |
deltas | The deltas, must have a range of only 2 | |
ndeltas | The number of deltas | |
min | The minimum value | |
max_means_0 | If true, when the original code lengths restored from the deltas, the maximum code length really means 0 |
In practice here are the assignments
If max is Bin0 Bin1 Bin2 Len:Code Len:Code Lne:Code Min == -1 2,3 1,0 2,2 Min != -1 1:0 2,2 2,3
static __inline unsigned int pack_delta_huff | ( | unsigned int * | buf, | |
unsigned int | pos, | |||
const signed char * | deltas, | |||
int | ndeltas, | |||
int | min, | |||
int | max, | |||
int | max_means_0 | |||
) | [static] |
Packs the delta code lengths as a huffman table.
buf | The output buffer | |
pos | The position of the next bit to fill | |
deltas | The deltas to pack | |
ndeltas | The number of deltas to pack | |
min | The minimum delta value | |
max | The maximum delta value | |
max_means_0 | If true, when the original code lengths restored from the deltas, the maximum code length really means 0 |
static __inline unsigned int pack_seed_min_max | ( | unsigned int * | buf, | |
unsigned int | pos, | |||
int | seed, | |||
int | min, | |||
int | max | |||
) | [static] |
buf | The output buffer | |
pos | The position of the next bit to fill | |
seed | The seed value | |
min | The minimum delta value | |
max | The maximum delta value |
static __inline unsigned int pack_short | ( | unsigned int * | buf, | |
unsigned int | pos, | |||
short int | val | |||
) | [static] |
Packs the number of bits needed to contain the short integer and its value.
buf | The output buffer | |
pos | The position of the next bit to fill | |
val | The value to pack |