AlternativeUniversity.net
Alternative University

Computer Science

Raster Image Storage

Higher Precision Extended Range

XRH File Format 3.0

SZMOD Compression

If the Compression Type integer of a Channel Block is 0x535A4D00030000 (SZMOD), an SZMod Compression Stream immediately follows the Compression Type integer, 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 0x535A4D00030000, 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 floating point numbers (Float32 or Float64). 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 (0x535A4D00030000),

followed with a 32-bit Sample Type and Stride integer (must equal the Channel Block Sample Type and Stride which must be 0x10004 or 0x10008 for Float32 or Float64 respectively),

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 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 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 3.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 Type and Stride is a 4-byte integer storing the type of sample in the upper two bytes (must be 1 for floating point), and storing the byte length of each sample in the lower two bytes (must be 4 or 8). Hence, Sample Type and Stride must be 0x10004 or 0x10008, for Float32 or Float64 respectively.


New Version Available

Newer XRH version recommended for new applications:

XRH version 4.0


< Previous: Zebra Compression    
    Next: Color Transformations >

XRH 3.0 File Format

Page 1 : 
Page 2 : 
Page 3 : 
Page 4 : 
Page 5 : 
Page 6 : 
Page 7 : 
Page 8 : 
Page 9 : 
Page 10 : 
Introduction
File Layout & Header
Comments
Custom Properties
Channel Names
Channels
Zebra Compression
SZMOD Compression (this page)
Color Transformations
Sample Files