Observation
|
A FELICS_Line_Cache extends a Line_Cache by adding management of FELICS compressed line data. More...
#include <FELICS_Line_Cache.hh>
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_Cache & | source (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. |
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.
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().
unsigned long long bytes_read | ( | ) | const [virtual] |
Gets the total number of bytes read from the source stream.
Reimplemented from Line_Cache.
References Cache::bytes_read().
virtual bool compressed_data | ( | ) | const [inline, virtual] |
virtual unsigned long long compressed_bytes | ( | ) | const [inline, virtual] |
Gets the amount (bytes) of compressed data that has been processed.
Reimplemented from Line_Cache.
virtual unsigned long long decompressed_bytes | ( | ) | const [inline, virtual] |
Gets the amount of decompressed data that has been generated.
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.
stream | The istream to be used as the source of data. |
Reimplemented from Line_Cache.
References Line_Cache::source().
std::istream & source | ( | ) | const [virtual] |
Gets the data source stream.
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.
max_amount | The maximum amount of data to obtain. This is ignored. |
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.
compressed | Address of the FELICS encoded compressed data. |
amount | Amount, in bytes, of compressed data. |
decompressed | Address of the storage area to receive the decompressed data. This storage area must be large enough to contain width * height bytes of data. |
width | Line width of the decompressed image data, in single byte columns. |
height | Row height of the decompressed image data. |
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.
data_at | Address the data to be tested. |
Reimplemented from Image_Line.
Referenced by Image_Line::next_sync().
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] |
{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.
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.