summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMuQun Yang <ymuqun@hdfgroup.org>2001-08-17 23:13:03 (GMT)
committerMuQun Yang <ymuqun@hdfgroup.org>2001-08-17 23:13:03 (GMT)
commitdd4e89adcc7a6a31db61d9facd26bbe906d82070 (patch)
tree751941da86c7d81d669619705f8203a620bdaf1d /tools
parent4eeb6d31cb685709ad81a7da5d158b088e7b7c2e (diff)
downloadhdf5-dd4e89adcc7a6a31db61d9facd26bbe906d82070.zip
hdf5-dd4e89adcc7a6a31db61d9facd26bbe906d82070.tar.gz
hdf5-dd4e89adcc7a6a31db61d9facd26bbe906d82070.tar.bz2
[svn-r4384]
Purpose: add a real raster-24 bit testing for interlace mode. fix a bug turn off a feature Description: 1. change the output of GRgetiminfo from NULL to &interlace_mode. 2. turn off the feature to change line-interleaved feature into pixel-interleaved feature since inconsistent behaviour is found in GR interface. 3. GR interfaces will never create an HDF4 file with interlace mode other than pixel interleaved. DF24 interfaces can create HDF4 file with different interleaved. There are inconsistent behaviors between GRreqimageil and GRreadimage, data read into the memory will not behave properly if a new interlace mode is asked. 4. Currently HDF5 image spec. supports pixel interleaved and plane interleaved. We make a real image file to test whether the converter is doing the right thing. Solution: We use DF24 bit APIs to generate a real image file that can be tested by H5view. Platforms tested: RedHat Zoot 6.2, sol 2.7
Diffstat (limited to 'tools')
-rw-r--r--tools/h4toh5/h4toh5image.c51
-rw-r--r--tools/h4toh5/h4toh5sds.c4
-rw-r--r--tools/h4toh5/h4toh5test.c148
-rw-r--r--tools/h4toh5/h4toh5util.h6
-rwxr-xr-xtools/h4toh5/testh4toh5.sh1
5 files changed, 188 insertions, 22 deletions
diff --git a/tools/h4toh5/h4toh5image.c b/tools/h4toh5/h4toh5image.c
index 9da5378..a1ab359 100644
--- a/tools/h4toh5/h4toh5image.c
+++ b/tools/h4toh5/h4toh5image.c
@@ -118,7 +118,7 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in
}
istat = GRgetiminfo(ri_id, image_name, &ncomp, &image_dtype,
- NULL, dimsizes, &ngrattrs);
+ &interlace_mode, dimsizes, &ngrattrs);
if(istat == FAIL) {
printf("Cannot obtain GR info. at Image routine.\n");
@@ -154,7 +154,16 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in
printf("error in allocating memory for image data. \n");
return FAIL;
}
-
+ /* GRreqimageil or GRreadimage are not working, comment this out for the time being.
+ if(interlace_mode == MFGR_INTERLACE_LINE){
+ istat = GRreqimageil(ri_id,MFGR_INTERLACE_PIXEL);
+ if(istat == FAIL){
+ printf("error in setting interlace_mode.\n");
+ free(image_data);
+ return FAIL;
+ }
+ }
+ */
istat = GRreadimage(ri_id, start, NULL, edges, (VOIDP)image_data);
if (istat == FAIL) {
@@ -179,13 +188,16 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in
h5dims24[1] = edges[0]-start[0];
h5dims24[2] = 3;
}
- /* currently scan-line is not supported.
+ /* currently scan-line is not supported. */
else if (interlace_mode == MFGR_INTERLACE_LINE){
- h5dims24[0] = 3;
+ printf("currently line interleaving is not supported.\n");
+ printf("the image %s will not be converted.\n",image_name);
+ free(image_data);
+ return SUCCEED;
+ /*h5dims24[0] = 3;
h5dims24[1] = edges[1]-start[1];
- h5dims24[2] = edges[0]-start[0];
+ h5dims24[2] = edges[0]-start[0];*/
}
- */
else if (interlace_mode == MFGR_INTERLACE_COMPONENT){
h5dims24[0] = 3;
h5dims24[1] = edges[1]-start[1];
@@ -411,6 +423,18 @@ 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. */
+ /* we don't use data transfer property list.
+ write_plist = H5Pcreate_list(H5P_DATASET_XFER_NEW);
+ bufsize = h4memsize *h5dims[1]*ncomp;
+
+ if(H5Pset_buffer(write_plist,bufsize,NULL,NULL)<0) {
+ printf("fail to create data transfer property list.\n");
+ free(image_data);
+ free(h5cimage_name);
+ H5Pclose(create_plist);
+ return FAIL;
+ }
+ */
if (ncomp == 1) {
h5d_sid = H5Screate_simple(2,h5dims,NULL);
@@ -442,18 +466,11 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in
return FAIL;
}
- }
+ }
- else { /* 24-bit image */
+ else { /* 24-bit image */
h5d_sid = H5Screate_simple(3,h5dims24,NULL);
- if(h5d_sid < 0) {
- printf("error in creating space. \n");
- free(image_data);
- free(h5cimage_name);
- H5Pclose(create_plist);
- return FAIL;
- }
h5dset = H5Dcreate(h5_group,h5cimage_name,h5ty_id,h5d_sid,
create_plist);
@@ -473,7 +490,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(image_data);
/* convert image annotation into attribute of image dataset.
@@ -652,7 +669,7 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in
istat = GRendaccess(ri_id);
free(h5cimage_name);
return SUCCEED;
-}
+ }
/**** palette routine. ****/
/*-------------------------------------------------------------------------
diff --git a/tools/h4toh5/h4toh5sds.c b/tools/h4toh5/h4toh5sds.c
index 7de526a..245da81 100644
--- a/tools/h4toh5/h4toh5sds.c
+++ b/tools/h4toh5/h4toh5sds.c
@@ -55,7 +55,7 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int
int32* sds_stride;
int32 count_sdsdata;
int32 sds_ref;
- int sds_empty;
+ intn sds_empty;
int32 istat;
int i;
int32 num_sdsattrs;
@@ -453,7 +453,7 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int
}
if (H5Dwrite(h5dset,h5_memtype,h5d_sid,h5d_sid,write_plist,
(void *)sds_data)<0) { */
- if (H5Dwrite(h5dset,h5_memtype,h5d_sid,h5d_sid,NULL,
+ if (H5Dwrite(h5dset,h5_memtype,h5d_sid,h5d_sid,H5P_DEFAULT,
(void *)sds_data)<0) {
printf("failed to write data into hdf5 dataset");
printf(" converted from SDS.\n");
diff --git a/tools/h4toh5/h4toh5test.c b/tools/h4toh5/h4toh5test.c
index 4a985d6..e398a11 100644
--- a/tools/h4toh5/h4toh5test.c
+++ b/tools/h4toh5/h4toh5test.c
@@ -1071,7 +1071,13 @@ int test_ras24() {
int32 start[2], edges[2],dims[2];
int8 image_data24[Y_LENGTH][X_LENGTH][3];
uint8 image_datau24[Y_LENGTH][X_LENGTH][3];
+<<<<<<< h4toh5test.c
+ unsigned char t24[13][15][3],tl24[13][3][15],tp24[3][13][15];
+ int32 dimst24[2];
+ intn i, j,k,m,n,p,q,co;
+=======
int i, j;
+>>>>>>> 1.3.2.5
int32 CUB_SIZE;
@@ -1095,6 +1101,69 @@ int test_ras24() {
}
}
+ k =0;
+ m = 0;
+ n = 0;
+ for (j = 0; j < 13; j++) {
+ for (i = 0; i < 15; i++) {
+ t24[j][i][0] = k;
+ t24[j][i][1] = k;
+ t24[j][i][2] = k;
+ k = k+1;
+ n = n+1;
+ if(n%13==0) {
+ k=m+1;
+ m++;
+ }
+ }
+ }
+
+ k = 0;
+ m = 0;
+ n = 0;
+ p = 0;
+ for (j = 0; j < 13; j++) {
+ for (co =0;co<3;co++) {
+ for (i = 0; i < 15; i++) {
+ tl24[j][co][i] = k;
+ k = k+1;
+ p = p+1;
+ if(p%13==0) {
+ m=m+1;
+ if(m%3==0) n++;
+ k = n;
+ }
+ }
+ }
+ }
+
+ k = 0;
+ m = 0;
+ n = 0;
+ p = 0;
+ q = 0;
+ for (co = 0; co < 3; co++) {
+ for (j =0;j<13;j++) {
+ for (i = 0; i < 15; i++) {
+ tp24[co][j][i] = k;
+ k++;
+ m++;
+ q++;
+ p++;
+ if(p%13 ==0) {
+ n++;
+ k = n;
+ }
+ if(q%(13*15)==0) {
+ k = 0;
+ n = 0;
+ }
+ }
+ }
+ }
+ dimst24[0] = 13;
+ dimst24[1] = 15;
+
/* Open the file. */
file_id = Hopen(FILERAS24, DFACC_CREATE, 0);
@@ -1157,6 +1226,85 @@ int test_ras24() {
printf("fail to write GR image.\n");
return FAIL;
}
+ /* Terminate access to the image. */
+ GRendaccess(ri_id);
+
+
+/* pixel interlaced.*/
+ncomp = 3;
+il = MFGR_INTERLACE_PIXEL;
+for(i=0;i<2;i++)
+{
+
+ start[i] =0;
+ edges[i] = dimst24[i];
+}
+ ri_id = GRcreate(gr_id, "t24", ncomp, DFNT_UCHAR8, il, dimst24);
+ if(ri_id == FAIL) {
+ printf("fail to create GR object.\n");
+ return FAIL;
+ }
+ istat = GRwriteimage(ri_id, start, NULL, edges, (VOIDP)t24);
+ if(istat == FAIL) {
+ printf("fail to write GR image.\n");
+ return FAIL;
+ }
+
+ GRendaccess(ri_id);
+
+ /* we will use DF24 APIs to test interlace function of image. */
+ DF24setil(MFGR_INTERLACE_PIXEL);
+ DF24addimage("ras24il.hdf",(VOIDP)t24,13,15);
+ DF24setil(MFGR_INTERLACE_COMPONENT);
+ DF24addimage("ras24il.hdf",(VOIDP)tp24,13,15);
+
+/* component interlaced.*/
+ ncomp = 3;
+ il = MFGR_INTERLACE_COMPONENT;
+
+for(i=0;i<2;i++)
+{
+
+ start[i] =0;
+ edges[i] = dimst24[i];
+}
+ /* Create the array. */
+ ri_id = GRcreate(gr_id, "tp24", ncomp, DFNT_UCHAR8, il, dimst24);
+ if(ri_id == FAIL) {
+ printf("fail to create GR object.\n");
+ return FAIL;
+ }
+ /* Write the stored data to the image array. */
+ istat = GRwriteimage(ri_id, start, NULL, edges, (VOIDP)tp24);
+ if(istat == FAIL) {
+ printf("fail to write GR image.\n");
+ return FAIL;
+ }
+
+ /* Terminate access to the image. */
+ GRendaccess(ri_id);
+
+/* line interlaced. */
+ ncomp = 3;
+ il = MFGR_INTERLACE_LINE;
+for(i=0;i<2;i++)
+{
+
+ start[i] =0;
+ edges[i] = dimst24[i];
+}
+ /* Create the array. */
+ ri_id = GRcreate(gr_id, "tl24", ncomp, DFNT_UCHAR8, il, dimst24);
+ if(ri_id == FAIL) {
+ printf("fail to create GR object.\n");
+ return FAIL;
+ }
+ /* Write the stored data to the image array. */
+ istat = GRwriteimage(ri_id, start, NULL, edges, (VOIDP)tl24);
+ if(istat == FAIL) {
+ printf("fail to write GR image.\n");
+ return FAIL;
+ }
/* Terminate access to the image. */
GRendaccess(ri_id);
diff --git a/tools/h4toh5/h4toh5util.h b/tools/h4toh5/h4toh5util.h
index 27bdcb5..e04aa35 100644
--- a/tools/h4toh5/h4toh5util.h
+++ b/tools/h4toh5/h4toh5util.h
@@ -98,9 +98,9 @@ converter.*/
#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"
+#define PIXEL_INTERLACE "INTERLACE_PIXEL"
+#define LINE_INTERLACE "INTERLACE_LINE"
+#define PLANE_INTERLACE "INTERLACE_PLANE"
/* 8. reserved group name for HDF4 dimensional scale and palette. */
diff --git a/tools/h4toh5/testh4toh5.sh b/tools/h4toh5/testh4toh5.sh
index c2a196e..d392a6a 100755
--- a/tools/h4toh5/testh4toh5.sh
+++ b/tools/h4toh5/testh4toh5.sh
@@ -221,6 +221,7 @@ CONVERT gr_typ_test.hdf gr_typ_test.h5
CONVERT grnameclash_test.hdf grnameclash_test.h5
CONVERT image_attr_test.hdf image_attr_test.h5
#CONVERT image_maxsize.hdf image_maxsize.h5
+CONVERT ras24il.hdf ras24il.h5
CONVERT ras_24_test.hdf ras_24_test.h5
CONVERT ras_8_test.hdf ras_8_test.h5
CONVERT sds_attr_test.hdf sds_attr_test.h5