Add/update plugins examples (#5670)

* Fixed all incorrect control char
* Synch filter examples to other examples
This commit is contained in:
Allen Byrne
2025-07-28 09:34:22 -05:00
committed by GitHub
parent f8aa8aa1ba
commit fc3f153742
17 changed files with 209 additions and 306 deletions
+8
View File
@@ -40,6 +40,14 @@ else ()
set (BITGROOM_AVAILABLE 0)
endif ()
option (ENABLE_BITROUND "Enable Library Building for bitround plugin" ON)
if (ENABLE_BITROUND)
set (BITROUND_AVAILABLE 1)
set (dyn_examples ${dyn_examples} h5ex_d_granularbr)
else ()
set (BITROUND_AVAILABLE 0)
endif ()
option (ENABLE_BSHUF "Enable Library Building for bshuf plugin" ON)
if (ENABLE_BSHUF)
if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
+22 -34
View File
@@ -1,29 +1,18 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 BitGroom filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* terms governing use, modification, and redistribution, is contained in *
* the file COPYING, which can be found at the root of the BITGROOM source code *
* distribution tree. If you do not have access to this file, you may *
* request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/************************************************************
This example shows how to write data and read it from a dataset
using BitGroom quantization.
The BitGroom filter is not available by default in HDF5.
The BitGroom filter is not available in HDF5.
The example uses a new feature available in HDF5 version 1.8.11
to discover, load and register filters at run time.
************************************************************/
#include "hdf5.h"
#include <stdio.h>
#include <stdlib.h>
#define FILE "h5ex_d_bitgroom.h5"
#define FILENAME "h5ex_d_bitgroom.h5"
#define DATASET "DS1"
#define DIM0 32
#define DIM1 64
@@ -34,40 +23,39 @@
int
main(void)
{
hid_t file_id = -1; /* Handles */
hid_t space_id = -1; /* Handles */
hid_t dset_id = -1; /* Handles */
hid_t dcpl_id = -1; /* Handles */
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
char filter_name[80];
hsize_t dims[2] = {DIM0, DIM1}, chunk[2] = {CHUNK0, CHUNK1};
size_t nelmts = 5;
/* number of elements in cd_values */ /* NB: Must equal H5Zbitgroom.c: CCR_FLT_PRM_NBR */
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
char filter_name[80];
hsize_t dims[2] = {DIM0, DIM1}, chunk[2] = {CHUNK0, CHUNK1};
size_t nelmts = 5; /* number of elements in cd_values */
unsigned int flags;
unsigned filter_config;
const unsigned int cd_values[5] = {
3, 4, 0, 0, 0}; /* BitGroom argument ordering is
NSD,sizeof(data),has_mss_val,mss_val_byt_1to4[,mss_val_byt_5to8] */
unsigned int values_out[5] = {99, 99, 99, 99, 99};
float wdata[DIM0][DIM1], /* Write buffer */
rdata[DIM0][DIM1], /* Read buffer */
max;
hsize_t i, j;
int ret_value = 1;
float wdata[DIM0][DIM1]; /* Write buffer */
float rdata[DIM0][DIM1]; /* Read buffer */
float max;
hsize_t i, j;
int ret_value = 1;
/*
* Initialize data.
*/
for (i = 0; i < DIM0; i++)
for (j = 0; j < DIM1; j++)
wdata[i][j] = i * j - j;
wdata[i][j] = (float)(i * j) - (float)(j);
/*
* Create a new file using the default properties.
*/
file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (file_id < 0)
goto done;
@@ -156,7 +144,7 @@ main(void)
/*
* Open file and dataset using the default properties.
*/
file_id = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT);
file_id = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
if (file_id < 0)
goto done;
@@ -205,7 +193,7 @@ main(void)
max = rdata[0][0];
for (i = 0; i < DIM0; i++)
for (j = 0; j < DIM1; j++) {
/*printf("%d \n", rdata[i][j]); */
/*printf("%f \n", rdata[i][j]); */
if (max < rdata[i][j])
max = rdata[i][j];
}
+9 -21
View File
@@ -1,15 +1,3 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 BLOSC filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* terms governing use, modification, and redistribution, is contained in *
* the file LICENSE, which can be found at the root of the BLOSC source code *
* distribution tree. If you do not have access to this file, you may *
* request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/************************************************************
This example shows how to write data and read it from a dataset
@@ -35,10 +23,10 @@
int
main(void)
{
hid_t file_id = H5I_INVALID_HID; /* Handles */
hid_t space_id = H5I_INVALID_HID; /* Handles */
hid_t dset_id = H5I_INVALID_HID; /* Handles */
hid_t dcpl_id = H5I_INVALID_HID; /* Handles */
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
@@ -49,11 +37,11 @@ main(void)
unsigned filter_config;
const unsigned int cd_values[7] = {0, 0, 0, 0, 4, 1, 2}; /* blosc parameters */
unsigned int values_out[7] = {99, 99, 99, 99, 99, 99, 99};
int wdata[DIM0][DIM1], /* Write buffer */
rdata[DIM0][DIM1], /* Read buffer */
max;
hsize_t i, j;
int ret_value = 1;
int wdata[DIM0][DIM1]; /* Write buffer */
int rdata[DIM0][DIM1]; /* Read buffer */
int max;
hsize_t i, j;
int ret_value = 1;
/*
* Initialize data.
+9 -21
View File
@@ -1,15 +1,3 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 BLOSC2 filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* terms governing use, modification, and redistribution, is contained in *
* the file LICENSE, which can be found at the root of the BLOSC2 source code *
* distribution tree. If you do not have access to this file, you may *
* request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/************************************************************
This example shows how to write data and read it from a dataset
@@ -35,10 +23,10 @@
int
main(void)
{
hid_t file_id = H5I_INVALID_HID; /* Handles */
hid_t space_id = H5I_INVALID_HID; /* Handles */
hid_t dset_id = H5I_INVALID_HID; /* Handles */
hid_t dcpl_id = H5I_INVALID_HID; /* Handles */
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
@@ -49,11 +37,11 @@ main(void)
unsigned filter_config;
const unsigned int cd_values[10] = {0, 0, 0, 0, 4, 1, 2, 2, 4, 8}; /* blosc parameters */
unsigned int values_out[10] = {99, 99, 99, 99, 99, 99, 99, 99, 99, 99};
int wdata[DIM0][DIM1], /* Write buffer */
rdata[DIM0][DIM1], /* Read buffer */
max;
hsize_t i, j;
int ret_value = 1;
int wdata[DIM0][DIM1]; /* Write buffer */
int rdata[DIM0][DIM1]; /* Read buffer */
int max;
hsize_t i, j;
int ret_value = 1;
/*
* Initialize data.
+9 -21
View File
@@ -1,15 +1,3 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 BSHUF filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* terms governing use, modification, and redistribution, is contained in *
* the file LICENSE, which can be found at the root of the BSHUF source code *
* distribution tree. If you do not have access to this file, you may *
* request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/************************************************************
This example shows how to write data and read it from a dataset
@@ -35,10 +23,10 @@
int
main(void)
{
hid_t file_id = H5I_INVALID_HID; /* Handles */
hid_t space_id = H5I_INVALID_HID; /* Handles */
hid_t dset_id = H5I_INVALID_HID; /* Handles */
hid_t dcpl_id = H5I_INVALID_HID; /* Handles */
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
@@ -49,11 +37,11 @@ main(void)
unsigned filter_config;
const unsigned int cd_values[3] = {0, 0, 0};
unsigned int values_out[3] = {99, 99, 99};
int wdata[DIM0][DIM1], /* Write buffer */
rdata[DIM0][DIM1], /* Read buffer */
max;
hsize_t i, j;
int ret_value = 1;
int wdata[DIM0][DIM1]; /* Write buffer */
int rdata[DIM0][DIM1]; /* Read buffer */
int max;
hsize_t i, j;
int ret_value = 1;
/*
* Initialize data.
+9 -21
View File
@@ -1,15 +1,3 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 BZIP2 filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* terms governing use, modification, and redistribution, is contained in *
* the file LICENSE, which can be found at the root of the BZIP2 source code *
* distribution tree. If you do not have access to this file, you may *
* request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/************************************************************
This example shows how to write data and read it from a dataset
@@ -35,10 +23,10 @@
int
main(void)
{
hid_t file_id = H5I_INVALID_HID; /* Handles */
hid_t space_id = H5I_INVALID_HID; /* Handles */
hid_t dset_id = H5I_INVALID_HID; /* Handles */
hid_t dcpl_id = H5I_INVALID_HID; /* Handles */
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
@@ -49,11 +37,11 @@ main(void)
unsigned filter_config;
const unsigned int cd_values[1] = {2}; /* bzip2 default level is 2 */
unsigned int values_out[1] = {99};
int wdata[DIM0][DIM1], /* Write buffer */
rdata[DIM0][DIM1], /* Read buffer */
max;
hsize_t i, j;
int ret_value = 1;
int wdata[DIM0][DIM1]; /* Write buffer */
int rdata[DIM0][DIM1]; /* Read buffer */
int max;
hsize_t i, j;
int ret_value = 1;
/*
* Initialize data.
@@ -1,20 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 MAFISC filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* terms governing use, modification, and redistribution, is contained in *
* the file LICENSE, which can be found at the root of the MAFISC source code *
* distribution tree. If you do not have access to this file, you may *
* request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/************************************************************
This example shows how to write data and read it from a dataset
using mafisc compression.
mafisc filter is not available in HDF5.
using Granular BitRound quantization.
The Granular BitRound filter is not available in HDF5.
The example uses a new feature available in HDF5 version 1.8.11
to discover, load and register filters at run time.
@@ -24,36 +12,38 @@
#include <stdio.h>
#include <stdlib.h>
#define FILENAME "h5ex_d_mafisc.h5"
#define DATASET "DS1"
#define DIM0 32
#define DIM1 64
#define CHUNK0 4
#define CHUNK1 8
#define H5Z_FILTER_MAFISC 32002
#define FILENAME "h5ex_d_granularbr.h5"
#define DATASET "DS1"
#define DIM0 32
#define DIM1 64
#define CHUNK0 4
#define CHUNK1 8
#define H5Z_FILTER_GRANULARBR 32023
int
main(void)
{
hid_t file_id = H5I_INVALID_HID; /* Handles */
hid_t space_id = H5I_INVALID_HID; /* Handles */
hid_t dset_id = H5I_INVALID_HID; /* Handles */
hid_t dcpl_id = H5I_INVALID_HID; /* Handles */
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
char filter_name[128];
char filter_name[80];
hsize_t dims[2] = {DIM0, DIM1}, chunk[2] = {CHUNK0, CHUNK1};
size_t nelmts = 8; /* number of elements in cd_values */
size_t nelmts = 5; /* number of elements in cd_values */
unsigned int flags;
unsigned filter_config;
const unsigned int cd_values[8]; /* mafisc default is 6 + rank */
unsigned int values_out[8] = {99, 99, 99, 99, 99, 99, 99, 99};
int wdata[DIM0][DIM1], /* Write buffer */
rdata[DIM0][DIM1], /* Read buffer */
max;
hsize_t i, j;
int ret_value = 1;
const unsigned int cd_values[5] = {
3, 4, 0, 0, 0}; /* Granular BitRound argument ordering is
NSD,sizeof(data),has_mss_val,mss_val_byt_1to4[,mss_val_byt_5to8] */
unsigned int values_out[5] = {99, 99, 99, 99, 99};
float wdata[DIM0][DIM1]; /* Write buffer */
float rdata[DIM0][DIM1]; /* Read buffer */
float max;
hsize_t i, j;
int ret_value = 1;
/*
* Initialize data.
@@ -78,14 +68,16 @@ main(void)
goto done;
/*
* Create the dataset creation property list, add the gzip
* compression filter and set the chunk size.
* Create the dataset creation property list, add the Granular BitRound
* quantization filter and set the chunk size.
*/
dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
if (dcpl_id < 0)
goto done;
status = H5Pset_filter(dcpl_id, H5Z_FILTER_MAFISC, H5Z_FLAG_MANDATORY, nelmts, cd_values);
/* 20200929: csz change this to H5Z_FLAG_OPTIONAL, so that can_apply() can reject filter for
integers without causing program to exit()? */
status = H5Pset_filter(dcpl_id, H5Z_FILTER_GRANULARBR, H5Z_FLAG_MANDATORY, nelmts, cd_values);
if (status < 0)
goto done;
@@ -93,12 +85,12 @@ main(void)
* Check that filter is registered with the library now.
* If it is registered, retrieve filter's configuration.
*/
avail = H5Zfilter_avail(H5Z_FILTER_MAFISC);
avail = H5Zfilter_avail(H5Z_FILTER_GRANULARBR);
if (avail) {
status = H5Zget_filter_info(H5Z_FILTER_MAFISC, &filter_config);
status = H5Zget_filter_info(H5Z_FILTER_GRANULARBR, &filter_config);
if ((filter_config & H5Z_FILTER_CONFIG_ENCODE_ENABLED) &&
(filter_config & H5Z_FILTER_CONFIG_DECODE_ENABLED))
printf("mafisc filter is available for encoding and decoding.\n");
printf("Granular BitRound filter is available for quantization and decoding.\n");
}
else {
printf("H5Zfilter_avail - not found.\n");
@@ -112,7 +104,7 @@ main(void)
* Create the dataset.
*/
printf("....Create dataset ................\n");
dset_id = H5Dcreate(file_id, DATASET, H5T_STD_I32LE, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
dset_id = H5Dcreate(file_id, DATASET, H5T_IEEE_F32LE, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
if (dset_id < 0) {
printf("failed to create dataset.\n");
goto done;
@@ -121,8 +113,8 @@ main(void)
/*
* Write the data to the dataset.
*/
printf("....Writing mafisc compressed data ................\n");
status = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata[0]);
printf("....Writing Granular BitRound-quantized data ................\n");
status = H5Dwrite(dset_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)wdata);
if (status < 0)
printf("failed to write data.\n");
@@ -167,27 +159,17 @@ main(void)
goto done;
/*
* Retrieve and print the filter id, compression level and filter's name for mafisc.
* Retrieve and print the filter id, quantization level and filter's name for Granular BitRound.
*/
/* Format of the cd_values array:
cd_values[0] = version = 0;
cd_values[1] = datasetId (created randomly);
cd_values[2] = dataTypeSize (in bytes);
cd_values[3] = isFloat (true, if the datatype is a float type);
cd_values[4] = byteOrder (same as H5T_order_t);
cd_values[5] = rank (# of dimension of a chunk);
cd_values[6] = Size of first dimension (the size of the chunk!);
...
cd_values[6+rank-1] = Size of last dimension; */
filter_id = H5Pget_filter2(dcpl_id, (unsigned)0, &flags, &nelmts, values_out, sizeof(filter_name),
filter_name, NULL);
printf("Filter info is available from the dataset creation property \n ");
printf(" Filter identifier is ");
switch (filter_id) {
case H5Z_FILTER_MAFISC:
case H5Z_FILTER_GRANULARBR:
printf("%d\n", filter_id);
printf(" Number of parameters is %d with rank %u values %u %u\n", nelmts, values_out[5],
values_out[6], values_out[7]);
printf(" Number of parameters is %lu with the values %u, %u, %u, %u, %u\n", nelmts,
values_out[0], values_out[1], values_out[2], values_out[3], values_out[4]);
printf(" To find more about the filter check %s\n", filter_name);
break;
default:
@@ -198,8 +180,8 @@ main(void)
/*
* Read the data using the default properties.
*/
printf("....Reading mafisc compressed data ................\n");
status = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata[0]);
printf("....Reading Granular BitRound-quantized data ................\n");
status = H5Dread(dset_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata[0]);
if (status < 0)
printf("failed to read data.\n");
@@ -217,13 +199,13 @@ main(void)
/*
* Print the maximum value.
*/
printf("Maximum value in %s is %d\n", DATASET, max);
printf("Maximum value in %s is %g\n", DATASET, max);
/*
* Check that filter is registered with the library now.
*/
avail = H5Zfilter_avail(H5Z_FILTER_MAFISC);
avail = H5Zfilter_avail(H5Z_FILTER_GRANULARBR);
if (avail)
printf("mafisc filter is available now since H5Dread triggered loading of the filter.\n");
printf("Granular BitRound filter is available now since H5Dread triggered loading of the filter.\n");
ret_value = 0;
+29 -46
View File
@@ -1,15 +1,3 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 JPEG filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* terms governing use, modification, and redistribution, is contained in *
* the file LICENSE, which can be found at the root of the JPEG source code *
* distribution tree. If you do not have access to this file, you may *
* request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/************************************************************
This example shows how to write data and read it from a dataset
@@ -38,10 +26,10 @@
int
main(void)
{
hid_t file_id = H5I_INVALID_HID; /* Handles */
hid_t space_id = H5I_INVALID_HID; /* Handles */
hid_t dset_id = H5I_INVALID_HID; /* Handles */
hid_t dcpl_id = H5I_INVALID_HID; /* Handles */
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
@@ -59,11 +47,11 @@ main(void)
/* Color mode (0=Mono, 1=RGB) */
const unsigned int cd_values[4] = {JPEG_QUALITY, DIM1, DIM0, 0}; /* jpeg default level is 2 */
unsigned int values_out[4] = {99, 99, 99, 99};
unsigned char *wdata, /* Write buffer */
*rdata; /* Read buffer */
int num_diff = 0;
hsize_t i;
int ret_value = 1;
unsigned char *wdata; /* Write buffer */
unsigned char *rdata; /* Read buffer */
int num_diff = 0;
hsize_t i;
int ret_value = 1;
wdata = (unsigned char *)malloc(sizeof(unsigned char) * data_size);
rdata = (unsigned char *)malloc(sizeof(unsigned char) * data_size);
@@ -108,35 +96,33 @@ main(void)
status = H5Zget_filter_info(H5Z_FILTER_JPEG, &filter_config);
if ((filter_config & H5Z_FILTER_CONFIG_ENCODE_ENABLED) &&
(filter_config & H5Z_FILTER_CONFIG_DECODE_ENABLED))
fprintf(stdout, "jpeg filter is available for encoding and decoding.\n");
printf("jpeg filter is available for encoding and decoding.\n");
}
else {
fprintf(stdout, "H5Zfilter_avail - not found.\n");
printf("H5Zfilter_avail - not found.\n");
goto done;
}
status = H5Pset_chunk(dcpl_id, 3, chunk);
if (status < 0)
fprintf(stdout, "failed to set chunk.\n");
printf("failed to set chunk.\n");
/*
* Create the dataset.
*/
fprintf(stdout, "....Create dataset ................\n");
printf("....Create dataset ................\n");
dset_id = H5Dcreate(file_id, DATASET, H5T_NATIVE_UINT8, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
if (dset_id < 0) {
fprintf(stdout, "failed to create dataset.\n");
printf("failed to create dataset.\n");
goto done;
}
fflush(stdout);
/*
* Write the data to the dataset.
*/
fprintf(stdout, "....Writing jpeg compressed data ................\n");
printf("....Writing jpeg compressed data ................\n");
status = H5Dwrite(dset_id, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
if (status < 0)
fprintf(stdout, "failed to write data.\n");
fflush(stdout);
printf("failed to write data.\n");
/*
* Close and release resources.
@@ -151,11 +137,11 @@ main(void)
file_id = -1;
status = H5close();
if (status < 0) {
fprintf(stdout, "\nFAILED to close library\n");
printf("\nFAILED to close library\n");
goto done;
}
fprintf(stdout, "....Close the file and reopen for reading ........\n");
printf("....Close the file and reopen for reading ........\n");
/*
* Now we begin the read section of this example.
*/
@@ -183,28 +169,26 @@ main(void)
*/
filter_id = H5Pget_filter2(dcpl_id, (unsigned)0, &flags, &nelmts, values_out, sizeof(filter_name),
filter_name, NULL);
fprintf(stdout, "Filter info is available from the dataset creation property \n ");
fprintf(stdout, " Filter identifier is ");
printf("Filter info is available from the dataset creation property \n ");
printf(" Filter identifier is ");
switch (filter_id) {
case H5Z_FILTER_JPEG:
fprintf(stdout, "%d\n", filter_id);
fprintf(stdout, " Number of parameters is %d with the value %u\n", nelmts, values_out[0]);
fprintf(stdout, " To find more about the filter check %s\n", filter_name);
printf("%d\n", filter_id);
printf(" Number of parameters is %d with the value %u\n", nelmts, values_out[0]);
printf(" To find more about the filter check %s\n", filter_name);
break;
default:
fprintf(stdout, "Not expected filter\n");
printf("Not expected filter\n");
break;
}
fflush(stdout);
/*
* Read the data using the default properties.
*/
fprintf(stdout, "....Reading jpeg compressed data ................\n");
printf("....Reading jpeg compressed data ................\n");
status = H5Dread(dset_id, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
if (status < 0)
fprintf(stdout, "failed to read data.\n");
fflush(stdout);
printf("failed to read data.\n");
/*
* Find the maximum value in the dataset, to verify that it was
@@ -218,19 +202,18 @@ main(void)
/*
* Print the number of differences.
*/
fprintf(stdout, "JPEG quality=%d, percent of differing array elements=%f\n", JPEG_QUALITY,
100. * (double)num_diff / data_size);
printf("JPEG quality=%d, percent of differing array elements=%f\n", JPEG_QUALITY,
100. * (double)num_diff / data_size);
/*
* Check that filter is registered with the library now.
*/
avail = H5Zfilter_avail(H5Z_FILTER_JPEG);
if (avail)
fprintf(stdout, "jpeg filter is available now since H5Dread triggered loading of the filter.\n");
printf("jpeg filter is available now since H5Dread triggered loading of the filter.\n");
ret_value = 0;
done:
fflush(stdout);
free(rdata);
free(wdata);
/*
+9 -21
View File
@@ -1,15 +1,3 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 LZ4 filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* terms governing use, modification, and redistribution, is contained in *
* the file LICENSE, which can be found at the root of the LZ4 source code *
* distribution tree. If you do not have access to this file, you may *
* request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/************************************************************
This example shows how to write data and read it from a dataset
@@ -35,10 +23,10 @@
int
main(void)
{
hid_t file_id = H5I_INVALID_HID; /* Handles */
hid_t space_id = H5I_INVALID_HID; /* Handles */
hid_t dset_id = H5I_INVALID_HID; /* Handles */
hid_t dcpl_id = H5I_INVALID_HID; /* Handles */
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
@@ -49,11 +37,11 @@ main(void)
unsigned filter_config;
const unsigned int cd_values[1] = {3}; /* lz4 default is 3 */
unsigned int values_out[1] = {99};
int wdata[DIM0][DIM1], /* Write buffer */
rdata[DIM0][DIM1], /* Read buffer */
max;
hsize_t i, j;
int ret_value = 1;
int wdata[DIM0][DIM1]; /* Write buffer */
int rdata[DIM0][DIM1]; /* Read buffer */
int max;
hsize_t i, j;
int ret_value = 1;
/*
* Initialize data.
+9 -21
View File
@@ -1,15 +1,3 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 LZF filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* terms governing use, modification, and redistribution, is contained in *
* the file LICENSE, which can be found at the root of the LZF source code *
* distribution tree. If you do not have access to this file, you may *
* request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/************************************************************
This example shows how to write data and read it from a dataset
@@ -35,10 +23,10 @@
int
main(void)
{
hid_t file_id = H5I_INVALID_HID; /* Handles */
hid_t space_id = H5I_INVALID_HID; /* Handles */
hid_t dset_id = H5I_INVALID_HID; /* Handles */
hid_t dcpl_id = H5I_INVALID_HID; /* Handles */
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
@@ -49,11 +37,11 @@ main(void)
unsigned filter_config;
const unsigned int cd_values[3] = {0, 0, 0};
unsigned int values_out[3] = {99, 99, 99};
int wdata[DIM0][DIM1], /* Write buffer */
rdata[DIM0][DIM1], /* Read buffer */
max;
hsize_t i, j;
int ret_value = 1;
int wdata[DIM0][DIM1]; /* Write buffer */
int rdata[DIM0][DIM1]; /* Read buffer */
int max;
hsize_t i, j;
int ret_value = 1;
/*
* Initialize data.
+9 -21
View File
@@ -1,15 +1,3 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 ZFP filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* terms governing use, modification, and redistribution, is contained in *
* the file LICENSE, which can be found at the root of the ZFP source code *
* distribution tree. If you do not have access to this file, you may *
* request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/************************************************************
This example shows how to write data and read it from a dataset
@@ -35,10 +23,10 @@
int
main(void)
{
hid_t file_id = H5I_INVALID_HID; /* Handles */
hid_t space_id = H5I_INVALID_HID; /* Handles */
hid_t dset_id = H5I_INVALID_HID; /* Handles */
hid_t dcpl_id = H5I_INVALID_HID; /* Handles */
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
@@ -49,11 +37,11 @@ main(void)
unsigned filter_config;
const unsigned int cd_values[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned int values_out[10] = {99, 99, 99, 99, 99, 99, 99, 99, 99, 99};
float wdata[DIM0][DIM1], /* Write buffer */
rdata[DIM0][DIM1]; /* Read buffer */
float max;
hsize_t i, j;
int ret_value = 1;
float wdata[DIM0][DIM1]; /* Write buffer */
float rdata[DIM0][DIM1]; /* Read buffer */
float max;
hsize_t i, j;
int ret_value = 1;
/*
* Initialize data.
+4 -16
View File
@@ -1,15 +1,3 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 ZSTD filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* terms governing use, modification, and redistribution, is contained in *
* the file LICENSE, which can be found at the root of the ZSTD source code *
* distribution tree. If you do not have access to this file, you may *
* request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/************************************************************
This example shows how to write data and read it from a dataset
@@ -37,10 +25,10 @@
int
main(void)
{
hid_t file_id = H5I_INVALID_HID; /* Handles */
hid_t space_id = H5I_INVALID_HID; /* Handles */
hid_t dset_id = H5I_INVALID_HID; /* Handles */
hid_t dcpl_id = H5I_INVALID_HID; /* Handles */
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
herr_t status;
htri_t avail;
H5Z_filter_t filter_id = 0;
@@ -2,7 +2,7 @@ BitGroom filter is available for quantization and decoding.
....Create dataset ................
....Writing BitGroom-quantized data ................
....Close the file and reopen for reading ........
Filter info is available from the dataset creation property
Filter info is available from the dataset creation property
Filter identifier is 32022
Number of parameters is 5 with the values 3, 4, 0, 0, 0
To find more about the filter check BitGroom filter (Zender, 2016 GMD: http://www.geosci-model-dev.net/9/3199/2016)
@@ -0,0 +1,26 @@
HDF5 "h5ex_d_granularbr.h5" {
GROUP "/" {
DATASET "DS1" {
DATATYPE H5T_IEEE_F32LE
DATASPACE SIMPLE { ( 32, 64 ) / ( 32, 64 ) }
STORAGE_LAYOUT {
CHUNKED ( 4, 8 )
SIZE 8192 (1.000:1 COMPRESSION)
}
FILTERS {
USER_DEFINED_FILTER {
FILTER_ID 32023
COMMENT Granular BitRound filter
PARAMS { 3 4 0 0 0 }
}
}
FILLVALUE {
FILL_TIME H5D_FILL_TIME_IFSET
VALUE H5D_FILL_VALUE_DEFAULT
}
ALLOCATION_TIME {
H5D_ALLOC_TIME_INCR
}
}
}
}
Binary file not shown.
@@ -0,0 +1,11 @@
Granular BitRound filter is available for quantization and decoding.
....Create dataset ................
....Writing Granular BitRound-quantized data ................
....Close the file and reopen for reading ........
Filter info is available from the dataset creation property
Filter identifier is 32023
Number of parameters is 5 with the values 3, 4, 0, 0, 0
To find more about the filter check Granular BitRound filter
....Reading Granular BitRound-quantized data ................
Maximum value in DS1 is 1.84467e+19
Granular BitRound filter is available now since H5Dread triggered loading of the filter.