| 1 |
#include <stdio.h> |
| 2 |
#include <stdlib.h> |
| 3 |
#include "h5z-sperr.h" |
| 4 |
|
| 5 |
int main(int argc, char* argv[]) |
| 6 |
{ |
| 7 |
if (argc < 3 || argc > 4) { |
| 8 |
printf("Usage: ./generate_cd_values compression_mode compression_quality [rank_swap_flag]\n"); |
| 9 |
exit(1); |
| 10 |
} |
| 11 |
|
| 12 |
int mode = atoi(argv[1]); |
| 13 |
double quality = atof(argv[2]); |
| 14 |
int swap = argc == 3 ? 0 : 1; |
| 15 |
unsigned int cd_values = H5Z_SPERR_make_cd_values(mode, quality, swap); |
| 16 |
|
| 17 |
H5Z_SPERR_decode_cd_values(cd_values, &mode, &quality, &swap); |
| 18 |
|
| 19 |
switch (mode) { |
| 20 |
case 1: |
| 21 |
if (quality > 0.0 && quality < 64.0) |
| 22 |
printf("For fixed-rate compression with a bitrate of %.4f,", quality); |
| 23 |
else { |
| 24 |
printf("Target bitrate should in between of 0.0 and 64.0\n"); |
| 25 |
exit(1); |
| 26 |
} |
| 27 |
break; |
| 28 |
case 2: |
| 29 |
if (quality > 0.0) |
| 30 |
printf("For fixed-PSNR compression with a target PSNR of %.4f,", quality); |
| 31 |
else { |
| 32 |
printf("Target PSNR should be greater than 0.0.\n"); |
| 33 |
exit(1); |
| 34 |
} |
| 35 |
break; |
| 36 |
case 3: |
| 37 |
if (quality > 0.0) |
| 38 |
printf("For fixed-PWE compression with a PWE tolerance of %.4g,", quality); |
| 39 |
else { |
| 40 |
printf("PWE tolerance should be greater than 0.0.\n"); |
| 41 |
exit(1); |
| 42 |
} |
| 43 |
break; |
| 44 |
default: |
| 45 |
printf("Compression mode should be 1, 2, or 3\n"); |
| 46 |
exit(1); |
| 47 |
} |
| 48 |
|
| 49 |
if (swap) |
| 50 |
printf(" swapping rank orders,\n"); |
| 51 |
else |
| 52 |
printf(" without swapping rank orders,\n"); |
| 53 |
printf("H5Z-SPERR cd_values = %uu (Filter ID = %d).\n", cd_values, H5Z_FILTER_SPERR); |
| 54 |
printf("Please use this value as a single 32-bit unsigned integer in your applications.\n"); |
| 55 |
} |