AlternativeUniversity.net
Alternative University

Computer Science

Raster Image Storage

Higher Precision Extended Range

XRH File Format 4.0

SZMOD Compression

If the Compression Type integer of a Channel Block is 0x535A4D00040000 (SZMOD), the Channel Block Data is an SZMod Compression Stream, after which the end-of-channel-block marker follows the SZMod Compression Stream.


Figure 1:  Channel Block (image plane) of an XRH file, with Compression Type set to 0x535A4D00040000, stores an SZMod Compression Stream as the Channel Block Data (yellow in this diagram).

SZMod is a modular port of SZ version 2.1 for compressing 32-bit or 64-bit IEEE floating point numbers. SZMod does not support compression of other types or sizes of numbers.

On both 32-bit and 64-bit systems, SZMod generates and decodes the same SZ code stream that SZ 2.1.x generates and decodes on 64-bit systems, provided that SZ 2.1.x used Zstandard (not ZLIB) in the lossless compression stage (the final encoding step). While SZ supports either Zstandard or ZLIB, SZMod only supports Zstandard, because Zstandard supports larger memory buffers.


SZMod Compression Stream

The SZMod Compression Stream begins with a 4-byte start-of-szmod marker (ASCII string SSZ\0),

followed with a 64-bit Size integer that stores the Size of the SZMod Compression Stream (including the start-of-szmod marker and this Size integer),

followed with a 64-bit Compression Type integer (0x535A4D00040000),

followed with a 32-bit integer that stores the Image Width (same as the File Header Image Width),

followed with a 32-bit integer that stores the Image Height (same as File Header Image Height),

followed with a 32-bit Sample Definition integer which must equal the Channel Block Sample Definition,

followed with 12 bytes that are reserved for future use and must be zero,

followed with a 32-bit integer that stores the SZ Error Bound Type (0=ABS or 1=REL),

followed with a 64-bit floating point number that specfies the Error Bound (absErrBound for ABS or relBoundRatio for REL),

followed with a 64-bit Size integer that stores the size of the SZ version 2.1 code stream,

followed with the compressed SZ 2.1 code stream,

followed with an internal 32-bit cyclical redundancy check (CRC32) of the SZ 2.1 code stream (described below),

which is followed with the end-of-szmod marker (ASCII string ESZ\0) that marks the end of the SZMod Compression Stream.


Figure 2:  SZMod Compression Stream (shown yellow and light brown) as the Data of a Channel Block in an XRH 4.0 file. The SZ Code Stream (generated by SZ 2.1) is depicted light brown. The byte offset (number of bytes) from the beginning of the SZMod Compression Stream to the beginning of the SZ Code Stream is 64 bytes.

The SZMod Compression Stream is self-contained and may be used in any file format (not just in an XRH file).

The first four bytes of an SZMod Compression Stream store the value 0x53535A00 (ASCII string SSZ\0) which marks the start-of-sz.

Start of SZMod Stream Marker:  SSZ\0

The last 4 bytes of an SZMod Compression Stream store the value 0x45535A00 (ASCII string ESZ\0) which marks the end-of-sz (the last 4 bytes of the SZMod Compression Stream).

End of SZMod Stream Marker:  ESZ\0

The Internal SZ 2.1 CRC is the 32-bit cyclical redundancy check of the SZ 2.1 code stream before the final SZ encoding step. This is the CRC 32 of the lossy SZ code stream after Huffman encoding before the final Zstandard compression. Use of this field is optional. It may be required by an application. All of our applications require this. Applications that do not use this field should store zero in this field.

Sample Definition is a 4-byte integer storing the Sample Type in the upper byte (must be 1 for IEEE floating point), storing the padding between samples in the next byte (must be zero), and storing the Sample Width in the lower two bytes (must be 32 or 64).


< Previous: Zebra Compression    
    Next: JP2K Compression >

XRH 4.0 File Format

Page 1 : 
Page 2 : 
Page 3 : 
Page 4 : 
Page 5 : 
Page 6 : 
Page 7 : 
Page 8 : 
Page 9 : 
Page 10 : 
Page 11 : 
Page 12 : 
Introduction
Data Types
File Layout & Header
Comments
Custom Properties
Channel Names
Channels
Zebra Compression
SZMOD Compression (this page)
JP2K Compression
Color Transformations
Example Images