diff --git a/hdf/src/cszip.c b/hdf/src/cszip.c index 7056820494..c361f45b0b 100644 --- a/hdf/src/cszip.c +++ b/hdf/src/cszip.c @@ -951,7 +951,7 @@ HCPcszip_endaccess(accrec_t *access_rec) HCPsetup_szip_parms -- Initialize SZIP parameters USAGE - intn HCPcszip_setup_parms( comp_info *c_info, int32 nt, int32 ndims, int32 *dims, int32 *cdims) + intn HCPsetup_szip_parms( comp_info *c_info, int32 nt, int32 ndims, int32 *dims, int32 *cdims) comp_info *c_info; IN/OUT: the szip compression params int32 nt; IN: the number type of the data int32 ncomp; IN: components in GR, 1 for SD @@ -969,7 +969,7 @@ HCPcszip_endaccess(accrec_t *access_rec) pixels_per_scanline bits_per_pixel - This is called from SDsetcompress, SDsetchunk, GRsetcompress, GRsetchunk + This is called from GRsetup_szip_parms and SDsetup_szip_parms GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS @@ -1059,3 +1059,44 @@ HCPsetup_szip_parms(comp_info *c_info, int32 nt, int32 ncomp, int32 ndims, int32 return FAIL; #endif } + +/*-------------------------------------------------------------------------- + NAME + HCPrm_szip_special_bit -- Removes the special bit that signals szip revised format + + USAGE + intn HCPrm_szip_special_bit(comp_info *c_info) + comp_info *c_info; IN/OUT: the szip compression params + + RETURNS + Returns SUCCEED + + DESCRIPTION + + A special bit, SZ_H4_REV_2, was introduced to indicate that the szip info + was stored in a new way. This bit was set in the options_mask field + of the szip info struct. As a result, the value of options_mask became + incorrect when the special bit was not removed from the options_mask before + returning to the application. + + This is used in SDgetcompinfo and GRgetcompinfo. + +--------------------------------------------------------------------------*/ +intn +HCPrm_szip_special_bit(comp_info *c_info) +{ + int sz_newway = 0; /* indicates the special bit presents in the options_mask */ + intn ret_value = SUCCEED; + + if (c_info == NULL) + HRETURN_ERROR(DFE_INTERNAL, FAIL); + + /* if the special bit presents for SZIP compression, remove it to + return the correct options_mask */ + sz_newway = (int)c_info->szip.options_mask & SZ_H4_REV_2; + if (sz_newway) + c_info->szip.options_mask = c_info->szip.options_mask & ~SZ_H4_REV_2; + +done: + return SUCCEED; +} diff --git a/hdf/src/hchunks.c b/hdf/src/hchunks.c index 7a6979b05a..7edada53ce 100644 --- a/hdf/src/hchunks.c +++ b/hdf/src/hchunks.c @@ -1507,6 +1507,7 @@ HMCcreate(int32 file_id, /* IN: file to put chunked element in */ if (HCPdecode_header((uint8 *)info->comp_sp_tag_header, (comp_model_t *)&info->model_type, info->minfo, (comp_coder_t *)&info->comp_type, info->cinfo) == FAIL) HGOTO_ERROR(DFE_INTERNAL, FAIL); + break; default: /* Do nothing */ diff --git a/hdf/src/hproto.h b/hdf/src/hproto.h index e8a29fe29d..ddaa0d37fc 100644 --- a/hdf/src/hproto.h +++ b/hdf/src/hproto.h @@ -393,6 +393,7 @@ HDFLIBAPI intn HCPdecode_header(uint8 *p, comp_model_t *model_type, model_info * HDFLIBAPI intn HCPsetup_szip_parms(comp_info *c_info, int32 nt, int32 ncomp, int32 ndims, int32 *dims, int32 *cdims); +HDFLIBAPI intn HCPrm_szip_special_bit(comp_info *c_info); /* ** from hbuffer.c */ diff --git a/mfhdf/dumper/testfiles/dumpsds-15szip.out b/mfhdf/dumper/testfiles/dumpsds-15szip.out index 86aaf0cf9b..704fc37f03 100644 --- a/mfhdf/dumper/testfiles/dumpsds-15szip.out +++ b/mfhdf/dumper/testfiles/dumpsds-15szip.out @@ -79,7 +79,7 @@ Variable Name = SDSszip Type= 32-bit signed integer Ref. = 6 Compression method = SZIP - Option mask = H4_SZ_EC_OPTION_MASK|H4_SZ_RAW_OPTION_MASK (65668) + Option mask = H4_SZ_EC_OPTION_MASK|H4_SZ_RAW_OPTION_MASK (132) Pixels per block = 2 Pixels per scanline = 5 Bits per pixel = 32 diff --git a/mfhdf/libsrc/mfsd.c b/mfhdf/libsrc/mfsd.c index 0266e21c07..2b9acd908e 100644 --- a/mfhdf/libsrc/mfsd.c +++ b/mfhdf/libsrc/mfsd.c @@ -4098,10 +4098,16 @@ SDgetcompinfo(int32 sdsid, /* IN: dataset ID */ /* use lower-level routine to get the compression information */ status = HCPgetcompinfo(handle->hdf_file, var->data_tag, var->data_ref, comp_type, c_info); - if (status == FAIL) HGOTO_ERROR(DFE_INTERNAL, FAIL); + /* remove the szip special bit if necessary */ + if (*comp_type == COMP_CODE_SZIP) { + status = HCPrm_szip_special_bit(c_info); + if (status == FAIL) + HGOTO_ERROR(DFE_INTERNAL, FAIL); + } + done: return ret_value; } /* SDgetcompinfo */ diff --git a/mfhdf/test/tszip.c b/mfhdf/test/tszip.c index a78eba752f..c2d9bb9ad9 100644 --- a/mfhdf/test/tszip.c +++ b/mfhdf/test/tszip.c @@ -1089,8 +1089,7 @@ test_szip_unlimited() /* Initialize for SZIP */ c_info.szip.pixels_per_block = 2; - - c_info.szip.options_mask = SZ_EC_OPTION_MASK; + c_info.szip.options_mask = SZ_EC_OPTION_MASK; c_info.szip.options_mask |= SZ_RAW_OPTION_MASK; c_info.szip.bits_per_pixel = 0; c_info.szip.pixels = 0;