Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup - Remove getcompress functions #477

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions hdf/src/cszip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions hdf/src/hchunks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
107 changes: 0 additions & 107 deletions hdf/src/hcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,102 +808,6 @@ HCcreate(int32 file_id, uint16 tag, uint16 ref, comp_model_t model_type, model_i
return ret_value;
} /* end HCcreate() */

/*--------------------------------------------------------------------------
NAME
HCPgetcompress -- Retrieves compression information of an element
USAGE
intn HCPgetcompress(aid, coder_type, c_info)
int32 aid; IN: access record ID
comp_coder_t* coder_type; OUT: the type of compression
comp_info* c_info; OUT: ptr to compression information
structure for storing the retrieved info
RETURNS
SUCCEED/FAIL
DESCRIPTION
This routine retrieves the compression type and the compression
information of the element, identified by 'aid'. The routine is
used by GRgetcompinfo and SDgetcompinfo at this time.

GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
July 2001: Added to fix bug #307 - BMR
Dec. 2004: Changed name to HCPgetcompress, to be consistent with other
practice. REM
--------------------------------------------------------------------------*/
intn
HCPgetcompress(int32 file_id, uint16 data_tag, uint16 data_ref,
comp_coder_t *comp_type, /* OUT: compression type */
comp_info *c_info) /* OUT: retrieved compression info */
{
int32 aid = 0, status;
accrec_t *access_rec = NULL; /* access element record */
compinfo_t *info = NULL; /* compressed element information */
model_info m_info; /* modeling information - dummy */
int32 ret_value = SUCCEED;

/* clear error stack */
HEclear();

/* start read access on the access record of the data element, which
is being inquired for its compression information */
aid = Hstartread(file_id, data_tag, data_ref);

/* get the access_rec pointer */
access_rec = HAatom_object(aid);
if (access_rec == NULL)
HGOTO_ERROR(DFE_ARGS, FAIL);

/* if the element is compressed, get the compression info as requested*/
if (access_rec->special == SPECIAL_COMP) {
info = (compinfo_t *)access_rec->special_info;
if (info == NULL)
HGOTO_ERROR(DFE_COMPINFO, FAIL);

status = HCIread_header(access_rec, info, c_info, &m_info);
if (status == FAIL)
HGOTO_ERROR(DFE_COMPINFO, FAIL);

/* get the compression type */
*comp_type = info->cinfo.coder_type;

} /* end if element is compressed */

/* if the element is chunked, call HMCgetcompress to get the
compression info as appropriate */
else if (access_rec->special == SPECIAL_CHUNKED) {
status = HMCgetcompress(access_rec, comp_type, c_info);
if (status == FAIL)
HGOTO_ERROR(DFE_COMPINFO, FAIL);
}

/* flag the error when attempting to get compression info on a
non-compressed element */
else
/* EIP 9/16/03 Fail but return compression type COMP_CODE_NONE
instead of junk in this case.
*/
{
/*Mac OSX screams here (comp_coder_t)*comp_type = COMP_CODE_NONE; */
*comp_type = COMP_CODE_NONE;
HGOTO_ERROR(DFE_ARGS, FAIL);
}
/* end access to the aid appropriately */
if (Hendaccess(aid) == FAIL)
HGOTO_ERROR(DFE_CANTENDACCESS, FAIL);

done:
if (ret_value == FAIL) { /* Error condition cleanup */
/* end access to the aid if it's been accessed */
if (aid != 0)
if (Hendaccess(aid) == FAIL)
HERROR(DFE_CANTENDACCESS);
}

return ret_value;
} /* HCPgetcompress */

/*--------------------------------------------------------------------------
NAME
HCPgetcompinfo -- Retrieves compression information of an element
Expand All @@ -920,17 +824,6 @@ HCPgetcompress(int32 file_id, uint16 data_tag, uint16 data_ref,
information of the element, identified by 'aid'. The routine is
used by GRgetcompinfo and SDgetcompinfo at this time.

GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
July 2001: Added to fix bug #307 - BMR
Dec. 2004: Changed name to HCPgetcompress, to be consistent with other
practice. REM
Apr. 2005: HCPgetcompinfo was added to fix bugzilla #130 and may replace
HCPgetcompress in the future because HCPgetcompress did not
behave correctly. The revision logs above are carried over
from HCPgetcompress for the records.
--------------------------------------------------------------------------*/
intn
HCPgetcompinfo(int32 file_id, uint16 data_tag, uint16 data_ref,
Expand Down
4 changes: 1 addition & 3 deletions hdf/src/hproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,6 @@ HDFLIBAPI intn HXsetdir(const char *dir);
HDFLIBAPI int32 HCcreate(int32 file_id, uint16 tag, uint16 ref, comp_model_t model_type, model_info *m_info,
comp_coder_t coder_type, comp_info *c_info);

HDFLIBAPI intn HCPgetcompress(int32 file_id, uint16 data_tag, uint16 data_ref, comp_coder_t *coder_type,
comp_info *c_info);

HDFLIBAPI intn HCPgetcompinfo(int32 file_id, uint16 data_tag, uint16 data_ref, comp_coder_t *coder_type,
comp_info *c_info);

Expand All @@ -393,6 +390,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
*/
Expand Down
57 changes: 5 additions & 52 deletions hdf/src/mfgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4083,7 +4083,7 @@ GRsetcompress(int32 riid, comp_coder_t comp_type, comp_info *cinfo)

/*--------------------------------------------------------------------------
NAME
GRgetcompress
GRgetcompress - Deprecated in favor of GRgetcompinfo

PURPOSE
Get the compression information of a raster image's data.
Expand All @@ -4109,53 +4109,15 @@ GRsetcompress(int32 riid, comp_coder_t comp_type, comp_info *cinfo)
mapped to a quantization table. Thus, only the correct compression
type will be returned; cinfo will only contain 0s.

EXAMPLES
REVISION LOG
July 2001: Added to fix bug #307 -BMR
Apr 2005: Replaced by GRgetcompinfo due to deficiency in handling some
special elements. -BMR
--------------------------------------------------------------------------*/
intn
GRgetcompress(int32 riid, comp_coder_t *comp_type, comp_info *cinfo)
{
ri_info_t *ri_ptr; /* ptr to the image to work with */
int32 file_id;
uint16 scheme; /* compression scheme used for JPEG images */
intn ret_value = SUCCEED;

/* clear error stack and check validity of args */
HEclear();

/* check the validity of the RI ID */
if (HAatom_group(riid) != RIIDGROUP)
HGOTO_ERROR(DFE_ARGS, FAIL);

/* and check the output arguments */
if (comp_type == NULL || cinfo == NULL)
HGOTO_ERROR(DFE_ARGS, FAIL);

/* locate RI's object in hash table */
if (NULL == (ri_ptr = (ri_info_t *)HAatom_object(riid)))
HGOTO_ERROR(DFE_BADPTR, FAIL);

file_id = ri_ptr->gr_ptr->hdf_file_id; /* temporary use */
intn ret_value = SUCCEED;

/* If the compression scheme used was JPEG, return the compression type
and 0 for the 'quality' and 'force_baseline' parameters, because
these parameters are currently not possible to be retrieved. */
scheme = ri_ptr->img_dim.comp_tag;
if (scheme == DFTAG_JPEG5 || scheme == DFTAG_GREYJPEG5 || scheme == DFTAG_JPEG ||
scheme == DFTAG_GREYJPEG) {
*comp_type = COMP_CODE_JPEG;
cinfo->jpeg.quality = 0;
cinfo->jpeg.force_baseline = 0;
}
else {
/* use lower-level routine to get the compression information */
ret_value = HCPgetcompress(file_id, ri_ptr->img_tag, ri_ptr->img_ref, comp_type, cinfo);
if (ret_value == FAIL)
HGOTO_ERROR(DFE_INTERNAL, FAIL);
}
ret_value = GRgetcompinfo(riid, comp_type, cinfo);
if (ret_value == FAIL)
HGOTO_ERROR(DFE_INTERNAL, FAIL);

done:
return ret_value;
Expand Down Expand Up @@ -4293,15 +4255,6 @@ GRgetcomptype(int32 riid, comp_coder_t *comp_type)
mapped to a quantization table. Thus, only the correct compression
type will be returned; cinfo will only contain 0s.

EXAMPLES
REVISION LOG
July 2001: Added to fix bug #307 - BMR (from GRgetcompress)
Apr 2005: This function was actually created at this time, but it is
almost a duplicate of GRgetcompress, which is intended to be
removed in the future, due to its incorrect behavior. The
only difference is the call to the low-level routine,
HCPgetcompinfo, instead of HCPgetcompress.

--------------------------------------------------------------------------*/
intn
GRgetcompinfo(int32 riid, comp_coder_t *comp_type, comp_info *cinfo)
Expand Down
2 changes: 1 addition & 1 deletion mfhdf/dumper/testfiles/dumpsds-15.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mfhdf/dumper/testfiles/dumpsds-15szip.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading