[svn-r14355] uncomment previously commented code regarding nbit and scale-offset filter adding

changed the logic of the filter compare function to first compare filter type, then filter client data values (separate here in each individual case, since some filters return private filter values. Todo: handle the nbit and scale-offest cases)

tested: windows, linux
This commit is contained in:
Pedro Vicente Nunes 2007-12-20 16:31:34 -05:00
parent 8377804436
commit 491971980d
2 changed files with 95 additions and 60 deletions

View File

@ -29,14 +29,21 @@ static int filtcmp( filter_info_t f1, filter_info_t f2);
/*-------------------------------------------------------------------------
* Function: h5repack_verify
*
* Purpose: verify if the filters and layout specified in the options list are
* present on the OUTPUT file
* Purpose: verify if filters and layout in the input file match the output file
*
* Return: 1=present, 0=not present, -1=error
* Return:
* 1 match
* 0 do not match
* -1 error
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
* Programmer: Pedro Vicente, pvn@hdfgroup.org
*
* Date: December 19, 2003
* Modified: December, 19, 2007 (exactly 4 years later :-) )
* Separate into 3 cases
* 1) no filter input, get all datasets and compare DCPLs. TO DO
* 2) filter input on selected datasets, get each one trough OBJ and match
* 3) filter input on all datasets, get all objects and match
*
*-------------------------------------------------------------------------
*/
@ -696,61 +703,13 @@ static int filtcmp( filter_info_t f1 /*DCPL*/, filter_info_t f2 /*OPT*/)
{
unsigned i;
/*-------------------------------------------------------------------------
* compare cd_nelmts and cd_values
*-------------------------------------------------------------------------
*/
if ( f1.filtn == 4 ) /* SZIP special case */
{
if ( f1.cd_nelmts != 4 && f2.cd_nelmts != 2 )
return -1;
if ( f2.cd_values[0] != f1.cd_values[2] &&
f2.cd_values[1] != f1.cd_values[1] )
return -1;
}
else if ( f1.filtn == 2 ) /* SHUFFLE returns 1 cd_nelmts */
{
if ( f1.cd_nelmts != 1 && f2.cd_nelmts != 0 )
return -1;
}
else
{
if ( f1.cd_nelmts != f2.cd_nelmts )
return -1;
/* consider different filter values as "less" */
for( i = 0; i < f1.cd_nelmts; i++)
{
if (f1.cd_values[i] != f2.cd_values[i])
{
return -1;
}
}
}
/*-------------------------------------------------------------------------
* compare the filter type
* compare first the filter type
*-------------------------------------------------------------------------
*/
if (f1.filtn == f2.filtn)
{
return 0;
}
else if (f1.filtn < f2.filtn)
if (f1.filtn < f2.filtn)
{
return -1;
}
@ -758,6 +717,86 @@ static int filtcmp( filter_info_t f1 /*DCPL*/, filter_info_t f2 /*OPT*/)
{
return 1;
}
else if (f1.filtn == f2.filtn)
{
switch (f1.filtn)
{
case H5Z_FILTER_SHUFFLE:
/* 1 private client value is returned by DCPL */
if ( f1.cd_nelmts != 1 && f2.cd_nelmts != 0 )
return -1;
return 0;
break;
case H5Z_FILTER_SZIP:
/* 4 private client values are returned by DCPL */
if ( f1.cd_nelmts != 4 && f2.cd_nelmts != 2 )
return -1;
if ( f2.cd_values[0] != f1.cd_values[2] &&
f2.cd_values[1] != f1.cd_values[1] )
return -1;
return 0;
break;
case H5Z_FILTER_NBIT:
/* TO DO */
return 0;
break;
case H5Z_FILTER_SCALEOFFSET:
/* TO DO */
return 0;
break;
case H5Z_FILTER_FLETCHER32:
case H5Z_FILTER_DEFLATE:
if ( f1.cd_nelmts != f2.cd_nelmts )
return -1;
/* consider different filter values as "less" */
for( i = 0; i < f1.cd_nelmts; i++)
{
if (f1.cd_values[i] != f2.cd_values[i])
{
return -1;
}
}
return 0;
break;
} /* switch */
} /* f1.filtn == f2.filtn */
assert(0);
return -1;

View File

@ -896,6 +896,8 @@ if (szip_can_encode) {
GOERROR;
if (h5repack_verify(FNAME7OUT,&pack_options)<=0)
GOERROR;
if (h5repack_cmpdcpl(FNAME7,FNAME7OUT)<=0)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
@ -1097,8 +1099,6 @@ if (szip_can_encode) {
SKIPPED();
#endif
#if 0
/* solve bug in Nbit filter return value of cd_nelmts */
TESTING(" adding nbit filter");
@ -1121,7 +1121,6 @@ if (szip_can_encode) {
SKIPPED();
#endif
#endif
TESTING(" copy of scaleoffset filter");
@ -1163,8 +1162,6 @@ if (szip_can_encode) {
SKIPPED();
#endif
#if 0
/* solve bug in scaleoffset filter return value of cd_nelmts */
TESTING(" adding scaleoffset filter");
@ -1188,7 +1185,6 @@ if (szip_can_encode) {
#endif
#endif
/*-------------------------------------------------------------------------
* file with all filters