GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LDT / dev > encdec / rhel6-64
#include <LDT/BA.h>
Classes | |
struct | _APE_cv_ui |
Defines the limits of the condition value as two 32-bit integers. More... | |
struct | _APE_cv |
Defines the limits of the condition value as union between the field definition two 32-bit integers and an interpretted 64-bit number. More... | |
struct | _APE_etx |
Encoding context. More... | |
Typedefs | |
typedef struct _APE_cv_ui | APE_cv_ui |
Typedef for APE_cv_ui. | |
typedef union _APE_cv | APE_cv |
Typedef for APE_cv. | |
typedef struct _APE_etx | APE_etx |
Typedef for struct _APE_etx. | |
Functions | |
unsigned int | APE_bcompress (unsigned char *out, unsigned int boff, unsigned char *max, const unsigned int *table, const unsigned char *in, int cnt, int *unencoded) |
Convenience routine to compress a byte stream. | |
int | APE_reset (APE_etx *etx, unsigned char *out, unsigned int boff, const unsigned char *max) |
Resets the output context. | |
int | APE_start (APE_etx *etx, unsigned char *out, unsigned int boff, const unsigned char *max) |
Initializes the encoding context. | |
int | APE_encode (APE_etx *etx, const unsigned int *table, unsigned int sym) |
Encodes one symbol. | |
int | APE_bencode (APE_etx *etx, const unsigned int *table, const unsigned char *syms, int nsyms) |
Encodes an array of unsigned char symbols. | |
int | APE_sencode (APE_etx *etx, const unsigned int *table, const unsigned short *syms, int nsyms) |
Encodes an array of unsigned char symbols. | |
int | APE_blencode (APE_etx *etx, const unsigned int **tables, unsigned char const *syms, int nsyms) |
Encodes an array of unsigned char symbols. | |
int | APE_slencode (APE_etx *etx, const unsigned int **tables, unsigned short const *syms, int nsyms) |
Encodes an array of unsigned short integer symbols each with their own table. | |
int | APE_finish (APE_etx *etx) |
Finishes the encoding by flushing out any currently buffered bits. |
CVS $Id: APE.h,v 1.4 2011/03/25 23:57:12 russell Exp $
Interface specification for routines to encode symbols using an arithmetic encoding technique. The encoding tables are 32-bits wide. This allows probabilities to (in principle) hold a range of 1/2**32.
Do not confuse the width of the symbol being encoded with the width of the probability tables. The width of the symbol being encoded is not a fundamental property of these routines. That is, these routines can be used to encode symbols of different widths. All that the user needs to do is provide a probability table that can be indexed by a symbol to give the cumulative probability of that symbol occuring. It is the width of the symbol (or more appropriately, the range of the symbol), that determines the number of elements in the table.
The choice of using 32-bit wide probability tables is a trade-off between two performance metrics, CPU vs compress efficiency. Smaller width tables will give slightly better CPU performance on certain machines, while wider width tables will come closer to achieving the maximum compression possible. It was found, that with careful coding, the CPU performance differences where small. Most this difference can be traced to the increased memory access (read cache misses) intrinsic in accessing a wider table. Thus it was decided to offer only the 32-bit width table as a one-size-fits-all solution.
Typedef for struct _APE_etx.
While this is defined in the public interface, this structure should be treated like a C++ private member. All manipulation of this structure should be through the APE routines.
unsigned int APE_bcompress | ( | unsigned char * | out, | |
unsigned int | boff, | |||
unsigned char * | max, | |||
const unsigned int * | table, | |||
const unsigned char * | in, | |||
int | cnt, | |||
int * | unencoded | |||
) |
Convenience routine to compress a byte stream.
out | The output buffer | |
boff | The current bit offset | |
max | The maximum output address (actually 1 byte past it) | |
table | The encoding table | |
in | The input buffer of symbols. | |
cnt | The number of input symbols. | |
unencoded | The number of input symbols left to encode. If successful this will be 0. |
References APE_bencode(), APE_finish(), and APE_start().
int APE_bencode | ( | APE_etx * | etx, | |
const unsigned int * | table, | |||
const unsigned char * | syms, | |||
int | nsyms | |||
) |
Encodes an array of unsigned char symbols.
etx | The encoding context | |
table | The encoding table | |
syms | The array of symbols to encode | |
nsyms | The number of symbols |
References APE_SYMTYPE_K_ARRAY_BYTE, and encode().
Referenced by APE_bcompress().
int APE_blencode | ( | APE_etx * | etx, | |
const unsigned int ** | tables, | |||
unsigned char const * | syms, | |||
int | nsyms | |||
) |
Encodes an array of unsigned char symbols.
etx | The encoding context | |
tables | The encoding table | |
syms | The array of symbols to encode | |
nsyms | The number of symbols |
References APE_SYMTYPE_K_ARRAY_BYTE, and encode_list().
int APE_encode | ( | APE_etx * | etx, | |
const unsigned int * | table, | |||
unsigned int | sym | |||
) |
Encodes one symbol.
etx | The encoding context | |
table | The encoding table | |
sym | The symbol to encode |
References immediate_encode().
int APE_finish | ( | APE_etx * | etx | ) |
Finishes the encoding by flushing out any currently buffered bits.
If | > 0, the number of encoded bits. If < 0, the number of bits needed to encode the final piece |
etx | The encoding context |
If there is enough room, the number of encoded bits is returned as a positive number.
References _APE_etx::ba, _APE_etx::bbeg, _APE_etx::beg, _BA::buffer, _APE_etx::cv, _APE_cv_ui::lo, _APE_etx::max, _BA::out, _APE_etx::tofollow, _BA::togo, and _APE_cv::ui.
Referenced by APE_bcompress().
int APE_reset | ( | APE_etx * | etx, | |
unsigned char * | out, | |||
unsigned int | boff, | |||
const unsigned char * | max | |||
) |
Resets the output context.
0,If | successful | |
-1,If | failed to provide at least 1 byte of memory. |
etx | The encoding context to reset | |
out | The output buffer. | |
boff | The bit offset into the output buffer. | |
max | The maximum output address (actually 1 byte past it) |
References _APE_etx::ba, _BA::buffer, _BA::out, and _BA::togo.
int APE_sencode | ( | APE_etx * | etx, | |
const unsigned int * | table, | |||
const unsigned short * | syms, | |||
int | nsyms | |||
) |
Encodes an array of unsigned char symbols.
etx | The encoding context | |
table | The encoding table | |
syms | The array of symbols to encode | |
nsyms | The number of symbols |
References APE_SYMTYPE_K_ARRAY_SHORT, and encode().
int APE_slencode | ( | APE_etx * | etx, | |
const unsigned int ** | tables, | |||
unsigned short const * | syms, | |||
int | nsyms | |||
) |
Encodes an array of unsigned short integer symbols each with their own table.
etx | The encoding context | |
tables | The encoding table | |
syms | The array of symbols to encode | |
nsyms | The number of symbols |
References APE_SYMTYPE_K_ARRAY_SHORT, and encode_list().
int APE_start | ( | APE_etx * | etx, | |
unsigned char * | out, | |||
unsigned int | boff, | |||
const unsigned char * | max | |||
) |
Initializes the encoding context.
0,Currently,always | 0. This may expand to a status code if necessary |
etx | The encoding context to initialize | |
out | The output buffer | |
boff | The bit offset into the output buffer | |
max | The maximum output address (actually 1 byte past it) |
References _APE_etx::ba, _BA::buffer, _APE_etx::cv, _APE_cv_ui::hi, _APE_cv_ui::lo, _BA::out, _APE_etx::tofollow, _BA::togo, and _APE_cv::ui.
Referenced by APE_bcompress().