Skip to content
Snippets Groups Projects
Commit 4c544e57 authored by Dominik Loidolt's avatar Dominik Loidolt
Browse files

add an extra verbose flag -vv

parent e903a3f0
No related branches found
No related tags found
1 merge request!21add an extra verbose flag -vv
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [Unreleased]
### Added
- add -vv flag for extra verbose output
## [0.11] - 26-04-2023 ## [0.11] - 26-04-2023
### Added ### Added
- add -b or --binary option for read and write files in binary format - add -b or --binary option for read and write files in binary format
...@@ -21,7 +25,6 @@ All notable changes to this project will be documented in this file. ...@@ -21,7 +25,6 @@ All notable changes to this project will be documented in this file.
- fixed several bug when using the last_info option - fixed several bug when using the last_info option
- fix a bug in the calculation of the adaptive compression sizes - fix a bug in the calculation of the adaptive compression sizes
## [0.09] - 30-09-2022 ## [0.09] - 30-09-2022
### Added ### Added
- decompression/compression for non-imagette data - decompression/compression for non-imagette data
......
...@@ -11,7 +11,7 @@ Compiled executables can be found [here](https://gitlab.phaidra.org/loidoltd15/c ...@@ -11,7 +11,7 @@ Compiled executables can be found [here](https://gitlab.phaidra.org/loidoltd15/c
### General Options ### General Options
| Options | Description | | Options | Description |
|:------------------|:------------------------------------------------------------------------------| |:--------------------|:------------------------------------------------------------------------------|
| `-h, --help` | Print some help text and exit | | `-h, --help` | Print some help text and exit |
| `-o <prefix>` | Use the `<prefix>` for output files<sup>[1](#fnote1)</sup> | | `-o <prefix>` | Use the `<prefix>` for output files<sup>[1](#fnote1)</sup> |
| `-n, --model_cfg` | Print a default model configuration and exit<sup>[2](#fnote2)</sup> | | `-n, --model_cfg` | Print a default model configuration and exit<sup>[2](#fnote2)</sup> |
...@@ -19,7 +19,8 @@ Compiled executables can be found [here](https://gitlab.phaidra.org/loidoltd15/c ...@@ -19,7 +19,8 @@ Compiled executables can be found [here](https://gitlab.phaidra.org/loidoltd15/c
| `-b, --binary` | Read and write files in binary format | | `-b, --binary` | Read and write files in binary format |
| `-a, --rdcu_par` | Add additional RDCU control parameters | | `-a, --rdcu_par` | Add additional RDCU control parameters |
| `-V, --version` | Print program version and exit | | `-V, --version` | Print program version and exit |
| `-v, --verbose` | Print various debugging information | | `-v, -vv, --verbose`| Print various debugging information, -vv is extra verbose |
<a name="fnote1">1</a>) **NOTE:** If the -o option is not used the `<prefix>` <a name="fnote1">1</a>) **NOTE:** If the -o option is not used the `<prefix>`
will be set to "OUTPUT". will be set to "OUTPUT".
......
...@@ -201,6 +201,8 @@ int main(int argc, char **argv) ...@@ -201,6 +201,8 @@ int main(int argc, char **argv)
output_prefix = optarg; output_prefix = optarg;
break; break;
case 'v': /* --verbose */ case 'v': /* --verbose */
if (io_flags & CMP_IO_VERBOSE)
io_flags |= CMP_IO_VERBOSE_EXTRA;
io_flags |= CMP_IO_VERBOSE; io_flags |= CMP_IO_VERBOSE;
break; break;
case 'V': /* --version */ case 'V': /* --version */
...@@ -434,7 +436,7 @@ int main(int argc, char **argv) ...@@ -434,7 +436,7 @@ int main(int argc, char **argv)
cmp_ent_set_size(decomp_entity, (uint32_t)buf_size); cmp_ent_set_size(decomp_entity, (uint32_t)buf_size);
} }
if (io_flags & CMP_IO_VERBOSE) { if (io_flags & CMP_IO_VERBOSE_EXTRA) {
cmp_ent_print(decomp_entity); cmp_ent_print(decomp_entity);
printf("\n"); printf("\n");
} }
......
...@@ -29,8 +29,9 @@ ...@@ -29,8 +29,9 @@
#define BUFFER_LENGTH_DEF_FAKTOR 2 #define BUFFER_LENGTH_DEF_FAKTOR 2
/* flags argument options (can be combined) */ /* flags argument options (can be combined) */
#define CMP_IO_VERBOSE 1 #define CMP_IO_BINARY 0x1
#define CMP_IO_BINARY 2 #define CMP_IO_VERBOSE 0x2
#define CMP_IO_VERBOSE_EXTRA 0x4
void print_help(const char *program_name); void print_help(const char *program_name);
......
...@@ -2344,11 +2344,11 @@ void cmp_ent_print_header(struct cmp_entity *ent) ...@@ -2344,11 +2344,11 @@ void cmp_ent_print_header(struct cmp_entity *ent)
size_t i; size_t i;
for (i = 0; i < hdr_size; ++i) { for (i = 0; i < hdr_size; ++i) {
debug_print("%02X ", p[i]); printf("%02X ", p[i]);
if (i && !((i+1) % 32)) if (i && !((i+1) % 32))
debug_print("\n"); printf("\n");
} }
debug_print("\n"); printf("\n");
} }
...@@ -2368,11 +2368,11 @@ void cmp_ent_print_data(struct cmp_entity *ent) ...@@ -2368,11 +2368,11 @@ void cmp_ent_print_data(struct cmp_entity *ent)
return; return;
for (i = 0; i < data_size; ++i) { for (i = 0; i < data_size; ++i) {
debug_print("%02X ", p[i]); printf("%02X ", p[i]);
if (i && !((i+1) % 32)) if (i && !((i+1) % 32))
debug_print("\n"); printf("\n");
} }
debug_print("\n"); printf("\n");
} }
...@@ -2384,9 +2384,9 @@ void cmp_ent_print_data(struct cmp_entity *ent) ...@@ -2384,9 +2384,9 @@ void cmp_ent_print_data(struct cmp_entity *ent)
void cmp_ent_print(struct cmp_entity *ent) void cmp_ent_print(struct cmp_entity *ent)
{ {
debug_print("compression entity header:\n"); printf("compression entity header:\n");
cmp_ent_print_header(ent); cmp_ent_print_header(ent);
debug_print("compressed data in the compressed entity:\n"); printf("compressed data in the compressed entity:\n");
cmp_ent_print_data(ent); cmp_ent_print_data(ent);
} }
...@@ -2411,62 +2411,62 @@ static void cmp_ent_parse_generic_header(struct cmp_entity *ent) ...@@ -2411,62 +2411,62 @@ static void cmp_ent_parse_generic_header(struct cmp_entity *ent)
uint16_t major = (version_id & 0x7FFF0000U) >> 16U; uint16_t major = (version_id & 0x7FFF0000U) >> 16U;
uint16_t minor = version_id & 0xFFFFU; uint16_t minor = version_id & 0xFFFFU;
debug_print("Compressed with cmp_tool version: %u.%02u\n", major, minor); printf("Compressed with cmp_tool version: %u.%02u\n", major, minor);
} else } else
debug_print("ICU ASW Version ID: %08" PRIx32 "\n", version_id); printf("ICU ASW Version ID: %08" PRIx32 "\n", version_id);
cmp_ent_size = cmp_ent_get_size(ent); cmp_ent_size = cmp_ent_get_size(ent);
debug_print("Compression Entity Size: %" PRIu32 " byte\n", cmp_ent_size); printf("Compression Entity Size: %" PRIu32 " byte\n", cmp_ent_size);
original_size = cmp_ent_get_original_size(ent); original_size = cmp_ent_get_original_size(ent);
debug_print("Original Data Size: %" PRIu32 " byte\n", original_size); printf("Original Data Size: %" PRIu32 " byte\n", original_size);
start_coarse_time = cmp_ent_get_coarse_start_time(ent); start_coarse_time = cmp_ent_get_coarse_start_time(ent);
debug_print("Compression Coarse Start Time: %" PRIu32 "\n", start_coarse_time); printf("Compression Coarse Start Time: %" PRIu32 "\n", start_coarse_time);
start_fine_time = cmp_ent_get_fine_start_time(ent); start_fine_time = cmp_ent_get_fine_start_time(ent);
debug_print("Compression Fine Start Time: %d\n", start_fine_time); printf("Compression Fine Start Time: %d\n", start_fine_time);
end_coarse_time = cmp_ent_get_coarse_end_time(ent); end_coarse_time = cmp_ent_get_coarse_end_time(ent);
debug_print("Compression Coarse End Time: %" PRIu32 "\n", end_coarse_time); printf("Compression Coarse End Time: %" PRIu32 "\n", end_coarse_time);
end_fine_time = cmp_ent_get_fine_end_time(ent); end_fine_time = cmp_ent_get_fine_end_time(ent);
debug_print("Compression Fine End Time: %d\n", end_fine_time); printf("Compression Fine End Time: %d\n", end_fine_time);
#ifdef HAS_TIME_H #ifdef HAS_TIME_H
{ {
struct tm epoch_date = PLATO_EPOCH_DATE; struct tm epoch_date = PLATO_EPOCH_DATE;
time_t time = my_timegm(&epoch_date) + start_coarse_time; time_t time = my_timegm(&epoch_date) + start_coarse_time;
debug_print("Data were compressed on (local time): %s", ctime(&time)); printf("Data were compressed on (local time): %s", ctime(&time));
} }
#endif #endif
debug_print("The compression took %f second\n", end_coarse_time - start_coarse_time printf("The compression took %f second\n", end_coarse_time - start_coarse_time
+ ((end_fine_time - start_fine_time)/256./256.)); + ((end_fine_time - start_fine_time)/256./256.));
data_type = cmp_ent_get_data_type(ent); data_type = cmp_ent_get_data_type(ent);
debug_print("Data Product Type: %d\n", data_type); printf("Data Product Type: %d\n", data_type);
raw_bit = cmp_ent_get_data_type_raw_bit(ent); raw_bit = cmp_ent_get_data_type_raw_bit(ent);
debug_print("RAW bit in the Data Product Type is%s set\n", raw_bit ? "" : " not"); printf("RAW bit in the Data Product Type is%s set\n", raw_bit ? "" : " not");
cmp_mode_used = cmp_ent_get_cmp_mode(ent); cmp_mode_used = cmp_ent_get_cmp_mode(ent);
debug_print("Used Compression Mode: %" PRIu32 "\n", cmp_mode_used); printf("Used Compression Mode: %" PRIu32 "\n", cmp_mode_used);
model_value_used = cmp_ent_get_model_value(ent); model_value_used = cmp_ent_get_model_value(ent);
debug_print("Used Model Updating Weighing Value: %" PRIu32 "\n", model_value_used); printf("Used Model Updating Weighing Value: %" PRIu32 "\n", model_value_used);
model_id = cmp_ent_get_model_id(ent); model_id = cmp_ent_get_model_id(ent);
debug_print("Model ID: %" PRIu32 "\n", model_id); printf("Model ID: %" PRIu32 "\n", model_id);
model_counter = cmp_ent_get_model_counter(ent); model_counter = cmp_ent_get_model_counter(ent);
debug_print("Model Counter: %" PRIu32 "\n", model_counter); printf("Model Counter: %" PRIu32 "\n", model_counter);
max_used_bits_version = cmp_ent_get_max_used_bits_version(ent); max_used_bits_version = cmp_ent_get_max_used_bits_version(ent);
debug_print("Maximum Used Bits Registry Version: %" PRIu32 "\n", max_used_bits_version); printf("Maximum Used Bits Registry Version: %" PRIu32 "\n", max_used_bits_version);
lossy_cmp_par_used = cmp_ent_get_lossy_cmp_par(ent); lossy_cmp_par_used = cmp_ent_get_lossy_cmp_par(ent);
debug_print("Used Lossy Compression Parameters: %" PRIu32 "\n", lossy_cmp_par_used); printf("Used Lossy Compression Parameters: %" PRIu32 "\n", lossy_cmp_par_used);
} }
...@@ -2481,10 +2481,10 @@ static void cmp_ent_parese_imagette_header(struct cmp_entity *ent) ...@@ -2481,10 +2481,10 @@ static void cmp_ent_parese_imagette_header(struct cmp_entity *ent)
uint32_t spill_used, golomb_par_used; uint32_t spill_used, golomb_par_used;
spill_used = cmp_ent_get_ima_spill(ent); spill_used = cmp_ent_get_ima_spill(ent);
debug_print("Used Spillover Threshold Parameter: %" PRIu32 "\n", spill_used); printf("Used Spillover Threshold Parameter: %" PRIu32 "\n", spill_used);
golomb_par_used = cmp_ent_get_ima_golomb_par(ent); golomb_par_used = cmp_ent_get_ima_golomb_par(ent);
debug_print("Used Golomb Parameter: %" PRIu32 "\n", golomb_par_used); printf("Used Golomb Parameter: %" PRIu32 "\n", golomb_par_used);
} }
...@@ -2500,22 +2500,22 @@ static void cmp_ent_parese_adaptive_imagette_header(struct cmp_entity *ent) ...@@ -2500,22 +2500,22 @@ static void cmp_ent_parese_adaptive_imagette_header(struct cmp_entity *ent)
ap1_golomb_par_used, ap2_spill_used, ap2_golomb_par_used; ap1_golomb_par_used, ap2_spill_used, ap2_golomb_par_used;
spill_used = cmp_ent_get_ima_spill(ent); spill_used = cmp_ent_get_ima_spill(ent);
debug_print("Used Spillover Threshold Parameter: %" PRIu32 "\n", spill_used); printf("Used Spillover Threshold Parameter: %" PRIu32 "\n", spill_used);
golomb_par_used = cmp_ent_get_ima_golomb_par(ent); golomb_par_used = cmp_ent_get_ima_golomb_par(ent);
debug_print("Used Golomb Parameter: %" PRIu32 "\n", golomb_par_used); printf("Used Golomb Parameter: %" PRIu32 "\n", golomb_par_used);
ap1_spill_used = cmp_ent_get_ima_ap1_spill(ent); ap1_spill_used = cmp_ent_get_ima_ap1_spill(ent);
debug_print("Used Adaptive 1 Spillover Threshold Parameter: %" PRIu32 "\n", ap1_spill_used); printf("Used Adaptive 1 Spillover Threshold Parameter: %" PRIu32 "\n", ap1_spill_used);
ap1_golomb_par_used = cmp_ent_get_ima_ap1_golomb_par(ent); ap1_golomb_par_used = cmp_ent_get_ima_ap1_golomb_par(ent);
debug_print("Used Adaptive 1 Golomb Parameter: %" PRIu32 "\n", ap1_golomb_par_used); printf("Used Adaptive 1 Golomb Parameter: %" PRIu32 "\n", ap1_golomb_par_used);
ap2_spill_used = cmp_ent_get_ima_ap2_spill(ent); ap2_spill_used = cmp_ent_get_ima_ap2_spill(ent);
debug_print("Used Adaptive 2 Spillover Threshold Parameter: %" PRIu32 "\n", ap2_spill_used); printf("Used Adaptive 2 Spillover Threshold Parameter: %" PRIu32 "\n", ap2_spill_used);
ap2_golomb_par_used = cmp_ent_get_ima_ap2_golomb_par(ent); ap2_golomb_par_used = cmp_ent_get_ima_ap2_golomb_par(ent);
debug_print("Used Adaptive 2 Golomb Parameter: %" PRIu32 "\n", ap2_golomb_par_used); printf("Used Adaptive 2 Golomb Parameter: %" PRIu32 "\n", ap2_golomb_par_used);
} }
...@@ -2530,7 +2530,7 @@ static void cmp_ent_parese_specific_header(struct cmp_entity *ent) ...@@ -2530,7 +2530,7 @@ static void cmp_ent_parese_specific_header(struct cmp_entity *ent)
enum cmp_data_type data_type = cmp_ent_get_data_type(ent); enum cmp_data_type data_type = cmp_ent_get_data_type(ent);
if (cmp_ent_get_data_type_raw_bit(ent)) { if (cmp_ent_get_data_type_raw_bit(ent)) {
debug_print("Uncompressed data bit is set. No specific header is used.\n"); printf("Uncompressed data bit is set. No specific header is used.\n");
return; return;
} }
...@@ -2546,7 +2546,7 @@ static void cmp_ent_parese_specific_header(struct cmp_entity *ent) ...@@ -2546,7 +2546,7 @@ static void cmp_ent_parese_specific_header(struct cmp_entity *ent)
cmp_ent_parese_adaptive_imagette_header(ent); cmp_ent_parese_adaptive_imagette_header(ent);
break; break;
default: default:
debug_print("For this data product type no parse functions is implemented!\n"); printf("For this data product type no parse functions is implemented!\n");
break; break;
} }
} }
......
...@@ -84,7 +84,7 @@ void print_help(const char *program_name) ...@@ -84,7 +84,7 @@ void print_help(const char *program_name)
printf(" -b, --binary Read and write files in binary format\n"); printf(" -b, --binary Read and write files in binary format\n");
printf(" -a, --rdcu_par Add additional RDCU control parameters\n"); printf(" -a, --rdcu_par Add additional RDCU control parameters\n");
printf(" -V, --version Print program version and exit\n"); printf(" -V, --version Print program version and exit\n");
printf(" -v, --verbose Print various debugging information\n"); printf(" -v, -vv, --verbose Print various debugging information, -vv is extra verbose\n");
printf("Compression Options:\n"); printf("Compression Options:\n");
printf(" -c <file> File containing the compressing configuration\n"); printf(" -c <file> File containing the compressing configuration\n");
printf(" -d <file> File containing the data to be compressed\n"); printf(" -d <file> File containing the data to be compressed\n");
...@@ -157,7 +157,7 @@ static FILE *open_file(const char *dirname, const char *filename) ...@@ -157,7 +157,7 @@ static FILE *open_file(const char *dirname, const char *filename)
* @param data_type compression data type of the data * @param data_type compression data type of the data
* @param output_prefix file name without file extension * @param output_prefix file name without file extension
* @param name_extension extension (with leading point character) * @param name_extension extension (with leading point character)
* @param flags CMP_IO_VERBOSE print verbose output if set * @param flags CMP_IO_VERBOSE_EXTRA print verbose output if set
* CMP_IO_BINARY write file in binary format if set * CMP_IO_BINARY write file in binary format if set
* *
* @returns 0 on success, error otherwise * @returns 0 on success, error otherwise
...@@ -203,7 +203,7 @@ int write_input_data_to_file(void *data, uint32_t data_size, enum cmp_data_type ...@@ -203,7 +203,7 @@ int write_input_data_to_file(void *data, uint32_t data_size, enum cmp_data_type
* @param output_prefix file name without file extension * @param output_prefix file name without file extension
* @param name_extension file extension (with leading point character) * @param name_extension file extension (with leading point character)
* *
* @param flags CMP_IO_VERBOSE print verbose output if set * @param flags CMP_IO_VERBOSE_EXTRA print verbose output if set
* CMP_IO_BINARY write file in binary format if set * CMP_IO_BINARY write file in binary format if set
* *
* @returns 0 on success, error otherwise * @returns 0 on success, error otherwise
...@@ -268,9 +268,10 @@ int write_data_to_file(const void *buf, uint32_t buf_size, const char *output_pr ...@@ -268,9 +268,10 @@ int write_data_to_file(const void *buf, uint32_t buf_size, const char *output_pr
} }
} }
if (flags & CMP_IO_VERBOSE && !(flags & CMP_IO_BINARY)) { if (flags & CMP_IO_VERBOSE_EXTRA && !(flags & CMP_IO_BINARY)) {
printf("\n");
fwrite(output_file_data, 1, output_file_size, stdout); fwrite(output_file_data, 1, output_file_size, stdout);
printf("\n\n"); printf("\n");
} }
free(tmp_buf); free(tmp_buf);
...@@ -1309,7 +1310,7 @@ static __inline ssize_t str2uint8_arr(const char *str, uint8_t *data, uint32_t b ...@@ -1309,7 +1310,7 @@ static __inline ssize_t str2uint8_arr(const char *str, uint8_t *data, uint32_t b
* @param file_name data/model file name * @param file_name data/model file name
* @param buf buffer to write the file content (can be NULL) * @param buf buffer to write the file content (can be NULL)
* @param buf_size number of uint8_t data words to read in * @param buf_size number of uint8_t data words to read in
* @param flags CMP_IO_VERBOSE print verbose output if set * @param flags CMP_IO_VERBOSE_EXTRA print verbose output if set
* CMP_IO_BINARY read in file in binary format if set * CMP_IO_BINARY read in file in binary format if set
* *
* @returns the size in bytes to store the file content; negative on error * @returns the size in bytes to store the file content; negative on error
...@@ -1382,7 +1383,7 @@ ssize_t read_file8(const char *file_name, uint8_t *buf, uint32_t buf_size, int f ...@@ -1382,7 +1383,7 @@ ssize_t read_file8(const char *file_name, uint8_t *buf, uint32_t buf_size, int f
fclose(fp); fclose(fp);
fp = NULL; fp = NULL;
size = str2uint8_arr(file_cpy, buf, buf_size, file_name, flags & CMP_IO_VERBOSE); size = str2uint8_arr(file_cpy, buf, buf_size, file_name, flags & CMP_IO_VERBOSE_EXTRA);
free(file_cpy); free(file_cpy);
file_cpy = NULL; file_cpy = NULL;
...@@ -1406,7 +1407,7 @@ fail: ...@@ -1406,7 +1407,7 @@ fail:
* @param data_type compression data type used for the data * @param data_type compression data type used for the data
* @param buf buffer to write the file content (can be NULL) * @param buf buffer to write the file content (can be NULL)
* @param buf_size size in bytes of the buffer * @param buf_size size in bytes of the buffer
* @param flags CMP_IO_VERBOSE print verbose output if set * @param flags CMP_IO_VERBOSE_EXTRA print verbose output if set
* CMP_IO_BINARY read in file in binary format if set * CMP_IO_BINARY read in file in binary format if set
* *
* @returns the size in bytes to store the file content; negative on error * @returns the size in bytes to store the file content; negative on error
...@@ -1471,6 +1472,11 @@ ssize_t read_file_cmp_entity(const char *file_name, struct cmp_entity *ent, ...@@ -1471,6 +1472,11 @@ ssize_t read_file_cmp_entity(const char *file_name, struct cmp_entity *ent,
if (ent) { if (ent) {
enum cmp_data_type data_type = cmp_ent_get_data_type(ent); enum cmp_data_type data_type = cmp_ent_get_data_type(ent);
if (flags & CMP_IO_VERBOSE) {
printf("\n");
cmp_ent_parse(ent);
}
if (data_type == DATA_TYPE_UNKNOWN) { if (data_type == DATA_TYPE_UNKNOWN) {
fprintf(stderr, "%s: %s: Error: Compression data type is not supported. The header of the compression entity may be corrupted.\n", fprintf(stderr, "%s: %s: Error: Compression data type is not supported. The header of the compression entity may be corrupted.\n",
PROGRAM_NAME, file_name); PROGRAM_NAME, file_name);
...@@ -1481,9 +1487,6 @@ ssize_t read_file_cmp_entity(const char *file_name, struct cmp_entity *ent, ...@@ -1481,9 +1487,6 @@ ssize_t read_file_cmp_entity(const char *file_name, struct cmp_entity *ent,
PROGRAM_NAME, file_name, cmp_ent_get_size(ent), (size_t)size); PROGRAM_NAME, file_name, cmp_ent_get_size(ent), (size_t)size);
return -1; return -1;
} }
if (flags & CMP_IO_VERBOSE)
cmp_ent_parse(ent);
} }
return size; return size;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment