HiRISE
 Observation

Public Member Functions | Static Public Member Functions | Static Public Attributes

FELICS_Line_Cache Class Reference

A FELICS_Line_Cache extends a Line_Cache by adding management of FELICS compressed line data. More...

#include <FELICS_Line_Cache.hh>

Inheritance diagram for FELICS_Line_Cache:
Inheritance graph
[legend]
Collaboration diagram for FELICS_Line_Cache:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FELICS_Line_Cache (Image_Line &image_line, std::istream &stream)
 Constructs a FELICS_Line_Cache for an Image_Line bound to an istream.
virtual unsigned long long bytes_read () const
 Gets the total number of bytes read from the source stream.
virtual bool compressed_data () const
 Tests if the image data is compressed.
virtual unsigned long long compressed_bytes () const
 Gets the amount (bytes) of compressed data that has been processed.
virtual unsigned long long decompressed_bytes () const
 Gets the amount of decompressed data that has been generated.
virtual Line_Cachesource (std::istream &stream)
 Sets the data source stream.
virtual std::istream & source () const
 Gets the data source stream.
virtual bool refill (unsigned long max_amount=(unsigned long)-1)
 Refills the Line_Cache storage.
virtual void reset ()
 Resets the cache to its empty state and the line structure to match the current structure of the managed line.

Static Public Member Functions

static int decompress (char *compressed, unsigned int amount, char *decompressed, unsigned int width, unsigned int height)
 Decompresses FELICS compressed data.
static bool is_sync (void *data_at)
 Tests for a FELICS synchronization pattern.

Static Public Attributes

static const char *const ID = "UA::HiRISE::FELICS_Line_Cache (1.17 2024/02/29 02:50:07)"
 Class identification name with source code version and date.
static const int SYNC_BYTES = 16
 The number of bytes in the FELICS sync pattern.
static const u_int_8 SYNC_PATTERN []
 The synchronization pattern that begins each compressed data block.
static const int SYNC_BYTE_FACTOR = 0x11
 The byte number multiplier factor used to create the FELICS synchronization pattern.
static const int MAX_LINES_PER_BLOCK = LINES_PER_FELICS_BLOCK
 The maximum number of image lines in a FELICS data block.
static const int MIN_GAP_BYTES = 4
 The minimum number of gap value bytes in a gap sequence.

Detailed Description

A FELICS_Line_Cache extends a Line_Cache by adding management of FELICS compressed line data.

A locally managed Cache is used to obtain data from a source stream that is expected to contain FELICS compressed image data. The FELICS compressed data is the source stream is organized as a sequence of blocks delimited by a syncronization pattern unique to the FELICS data stream. Each block contains compressed data for up to 20 image lines. When the parent Line_Cache requests a refill the next available FELICS data block is found and its contents are decompressed into the storage of the Line_Cache. Sequences of bytes with gap values are excluded from the FELICS data blocks to be decompressed.

As with a Line_Cache, reading data from the source stream stops at an effective end-of-file, which is a real EOF (no more data available) or the presence of a Science Channel Header synchronization pattern in the stream.

Author:
Bradford Castalia, Christian Schaller, Robert King 1.12
See also:
Line_Cache
Cache

Constructor & Destructor Documentation

FELICS_Line_Cache ( Image_Line image_line,
std::istream &  stream 
) [explicit]

Constructs a FELICS_Line_Cache for an Image_Line bound to an istream.

Cache storage sufficient to hold at least twice the amount needed for 20 decompressed maximum size lines is allocated.

References Cache::data_margin().


Member Function Documentation

unsigned long long bytes_read (  ) const [virtual]

Gets the total number of bytes read from the source stream.

Returns:
The number of bytes read from the source.
See also:
Cache::bytes_read()

Reimplemented from Line_Cache.

References Cache::bytes_read().

virtual bool compressed_data (  ) const [inline, virtual]

Tests if the image data is compressed.

Returns:
Always returns true.

Reimplemented from Line_Cache.

virtual unsigned long long compressed_bytes (  ) const [inline, virtual]

Gets the amount (bytes) of compressed data that has been processed.

Returns:
The number of bytes of compressed data that have been processed since the last cache reset.
See also:
reset()
source(std::istream&)

Reimplemented from Line_Cache.

virtual unsigned long long decompressed_bytes (  ) const [inline, virtual]

Gets the amount of decompressed data that has been generated.

Returns:
The number of bytes of decompressed data that have been generated since the last reset.
See also:
reset()
source(std::istream&)

Reimplemented from Line_Cache.

Line_Cache & source ( std::istream &  stream ) [virtual]

Sets the data source stream.

The data source is set through the parent Line_Cache, which resets it. The local Cache is also reset.

Parameters:
streamThe istream to be used as the source of data.
Returns:
This FELICS_Line_Cache, as a Line_Cache.
See also:
Line_Cache::source(std::istream&)
reset()

Reimplemented from Line_Cache.

References Line_Cache::source().

std::istream & source (  ) const [virtual]

Gets the data source stream.

Returns:
The istream used to refill the cache storage.

Reimplemented from Line_Cache.

References Cache::source().

bool refill ( unsigned long  max_amount = (unsigned long)-1 ) [virtual]

Refills the Line_Cache storage.

A SYNC_PATTERN is found starting at the next user data location in the local Cache, which will be refilled as needed. Then the next SYNC_PATTERN, or start of a sequence of gap values, is found. This data range constitutes a FELICS data block.

The amount of free space in the parent Line_Cache storage area is increased, if needed, by first draining it and then increasing its capacity if required. Then the compressed data is decompressed into the parent Line_Cache storage area at the end of its current user data.

The accumulators of compressed and decompressed data processed are updated and the next user data location in the local Cache is updated to the end of the FELICS data block.

Parameters:
max_amountThe maximum amount of data to obtain. This is ignored.
Returns:
false if no more data is available before the effective end-of-file of the source stream; true otherwise. N.B.: If the cache storage is full no data will be read but the return value will still be true.
See also:
decompress(char*, unsigned int, char*, unsigned int, unsigned int)

Reimplemented from Line_Cache.

References decompress(), FELICS_CACHE_CAPACITY, and ID.

void reset (  ) [virtual]

Resets the cache to its empty state and the line structure to match the current structure of the managed line.

The structure of the reserved line is reset to match the structure of the managed line, the line counters are reset to zero, and the cache storage is reset to its empty state.

Reimplemented from Line_Cache.

References Cache::reset().

int decompress ( char *  compressed,
unsigned int  amount,
char *  decompressed,
unsigned int  width,
unsigned int  height 
) [static]

Decompresses FELICS compressed data.

The implemented algorithm is described in: "Fast and Efficient Lossless Image Compression", Paul G. Howard and Jeffrey Scott Vitter, Proceedings of the IEEE Computer Society/NASA/CESDIS Data Compression Conference, Snowbird, Utah, March 30 - April 1, 1993 and "Data Compression", David Solomon, Springer-Verlag, NY, 2000.

Parameters:
compressedAddress of the FELICS encoded compressed data.
amountAmount, in bytes, of compressed data.
decompressedAddress of the storage area to receive the decompressed data. This storage area must be large enough to contain width * height bytes of data.
widthLine width of the decompressed image data, in single byte columns.
heightRow height of the decompressed image data.
Returns:
The number of data bytes written to the decompressed storage area. This will never be greater than width * height.

Referenced by decompress().

bool is_sync ( void *  data_at ) [static]

Tests for a FELICS synchronization pattern.

Beginning at the argument address, SYNC_BYTES of data are tested for the FELICS SYNC_PATTERN.

Parameters:
data_atAddress the data to be tested.
Returns:
true If the data contains a FELICS synchronization pattern; false otherwise.

Reimplemented from Image_Line.

Referenced by Image_Line::next_sync().


Member Data Documentation

const char *const ID = "UA::HiRISE::FELICS_Line_Cache (1.17 2024/02/29 02:50:07)" [static]

Class identification name with source code version and date.

Reimplemented from Line_Cache.

Referenced by main().

const int SYNC_BYTES = 16 [static]

The number of bytes in the FELICS sync pattern.

Referenced by Image_Line::next_sync().

const u_int_8 SYNC_PATTERN [static]
Initial value:
        {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
         0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF}

The synchronization pattern that begins each compressed data block.

const int SYNC_BYTE_FACTOR = 0x11 [static]

The byte number multiplier factor used to create the FELICS synchronization pattern.

See also:
SYNC_BYTES
const int MAX_LINES_PER_BLOCK = LINES_PER_FELICS_BLOCK [static]

The maximum number of image lines in a FELICS data block.

const int MIN_GAP_BYTES = 4 [static]

The minimum number of gap value bytes in a gap sequence.


The documentation for this class was generated from the following files: