[Back to Interface] [Prev] [Next]

SDsetchunk/sfschnk

intn SDsetchunk(int32 sds_id, HDF_CHUNK_DEF cdef, int32 flag)

sds_id IN:

Data set identifier returned by SDcreate or SDselect

C only:

cdef IN:

Pointer to the chunk definition

flag IN:

Compression flag

Fortran only:

dim_length IN:

Chunk dimensions array

comp_flag IN:

Type of compression

comp_prm IN:

Compression parameters array

Purpose

Sets the chunk size and the compression method, if any, of a data set.

Return value

Returns SUCCEED (or 0) if successful and FAIL (or -1) otherwise.

Description

SDsetchunk makes the data set specified by the parameter sds_id a chunked data set according to the chunking and compression information provided in the parameters cdef and flag in C, and in the parameters comp_type and comp_prm in Fortran.

C only:

The parameter flag specifies the type of the data set, i.e., if the data set is chunked or chunked and compressed with either RLE, Skipping Huffman, GZIP or NBIT compression methods. Valid values of flag are HDF_CHUNK for a chunked data set, HDF_CHUNK | HDF_COMP for a chunked data set compressed with RLE, Skipping Huffman and GZIP compression methods, and HDF_CHUNK | HDF_NBIT for a chunked NBIT-compressed data set.

Chunking and compression information is passed in the parameter cdef. The parameter cdef has a type of HDF_CHUNK_DEF, defined in the HDF library as follows:

typedef union hdf_chunk_def_u
{
	int32 chunk_lengths[2];    /* chunk lengths along each dim */

	struct
	{
		int32 chunk_lengths[2]; 
		int32 comp_type;        /* compression type */
		struct comp_info cinfo;
	} comp;

	struct 
	{
		int32 chunk_lengths[2]; 
		intn start_bit;
		intn bit_len;
		intn sign_ext;
		intn fill_one;
	} nbit;
} HDF_CHUNK_DEF

There are three pieces of chunking and compression information which should be specified: chunking dimensions, compression type, and, if needed, compression parameters.

If the data set is chunked, i.e., flag value is HDF_CHUNK, then chunk_lengths[] elements of cdef union (cdef.chunk_lengths[]) have to be initialized to the chunk dimensions.

If data set is chunked and compressed using RLE, Skipping Huffman or GZIP methods (i.e., flag value is set up to HDF_CHUNK | HDF_COMP), then the elements chunk_lengths[] of the structure comp in the union cdef (cdef.comp.chunk_lengths[]) have to be initialized to the chunk dimensions.

If data set is chunked and NBIT compression is applied (i.e., flag values is set up to HDF_CHUNK | HDF_NBIT), then the elements chunk_lengths[] of the structure nbit in the union cdef (cdef.nbit.chunk_lengths[]) have to be initialized to the chunk dimensions.

Compression types are passed in the field comp_type of the structure cinfo , which is an element of the structure comp in the union cdef (cdef.comp.cinfo.comp_type). Valid compression types are: COMP_CODE_RLE for RLE, COMP_CODE_SKPHUFF for Skipping Huffman, COMP_CODE_DEFLATE for GZIP compression.

For Skipping Huffman and GZIP compression parameters are passed in corresponding fields of the structure cinfo. Specify skipping size for Skipping Huffman compression in the field cdef.comp.cinfo.skphuff.skp_size. Specify deflate level for GZIP compression in the field cdef.comp.cinfo.deflate_level. Valid values of deflate levels are integers between 1 and 9 inclusive.

Refer to the SDsetcompress page in this manual for the definition of the structure comp_info.

NBIT compression parameters are specified in the fields start_bit, bit_len, sign_ext, and fill_one in the structure nbit of the union cdef.

Fortran only:

The dim_length array specifies the chunk dimensions.

The comp_type parameter specifies the compression type. Valid compression types and their values are defined in the hdf.inc file, and are listed below.

COMP_CODE_NONE (or 0) for uncompressed data
COMP_CODE_RLE  (or 1) for data compressed using the RLE compression
algorithm
COMP_CODE_NBIT (or 2) for data compressed using the NBIT compression
algorithm
COMP_CODE_SKPHUFF (or 3) for data compressed using the Skipping 
Huffman compression algorithm
COMP_CODE_DEFLATE (or 4) for data compressed using the GZIP compression
algorithm

The comp_prm(1) parameter specifies the skipping size for the Skipping Huffman compression method and the deflate level for the GZIP compression method.

For NBIT compression, the four elements of the array comp_prm correspond to the four NBIT compression parameters listed in the structure nbit. The value of comp_prm(1) should be set to the value of start_bit, the value of comp_prm(2) should be set to the value of bit_len, the value of comp_prm(3) should be set to the value of sign_ext, and the value of comp_prm(4) should be set to the value of fill_one. See the HDF_CHUNK_DEF union description and the description of SDsetnbitdataset function for NBIT compression parameters definitions.

FORTRAN

integer sfschnk(sds_id, dim_length, comp_type, comp_prm)

integer sds_id, dim_length, comp_type, comp_prm(*)



[Back to Interface] [Prev] [Next]

hdfhelp@ncsa.uiuc.edu
HDF Reference Manual - 07/29/98, NCSA HDF Development Group.