Skip to content

Commit

Permalink
Additional fix to HDFFR-82 for SDgetchunkinfo
Browse files Browse the repository at this point in the history
Added tests for options_mask from SDgetcompinfo and SDgetchunkinfo
  • Loading branch information
bmribler committed Feb 3, 2024
1 parent 4928255 commit d022a0f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
13 changes: 7 additions & 6 deletions mfhdf/libsrc/mfsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -5364,12 +5364,6 @@ SDsetchunk(int32 sdsid, /* IN: sds access id */
RETURNS
SUCCEED/FAIL
AUTHOR
-GeorgeV
MODIFICATION
Jun, 2009: Added compression type and compression parameters.- BMR
******************************************************************************/
intn
SDgetchunkinfo(int32 sdsid, /* IN: sds access id */
Expand Down Expand Up @@ -5530,6 +5524,13 @@ SDgetchunkinfo(int32 sdsid, /* IN: sds access id */
else {
memcpy(&(chunk_def->comp.cinfo), &c_info, sizeof(comp_info));
chunk_def->comp.comp_type = (int32)comp_type;

/* remove the szip special bit if necessary */
if (comp_type == COMP_CODE_SZIP) {
ret_value = HCPrm_szip_special_bit(&chunk_def->comp.cinfo);
if (ret_value == FAIL)
HGOTO_ERROR(DFE_INTERNAL, FAIL);
}
}
} /* chunk_def != NULL */
break; /* default */
Expand Down
18 changes: 11 additions & 7 deletions mfhdf/test/tszip.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ test_szip_SDS8bit()
intn status;
int32 dim_sizes[2], array_rank, num_type, attributes;
char name[H4_MAX_NC_NAME];
comp_info c_info;
comp_info c_info; /* Compression parameters - union */
comp_info c_info_out; /* Compression parameters to retrieve into */
int32 start[2], edges[2];
int8 fill_value = 0; /* Fill value */
int i, j;
int num_errs = 0; /* number of errors so far */
comp_coder_t comp_type; /* to retrieve compression type into */
comp_coder_t comp_type; /* Compression type to retrieve into */
int8 out_data[LENGTH][WIDTH];
int8 in_data[LENGTH][WIDTH] = {{1, 1, 2, 2, 3, 4}, {1, 1, 2, 2, 3, 4}, {1, 1, 2, 2, 3, 4},
{3, 3, 0, 4, 3, 4}, {3, 3, 0, 4, 3, 4}, {3, 3, 0, 4, 3, 4},
Expand Down Expand Up @@ -115,11 +116,12 @@ test_szip_SDS8bit()

/* Retrieve compression informayion about the dataset */
comp_type = COMP_CODE_INVALID; /* reset variables before retrieving info */
memset(&c_info, 0, sizeof(c_info));
memset(&c_info_out, 0, sizeof(c_info_out));

status = SDgetcompinfo(sds_id, &comp_type, &c_info);
status = SDgetcompinfo(sds_id, &comp_type, &c_info_out);
CHECK(status, FAIL, "SDgetcompinfo");
VERIFY(comp_type, COMP_CODE_SZIP, "SDgetcompinfo");
VERIFY(c_info_out.szip.options_mask, c_info.szip.options_mask, "SDgetcompinfo");

/* Wipe out the output buffer */
memset(&out_data, 0, sizeof(out_data));
Expand Down Expand Up @@ -650,7 +652,7 @@ test_szip_chunk()
int32 column[CLENGTH] = {4, 4, 4};
int32 fill_value = 0; /* Fill value */
comp_coder_t comp_type; /* to retrieve compression type into */
comp_info cinfo; /* compression information structure */
comp_info cinfo_out; /* compression information structure */
int num_errs = 0; /* number of errors so far */
int i, j;

Expand Down Expand Up @@ -714,6 +716,7 @@ test_szip_chunk()
CHECK(status, FAIL, "SDgetchunkinfo");
VERIFY(c_flags_out, c_flags, "SDgetchunkinfo");
VERIFY(c_def_out.comp.comp_type, COMP_CODE_SZIP, "SDgetchunkinfo");
VERIFY(c_def_out.comp.cinfo.szip.options_mask, c_def.comp.cinfo.szip.options_mask, "SDgetchunkinfo");

/*
* Write chunks using SDwritechunk function. Chunks can be written
Expand Down Expand Up @@ -784,11 +787,12 @@ test_szip_chunk()

/* Retrieve compression information about the dataset */
comp_type = COMP_CODE_INVALID; /* reset variables before retrieving info */
memset(&cinfo, 0, sizeof(cinfo));
memset(&cinfo_out, 0, sizeof(cinfo_out));

status = SDgetcompinfo(sds_id, &comp_type, &cinfo);
status = SDgetcompinfo(sds_id, &comp_type, &cinfo_out);
CHECK(status, FAIL, "SDgetcompinfo");
VERIFY(comp_type, COMP_CODE_SZIP, "SDgetcompinfo");
VERIFY(cinfo_out.szip.options_mask, c_def.comp.cinfo.szip.options_mask, "SDgetcompinfo");

/* Retrieve compression method alone from the dataset */
comp_type = COMP_CODE_INVALID; /* reset variables before retrieving info */
Expand Down

0 comments on commit d022a0f

Please sign in to comment.