GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LDT / dev > encdec_unit_test / rhel6-32
#include <LDT/APM.h>
#include <LDT/APE.h>
#include <LDT/APD.h>
#include <LDT/HUFF.h>
#include <LDT/../src/TMR.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>
#include <LDT/../src/TMR.c>
Classes | |
struct | _Ctl |
struct | _MethodCommon |
struct | _MethodResult |
struct | _Test |
Typedefs | |
typedef enum _Options | Options |
typedef struct _Ctl | Ctl |
typedef struct _MethodCommon | MethodCommon |
typedef struct _MethodResult | MethodResult |
typedef struct _Test | Test |
Enumerations | |
enum | _Options { OPT_M_HCODE = 0x1 } |
Functions | |
int | test_conductor (int argc, char **argv) |
Tests the Arithmetic Probability and Huffman Encoding/Decoding for byte-sized tables. | |
static int | test_driver (const char *banner, unsigned int options, const unsigned int *freqs, int nfreqs, const unsigned char *symbols, int nsymbols, unsigned int *table, unsigned char *ebuf, unsigned int esiz, unsigned char *dbuf, unsigned int dsiz) |
Does a of the Arithmetic Probability Encoding and Huffman encoders using a byte-wide table. | |
static int | cheap_testA (unsigned int options) |
Cheap test of the encode/decode of a test distribution. | |
static int | cheap_test0 (unsigned int options) |
Cheap test of the encode/decode of a test distribution. | |
static int | cheap_test1 (unsigned int options) |
Cheap test of the encode/decode of a test distribution. | |
static int | cheap_test2 (unsigned int options) |
Cheap test of the encode/decode of a test distribution. This uses a table with an odd number of symbols, just to make sure that the binary search in the symbol lookup does not have problems. | |
static int | cheap_test3 (unsigned int options) |
Cheap test of the encode/decode of a test distribution. | |
static int | ap_composite_test (unsigned int options) |
Composite test of byte encoder. | |
static int | ap_file_test (const char *fileName, unsigned int options) |
Tests the encoding/decoding of the specified file. | |
static int | ap_self_encdec (const char *banner, unsigned int options, const unsigned char *symbols, int nsymbols) |
Encodes, then decodes the specified set of symbols. | |
static int | ap_test (MethodResult *result, const unsigned int *freqs, int nfreqs, const unsigned char *symbols, int nsymbols, unsigned int *table, unsigned char *ebuf, unsigned int esiz, unsigned char *dbuf, unsigned int dsiz) |
static int | huff_test (MethodResult *result, const unsigned int *freqs, int nfreqs, const unsigned char *symbols, int nsymbols, unsigned int *table, unsigned char *ebuf, unsigned int esiz, unsigned char *dbuf, unsigned int dsiz) |
static int | check (const unsigned int *table) |
static unsigned int | get_ctl (Ctl *ctl, int argc, char *const argv[]) |
Examines the command line parameters and fills in the test control structure. | |
static unsigned const char * | get_contents (const char *fileName, int *rsize) |
Reads in the specified file. | |
static void | report_test (const Test *test, unsigned int options) |
static double | get_byte_esize (const unsigned int *freqs, int nfreqs, const unsigned char *samples, int nsamples) |
Calculates the size, in bits, of the sample distribution based on the specified frequency table. | |
int | main (int argc, char **argv) |
Main program, it takes no arguments. | |
Variables | |
const unsigned int | Freqs [] |
Frequency distribution used in many of the tests. |
CVS $Id: encdec_unit_test.c,v 1.8 2011/03/31 18:39:36 russell Exp $
enum _Options |
static int ap_composite_test | ( | unsigned int | options | ) | [static] |
Composite test of byte encoder.
0 | if successful | |
2 | if failure |
options | An output options flag word |
References get_byte_esize().
Referenced by test_conductor().
static int ap_file_test | ( | const char * | fileName, | |
unsigned int | options | |||
) | [static] |
Tests the encoding/decoding of the specified file.
fileName | The name of the file to encode | |
options | An output options flag word |
References ap_self_encdec(), and get_contents().
Referenced by test_conductor().
static int ap_self_encdec | ( | const char * | banner, | |
unsigned int | options, | |||
const unsigned char * | symbols, | |||
int | nsymbols | |||
) | [static] |
Encodes, then decodes the specified set of symbols.
banner | Arbitrary string to use as a title banner | |
options | An output options word | |
symbols | The set of symbols to encode/decode | |
nsymbols | The number of symbols to encode/decode |
References test_driver().
Referenced by ap_file_test().
static int cheap_test0 | ( | unsigned int | options | ) | [static] |
Cheap test of the encode/decode of a test distribution.
options | An output options flag word |
0,if | successful | |
2,if | not |
References Freqs, and test_driver().
Referenced by test_conductor().
static int cheap_test1 | ( | unsigned int | options | ) | [static] |
Cheap test of the encode/decode of a test distribution.
options | An output options flag word |
0,if | successful | |
2,if | not |
References Freqs, and test_driver().
Referenced by test_conductor().
static int cheap_test2 | ( | unsigned int | options | ) | [static] |
Cheap test of the encode/decode of a test distribution. This uses a table with an odd number of symbols, just to make sure that the binary search in the symbol lookup does not have problems.
options | An output options flag word |
0,if | successful | |
2,if | not |
References Freqs, and test_driver().
Referenced by test_conductor().
static int cheap_test3 | ( | unsigned int | options | ) | [static] |
Cheap test of the encode/decode of a test distribution.
options | An output options flag word |
0,if | successful | |
2,if | not |
References Freqs, and test_driver().
Referenced by test_conductor().
static int cheap_testA | ( | unsigned int | options | ) | [static] |
Cheap test of the encode/decode of a test distribution.
options | An output options flag word |
0,if | successful | |
2,if | not |
References Freqs, and test_driver().
Referenced by test_conductor().
static int check | ( | const unsigned int * | table | ) | [static] |
printf ("Symbol = %d\n", sym1);
static double get_byte_esize | ( | const unsigned int * | freqs, | |
int | nfreqs, | |||
const unsigned char * | samples, | |||
int | nsamples | |||
) | [static] |
Calculates the size, in bits, of the sample distribution based on the specified frequency table.
freqs | The frequency table | |
nfreqs | The number of entries in the frequency table | |
samples | The array of samples | |
nsamples | The number of samples |
Referenced by ap_composite_test(), and test_driver().
static const unsigned char * get_contents | ( | const char * | fileName, | |
int * | rsize | |||
) | [static] |
Reads in the specified file.
fileName | The name of the file to encode | |
rsize | Pointer to receive the size of the file's content |
Referenced by ap_file_test().
static unsigned int get_ctl | ( | Ctl * | ctl, | |
int | argc, | |||
char *const | argv[] | |||
) | [static] |
Examines the command line parameters and fills in the test control structure.
ctl | The test control structure | |
argc | The number of command line parameters. | |
argv | The array of pointers to the command line parameters. |
References OPT_M_HCODE.
Referenced by test_conductor().
int main | ( | int | argc, | |
char ** | argv | |||
) |
Main program, it takes no arguments.
References test_conductor(), and TMR_initialize().
int test_conductor | ( | int | argc, | |
char ** | argv | |||
) |
Tests the Arithmetic Probability and Huffman Encoding/Decoding for byte-sized tables.
0 | if successful | |
2 | if failure |
References ap_composite_test(), ap_file_test(), cheap_test0(), cheap_test1(), cheap_test2(), cheap_test3(), cheap_testA(), and get_ctl().
Referenced by main().
static int test_driver | ( | const char * | banner, | |
unsigned int | options, | |||
const unsigned int * | freqs, | |||
int | nfreqs, | |||
const unsigned char * | symbols, | |||
int | nsymbols, | |||
unsigned int * | table, | |||
unsigned char * | ebuf, | |||
unsigned int | esiz, | |||
unsigned char * | dbuf, | |||
unsigned int | dsiz | |||
) | [static] |
Does a of the Arithmetic Probability Encoding and Huffman encoders using a byte-wide table.
0,if | successful | |
2,if | not |
banner | The title of this test | |
options | Reporting options | |
freqs | The frequency distribution | |
nfreqs | The number of entries in the frequency table | |
symbols | The symbols to encode | |
nsymbols | The number of symbols to encode | |
table | Storage for the encoding table | |
ebuf | The encode buffer | |
esiz | The encode buffer size, in bytes | |
dbuf | The decord buffer | |
dsiz | The decode buffer size, in bytes |
References get_byte_esize(), and OPT_M_HCODE.
Referenced by ap_self_encdec(), cheap_test0(), cheap_test1(), cheap_test2(), cheap_test3(), and cheap_testA().
const unsigned int Freqs |
Initial value:
{ 1195, 190, 102, 160, 187, 64, 157, 405, 1 }
Referenced by cheap_test0(), cheap_test1(), cheap_test2(), cheap_test3(), and cheap_testA().