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


Interface   Data Structures   File List   Data Fields   Globals  

RLE.c File Reference

Encodes up to 32-bit word using a run-length encoding method. More...

#include "ffs.h"
#include "LDT/RLE.h"
#include "LDT/BA.h"
#include "LDT/BFP.h"

Functions

unsigned int RLE_encode (unsigned int *buf, unsigned int pos, unsigned int word, int cnt)
 Uses a run length encoding method to encode the bits in the specified word.
int RLE_compare (unsigned int word, int cnt, int max)
 Compares the size of the max with run length method and returns (almost) rle_size - max.
unsigned int RLE_size (unsigned int word, int cnt)
 Returns the size of the run length encoding method.


Detailed Description

Encodes up to 32-bit word using a run-length encoding method.

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: RLE.c,v 1.1 2009/04/30 00:31:28 russell Exp $

Function Documentation

int RLE_compare ( unsigned int  word,
int  cnt,
int  max 
)

Compares the size of the max with run length method and returns (almost) rle_size - max.

Return values:
>0 Indicates RLE encoding is larger than max. How much larger is not encoded, only that it is larger.
=0 The number of bits needed by the RLE_encode is the same as max
<0 The number of bits needed by the RLE_compare is less than max. In this case, max + return value = size of RLE encoding.
Parameters:
word The word to encode
cnt The maximum bit number + 1 (LSB = 0) that can be set. For example, if all 32 bits can be set, then this is 32, if only 16 bits (right-jusified) then 16. This must be a value between 1 and 32.
max The maximum number of bits.
This routine can be used to judge whether some other encoding method is better than the run length method.

Example
If one wishes to use an asis encoding on a 16-bit value if the run length encoding method exceeds 16 bits
      / * Check if the run length encoding size is greater than or equal 16 * /
      if (RLE_compare (word, 16, 16) >= 0)
      {
          / * Yes, RLE method is greater than or equal to 16 bits 
              use asis encoding                                    * /
          pos = BFP_wordB (buf, pos, 1);
          pos = BFP_wordR (buf, pos, word, 16);
      }
      else
     {
          / * No, RLE_method is less than 16 bits * /
          pos = BFP_wordB  (buf, pos, 0);
          pos = RLE_encode (buf, pos, word, 16);
      }

unsigned int RLE_encode ( unsigned int *  buf,
unsigned int  pos,
unsigned int  word,
int  cnt 
)

Uses a run length encoding method to encode the bits in the specified word.

Returns:
The updated bit position
Parameters:
buf The output buffer
pos The current bit position
word The word to encode
cnt The maximum bit number + 1 (LSB = 0) that can be set. For example, if all 32 bits can be set, then this is 32, if only 16 bits (right-jusified) then 16. This must be a value between 1 and 32.

unsigned int RLE_size ( unsigned int  word,
int  cnt 
)

Returns the size of the run length encoding method.

Returns:
The number of bits needed by the RLE_encode
Parameters:
word The word to encode
cnt The maximum bit number + 1 (LSB = 0) that can be set. For example, if all 32 bits can be set, then this is 32, if only 16 bits (right-jusified) then 16. This must be a value between 1 and 32.


Generated on Mon Aug 23 09:45:06 2010 by  doxygen 1.5.3