diff options
author | MuQun Yang <ymuqun@hdfgroup.org> | 2001-08-13 19:07:54 (GMT) |
---|---|---|
committer | MuQun Yang <ymuqun@hdfgroup.org> | 2001-08-13 19:07:54 (GMT) |
commit | 156200d908b2ec8a5247feffb8922f48d7794923 (patch) | |
tree | f04d168e169d5c35d267900d50eecad049d337a1 /tools | |
parent | 9767e654cfc7ccab6d3ff29d8461d4a491c1d260 (diff) | |
download | hdf5-156200d908b2ec8a5247feffb8922f48d7794923.zip hdf5-156200d908b2ec8a5247feffb8922f48d7794923.tar.gz hdf5-156200d908b2ec8a5247feffb8922f48d7794923.tar.bz2 |
[svn-r4334]
Purpose:
1) fix the implementation of image according to image specfication
2) fix two bugs of SDS implemention. the first one is
to handle the unlimited SDS with the first dimensional size set to 0.
the second one is to change the way how HDF5 dataset is written.
Description:
1) mapping 24-bit image to 3D arrays instead of 2D compound datatype.
2) previously forgot considering unlimited SDS with the size set to 0.
3) H5P_set_buffer seems not working well for a extremely small size.
Solution:
1) see above.
2) add a special case to deal with this.
3) don't use H5Pset_buffer.
Platforms tested:
RedHat Zoot 6.2
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h4toh5/h4toh5image.c | 289 | ||||
-rw-r--r-- | tools/h4toh5/h4toh5main.c | 2 | ||||
-rw-r--r-- | tools/h4toh5/h4toh5main.h | 2 | ||||
-rw-r--r-- | tools/h4toh5/h4toh5sds.c | 483 | ||||
-rw-r--r-- | tools/h4toh5/h4toh5util.h | 9 |
5 files changed, 693 insertions, 92 deletions
diff --git a/tools/h4toh5/h4toh5image.c b/tools/h4toh5/h4toh5image.c index b34f4af..9662904 100644 --- a/tools/h4toh5/h4toh5image.c +++ b/tools/h4toh5/h4toh5image.c @@ -65,7 +65,9 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in void* image_data; HDF_CHUNK_DEF c_def_out; int32 chunk_dims[2]; + int32 chunk_dims24[3]; int32 c_flags; + int32 interlace_mode; /* for checking compression */ @@ -92,6 +94,7 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in size_t h4memsize; hsize_t fielddim[1]; hsize_t h5dims[2]; + hsize_t h5dims24[3]; hsize_t bufsize; herr_t ret; hid_t create_plist; @@ -162,14 +165,41 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in /* change the order of image dimension: due to the difference of hdf4 image specification and - hdf5 image specification. */ + hdf5 image specification. Here we should separate 8-bit from + 24-bit according to H4TOH5 mapping specification.*/ + if(ncomp == 1) { + h5dims[0] = edges[1]-start[1]; + h5dims[1] = edges[0]-start[0]; + } + + else { + if(interlace_mode == MFGR_INTERLACE_PIXEL){ + h5dims24[0] = edges[1]-start[1]; + h5dims24[1] = edges[0]-start[0]; + h5dims24[2] = 3; + } + /* currently scan-line is not supported. + else if (interlace_mode == MFGR_INTERLACE_LINE){ + h5dims24[0] = 3; + h5dims24[1] = edges[1]-start[1]; + h5dims24[2] = edges[0]-start[0]; + } + */ + else if (interlace_mode == MFGR_INTERLACE_COMPONENT){ + h5dims24[0] = 3; + h5dims24[1] = edges[1]-start[1]; + h5dims24[2] = edges[0]-start[0]; + } - h5dims[0] = edges[1]-start[1]; - h5dims[1] = edges[0]-start[0]; + else {/* treat as pixel */ + h5dims24[0] = edges[1]-start[1]; + h5dims24[1] = edges[0]-start[0]; + h5dims24[2] = 3; + } + } gr_ref = GRidtoref(ri_id); - if(gr_ref == 0) { printf("error in obtaining gr reference number. \n"); free(image_data); @@ -177,7 +207,6 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in } /* obtaining absolute path of image name.*/ - check_imagename = -10; h5cimage_name = get_name(gr_ref,2*num_images,gr_hashtab,&check_imagename); @@ -215,6 +244,8 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in /* wait until the compression information can be obtained for image, 4/28/2001, Kent Yang.*/ + /* the following code deals with compression. Has to use + some middle-level APIs. */ ri_ref = 0; /* ri_ref = get_RIref(file_id,DFTAG_VG,gr_ref,ptag_out); @@ -252,7 +283,7 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in H5Pclose(create_plist); return FAIL; } - /* free(info_block.cdims);*/ + if(info_block.key == SPECIAL_COMP) { if(c_flags == HDF_NONE){ @@ -260,20 +291,54 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in in order that the converted HDF5 is compressed, we have to provide a chunking size. currently it is set to h5dim[i].*/ - printf("okay to sds compress.\n"); - + if(ncomp == 1) { chunk_dims[0] = (hsize_t)(h5dims[0]); chunk_dims[1] =(hsize_t)(h5dims[1]); - if(H5Pset_chunk(create_plist, 2, chunk_dims)<0) { - printf("failed to set up chunking information for "); - printf("property list.\n"); - free(image_data); - free(h5cimage_name); - H5Pclose(create_plist); - return FAIL; + if(H5Pset_chunk(create_plist, 2, chunk_dims)<0) { + printf("failed to set up chunking information for "); + printf("property list.\n"); + free(image_data); + free(h5cimage_name); + H5Pclose(create_plist); + return FAIL; + } + } + + else if(ncomp ==3) {/*24-bit chunk dimension is set to the current + HDF5 dimension.*/ + if(interlace_mode == MFGR_INTERLACE_PIXEL){ + chunk_dims24[0] = edges[1]-start[1]; + chunk_dims24[1] = edges[0]-start[0]; + chunk_dims24[2] = 3; + } + /* currently scan-line is not supported. + else if (interlace_mode == MFGR_INTERLACE_LINE){ + chunk_dims24[0] = 3; + chunk_dims24[1] = edges[1]-start[1]; + chunk_dims24[2] = edges[0]-start[0]; + } + */ + else if (interlace_mode == MFGR_INTERLACE_COMPONENT){ + chunk_dims24[1] = edges[1]-start[1]; + chunk_dims24[2] = edges[0]-start[0]; + chunk_dims24[0] = 3; + } + + else {/* treat as pixel */ + chunk_dims24[0] = edges[1]-start[1]; + chunk_dims24[1] = edges[0]-start[0]; + chunk_dims24[2] = 3; + } + if(H5Pset_chunk(create_plist, 3, chunk_dims24)<0) { + printf("failed to set up chunking information for "); + printf("property list.\n"); + free(image_data); + free(h5cimage_name); + H5Pclose(create_plist); + return FAIL; + } } - if(H5Pset_deflate(create_plist,GZIP_COMLEVEL)<0){ /* if(H5Pset_deflate(create_plist,2)<0){*/ printf("fail to set compression method for HDF5 file.\n"); @@ -285,7 +350,6 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in } } - /* free(info_block.cdims);*/ } } @@ -293,22 +357,48 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in || c_flags == (HDF_CHUNK | HDF_NBIT) ){ if(c_def_out.comp.comp_type == COMP_CODE_RLE || c_def_out.comp.comp_type == COMP_CODE_NBIT || c_def_out.comp.comp_type == COMP_CODE_SKPHUFF || c_def_out.comp.comp_type == COMP_CODE_DEFLATE || c_def_out.comp.comp_type == COMP_CODE_JPEG) { - - chunk_dims[0] = c_def_out.chunk_lengths[0]; - chunk_dims[1] = c_def_out.chunk_lengths[1]; + if(ncomp ==1) { + chunk_dims[0] = c_def_out.chunk_lengths[0]; + chunk_dims[1] = c_def_out.chunk_lengths[1]; - if(H5Pset_chunk(create_plist, 2, (hsize_t *)chunk_dims)<0) { - printf("failed to set up chunking information for "); - printf("property list.\n"); - free(image_data); - free(h5cimage_name); - H5Pclose(create_plist); - return FAIL; - } + if(H5Pset_chunk(create_plist, 2, (hsize_t *)chunk_dims)<0) { + printf("failed to set up chunking information for "); + printf("property list.\n"); + free(image_data); + free(h5cimage_name); + H5Pclose(create_plist); + return FAIL; + } + } - if(c_def_out.comp.comp_type == COMP_CODE_DEFLATE) - gzip_level = c_def_out.comp.cinfo.deflate.level; - else gzip_level = GZIP_COMLEVEL; + else if(ncomp ==3) { + if(interlace_mode == MFGR_INTERLACE_PIXEL){ + chunk_dims24[0] = c_def_out.chunk_lengths[1]; + chunk_dims24[1] = c_def_out.chunk_lengths[0]; + chunk_dims24[2] = 3; + } + /* currently scan-line is not supported. + else if (interlace_mode == MFGR_INTERLACE_LINE){ + chunk_dims24[0] = c_def_out.chunk_lengths[1]; + chunk_dims24[2] = c_def_out.chunk_lengths[0]; + chunk_dims24[1] = 3; + } + */ + else if (interlace_mode == MFGR_INTERLACE_COMPONENT){ + chunk_dims24[1] = c_def_out.chunk_lengths[1]; + chunk_dims24[2] = c_def_out.chunk_lengths[0]; + chunk_dims24[0] = 3; + } + + else {/* treat as pixel */ + chunk_dims24[0] = c_def_out.chunk_lengths[1]; + chunk_dims24[1] = c_def_out.chunk_lengths[0]; + chunk_dims24[2] = 3; + } + } + if(c_def_out.comp.comp_type == COMP_CODE_DEFLATE) + gzip_level = c_def_out.comp.cinfo.deflate.level; + else gzip_level = GZIP_COMLEVEL; if(H5Pset_deflate(create_plist,gzip_level)<0){ printf("fail to set compression method for HDF5 file.\n"); free(image_data); @@ -321,6 +411,8 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in /* HDF4 can support various compression methods including simple RLE, NBIT, Skip Huffman, gzip,Jpeg , HDF5 currently only supports gzip compression. By default, we will compress HDF5 dataset by using gzip compression if HDF5 file is compressed. */ +<<<<<<< h4toh5image.c +======= write_plist = H5Pcreate_list(H5P_DATASET_XFER_NEW); bufsize = h4memsize *h5dims[1]*ncomp; @@ -334,6 +426,7 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in return FAIL; } +>>>>>>> 1.3 if (ncomp == 1) { h5d_sid = H5Screate_simple(2,h5dims,NULL); @@ -343,7 +436,10 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in free(image_data); free(h5cimage_name); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 return FAIL; } @@ -354,21 +450,29 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in free(image_data); free(h5cimage_name); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 return FAIL; } - if (H5Dwrite(h5dset,h5memtype,h5d_sid,h5d_sid,write_plist, + if (H5Dwrite(h5dset,h5memtype,h5d_sid,h5d_sid,H5P_DEFAULT, image_data)<0) { printf("error writing data for hdf5 dataset converted from images.\n"); free(image_data); free(h5cimage_name); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 return FAIL; } } +<<<<<<< h4toh5image.c +======= else { /* compound datatype. */ @@ -392,9 +496,13 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in return FAIL; } +>>>>>>> 1.3 - fielddim[0] = ncomp; + else { /* 24-bit image */ +<<<<<<< h4toh5image.c + h5d_sid = H5Screate_simple(3,h5dims24,NULL); +======= { hid_t arr_type; /* Array datatype for inserting fields */ @@ -460,45 +568,48 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in } h5d_sid = H5Screate_simple(2,h5dims,NULL); +>>>>>>> 1.3 if(h5d_sid < 0) { printf("error in creating space. \n"); free(image_data); free(h5cimage_name); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 return FAIL; } - h5dset = H5Dcreate(h5_group,h5cimage_name,h5_ctype,h5d_sid, + h5dset = H5Dcreate(h5_group,h5cimage_name,h5ty_id,h5d_sid, create_plist); if(h5dset < 0) { printf("error in creating dataset. \n"); free(image_data); free(h5cimage_name); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 return FAIL; } - if (H5Dwrite(h5dset,h5_cmemtype,h5d_sid,h5d_sid,write_plist, + if (H5Dwrite(h5dset,h5memtype,h5d_sid,h5d_sid,H5P_DEFAULT, (void *)image_data)<0) { printf("error writing data\n"); free(image_data); free(h5cimage_name); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 return FAIL; } - ret = H5Tclose(h5_ctype); - if(ret < 0) { - printf("error in closing h5_ctype. \n"); - } - ret = H5Tclose(h5_cmemtype); - if(ret <0) { - printf("error in closing h5_cmemtype. \n"); - } } - + + free(image_data); /* convert image annotation into attribute of image dataset. Since there is no routines to find the exact tag of image object, we will check three possible object tags of image objects, that is: @@ -509,10 +620,12 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in if(Annoobj_h4_to_h5(file_id,gr_ref,DFTAG_RIG,h5dset)== FAIL){ printf("failed to convert image annotation into hdf5 attribute.\n"); - free(image_data); free(h5cimage_name); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 H5Sclose(h5d_sid); H5Dclose(h5dset); return FAIL; @@ -521,9 +634,11 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in if(Annoobj_h4_to_h5(file_id,gr_ref,DFTAG_RI,h5dset)== FAIL){ printf("failed to convert image annotation into hdf5 attribute.\n"); free(h5cimage_name); - free(image_data); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 H5Sclose(h5d_sid); H5Dclose(h5dset); return FAIL; @@ -532,9 +647,11 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in if(Annoobj_h4_to_h5(file_id,gr_ref,DFTAG_RI8,h5dset)== FAIL){ printf("failed to convert image annotation into hdf5 attribute.\n"); free(h5cimage_name); - free(image_data); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 H5Sclose(h5d_sid); H5Dclose(h5dset); return FAIL; @@ -547,9 +664,11 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in check_gloattr = 0; if(gr_tranattrs(ri_id,h5dset,ngrattrs,check_gloattr)==FAIL){ printf(" cannot obtain attributes. \n"); - free(image_data); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 H5Sclose(h5d_sid); H5Dclose(h5dset); return FAIL; @@ -573,11 +692,13 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in if(h4_transpredattrs(h5dset,HDF4_OBJECT_TYPE,grlabel)==FAIL){ printf("error in getting hdf4 image type attribute \n"); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 H5Sclose(h5d_sid); H5Dclose(h5dset); free(h5cimage_name); - free(image_data); return FAIL; } @@ -585,25 +706,75 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in if(h4_transpredattrs(h5dset,HDF4_OBJECT_NAME,image_name)==FAIL){ printf("error in getting hdf4 image name attribute. \n"); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 H5Sclose(h5d_sid); H5Dclose(h5dset); free(h5cimage_name); - free(image_data); return FAIL; } } if(h4_transpredattrs(h5dset,HDF4_IMAGE_CLASS,image_class)==FAIL){ printf("error in getting hdf4 image class attribute. \n"); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 H5Sclose(h5d_sid); H5Dclose(h5dset); free(h5cimage_name); - free(image_data); return FAIL; } + if(ncomp >1) { + if(interlace_mode == MFGR_INTERLACE_PIXEL){ + if(h4_transpredattrs(h5dset,INTERLACE_MODE,PIXEL_INTERLACE)==FAIL){ + printf("unable to generate image pixel attribute.\n"); + H5Pclose(create_plist); + H5Sclose(h5d_sid); + H5Dclose(h5dset); + free(h5cimage_name); + return FAIL; + } + } + /* currently scan-line is not supported. + else if (interlace_mode == MFGR_INTERLACE_LINE){ + if(h4_transpredattrs(h5dset,INTERLACE_MODE,LINE_INTERLACE)==FAIL){ + printf("unable to generate image line attribute.\n"); + H5Pclose(create_plist); + H5Sclose(h5d_sid); + H5Dclose(h5dset); + free(h5cimage_name); + return FAIL; + } + }*/ + else if (interlace_mode == MFGR_INTERLACE_COMPONENT){ + if(h4_transpredattrs(h5dset,INTERLACE_MODE,PLANE_INTERLACE)==FAIL){ + printf("unable to generate image component attribute.\n"); + H5Pclose(create_plist); + H5Sclose(h5d_sid); + H5Dclose(h5dset); + free(h5cimage_name); + return FAIL; + } + } + + else {/* treat as pixel interlace mode. */ + if(h4_transpredattrs(h5dset,INTERLACE_MODE,PIXEL_INTERLACE)==FAIL){ + printf("unable to generate image pixel attribute.\n"); + H5Pclose(create_plist); + H5Sclose(h5d_sid); + H5Dclose(h5dset); + free(h5cimage_name); + return FAIL; + } + } + + } + if(h4_attr !=0){ gr_ref = GRidtoref(ri_id); @@ -611,22 +782,26 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in if(gr_ref == 0) { printf("error in obtaining reference number of GR.\n"); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 H5Sclose(h5d_sid); H5Dclose(h5dset); free(h5cimage_name); - free(image_data); return FAIL; } if(h4_transnumattr(h5dset,HDF4_REF_NUM,gr_ref)==FAIL) { printf("error in getting hdf4 image number attribute.\n"); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 H5Sclose(h5d_sid); H5Dclose(h5dset); free(h5cimage_name); - free(image_data); return FAIL; } } @@ -635,20 +810,24 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in if(gr_palette(file_id,ri_id,h5dset,h5_palgroup,h4_attr)== FAIL) { printf("error in translating palette into h5 dataset.\n"); H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= H5Pclose_list(write_plist); +>>>>>>> 1.3 H5Sclose(h5d_sid); H5Dclose(h5dset); free(h5cimage_name); - free(image_data); return FAIL; } ret = H5Pclose(create_plist); +<<<<<<< h4toh5image.c +======= ret = H5Pclose_list(write_plist); +>>>>>>> 1.3 ret = H5Sclose(h5d_sid); ret = H5Dclose(h5dset); istat = GRendaccess(ri_id); - free(image_data); free(h5cimage_name); return SUCCEED; } diff --git a/tools/h4toh5/h4toh5main.c b/tools/h4toh5/h4toh5main.c index 19d8f23..4b89656 100644 --- a/tools/h4toh5/h4toh5main.c +++ b/tools/h4toh5/h4toh5main.c @@ -1155,8 +1155,8 @@ int h4toh5lonevds(int32 file_id, hid_t h5group,int h4_attr){ return FAIL; } free(h5cvdata_name); + } - VSdetach(vdata_id); } free(ref_vdata_array); diff --git a/tools/h4toh5/h4toh5main.h b/tools/h4toh5/h4toh5main.h index 7bfa794..2802caa 100644 --- a/tools/h4toh5/h4toh5main.h +++ b/tools/h4toh5/h4toh5main.h @@ -89,7 +89,7 @@ int sds_transattrs(int32, hid_t,int,int); int sdsdim_to_h5dataset(int32,int32,hid_t,hid_t,int32); int convert_sdsfillvalue(int32,int32,hid_t,hid_t,int); uint16 get_SDref(int32,uint16,int32); - +int convert_zerosdsdsunlimit(int32,int32,hid_t,hid_t,int); /*subroutines for h4toh5image.c*/ int Image_h4_to_h5(int32,int32,hid_t,hid_t,int); int gr_tranattrs(int32, hid_t,int,int); diff --git a/tools/h4toh5/h4toh5sds.c b/tools/h4toh5/h4toh5sds.c index 58bca68..d693019 100644 --- a/tools/h4toh5/h4toh5sds.c +++ b/tools/h4toh5/h4toh5sds.c @@ -115,7 +115,13 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int return FAIL; } if(sds_empty !=0) { - if(convert_sdsfillvalue(file_id,sds_id,h5_group,h5_dimgroup,h4_attr)==FAIL) { + if(sds_dimsizes[0]==0) { + if(convert_zerosdsunlimit(file_id,sds_id,h5_group,h5_dimgroup,h4_attr)==FAIL){ + printf("cannot convert unlimited dimension SDS with 0.\n"); + return FAIL; + } + } + else if(convert_sdsfillvalue(file_id,sds_id,h5_group,h5_dimgroup,h4_attr)==FAIL) { printf("cannot convert fill value successfully.\n"); return FAIL; } @@ -127,7 +133,6 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int return FAIL; } - /* obtain start,edge, stride and number of sds data. */ sds_start = malloc(sizeof(int32)*sds_rank); @@ -157,14 +162,15 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int sds_start[i] = 0; sds_edge[i] = sds_dimsizes[i]; count_sdsdata = count_sdsdata*sds_dimsizes[i]; - } for (i=0;i<sds_rank;i++) { h5dims[i] = sds_edge[i]-sds_start[i]; max_h5dims[i] = h5dims[i]; } - if(SDisrecord(sds_id)) max_h5dims[0] = H5S_UNLIMITED; + if(SDisrecord(sds_id)) { + max_h5dims[0] = H5S_UNLIMITED; + } /* convert hdf4 data type to hdf5 data type. */ if (h4type_to_h5type(sds_dtype,&h5_memtype,&h4memsize,&h4size, @@ -200,7 +206,6 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int free(sds_stride); return FAIL; } - istat = SDreaddata(sds_id, sds_start, sds_stride, sds_edge, (VOIDP)sds_data); if (istat == FAIL) { @@ -316,7 +321,7 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int 2. the current HDF5 will not handle compression case itself, in order that the converted HDF5 is compressed, we have to provide a chunking size. currently it is set to h5dim[i].*/ - + for(i=0;i<sds_rank;i++){ chunk_dims[i] = (hsize_t)(h5dims[i]); } @@ -333,7 +338,6 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int return FAIL; } - printf("okay compressed \n"); if(H5Pset_deflate(create_plist,GZIP_COMLEVEL)<0){ /* if(H5Pset_deflate(create_plist,2)<0){*/ printf("fail to set compression method for HDF5 file.\n"); @@ -406,6 +410,19 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int } } + if(access_id == FAIL && c_flags != HDF_CHUNK && c_flags != (HDF_CHUNK | HDF_COMP) + && c_flags != (HDF_CHUNK | HDF_NBIT)) { + for(i=0;i<sds_rank;i++) + chunk_dims[i] = h5dims[i]; + if(H5Pset_chunk(create_plist, sds_rank, chunk_dims)<0) { + printf("failed to set up chunking information for "); + printf("property list.\n"); + free(chunk_dims); + H5Sclose(h5d_sid); + H5Pclose(create_plist); + return FAIL; + } + } h5dset = H5Dcreate(h5_group,h5csds_name,h5ty_id,h5d_sid,create_plist); if (h5dset < 0) { @@ -419,8 +436,12 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int H5Pclose(create_plist); return FAIL; } +<<<<<<< h4toh5sds.c + /* write_plist = H5Pcreate(H5P_DATASET_XFER); +======= write_plist = H5Pcreate_list(H5P_DATASET_XFER_NEW); +>>>>>>> 1.4 bufsize = h4memsize; for(i=1;i<sds_rank;i++) bufsize *= h5dims[i]; @@ -436,9 +457,10 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int H5Pclose_list(write_plist); return FAIL; } - if (H5Dwrite(h5dset,h5_memtype,h5d_sid,h5d_sid,write_plist, - (void *)sds_data)<0) { + (void *)sds_data)<0) { */ + if (H5Dwrite(h5dset,h5_memtype,h5d_sid,h5d_sid,NULL, + (void *)sds_data)<0) { printf("failed to write data into hdf5 dataset"); printf(" converted from SDS.\n"); H5Sclose(h5d_sid); @@ -453,7 +475,6 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int return FAIL; } - /* convert sds annotation into attribute of sds dataset. Since there is no routines to find the exact tag of sds object, we will check three possible object tags of sds objects, that is: @@ -874,11 +895,14 @@ hid_t h5dim_nameaid; h4toh5_ZeroMemory(h5dimpath_name,MAX_DIM_NAME*sizeof(char)); /*check whether the sds is created with unlimited dimension. */ + + if(firstdimsize !=0) { if(SDgetchunkinfo(sds_id,&c_def_out, &c_flags)== FAIL) { printf("error in getting chunking information. \n"); return FAIL; } - + } + /* initialize the dimensional number of sds dimensions, h5dim_dims is used for grabbing hdf5 dimensional name list and object reference list. */ @@ -886,8 +910,7 @@ hid_t h5dim_nameaid; count_h5objref = 0; count_h5attrname = 0; - for (i = 0; i<sds_rank;i++) { - + for (i = 0; i<sds_rank;i++) { sdsdim_id = SDgetdimid(sds_id,i); if(sdsdim_id == FAIL) { @@ -912,12 +935,13 @@ hid_t h5dim_nameaid; If user doesn't specific the name we will skip this dimension */ if(sdsdim_type == 0) { - if(strncmp(sdsdim_name,fakeDim,strlen(fakeDim))==0) + if(strncmp(sdsdim_name,fakeDim,strlen(fakeDim))==0){ + SDendaccess(sdsdim_id); continue; + } } /* for unlimited SDS dimension, grab the current dimensional size. */ if(sds_dimscasize[0] == 0) sds_dimscasize[0] = firstdimsize; - /* check whether this dimensional scale dataset is looked up. */ check_sdsdim = lookup_name(sdsdim_name,DIM_HASHSIZE,dim_hashtab); @@ -970,7 +994,7 @@ hid_t h5dim_nameaid; count_h5objref = count_h5objref + 1; count_h5attrname = count_h5attrname + 1; continue; - } + } if (check_sdsdim != 0) { printf("error in checking sds dimensions.\n"); @@ -1024,6 +1048,7 @@ hid_t h5dim_nameaid; /* set dimensional scale size properly. */ h5dimscas[0] = sds_dimscasize[0]; + /* only set for the first dimension if SDS is unlimited dimension. */ if(SDisrecord(sds_id) && i == 0) max_h5dimscas[0] = H5S_UNLIMITED; @@ -1133,7 +1158,7 @@ hid_t h5dim_nameaid; ret = H5Pclose(create_plist); count_h5objref = count_h5objref + 1; count_h5attrname =count_h5attrname + 1; - } + } /*1. create object reference number to dimensional scale dataset. 2. store absolute name of dimensional name into @@ -1250,10 +1275,11 @@ hid_t h5dim_nameaid; /*used for variable length HDF5 string. for(dim_index = 0; dim_index <count_h5attrname;dim_index++) free(h5sdsdim_allname[dim_index]); - 6/11/2001, kent*/ + 6/11/2001, kent + since variable length has not been supported in h5dump yet and + that will cause testing failed so we use NULL TERM instead. + 8/9/2001 kent */ } - - free(sdsdimempty); return SUCCEED; } @@ -1335,12 +1361,14 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg count_sdsdata = count_sdsdata*sds_dimsizes[i]; } - for (i=0;i<sds_rank;i++) { h5dims[i] = sds_edge[i]-sds_start[i]; max_h5dims[i] = h5dims[i]; } + if(SDisrecord(sds_id)) { + max_h5dims[0] = H5S_UNLIMITED; + } /* convert hdf4 data type to hdf5 data type. */ if (h4type_to_h5type(sds_dtype,&h5_memtype,&h4memsize,&h4size, &h5ty_id) == FAIL) { @@ -1456,13 +1484,37 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg return FAIL; } - + chunk_dims = malloc(sizeof(hsize_t)*sds_rank); + + if(chunk_dims == NULL) { + H5Pclose(H5P_DATASET_CREATE); + free(sds_start); + free(sds_edge); + free(sds_stride); + printf("unable to allocate memory for chunk_dims\n"); + return FAIL; + } + if(SDisrecord(sds_id)){ + for(i=0;i<sds_rank;i++){ + chunk_dims[i] = (hsize_t)(sds_dimsizes[i]/2); + } + if(H5Pset_chunk(create_plist, sds_rank, chunk_dims)<0) { + printf("cannot set chunking size properly.\n"); + free(sds_start); + free(sds_edge); + free(sds_stride); + free(chunk_dims); + H5Pclose(create_plist); + return FAIL; + } + } + if(H5Pset_fill_value(create_plist,h5ty_id,fill_value)<0){ printf("failed to set property list fill value.\n"); free(sds_start); free(sds_edge); free(sds_stride); - + free(chunk_dims); H5Sclose(h5d_sid); H5Pclose(create_plist); return FAIL; @@ -1475,7 +1527,7 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg free(sds_start); free(sds_edge); free(sds_stride); - + free(chunk_dims); H5Sclose(h5d_sid); H5Pclose(create_plist); return FAIL; @@ -1492,7 +1544,7 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg free(sds_start); free(sds_edge); free(sds_stride); - + free(chunk_dims); H5Sclose(h5d_sid); H5Pclose(create_plist); H5Pclose_list(write_plist); @@ -1510,7 +1562,7 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg free(sds_start); free(sds_edge); free(sds_stride); - + free(chunk_dims); return FAIL; } @@ -1528,7 +1580,7 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg free(sds_start); free(sds_edge); free(sds_stride); - + free(chunk_dims); H5Sclose(h5d_sid); H5Dclose(h5dset); H5Pclose(create_plist); @@ -1540,7 +1592,7 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg free(sds_start); free(sds_edge); free(sds_stride); - + free(chunk_dims); H5Sclose(h5d_sid); H5Dclose(h5dset); H5Pclose(create_plist); @@ -1552,7 +1604,7 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg free(sds_start); free(sds_edge); free(sds_stride); - + free(chunk_dims); H5Sclose(h5d_sid); H5Dclose(h5dset); H5Pclose(create_plist); @@ -1566,8 +1618,7 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg free(sds_start); free(sds_edge); free(sds_stride); - - free(chunk_dims); + free(chunk_dims); H5Sclose(h5d_sid); H5Dclose(h5dset); H5Pclose(create_plist); @@ -1586,7 +1637,7 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg free(sds_start); free(sds_edge); free(sds_stride); - + free(chunk_dims); H5Sclose(h5d_sid); H5Dclose(h5dset); @@ -1626,6 +1677,7 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg free(sds_start); free(sds_edge); free(sds_stride); + free(chunk_dims); free(fill_value); H5Sclose(h5d_sid); H5Dclose(h5dset); @@ -1643,7 +1695,10 @@ uint16 get_SDref(int32 file_id,uint16 tag,int32 sds_ref){ if((GroupID = DFdiread(file_id,tag,(uint16)sds_ref))<0){ - printf("cannot find sd_ref\n"); + /* for some cases, although sd_ref cannot be found, the current + SDS object is still legal(unlimited dimension with the current + size set to 0. so comment this the following warning printfs out. */ + /* printf("cannot find sd_ref\n");*/ return sd_ref; } @@ -1656,23 +1711,381 @@ uint16 get_SDref(int32 file_id,uint16 tag,int32 sds_ref){ } sd_ref = di.ref; - if(!found) - printf("cannot find sd_ref\n"); + if(!found) ; + /* printf("cannot find sd_ref\n");*/ DFdifree(GroupID); return sd_ref; } +int convert_zerosdsunlimit(int32 file_id, + int32 sds_id, + hid_t h5_group, + hid_t h5_dimgroup, + int h4_attr) { + int32 sds_dtype; + int32 sds_rank; + int32 sds_dimsizes[MAX_VAR_DIMS]; + int32* sds_start; + int32* sds_edge; + int32* sds_stride; + int32 count_sdsdata; + int32 sds_ref; + int32 istat; + int i; + int32 num_sdsattrs; + void* fill_value; + int check_sdsname; + int check_gloattr; + + char sdsname[MAX_NC_NAME]; + char sdslabel[MAX_NC_NAME]; + size_t h4size; + size_t h4memsize; + HDF_CHUNK_DEF c_def_out; + hsize_t* chunk_dims; + int32 c_flags; + /* for checking compression */ + sp_info_block_t info_block; + int16 special_code; + int32 access_id; + uint16 sd_ref; + int gzip_level; + /* define varibles for hdf5. */ + hid_t h5dset; + hid_t h5d_sid; + hid_t h5ty_id; + hid_t h5_memtype; + hid_t create_plist; + hid_t write_plist; + hsize_t h5dims[MAX_VAR_DIMS]; + hsize_t max_h5dims[MAX_VAR_DIMS]; + hsize_t bufsize; + char* h5csds_name; + + if (SDgetinfo(sds_id,sdsname,&sds_rank,sds_dimsizes,&sds_dtype, + &num_sdsattrs)==FAIL) { + printf("unable to get information of sds h5dset.\n"); + return FAIL; + } + + for (i=0;i<sds_rank;i++) { + h5dims[i] = sds_dimsizes[i]; + max_h5dims[i] = h5dims[i]; + } + + if(SDisrecord(sds_id)){ + max_h5dims[0] = H5S_UNLIMITED; + h5dims[0] = H5S_UNLIMITED; + } + + /* convert hdf4 data type to hdf5 data type. */ + if (h4type_to_h5type(sds_dtype,&h5_memtype,&h4memsize,&h4size, + &h5ty_id) == FAIL) { + printf("failed to translate datatype. \n"); + return FAIL; + } + + /* check whether the datatype is string, if we find string format, + we will change them back into integer format.*/ + + if (h5ty_id == H5T_STRING) { + /* rechange string datatype into numerical datatype.*/ + if(h5string_to_int(sds_dtype,&h5_memtype,h4memsize, + &h5ty_id)== FAIL) { + printf("error in translating H5T_STRING to int.\n"); + return FAIL; + } + } + + sds_ref = SDidtoref(sds_id); + if(sds_ref == FAIL) { + printf("error in obtaining sds reference number. \n"); + return FAIL; + } + + h5csds_name = get_name(sds_ref,2*num_sds,sds_hashtab,&check_sdsname); + if (h5csds_name == NULL && check_sdsname == 0 ) { + printf("error,cannot find sds name \n"); + return FAIL; + } + if (h5csds_name == NULL && check_sdsname == -1) { + printf("error,sds name is not defined.\n"); + return FAIL; + } + if (h5csds_name == NULL && check_sdsname == -2) { + printf("error,not enough memory for allocating sds name.\n"); + return FAIL; + } + + h5d_sid = H5Screate_simple(sds_rank,h5dims,max_h5dims); + + if (h5d_sid < 0) { + printf("failed to create hdf5 data space converted from SDS. \n"); + return FAIL; + } + + + /* create property list. */ + create_plist = H5Pcreate(H5P_DATASET_CREATE); + chunk_dims = malloc(sizeof(hsize_t)*sds_rank); + + sd_ref = get_SDref(file_id,DFTAG_NDG,sds_ref); + if(sd_ref == 0) + sd_ref = get_SDref(file_id,DFTAG_SDG,sds_ref); + if(sd_ref >0 ) + access_id = Hstartread(file_id,DFTAG_SD,sd_ref); + if(sd_ref == 0) + access_id = FAIL; + if(access_id != FAIL) { + istat = Hinquire(access_id,NULL,NULL,NULL,NULL,NULL,NULL,NULL,&special_code); + if(istat == FAIL) { + printf("failed to inquire information \n "); + free(chunk_dims); + H5Sclose(h5d_sid); + H5Pclose(create_plist); + free(h5csds_name); + return FAIL; + } + if(special_code >0){ + + if(HDget_special_info(access_id,&info_block)==FAIL){ + printf("fail to get special info.\n"); + free(chunk_dims); + H5Sclose(h5d_sid); + H5Pclose(create_plist); + free(h5csds_name); + return FAIL; + } + /* free(info_block.cdims);*/ + if(info_block.key == SPECIAL_COMP) { + + if(c_flags == HDF_NONE){ + /* 1. if the first dimension is unlimited dimension, + we have to provide a chunking size. + 2. the current HDF5 will not handle compression case itself, + in order that the converted HDF5 is compressed, we have to + provide a chunking size. currently it is set to h5dim[i].*/ + + for(i=0;i<sds_rank;i++){ + chunk_dims[i] = (hsize_t)(h5dims[i]); + } + if(H5Pset_chunk(create_plist, sds_rank, chunk_dims)<0) { + printf("failed to set up chunking information for "); + printf("property list.\n"); + free(chunk_dims); + free(h5csds_name); + H5Sclose(h5d_sid); + H5Pclose(create_plist); + return FAIL; + } + + if(H5Pset_deflate(create_plist,GZIP_COMLEVEL)<0){ + /* if(H5Pset_deflate(create_plist,2)<0){*/ + printf("fail to set compression method for HDF5 file.\n"); + free(chunk_dims); + free(h5csds_name); + H5Sclose(h5d_sid); + H5Pclose(create_plist); + } + } + + } + else if(c_flags == HDF_NONE && SDisrecord(sds_id)) + { + for(i=0;i<sds_rank;i++){ + chunk_dims[i] = (hsize_t)(sds_dimsizes[i]); + if(sds_dimsizes[0] == 0) + chunk_dims[0] = (hsize_t)DEF_CHUNKSIZE; + } + if(H5Pset_chunk(create_plist, sds_rank, chunk_dims)<0) { + printf("failed to set up chunking information for "); + printf("property list.\n"); + free(h5csds_name); + free(chunk_dims); + H5Pclose(create_plist); + return FAIL; + } + } + + } + + } + + /* HDF4 can support various compression methods including simple RLE, NBIT, Skip Huffman, gzip,Jpeg , HDF5 currently only supports gzip compression. + By default, we will compress HDF5 dataset by using gzip compression if HDF5 file is compressed. */ + + + if(c_flags == HDF_CHUNK || c_flags == (HDF_CHUNK | HDF_COMP) + || c_flags == (HDF_CHUNK | HDF_NBIT) ){ + + if(c_def_out.comp.comp_type == COMP_CODE_RLE || c_def_out.comp.comp_type == COMP_CODE_NBIT || c_def_out.comp.comp_type == COMP_CODE_SKPHUFF || c_def_out.comp.comp_type == COMP_CODE_DEFLATE || c_def_out.comp.comp_type == COMP_CODE_JPEG) { + + for(i=0;i<sds_rank;i++) + chunk_dims[i] = (hsize_t)c_def_out.chunk_lengths[i]; + + if(H5Pset_chunk(create_plist, sds_rank, chunk_dims)<0) { + printf("failed to set up chunking information for "); + printf("property list.\n"); + free(chunk_dims); + free(h5csds_name); + H5Sclose(h5d_sid); + H5Pclose(create_plist); + return FAIL; + } + if(c_def_out.comp.comp_type == COMP_CODE_DEFLATE) + gzip_level = c_def_out.comp.cinfo.deflate.level; + else gzip_level = GZIP_COMLEVEL; + if(H5Pset_deflate(create_plist,gzip_level)<0){ + printf("fail to set compression method for HDF5 file.\n"); + free(chunk_dims); + free(h5csds_name); + H5Sclose(h5d_sid); + H5Pclose(create_plist); + } + } + } + + if(access_id == FAIL) { + chunk_dims[0] = (hsize_t)DEF_CHUNKSIZE; + for(i=1;i<sds_rank;i++) + chunk_dims[i] = h5dims[i]; + if(H5Pset_chunk(create_plist, sds_rank, chunk_dims)<0) { + printf("failed to set up chunking information for "); + printf("property list.\n"); + free(chunk_dims); + free(h5csds_name); + H5Sclose(h5d_sid); + H5Pclose(create_plist); + return FAIL; + } + } + + h5dset = H5Dcreate(h5_group,h5csds_name,h5ty_id,h5d_sid,create_plist); + if (h5dset < 0) { + printf("failed to create hdf5 dataset converted from SDS. \n"); + free(chunk_dims); + free(h5csds_name); + H5Sclose(h5d_sid); + H5Pclose(create_plist); + return FAIL; + } + + if(sdsdim_to_h5dataset(sds_id,sds_rank,h5dset,h5_dimgroup,sds_dimsizes[0])<0){ + printf("failed to convert SDS dimensional scale dataset correctly \n"); free(h5csds_name); + free(chunk_dims); + H5Sclose(h5d_sid); + H5Pclose(create_plist); + return FAIL; + } + + /* convert sds annotation into attribute of sds dataset. + Since there is no routines to find the exact tag of sds object, + we will check three possible object tags of sds objects, that is: + DFTAG_SD,DFTAG_SDG,DFTAG_NDG. If the object tag of sds object is + falling out of this scope, we will not convert annotations into + hdf5 attributes; it is user's responsibility to make sure object tags + for sds objects are only one of the above three tags.*/ + + if(Annoobj_h4_to_h5(file_id,sds_ref,DFTAG_SD,h5dset)== FAIL){ + printf("failed to convert sds annotation into hdf5 attribute.\n"); + free(h5csds_name); + free(chunk_dims); + H5Sclose(h5d_sid); + H5Dclose(h5dset); + H5Pclose(create_plist); + return FAIL; + } + + if(Annoobj_h4_to_h5(file_id,sds_ref,DFTAG_SDG,h5dset)== FAIL){ + printf("failed to convert sds annotation into hdf5 attribute.\n"); + free(h5csds_name); + free(chunk_dims); + H5Sclose(h5d_sid); + H5Dclose(h5dset); + H5Pclose(create_plist); + return FAIL; + } + + if(Annoobj_h4_to_h5(file_id,sds_ref,DFTAG_NDG,h5dset)== FAIL){ + printf("failed to convert sds annotation into hdf5 attribute.\n"); + free(h5csds_name); + free(chunk_dims); + H5Sclose(h5d_sid); + H5Dclose(h5dset); + H5Pclose(create_plist); + return FAIL; + } + + check_gloattr = 0; + + + if (sds_transattrs(sds_id,h5dset,num_sdsattrs,check_gloattr)==FAIL) { + free(chunk_dims); + free(h5csds_name); + H5Sclose(h5d_sid); + H5Dclose(h5dset); + H5Pclose(create_plist); + printf(" Error in obtaining sds attributes. \n"); + return FAIL; + } + + /********************************************/ + /* handle extra attributes of sds : sds label, object type + and reference num */ + + if(h4_attr !=0) { + strcpy(sdslabel,SDSLABEL); + + if(h4_transpredattrs(h5dset,HDF4_OBJECT_TYPE,sdslabel)==FAIL) { + free(chunk_dims); + free(h5csds_name); + H5Sclose(h5d_sid); + H5Dclose(h5dset); + H5Pclose(create_plist); + printf("unable to transfer sds label to HDF4 OBJECT TYPE.\n"); + return FAIL; + } + + if(sdsname[0] != '\0') { + if(h4_transpredattrs(h5dset,HDF4_OBJECT_NAME,sdsname)==FAIL){ + free(chunk_dims); + free(h5csds_name); + H5Sclose(h5d_sid); + H5Dclose(h5dset); + H5Pclose(create_plist); + printf("unable to transfer sds name to HDF5 dataset attribute.\n"); + return FAIL; + } + } + + if(h4_transnumattr(h5dset,HDF4_REF_NUM,sds_ref)==FAIL){ + free(chunk_dims); + free(h5csds_name); + H5Sclose(h5d_sid); + H5Dclose(h5dset); + H5Pclose(create_plist); + printf("unable to transfer sds ref. to HDF5 dataset attribute.\n"); + return FAIL; + } + } + H5Sclose(h5d_sid); + free(h5csds_name); + free(chunk_dims); + H5Dclose(h5dset); + H5Pclose(create_plist); + return SUCCEED; +} diff --git a/tools/h4toh5/h4toh5util.h b/tools/h4toh5/h4toh5util.h index 2cda0cc..27bdcb5 100644 --- a/tools/h4toh5/h4toh5util.h +++ b/tools/h4toh5/h4toh5util.h @@ -96,6 +96,12 @@ converter.*/ #define LABEL_LENG 20 /* 7. define "IMAGE" CLASS required by image spec. */ #define IM_CLASS "IMAGE" +/*7.5. define interlace mode. */ +#define INTERLACE_MODE "INTERLACE_MODE" +#define PIXEL_INTERLACE "PIXEL_INTERLACE" +#define LINE_INTERLACE "LINE_INTERLACE" +#define PLANE_INTERLACE "PLANE_INTERLACE" + /* 8. reserved group name for HDF4 dimensional scale and palette. */ #define HDF4_DIMG "/HDF4_DIMGROUP" @@ -143,6 +149,9 @@ public constant for hdf lib, this constant can be released.*/ /*12. fake sds dimension name*/ #define fakeDim "fakeDim" +/*13. define a default first dimension chunking size when the + current unlimited dimensional size of SDS is set to 0. */ +#define DEF_CHUNKSIZE 20 extern int32 estnum_vg; extern int32 estnum_vd; extern int32 num_sds; |