summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repack_filters.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2009-06-17 18:42:23 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2009-06-17 18:42:23 (GMT)
commit86fa22c385bb655afaed25e31dd8676b9f94024b (patch)
tree5c532ed79b4dcec84878c91ecdad79a746b8670e /tools/h5repack/h5repack_filters.c
parent93a6cd92d7f2f6fd20bb22636a5c9245af01c7ef (diff)
downloadhdf5-86fa22c385bb655afaed25e31dd8676b9f94024b.zip
hdf5-86fa22c385bb655afaed25e31dd8676b9f94024b.tar.gz
hdf5-86fa22c385bb655afaed25e31dd8676b9f94024b.tar.bz2
[svn-r17077] merge 17076 from trunk
bug fix: h5repack was not applying a requested contiguous layout for a dataset with filters added a test to the C program test (not to the script), that verifies the layout and filters tested: linux
Diffstat (limited to 'tools/h5repack/h5repack_filters.c')
-rw-r--r--tools/h5repack/h5repack_filters.c106
1 files changed, 57 insertions, 49 deletions
diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c
index ee9621d..6b08a2f 100644
--- a/tools/h5repack/h5repack_filters.c
+++ b/tools/h5repack/h5repack_filters.c
@@ -42,10 +42,10 @@ int aux_find_obj(const char* name, /* object name from traverse list */
*obj = options->op_tbl->objs[i];
return i;
}
-
+
pdest = strstr(name,options->op_tbl->objs[i].path);
result = (int)(pdest - name);
-
+
/* found at position 1, meaning without '/' */
if( pdest != NULL && result==1 )
{
@@ -73,19 +73,19 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
pack_opt_t *options, /* repack options */
pack_info_t *obj /*OUT*/) /* info about object to filter */
{
-
+
int idx, i;
pack_info_t tmp;
-
+
init_packobject(&tmp);
-
+
idx = aux_find_obj(name,options,&tmp);
-
+
/* name was on input */
if (idx>=0)
{
-
-
+
+
/* applying to all objects */
if (options->all_layout)
{
@@ -125,9 +125,9 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
default:
break;
}/*switch*/
-
+
}
-
+
/* applying to all objects */
if (options->all_filter)
{
@@ -143,16 +143,16 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
tmp.filter[i] = options->op_tbl->objs[idx].filter[i];
}
}
-
-
+
+
} /* if idx */
-
-
+
+
/* no input name */
-
+
else
{
-
+
if (options->all_filter)
{
int k;
@@ -183,11 +183,11 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
}/*switch*/
}
}
-
+
*obj = tmp;
return 1;
-
-}
+
+}
/*-------------------------------------------------------------------------
@@ -223,40 +223,40 @@ int apply_filters(const char* name, /* object name from traverse list */
pack_info_t obj;
*has_filter = 0;
-
+
if (rank==0) /* scalar dataset, do not apply */
return 0;
-
+
/*-------------------------------------------------------------------------
* initialize the assigment object
*-------------------------------------------------------------------------
*/
init_packobject(&obj);
-
+
/*-------------------------------------------------------------------------
* find options
*-------------------------------------------------------------------------
*/
if (aux_assign_obj(name,options,&obj)==0)
return 0;
-
+
/* get information about input filters */
if ((nfilters = H5Pget_nfilters(dcpl_id))<0)
return -1;
-
+
/*-------------------------------------------------------------------------
* check if we have filters in the pipeline
* we want to replace them with the input filters
* only remove if we are inserting new ones
*-------------------------------------------------------------------------
*/
- if (nfilters && obj.nfilters )
+ if (nfilters && obj.nfilters )
{
*has_filter = 1;
if (H5Premove_filter(dcpl_id,H5Z_FILTER_ALL)<0)
return -1;
}
-
+
/*-------------------------------------------------------------------------
* check if there is an existent chunk
* read it only if there is not a requested layout
@@ -266,7 +266,7 @@ int apply_filters(const char* name, /* object name from traverse list */
{
if ((layout = H5Pget_layout(dcpl_id))<0)
return -1;
-
+
if (layout == H5D_CHUNKED)
{
if ((rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize/*out*/))<0)
@@ -277,7 +277,7 @@ int apply_filters(const char* name, /* object name from traverse list */
obj.chunk.chunk_lengths[i] = chsize[i];
}
}
-
+
/*-------------------------------------------------------------------------
* the type of filter and additional parameter
* type can be one of the filters
@@ -290,10 +290,10 @@ int apply_filters(const char* name, /* object name from traverse list */
* H5Z_FILTER_SCALEOFFSET 6 , scaleoffset compression
*-------------------------------------------------------------------------
*/
-
+
if (obj.nfilters)
{
-
+
/*-------------------------------------------------------------------------
* filters require CHUNK layout; if we do not have one define a default
*-------------------------------------------------------------------------
@@ -332,14 +332,14 @@ int apply_filters(const char* name, /* object name from traverse list */
}
}
-
+
for ( i=0; i<obj.nfilters; i++)
{
switch (obj.filter[i].filtn)
{
default:
break;
-
+
/*-------------------------------------------------------------------------
* H5Z_FILTER_DEFLATE 1 , deflation like gzip
*-------------------------------------------------------------------------
@@ -347,7 +347,7 @@ int apply_filters(const char* name, /* object name from traverse list */
case H5Z_FILTER_DEFLATE:
{
unsigned aggression; /* the deflate level */
-
+
aggression = obj.filter[i].cd_values[0];
/* set up for deflated data */
if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
@@ -356,7 +356,7 @@ int apply_filters(const char* name, /* object name from traverse list */
return -1;
}
break;
-
+
/*-------------------------------------------------------------------------
* H5Z_FILTER_SZIP 4 , szip compression
*-------------------------------------------------------------------------
@@ -365,19 +365,19 @@ int apply_filters(const char* name, /* object name from traverse list */
{
unsigned options_mask;
unsigned pixels_per_block;
-
+
options_mask = obj.filter[i].cd_values[0];
pixels_per_block = obj.filter[i].cd_values[1];
-
+
/* set up for szip data */
if(H5Pset_chunk(dcpl_id,obj.chunk.rank,obj.chunk.chunk_lengths)<0)
return -1;
if (H5Pset_szip(dcpl_id,options_mask,pixels_per_block)<0)
return -1;
-
+
}
break;
-
+
/*-------------------------------------------------------------------------
* H5Z_FILTER_SHUFFLE 2 , shuffle the data
*-------------------------------------------------------------------------
@@ -388,7 +388,7 @@ int apply_filters(const char* name, /* object name from traverse list */
if (H5Pset_shuffle(dcpl_id)<0)
return -1;
break;
-
+
/*-------------------------------------------------------------------------
* H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
*-------------------------------------------------------------------------
@@ -413,15 +413,15 @@ int apply_filters(const char* name, /* object name from traverse list */
* H5Z_FILTER_SCALEOFFSET , scale+offset compression
*-------------------------------------------------------------------------
*/
-
+
case H5Z_FILTER_SCALEOFFSET:
{
H5Z_SO_scale_type_t scale_type;
int scale_factor;
-
+
scale_type = obj.filter[i].cd_values[0];
scale_factor = obj.filter[i].cd_values[1];
-
+
if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
return -1;
if (H5Pset_scaleoffset(dcpl_id,scale_type,scale_factor)<0)
@@ -430,30 +430,38 @@ int apply_filters(const char* name, /* object name from traverse list */
break;
} /* switch */
}/*i*/
-
+
}
/*obj.nfilters*/
-
+
/*-------------------------------------------------------------------------
* layout
*-------------------------------------------------------------------------
*/
-
+
if (obj.layout>=0)
{
/* a layout was defined */
if (H5Pset_layout(dcpl_id, obj.layout)<0)
return -1;
-
- if (H5D_CHUNKED==obj.layout) { /* set up chunk */
+
+ if (H5D_CHUNKED == obj.layout)
+ {
if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
return -1;
}
- else if (H5D_COMPACT==obj.layout) {
+ else if (H5D_COMPACT == obj.layout)
+ {
if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY)<0)
return -1;
}
-
+ /* remove filters for the H5D_CONTIGUOUS case */
+ else if (H5D_CONTIGUOUS == obj.layout)
+ {
+ if (H5Premove_filter(dcpl_id,H5Z_FILTER_ALL)<0)
+ return -1;
+ }
+
}
return 0;