GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > LDT / V0-3-4

Constituent: encdec_unit_test     Tag: sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

encdec_unit_test.c File Reference

Tests the encode/decode library 'encdec'. More...

#include "LDT/APM.h"
#include "LDT/APE.h"
#include "LDT/APD.h"
#include "LDT/HUFF.h"
#include "PBS/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 dependency graph for encdec_unit_test.c:


Data Structures

struct  _Ctl
struct  _MethodCommon
struct  _MethodResult
struct  _Test

Typedefs

typedef enum _Options Options
typedef _Ctl Ctl
typedef _MethodCommon MethodCommon
typedef _MethodResult MethodResult
typedef _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 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 cheap_test4 (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 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.

Detailed Description

Tests the encode/decode library 'encdec'.

Author:
JJRussell - russell@slac.stanford.edu
   CVS $Id: encdec_unit_test.c,v 1.4 2006/11/01 21:23:34 russell Exp $

Enumeration Type Documentation

enum _Options
 

Enumerator:
OPT_M_HCODE  Print huffman table of codes


Function Documentation

static int ap_composite_test unsigned int  options  )  [static]
 

Composite test of byte encoder.

Return values:
0 if successful
2 if failure
Parameters:
options An output options flag word
This tests the ability to use multiple encoding tables. The encoding tables for two distributions are computed from two separate distributions. The probablity distributions are then encoding by picking a symbol first from one distribution then the other. The decoding is then done with the result being checked against the original

static int ap_file_test const char *  fileName,
unsigned int  options
[static]
 

Tests the encoding/decoding of the specified file.

Parameters:
fileName The name of the file to encode
options An output options flag word

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.

Returns:
Status, 0 if successful
Parameters:
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

static int cheap_test0 unsigned int  options  )  [static]
 

Cheap test of the encode/decode of a test distribution.

Parameters:
options An output options flag word
Return values:
0,if successful
2,if not

static int cheap_test1 unsigned int  options  )  [static]
 

Cheap test of the encode/decode of a test distribution.

Parameters:
options An output options flag word
Return values:
0,if successful
2,if not

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.

Parameters:
options An output options flag word
Return values:
0,if successful
2,if not

static int cheap_test3 unsigned int  options  )  [static]
 

Cheap test of the encode/decode of a test distribution.

Parameters:
options An output options flag word
Return values:
0,if successful
2,if not

static int cheap_test4 unsigned int  options  )  [static]
 

Cheap test of the encode/decode of a test distribution.

Parameters:
options An output options flag word
Return values:
0,if successful
2,if not

static int cheap_testA unsigned int  options  )  [static]
 

Cheap test of the encode/decode of a test distribution.

Parameters:
options An output options flag word
Return values:
0,if successful
2,if not

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.

Returns:
The size, int bits, of the sample distribution
Parameters:
freqs The frequency table
nfreqs The number of entries in the frequency table
samples The array of samples
nsamples The number of samples

static const unsigned char * get_contents const char *  fileName,
int *  rsize
[static]
 

Reads in the specified file.

Returns:
A pointer to the file's content and, in an argument, its size in bytes
Parameters:
fileName The name of the file to encode
rsize Pointer to receive the size of the file's content

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.

Parameters:
ctl The test control structure
argc The number of command line parameters.
argv The array of pointers to the command line parameters.
Returns:
Status

int main int  argc,
char **  argv
 

Main program, it takes no arguments.

Returns:
0 if successful, else bit mask of those tests that failed

int test_conductor int  argc,
char **  argv
 

Tests the Arithmetic Probability and Huffman Encoding/Decoding for byte-sized tables.

Return values:
0 if successful
2 if failure

static int test_driver const char *  banner,
unsigned int  options,
const 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.

Return values:
0,if successful
2,if not
Parameters:
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


Variable Documentation

const unsigned int Freqs
 

Initial value:

{
  1195,
  190,
  102,
  160,
  187,
  64,
  157,
  405,
  1
}
Frequency distribution used in many of the tests.


Generated on Wed Dec 5 08:36:35 2007 by  doxygen 1.4.4