From 1c99e79c91011f9ca4decd1904d66f7bce505e53 Mon Sep 17 00:00:00 2001
From: Dominik Loidolt <dominik.loidolt@univie.ac.at>
Date: Fri, 18 Nov 2022 17:10:36 +0100
Subject: [PATCH] Update (doxygen) documentation; fix some code formatting

---
 INSTALL.md                                |   2 +
 cmp_tool.c                                |  45 +-
 doc/doxygen/Doxyfile.in                   |   2 +-
 how_to_no_header.md                       |   2 +-
 include/byteorder.h                       |   4 +-
 include/cmp_data_types.h                  | 109 ++++-
 include/cmp_entity.h                      | 109 +++--
 include/cmp_io.h                          |   4 +-
 include/cmp_rdcu_cfg.h                    |   2 +-
 include/cmp_rdcu_extended.h               |  30 --
 include/cmp_support.h                     | 152 +++---
 include/my_inttypes.h                     |   6 +-
 include/rdcu_cmd.h                        |   1 +
 include/rdcu_ctrl.h                       |   7 +
 include/rdcu_pkt_to_file.h                |   1 +
 include/rdcu_rmap.h                       |   1 +
 include/rmap.h                            |  29 +-
 lib/cmp_guess.c                           |   3 +-
 lib/cmp_icu.c                             |  30 +-
 lib/cmp_io.c                              |  15 +-
 lib/cmp_support.c                         |   3 +-
 lib/decmp.c                               |  14 +-
 lib/rdcu_ctrl.c                           |   2 +-
 lib/rdcu_pkt_to_file.c                    |   6 +-
 lib/rdcu_rmap.c                           |   8 +-
 test/cmp_data_types/test_cmp_data_types.c |   5 +-
 test/cmp_decmp/test_cmp_decmp.c           |  12 +-
 test/cmp_icu/test_cmp_icu.c               |  73 ++-
 test/cmp_icu/test_decmp.c                 |  35 +-
 test/cmp_tool/cmp_tool_lib_test.c         | 540 ----------------------
 30 files changed, 452 insertions(+), 800 deletions(-)
 delete mode 100644 include/cmp_rdcu_extended.h
 delete mode 100644 test/cmp_tool/cmp_tool_lib_test.c

diff --git a/INSTALL.md b/INSTALL.md
index 3c2eab4..4babccb 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -141,7 +141,9 @@ Optional you can install the "dot" tool from [graphviz](http://www.graphviz.org/
 To generate the documentation you need to run:
 
 ```
+git submodule update --init
 cd <name of the build directory>
 meson compile doc
 ```
 
+You can find the documentation in the directory **generated_documentation**.
diff --git a/cmp_tool.c b/cmp_tool.c
index edae320..a306761 100644
--- a/cmp_tool.c
+++ b/cmp_tool.c
@@ -1,7 +1,7 @@
 /**
  * @file   cmp_tool.c
- * @author Johannes Seelig (johannes.seelig@univie.ac.at)
  * @author Dominik Loidolt (dominik.loidolt@univie.ac.at)
+ * @author Johannes Seelig (johannes.seelig@univie.ac.at)
  * @date   2020
  *
  * @copyright GPLv2
@@ -55,9 +55,9 @@ static int compression(struct cmp_cfg *cfg, struct cmp_info *info);
 static int decompression(struct cmp_entity *ent, uint16_t *input_model_buf);
 
 /* create a default configuration for a compression data type */
-enum cfg_default_opt {DIFF_CFG, MODEL_CFG};
-int cmp_cfg_create_default(struct cmp_cfg *cfg, enum cmp_data_type data_type,
-			   enum cfg_default_opt mode);
+static enum cfg_default_opt {DIFF_CFG, MODEL_CFG};
+static int cmp_cfg_create_default(struct cmp_cfg *cfg, enum cmp_data_type data_type,
+				  enum cfg_default_opt mode);
 
 
 /*
@@ -329,6 +329,7 @@ int main(int argc, char **argv)
 		/* count the samples in the data file when samples == 0 */
 		if (cfg.samples == 0) {
 			int32_t samples;
+
 			size = read_file_data(data_file_name, cfg.data_type, NULL, 0, 0);
 			if (size <= 0 || size > UINT32_MAX) /* empty file is treated as an error */
 				goto fail;
@@ -522,7 +523,10 @@ fail:
 }
 
 
-/* parse a data_type option argument */
+/**
+ * @brief parse a data_type option argument
+ */
+
 static enum cmp_data_type parse_data_type(const char *data_type_str)
 {
 	/* default data type if no optional argument is used */
@@ -538,7 +542,10 @@ static enum cmp_data_type parse_data_type(const char *data_type_str)
 }
 
 
-/* find a good set of compression parameters for a given dataset */
+/**
+ * @brief find a good set of compression parameters for a given dataset
+ */
+
 static int guess_cmp_pars(struct cmp_cfg *cfg, const char *guess_cmp_mode,
 			  int guess_level)
 {
@@ -592,7 +599,10 @@ static int guess_cmp_pars(struct cmp_cfg *cfg, const char *guess_cmp_mode,
 }
 
 
-/* generate packets to setup an RDCU compression */
+/**
+ * @brief generate packets to setup an RDCU compression
+ */
+
 static int gen_rdcu_write_pkts(struct cmp_cfg *cfg)
 {
 	int error;
@@ -704,7 +714,10 @@ static int cmp_gernate_rdcu_info(const struct cmp_cfg *cfg, int cmp_size_bit,
 }
 
 
-/* compress the data and write the results to files */
+/**
+ * @brief compress the data and write the results to files
+ */
+
 static int compression(struct cmp_cfg *cfg, struct cmp_info *info)
 {
 	int cmp_size, error;
@@ -752,6 +765,7 @@ static int compression(struct cmp_cfg *cfg, struct cmp_info *info)
 
 	if (model_id_str) {
 		uint32_t red_val;
+
 		error = atoui32("model_id", model_id_str, &red_val);
 		if (error || red_val > UINT16_MAX)
 			return -1;
@@ -759,6 +773,7 @@ static int compression(struct cmp_cfg *cfg, struct cmp_info *info)
 	}
 	if (model_counter_str) {
 		uint32_t red_val;
+
 		error = atoui32("model_counter", model_counter_str, &red_val);
 		if (error || red_val > UINT8_MAX)
 			return -1;
@@ -833,7 +848,10 @@ error_cleanup:
 }
 
 
-/* decompress the data and write the results in file(s)*/
+/**
+ * @brief decompress the data and write the results in file(s)
+ */
+
 static int decompression(struct cmp_entity *ent, uint16_t *input_model_buf)
 {
 	int error;
@@ -880,9 +898,12 @@ static int decompression(struct cmp_entity *ent, uint16_t *input_model_buf)
 }
 
 
-/* create a default configuration for a compression data type */
-int cmp_cfg_create_default(struct cmp_cfg *cfg, enum cmp_data_type data_type,
-			   enum cfg_default_opt mode)
+/**
+ * @brief create a default configuration for a compression data type
+ */
+
+static int cmp_cfg_create_default(struct cmp_cfg *cfg, enum cmp_data_type data_type,
+				  enum cfg_default_opt mode)
 {
 	if (cmp_data_type_is_invalid(data_type))
 		return -1;
diff --git a/doc/doxygen/Doxyfile.in b/doc/doxygen/Doxyfile.in
index dc226fc..bd30e4c 100644
--- a/doc/doxygen/Doxyfile.in
+++ b/doc/doxygen/Doxyfile.in
@@ -781,7 +781,7 @@ SHOW_NAMESPACES        = YES
 # by doxygen. Whatever the program writes to standard output is used as the file
 # version. For an example see the documentation.
 
-FILE_VERSION_FILTER    = "/bin/sh -c 'git log --pretty=\"format:%ci, author:%aN <%aE>, commit:%h\" -1 \"${1}\" || echo no git'"
+FILE_VERSION_FILTER    = git log --pretty='format:%ci, author: %aN <%aE>, commit: %h' -1
 
 # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
 # by doxygen. The layout file controls the global structure of the generated
diff --git a/how_to_no_header.md b/how_to_no_header.md
index 3d0f800..5300fc9 100644
--- a/how_to_no_header.md
+++ b/how_to_no_header.md
@@ -2,7 +2,7 @@
 
 A simple example to show how the compression tool works without the compression entity header.
 
-0. Download the [tool][3] or run `make` to build the tool
+0. Download the [cmp_tool](https://gitlab.phaidra.org/loidoltd15/cmp_tool/-/releases) or [build](INSTALL.md) the tool
 
 1. Create a configuration file
 * Create a cfg directory  
diff --git a/include/byteorder.h b/include/byteorder.h
index ff25578..efd4c59 100644
--- a/include/byteorder.h
+++ b/include/byteorder.h
@@ -13,8 +13,8 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
- * This is a set of macros for consistent endianess conversion. They work
- * for both little and big endian cpus.
+ * @brief This is a set of macros for consistent endianess conversion. They work
+ *	for both little and big endian cpus.
  *
  * conversion of XX-bit integers (16- or 32-) between native CPU format
  * and little/big endian format:
diff --git a/include/cmp_data_types.h b/include/cmp_data_types.h
index 68e70d3..ec95be8 100644
--- a/include/cmp_data_types.h
+++ b/include/cmp_data_types.h
@@ -2,7 +2,7 @@
  * @file   cmp_data_types.h
  * @author Dominik Loidolt (dominik.loidolt@univie.ac.at),
  * @date   2020
- * @brief definition of the different data types
+ * @brief definition of the different compression data types
  *
  * @copyright GPLv2
  * This program is free software; you can redistribute it and/or modify it
@@ -14,7 +14,7 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
- * @see for N-DPU packed definition: PLATO-LESIA-PL-RP-0031 Issue: 1.9 (N-DPU->ICU data rate)
+ * @see for N-DPU packed definition: PLATO-LESIA-PL-RP-0031 Issue: 2.9 (N-DPU->ICU data rate)
  * @see for calculation of the max used bits: PLATO-LESIA-PDC-TN-0054 Issue: 1.7
  *
  * Three data rates (for N-DPU):
@@ -26,9 +26,9 @@
  * exp_flags = selected exposure flags
  * fx = normal light flux
  * ncob = normal center of brightness
- * efx = extended flux
+ * efx = extended light flux
  * ecob = extended center of brightness
- * The prefixes F, S and L stand for Fast, Short and Long cadence
+ * The prefixes f, s and l stand for fast, short and long cadence
  */
 
 #ifndef CMP_DATA_TYPE_H
@@ -39,6 +39,10 @@
 #include <compiler.h>
 #include <cmp_support.h>
 
+
+/* size of the source data header structure for multi entry packet */
+#define MULTI_ENTRY_HDR_SIZE 12
+
 #define MAX_USED_NC_IMAGETTE_BITS		16
 #define MAX_USED_SATURATED_IMAGETTE_BITS	16 /* TBC */
 #define MAX_USED_FC_IMAGETTE_BITS		16 /* TBC */
@@ -82,7 +86,10 @@
 #define MAX_USED_FC_BACKGROUND_OUTLIER_PIXELS_BITS	16 /* TBC */
 
 
-/* struct holding the maximum length of the different data product types in bits */
+/**
+ * @brief Structure holding the maximum length of the different data product types in bits
+ */
+
 struct cmp_max_used_bits {
 	uint8_t version;
 	unsigned int s_exp_flags;
@@ -121,18 +128,12 @@ struct cmp_max_used_bits {
 };
 
 
-/* Set and read the max_used_bits, which specify how many bits are needed to
- * represent the highest possible value.
+/**
+ * @brief source data header structure for multi entry packet
+ * @note a scientific package contains a multi-entry header followed by multiple
+ *	entries of the same entry definition
+ * @see PLATO-LESIA-PL-RP-0031(N-DPU->ICU data rate)
  */
-void cmp_set_max_used_bits(const struct cmp_max_used_bits *set_max_used_bits);
-struct cmp_max_used_bits cmp_get_max_used_bits(void);
-
-uint8_t cmp_get_max_used_bits_version(void);
-
-
-/* Source data header structure for multi entry packet */
-#define MULTI_ENTRY_HDR_SIZE 12
-compile_time_assert(MULTI_ENTRY_HDR_SIZE % sizeof(uint32_t) == 0, N_DPU_ICU_MULTI_ENTRY_HDR_NOT_4_BYTE_ALLIED);
 
 __extension__
 struct multi_entry_hdr {
@@ -144,14 +145,23 @@ struct multi_entry_hdr {
 	uint8_t  entry[];
 } __attribute__((packed));
 compile_time_assert(sizeof(struct multi_entry_hdr) == MULTI_ENTRY_HDR_SIZE, N_DPU_ICU_MULTI_ENTRY_HDR_SIZE_IS_NOT_CORRECT);
+compile_time_assert(sizeof(struct multi_entry_hdr) % sizeof(uint32_t) == 0, N_DPU_ICU_MULTI_ENTRY_HDR_NOT_4_BYTE_ALLIED);
+
 
+/**
+ * @brief short cadence normal light flux entry definition
+ */
 
 struct s_fx {
-	uint8_t exp_flags; /* selected exposure flags (2 flags + 6 spare bits) */
-	uint32_t fx;       /* normal light flux */
+	uint8_t exp_flags; /**< selected exposure flags (2 flags + 6 spare bits) */
+	uint32_t fx;       /**< normal light flux */
 } __attribute__((packed));
 
 
+/**
+ * @brief short cadence normal and extended light flux entry definition
+ */
+
 struct s_fx_efx {
 	uint8_t exp_flags;
 	uint32_t fx;
@@ -159,6 +169,10 @@ struct s_fx_efx {
 } __attribute__((packed));
 
 
+/**
+ * @brief short cadence normal light flux, normal center of brightness entry definition
+ */
+
 struct s_fx_ncob {
 	uint8_t exp_flags;
 	uint32_t fx;
@@ -167,6 +181,10 @@ struct s_fx_ncob {
 } __attribute__((packed));
 
 
+/**
+ * @brief short cadence normal and extended flux, normal and extended center of brightness entry definition
+ */
+
 struct s_fx_efx_ncob_ecob {
 	uint8_t exp_flags;
 	uint32_t fx;
@@ -178,17 +196,29 @@ struct s_fx_efx_ncob_ecob {
 } __attribute__((packed));
 
 
+/**
+ * @brief fast cadence normal light flux entry definition
+ */
+
 struct f_fx {
 	uint32_t fx;
 } __attribute__((packed));
 
 
+/**
+ * @brief fast cadence normal and extended light flux entry definition
+ */
+
 struct f_fx_efx {
 	uint32_t fx;
 	uint32_t efx;
 } __attribute__((packed));
 
 
+/**
+ * @brief fast cadence normal light flux, normal center of brightness entry definition
+ */
+
 struct f_fx_ncob {
 	uint32_t fx;
 	uint32_t ncob_x;
@@ -196,6 +226,11 @@ struct f_fx_ncob {
 } __attribute__((packed));
 
 
+/**
+ * @brief fast cadence normal and extended flux, normal and extended center of
+ *	brightness entry definition
+ */
+
 struct f_fx_efx_ncob_ecob {
 	uint32_t fx;
 	uint32_t ncob_x;
@@ -206,6 +241,10 @@ struct f_fx_efx_ncob_ecob {
 } __attribute__((packed));
 
 
+/**
+ * @brief long cadence normal light flux entry definition
+ */
+
 __extension__
 struct l_fx {
 	uint32_t exp_flags:24; /* selected exposure flags (24 flags) */
@@ -214,6 +253,10 @@ struct l_fx {
 } __attribute__((packed));
 
 
+/**
+ * @brief long cadence normal and extended light flux entry definition
+ */
+
 __extension__
 struct l_fx_efx {
 	uint32_t exp_flags:24; /* selected exposure flags (24 flags) */
@@ -223,6 +266,10 @@ struct l_fx_efx {
 } __attribute__((packed));
 
 
+/**
+ * @brief long cadence normal light flux, normal center of brightness entry definition
+ */
+
 __extension__
 struct l_fx_ncob {
 	uint32_t exp_flags:24; /* selected exposure flags (24 flags) */
@@ -235,6 +282,11 @@ struct l_fx_ncob {
 } __attribute__((packed));
 
 
+/**
+ * @brief long cadence normal and extended flux, normal and extended center of
+ *	brightness entry definition
+ */
+
 __extension__
 struct l_fx_efx_ncob_ecob {
 	uint32_t exp_flags:24; /* selected exposure flags (24 flags) */
@@ -250,12 +302,20 @@ struct l_fx_efx_ncob_ecob {
 } __attribute__((packed));
 
 
+/**
+ * @brief normal offset entry definition
+ */
+
 struct nc_offset {
 	uint32_t mean;
 	uint32_t variance;
 } __attribute__((packed));
 
 
+/**
+ * @brief normal background entry definition
+ */
+
 struct nc_background {
 	uint32_t mean;
 	uint32_t variance;
@@ -263,6 +323,10 @@ struct nc_background {
 } __attribute__((packed));
 
 
+/**
+ * @brief smearing entry definition
+ */
+
 struct smearing {
 	uint32_t mean;
 	uint16_t variance_mean;
@@ -270,6 +334,15 @@ struct smearing {
 } __attribute__((packed));
 
 
+/*
+ * Set and read the max_used_bits registry, which specify how many bits are
+ * needed to represent the highest possible value.
+ */
+uint8_t cmp_get_max_used_bits_version(void);
+struct cmp_max_used_bits cmp_get_max_used_bits(void);
+void cmp_set_max_used_bits(const struct cmp_max_used_bits *set_max_used_bits);
+
+
 size_t size_of_a_sample(enum cmp_data_type data_type);
 uint32_t cmp_cal_size_of_data(uint32_t samples, enum cmp_data_type data_type);
 int32_t cmp_input_size_to_samples(uint32_t size, enum cmp_data_type data_type);
diff --git a/include/cmp_entity.h b/include/cmp_entity.h
index d9d7fb5..2444434 100644
--- a/include/cmp_entity.h
+++ b/include/cmp_entity.h
@@ -1,7 +1,7 @@
 /**
  * @file   cmp_entity.h
  * @author Dominik Loidolt (dominik.loidolt@univie.ac.at),
- * @date   Mai, 2021
+ * @date   May, 2021
  *
  * @copyright GPLv2
  * This program is free software; you can redistribute it and/or modify it
@@ -19,8 +19,8 @@
  * @note this code can also used on a little endian machine
  *
  * @warning: If you create an entity of one data product type and use get/set
- * functions intended for another data product type, it will result in a
- * corrupted entity. Do not do this.
+ *	functions intended for another data product type, it will result in a
+ *	corrupted entity or garbage data. Do not do this.
  */
 
 
@@ -51,73 +51,93 @@
 
 #define CMP_TOOL_VERSION_ID_BIT 0x80000000U
 
+
+/**
+ * @brief PALTO CUC timestamp format
+ */
+
 __extension__
 struct timestamp_cmp_ent {
 	uint32_t coarse;
 	uint16_t fine;
 } __attribute__((packed));
 
+
+/**
+ * @brief imagette specific part of compression entity
+ */
+
 __extension__
 struct imagette_header {
-	uint16_t spill_used;		/* Spillover threshold used */
-	uint8_t  golomb_par_used;	/* Golomb parameter used */
+	uint16_t spill_used;		/**< Spillover threshold used */
+	uint8_t  golomb_par_used;	/**< Golomb parameter used */
 	union{
 		struct {
 			uint8_t spare1;
-			uint8_t ima_cmp_dat[];		/* compressed data for imagette specific header */
+			uint8_t ima_cmp_dat[];		/**< compressed data for imagette specific header */
 		} __attribute__((packed));
 		struct {
-			uint16_t ap1_spill_used;	/* Adaptive Spillover threshold used 1 */
-			uint8_t  ap1_golomb_par_used;	/* Adaptive Golomb parameter used 1 */
-			uint16_t ap2_spill_used;	/* Adaptive Spillover threshold used 2 */
-			uint8_t  ap2_golomb_par_used;	/* Adaptive Golomb parameter used 2 */
+			uint16_t ap1_spill_used;	/**< Adaptive Spillover threshold used 1 */
+			uint8_t  ap1_golomb_par_used;	/**< Adaptive Golomb parameter used 1 */
+			uint16_t ap2_spill_used;	/**< Adaptive Spillover threshold used 2 */
+			uint8_t  ap2_golomb_par_used;	/**< Adaptive Golomb parameter used 2 */
 			uint8_t  spare2;
 			uint16_t spare3;
-			uint8_t  ap_ima_cmp_data[];	/* compressed data for adaptive imagette specific header */
+			uint8_t  ap_ima_cmp_data[];	/**< compressed data for adaptive imagette specific header */
 		} __attribute__((packed));
 	};
 } __attribute__((packed));
 compile_time_assert(sizeof(struct imagette_header) == SPECIFIC_IMAGETTE_ADAPTIVE_HEADER_SIZE, AP_IMAGETTE_HEADER_T_SIZE_IS_NOT_CORRECT);
 
+
+/**
+ * @brief non-imagette specific part of compression entity
+ */
+
 __extension__
 struct non_imagette_header {
-	uint32_t spill_1_used:24;	/* spillover threshold 1 used */
-	uint16_t cmp_par_1_used;	/* compression parameter 1 used */
-	uint32_t spill_2_used:24;	/* spillover threshold 2 used */
-	uint16_t cmp_par_2_used;	/* compression parameter 2 used */
-	uint32_t spill_3_used:24;	/* spillover threshold 3 used */
-	uint16_t cmp_par_3_used;	/* compression parameter 3 used */
-	uint32_t spill_4_used:24;	/* spillover threshold 4 used */
-	uint16_t cmp_par_4_used;	/* compression parameter 4 used */
-	uint32_t spill_5_used:24;	/* spillover threshold 5 used */
-	uint16_t cmp_par_5_used;	/* compression parameter 5 used */
-	uint32_t spill_6_used:24;	/* spillover threshold 6 used */
-	uint16_t cmp_par_6_used;	/* compression parameter 6 used */
+	uint32_t spill_1_used:24;	/**< spillover threshold 1 used */
+	uint16_t cmp_par_1_used;	/**< compression parameter 1 used */
+	uint32_t spill_2_used:24;	/**< spillover threshold 2 used */
+	uint16_t cmp_par_2_used;	/**< compression parameter 2 used */
+	uint32_t spill_3_used:24;	/**< spillover threshold 3 used */
+	uint16_t cmp_par_3_used;	/**< compression parameter 3 used */
+	uint32_t spill_4_used:24;	/**< spillover threshold 4 used */
+	uint16_t cmp_par_4_used;	/**< compression parameter 4 used */
+	uint32_t spill_5_used:24;	/**< spillover threshold 5 used */
+	uint16_t cmp_par_5_used;	/**< compression parameter 5 used */
+	uint32_t spill_6_used:24;	/**< spillover threshold 6 used */
+	uint16_t cmp_par_6_used;	/**< compression parameter 6 used */
 	uint16_t spare;
 	uint8_t  cmp_data[];
 } __attribute__((packed));
 compile_time_assert(sizeof(struct non_imagette_header) == SPECIFIC_NON_IMAGETTE_HEADER_SIZE, NON_IMAGETTE_HEADER_T_SIZE_IS_NOT_CORRECT);
 
+
+/**
+ * @brief definition of the compression entity format
+ */
+
 __extension__
 struct cmp_entity {
-	uint32_t version_id;			/* ICU ASW/cmp_tool Version ID */
-	uint32_t cmp_ent_size:24;		/* Compression Entity Size */
-	uint32_t original_size:24;		/* Original Data Size */
+	uint32_t version_id;			/**< ICU ASW/cmp_tool Version ID */
+	uint32_t cmp_ent_size:24;		/**< Compression Entity Size */
+	uint32_t original_size:24;		/**< Original Data Size */
 	union {
-		uint64_t start_timestamp:48;	/* Compression Start Timestamp */
+		uint64_t start_timestamp:48;	/**< Compression Start Timestamp */
 		struct timestamp_cmp_ent start_time;
 	} __attribute__((packed));
 	union {
-		uint64_t end_timestamp:48;	/* Compression End Timestamp */
+		uint64_t end_timestamp:48;	/**< Compression End Timestamp */
 		struct timestamp_cmp_ent end_time;
 	} __attribute__((packed));
-	uint16_t data_type;			/* Data Product Type */
-	uint8_t  cmp_mode_used;			/* used Compression Mode */
-	uint8_t  model_value_used;		/* used Model Updating Weighing Value */
-	uint16_t model_id;			/* Model ID */
-	uint8_t  model_counter;			/* Model Counter */
+	uint16_t data_type;			/**< Data Product Type */
+	uint8_t  cmp_mode_used;			/**< used Compression Mode */
+	uint8_t  model_value_used;		/**< used Model Updating Weighing Value */
+	uint16_t model_id;			/**< Model ID */
+	uint8_t  model_counter;			/**< Model Counter */
 	uint8_t  max_used_bits_version;
-	uint16_t lossy_cmp_par_used;		/* used Lossy Compression Parameters */
+	uint16_t lossy_cmp_par_used;		/**< used Lossy Compression Parameters */
 	union {	/* specific Compression Entity Header for the different Data Product Types */
 		struct imagette_header ima;
 		struct non_imagette_header non_ima;
@@ -127,7 +147,8 @@ compile_time_assert(sizeof(struct cmp_entity) == NON_IMAGETTE_HEADER_SIZE, CMP_E
 
 
 
-/* create a compression entity by setting the size of the compression entity and
+/*
+ * create a compression entity by setting the size of the compression entity and
  * the data product type in the entity header
  */
 uint32_t cmp_ent_create(struct cmp_entity *ent, enum cmp_data_type data_type,
@@ -141,13 +162,15 @@ size_t cmp_ent_build(struct cmp_entity *ent, uint32_t version_id,
 /* read in a compression entity header */
 int cmp_ent_read_header(struct cmp_entity *ent, struct cmp_cfg *cfg);
 
-/* write the compression parameters from a compression configuration into the
+/*
+ * write the compression parameters from a compression configuration into the
  * compression entity header
  */
 int cmp_ent_write_cmp_pars(struct cmp_entity *ent, const struct cmp_cfg *cfg,
 			   int cmp_size_bits);
 
-/* write the parameters from the RDCU decompression information structure in the
+/*
+ * write the parameters from the RDCU decompression information structure in the
  * compression entity header
  */
 int cmp_ent_write_rdcu_cmp_pars(struct cmp_entity *ent, const struct cmp_info *info,
@@ -178,14 +201,16 @@ int cmp_ent_set_max_used_bits_version(struct cmp_entity *ent, uint8_t max_used_b
 int cmp_ent_set_lossy_cmp_par(struct cmp_entity *ent, uint32_t lossy_cmp_par_used);
 
 
-/* set functions for specific entity header for imagette and adaptive imagette
+/*
+ * set functions for specific entity header for imagette and adaptive imagette
  * data product types
  */
 int cmp_ent_set_ima_spill(struct cmp_entity *ent, uint32_t spill_used);
 int cmp_ent_set_ima_golomb_par(struct cmp_entity *ent, uint32_t golomb_par_used);
 
 
-/* set functions for specific entity header for adaptive imagette data product
+/*
+ * set functions for specific entity header for adaptive imagette data product
  * types
  */
 int cmp_ent_set_ima_ap1_spill(struct cmp_entity *ent, uint32_t ap1_spill_used);
@@ -240,14 +265,16 @@ uint8_t cmp_ent_get_max_used_bits_version(struct cmp_entity *ent);
 uint16_t cmp_ent_get_lossy_cmp_par(struct cmp_entity *ent);
 
 
-/* get functions for specific entity header for imagette and adaptive imagette
+/*
+ * get functions for specific entity header for imagette and adaptive imagette
  * data product types
  */
 uint16_t cmp_ent_get_ima_spill(struct cmp_entity *ent);
 uint8_t cmp_ent_get_ima_golomb_par(struct cmp_entity *ent);
 
 
-/* get functions for specific entity header for adaptive imagette data product
+/*
+ * get functions for specific entity header for adaptive imagette data product
  * types
  */
 uint16_t cmp_ent_get_ima_ap1_spill(struct cmp_entity *ent);
diff --git a/include/cmp_io.h b/include/cmp_io.h
index 7ac7880..ec5a77a 100644
--- a/include/cmp_io.h
+++ b/include/cmp_io.h
@@ -1,7 +1,7 @@
 /**
  * @file   cmp_io.h
+ * @author Dominik Loidolt (dominik.loidolt@univie.ac.at)
  * @author Johannes Seelig (johannes.seelig@univie.ac.at)
- * @author Dominik Loidolt (dominik.loidolt@univie.ac.at),
  * @date   2020
  *
  * @copyright GPLv2
@@ -13,6 +13,8 @@
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
+ *
+ * @brief compression tool input/output library header file
  */
 
 #include <string.h>
diff --git a/include/cmp_rdcu_cfg.h b/include/cmp_rdcu_cfg.h
index ca7b279..d5346ad 100644
--- a/include/cmp_rdcu_cfg.h
+++ b/include/cmp_rdcu_cfg.h
@@ -1,5 +1,5 @@
 /**
- * @file   cmp_rdcu_rdcu.h
+ * @file   cmp_rdcu_cfg.h
  * @author Dominik Loidolt (dominik.loidolt@univie.ac.at),
  * @date   2020
  *
diff --git a/include/cmp_rdcu_extended.h b/include/cmp_rdcu_extended.h
deleted file mode 100644
index 7ab229b..0000000
--- a/include/cmp_rdcu_extended.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * @file   cmp_rdcu_extended.h
- * @author Dominik Loidolt (dominik.loidolt@univie.ac.at),
- * @date   2021
- *
- * @copyright GPLv2
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- */
-
-
-#ifndef _CMP_RDCU_EXTENDED_H_
-#define _CMP_RDCU_EXTENDED_H_
-
-#include <cmp_rdcu.h>
-
-int rdcu_start_compression(void);
-
-int rdcu_set_compression_register(const struct cmp_cfg *cfg);
-
-int rdcu_compress_data_parallel(const struct cmp_cfg *cfg,
-				const struct cmp_info *last_info);
-
-#endif /* _CMP_RDCU_EXTENDED_H_ */
diff --git a/include/cmp_support.h b/include/cmp_support.h
index 2ea2a3e..3d53e7f 100644
--- a/include/cmp_support.h
+++ b/include/cmp_support.h
@@ -34,9 +34,8 @@
 #define CMP_LOSSLESS	0
 #define CMP_PAR_UNUNSED	0
 
-
-#define MAX_MODEL_VALUE                                                        \
-	16U /* the maximal model values used in the update equation for the new model */
+/* the maximal model values used in the update equation for the new model */
+#define MAX_MODEL_VALUE 16U
 
 /* valid compression parameter ranges for RDCU/ICU imagette compression according to PLATO-UVIE-PL-UM-0001 */
 #define MAX_RDCU_CMP_MODE	4U
@@ -91,10 +90,18 @@
 #define CMP_DEF_IMA_DIFF_RDCU_UP_MODEL_ADR	0x000000 /* not needed for 1d-differencing cmp_mode */
 #define CMP_DEF_IMA_DIFF_RDCU_BUFFER_ADR	0x600000
 
-enum check_opt {ICU_CHECK, RDCU_CHECK}; /* options for configuration check functions */
+
+/**
+ * @brief options for configuration check functions
+ */
+
+enum check_opt {ICU_CHECK, RDCU_CHECK};
 
 
-/* defined compression data product types */
+/**
+ * @brief defined compression data product types
+ */
+
 enum cmp_data_type {
 	DATA_TYPE_UNKNOWN,
 	DATA_TYPE_IMAGETTE,
@@ -123,7 +130,10 @@ enum cmp_data_type {
 };
 
 
-/* defined compression mode */
+/**
+ * @brief defined compression mode
+ */
+
 enum cmp_mode {
 	CMP_MODE_RAW,
 	CMP_MODE_MODEL_ZERO,
@@ -136,90 +146,93 @@ enum cmp_mode {
 
 /**
  * @brief The cmp_cfg structure can contain the complete configuration of the HW as
- *      well as the SW compressor.
+ *	well as the SW compressor.
  * @note the icu_output_buf will not be used for HW compression
  * @note the rdcu_***_adr parameters are ignored for SW compression
  */
 
 struct cmp_cfg {
-	void *input_buf;            /* Pointer to the data to compress buffer */
-	void *model_buf;            /* Pointer to the model buffer */
-	void *icu_new_model_buf;    /* Pointer to the updated model buffer (not used for RDCU compression )*/
-	uint32_t *icu_output_buf;   /* Pointer to the compressed data buffer (not used for RDCU compression) */
-	uint32_t samples;           /* Number of samples to compress, length of the data and model buffer
+	void *input_buf;            /**< Pointer to the data to compress buffer */
+	void *model_buf;            /**< Pointer to the model buffer */
+	void *icu_new_model_buf;    /**< Pointer to the updated model buffer (not used for RDCU compression )*/
+	uint32_t *icu_output_buf;   /**< Pointer to the compressed data buffer (not used for RDCU compression) */
+	uint32_t samples;           /**< Number of samples to compress, length of the data and model buffer
 				     * (including the multi entity header by non-imagette data)
 				     */
-	uint32_t buffer_length;     /* Length of the compressed data buffer in number of samples */
-	uint32_t rdcu_data_adr;     /* RDCU data to compress start address, the first data address in the RDCU SRAM; HW only */
-	uint32_t rdcu_model_adr;    /* RDCU model start address, the first model address in the RDCU SRAM */
-	uint32_t rdcu_new_model_adr;/* RDCU updated model start address, the address in the RDCU SRAM where the updated model is stored */
-	uint32_t rdcu_buffer_adr;   /* RDCU compressed data start address, the first output data address in the RDCU SRAM */
-	enum cmp_data_type data_type; /* Compression Data Product Types */
-	enum cmp_mode cmp_mode;     /* 0: raw mode
+	uint32_t buffer_length;     /**< Length of the compressed data buffer in number of samples */
+	uint32_t rdcu_data_adr;     /**< RDCU data to compress start address, the first data address in the RDCU SRAM; HW only */
+	uint32_t rdcu_model_adr;    /**< RDCU model start address, the first model address in the RDCU SRAM */
+	uint32_t rdcu_new_model_adr;/**< RDCU updated model start address, the address in the RDCU SRAM where the updated model is stored */
+	uint32_t rdcu_buffer_adr;   /**< RDCU compressed data start address, the first output data address in the RDCU SRAM */
+	enum cmp_data_type data_type; /**< Compression Data Product Types */
+	enum cmp_mode cmp_mode;     /**< 0: raw mode
 				     * 1: model mode with zero escape symbol mechanism
 				     * 2: 1d differencing mode without input model with zero escape symbol mechanism
 				     * 3: model mode with multi escape symbol mechanism
 				     * 4: 1d differencing mode without input model multi escape symbol mechanism
 				     */
-	uint32_t model_value;       /* Model weighting parameter */
-	uint32_t round;             /* lossy compression parameter */
-	uint32_t golomb_par;        /* Golomb parameter for imagette data compression */
-	uint32_t spill;             /* Spillover threshold parameter for imagette compression */
-	uint32_t ap1_golomb_par;    /* Adaptive 1 spillover threshold for imagette data; HW only */
-	uint32_t ap1_spill;         /* Adaptive 1 Golomb parameter for imagette data; HW only */
-	uint32_t ap2_golomb_par;    /* Adaptive 2 spillover threshold for imagette data; HW only */
-	uint32_t ap2_spill;         /* Adaptive 2 Golomb parameter; HW only */
-	uint32_t cmp_par_exp_flags; /* Compression parameter for exposure flags compression */
-	uint32_t spill_exp_flags;   /* Spillover threshold parameter for exposure flags compression */
-	uint32_t cmp_par_fx;	    /* Compression parameter for normal flux compression */
-	uint32_t spill_fx;          /* Spillover threshold parameter for normal flux compression */
-	uint32_t cmp_par_ncob;      /* Compression parameter for normal center of brightness compression */
-	uint32_t spill_ncob;        /* Spillover threshold parameter for normal center of brightness compression */
-	uint32_t cmp_par_efx;       /* Compression parameter for extended flux compression */
-	uint32_t spill_efx;         /* Spillover threshold parameter for extended flux compression */
-	uint32_t cmp_par_ecob;      /* Compression parameter for executed center of brightness compression */
-	uint32_t spill_ecob;        /* Spillover threshold parameter for executed center of brightness compression */
-	uint32_t cmp_par_fx_cob_variance; /* Compression parameter for flux/COB variance compression */
-	uint32_t spill_fx_cob_variance; /* Spillover threshold parameter for flux/COB variance compression */
-	uint32_t cmp_par_mean;      /* Compression parameter for auxiliary science mean compression */
-	uint32_t spill_mean;        /* Spillover threshold parameter for auxiliary science mean compression */
-	uint32_t cmp_par_variance;  /* Compression parameter for auxiliary science variance compression */
-	uint32_t spill_variance;    /* Spillover threshold parameter for auxiliary science variance compression */
-	uint32_t cmp_par_pixels_error; /* Compression parameter for auxiliary science outlier pixels number compression */
-	uint32_t spill_pixels_error; /* Spillover threshold parameter for auxiliary science outlier pixels number compression */
+	uint32_t model_value;       /**< Model weighting parameter */
+	uint32_t round;             /**< lossy compression parameter */
+	uint32_t golomb_par;        /**< Golomb parameter for imagette data compression */
+	uint32_t spill;             /**< Spillover threshold parameter for imagette compression */
+	uint32_t ap1_golomb_par;    /**< Adaptive 1 spillover threshold for imagette data; HW only */
+	uint32_t ap1_spill;         /**< Adaptive 1 Golomb parameter for imagette data; HW only */
+	uint32_t ap2_golomb_par;    /**< Adaptive 2 spillover threshold for imagette data; HW only */
+	uint32_t ap2_spill;         /**< Adaptive 2 Golomb parameter; HW only */
+	uint32_t cmp_par_exp_flags; /**< Compression parameter for exposure flags compression */
+	uint32_t spill_exp_flags;   /**< Spillover threshold parameter for exposure flags compression */
+	uint32_t cmp_par_fx;	    /**< Compression parameter for normal flux compression */
+	uint32_t spill_fx;          /**< Spillover threshold parameter for normal flux compression */
+	uint32_t cmp_par_ncob;      /**< Compression parameter for normal center of brightness compression */
+	uint32_t spill_ncob;        /**< Spillover threshold parameter for normal center of brightness compression */
+	uint32_t cmp_par_efx;       /**< Compression parameter for extended flux compression */
+	uint32_t spill_efx;         /**< Spillover threshold parameter for extended flux compression */
+	uint32_t cmp_par_ecob;      /**< Compression parameter for executed center of brightness compression */
+	uint32_t spill_ecob;        /**< Spillover threshold parameter for executed center of brightness compression */
+	uint32_t cmp_par_fx_cob_variance; /**< Compression parameter for flux/COB variance compression */
+	uint32_t spill_fx_cob_variance; /**< Spillover threshold parameter for flux/COB variance compression */
+	uint32_t cmp_par_mean;      /**< Compression parameter for auxiliary science mean compression */
+	uint32_t spill_mean;        /**< Spillover threshold parameter for auxiliary science mean compression */
+	uint32_t cmp_par_variance;  /**< Compression parameter for auxiliary science variance compression */
+	uint32_t spill_variance;    /**< Spillover threshold parameter for auxiliary science variance compression */
+	uint32_t cmp_par_pixels_error; /**< Compression parameter for auxiliary science outlier pixels number compression */
+	uint32_t spill_pixels_error; /**< Spillover threshold parameter for auxiliary science outlier pixels number compression */
 };
 
 
-/* The cmp_status structure can contain the information of the compressor status
- * register from the RDCU, see RDCU-FRS-FN-0632.
+/**
+ * @brief The cmp_status structure can contain the information of the compressor
+ *	status register from the RDCU
+ * @see RDCU-FRS-FN-0632
  */
 
 struct cmp_status {
-	uint8_t cmp_ready; /* Data Compressor Ready; 0: Compressor is busy 1: Compressor is ready */
-	uint8_t cmp_active; /* Data Compressor Active; 0: Compressor is on hold; 1: Compressor is active */
-	uint8_t data_valid; /* Compressor Data Valid; 0: Data is invalid; 1: Data is valid */
-	uint8_t cmp_interrupted; /* Data Compressor Interrupted; HW only; 0: No compressor interruption; 1: Compressor was interrupted */
-	uint8_t rdcu_interrupt_en; /* RDCU Interrupt Enable; HW only; 0: Interrupt is disabled; 1: Interrupt is enabled */
+	uint8_t cmp_ready; /**< Data Compressor Ready; 0: Compressor is busy 1: Compressor is ready */
+	uint8_t cmp_active; /**< Data Compressor Active; 0: Compressor is on hold; 1: Compressor is active */
+	uint8_t data_valid; /**< Compressor Data Valid; 0: Data is invalid; 1: Data is valid */
+	uint8_t cmp_interrupted; /**< Data Compressor Interrupted; HW only; 0: No compressor interruption; 1: Compressor was interrupted */
+	uint8_t rdcu_interrupt_en; /**< RDCU Interrupt Enable; HW only; 0: Interrupt is disabled; 1: Interrupt is enabled */
 };
 
 
-/* The cmp_info structure can contain the information and metadata of an
- * executed RDCU compression.
+/**
+ * @brief The cmp_info structure contain the information and metadata of an
+ *	executed RDCU compression.
  */
 
 struct cmp_info {
-	uint32_t cmp_mode_used;       /* Compression mode used */
-	uint32_t spill_used;          /* Spillover threshold used */
-	uint32_t golomb_par_used;     /* Golomb parameter used */
-	uint32_t samples_used;        /* Number of samples (16 bit value) to be stored */
-	uint32_t cmp_size;            /* Compressed data size; measured in bits */
-	uint32_t ap1_cmp_size;        /* Adaptive compressed data size 1; measured in bits */
-	uint32_t ap2_cmp_size;        /* Adaptive compressed data size 2; measured in bits */
-	uint32_t rdcu_new_model_adr_used; /* Updated model start  address used */
-	uint32_t rdcu_cmp_adr_used;   /* Compressed data start address */
-	uint8_t  model_value_used;    /* Model weighting parameter used */
-	uint8_t  round_used;          /* Number of noise bits to be rounded used */
-	uint16_t cmp_err;             /* Compressor errors
+	uint32_t cmp_mode_used;       /**< Compression mode used */
+	uint32_t spill_used;          /**< Spillover threshold used */
+	uint32_t golomb_par_used;     /**< Golomb parameter used */
+	uint32_t samples_used;        /**< Number of samples (16 bit value) to be stored */
+	uint32_t cmp_size;            /**< Compressed data size; measured in bits */
+	uint32_t ap1_cmp_size;        /**< Adaptive compressed data size 1; measured in bits */
+	uint32_t ap2_cmp_size;        /**< Adaptive compressed data size 2; measured in bits */
+	uint32_t rdcu_new_model_adr_used; /**< Updated model start  address used */
+	uint32_t rdcu_cmp_adr_used;   /**< Compressed data start address */
+	uint8_t  model_value_used;    /**< Model weighting parameter used */
+	uint8_t  round_used;          /**< Number of noise bits to be rounded used */
+	uint16_t cmp_err;             /**< Compressor errors
 				       * [bit 0] small_buffer_err; The length for the compressed data buffer is too small
 				       * [bit 1] cmp_mode_err; The cmp_mode parameter is not set correctly
 				       * [bit 2] model_value_err; The model_value parameter is not set correctly
@@ -233,7 +246,12 @@ struct cmp_info {
 				       */
 };
 
-/* structure containing flux/COB compression parameters pairs */
+
+/**
+ * @brief structure containing flux/COB compression parameters pairs for the
+ *	cmp_cfg_fx_cob_get_need_pars() function
+ */
+
 struct fx_cob_par {
 	uint8_t exp_flags;
 	uint8_t fx;
diff --git a/include/my_inttypes.h b/include/my_inttypes.h
index 8f0acf7..0af552b 100644
--- a/include/my_inttypes.h
+++ b/include/my_inttypes.h
@@ -13,9 +13,9 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
- * @brief This is a self-created inttypes.h, since the sparc-elf-gcc toolchain
- * does not provide one.
- * WARNING: Does not fully implement the standard.
+ * @brief This is a simple inttypes.h implementation for the sparc platform,
+ * since the sparc-elf-gcc toolchain does not provide one.
+ * @warning Does not fully implement the standard.
  */
 
 
diff --git a/include/rdcu_cmd.h b/include/rdcu_cmd.h
index 0e4b8f4..5cb168f 100644
--- a/include/rdcu_cmd.h
+++ b/include/rdcu_cmd.h
@@ -13,6 +13,7 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
+ * @brief RMAP RDCU RMAP command library header file
  * @see FPGA Requirement Specification PLATO-IWF-PL-RS-005 Issue 0.6
  */
 #ifndef _RDCU_CMD_H_
diff --git a/include/rdcu_ctrl.h b/include/rdcu_ctrl.h
index ac3f03f..eb3e3a0 100644
--- a/include/rdcu_ctrl.h
+++ b/include/rdcu_ctrl.h
@@ -13,14 +13,21 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
+ * @brief RMAP RDCU control library header file
  * @see FPGA Requirement Specification PLATO-IWF-PL-RS-005 Issue 0.6
  */
+
+
 #ifndef _RDCU_CTRL_H_
 #define _RDCU_CTRL_H_
 
 #include <stdint.h>
 
 
+/**
+ * @brief local mirror of the RDCU registers
+ */
+
 struct rdcu_mirror {
 	/* RDCU registers */
 	uint32_t fpga_version;			/* RDCU-FRS-FN-0522 */
diff --git a/include/rdcu_pkt_to_file.h b/include/rdcu_pkt_to_file.h
index b0f0558..49267d8 100644
--- a/include/rdcu_pkt_to_file.h
+++ b/include/rdcu_pkt_to_file.h
@@ -13,6 +13,7 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
+ * @brief RDCU packets to file library header file
  */
 
 #ifndef _RDCU_PKT_TO_FILE_H_
diff --git a/include/rdcu_rmap.h b/include/rdcu_rmap.h
index b6ce568..94ba069 100644
--- a/include/rdcu_rmap.h
+++ b/include/rdcu_rmap.h
@@ -13,6 +13,7 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
+ * @brief RMAP RDCU link interface header file
  */
 
 #ifndef _RDCU_RMAP_H_
diff --git a/include/rmap.h b/include/rmap.h
index c581575..f70f3c8 100644
--- a/include/rmap.h
+++ b/include/rmap.h
@@ -134,6 +134,9 @@
 #define RMAP_MAX_DATA_LEN	   0xFFFFFFUL
 
 
+/**
+ * @brief RMAP header instruction field definition
+ */
 
 __extension__
 struct rmap_instruction {
@@ -156,32 +159,32 @@ compile_time_assert(sizeof(struct rmap_instruction) == sizeof(uint8_t), RMAP_INS
 
 
 /**
- * This structure holds the relevant contents of an RMAP packet.
+ * @brief This structure holds the relevant contents of an RMAP packet.
  *
  * @note this is NOT an actual RMAP packet!
  */
 
 __extension__
 struct rmap_pkt {
-	uint8_t		*path;		/* path to SpW target */
-	uint8_t		path_len;	/* entries in the path */
-	uint8_t		dst;		/* target logical address */
-	uint8_t		proto_id;	/* protoco id (0x1 = RMAP */
+	uint8_t		*path;		/**< path to SpW target */
+	uint8_t		path_len;	/**< entries in the path */
+	uint8_t		dst;		/**< target logical address */
+	uint8_t		proto_id;	/**< protocol id (0x1 = RMAP */
 	union {
 		struct rmap_instruction ri;
 		uint8_t	instruction;
 	};
 	union {
-		uint8_t	key;		/* command authorisation key */
-		uint8_t	status;		/* reply error/status codes */
+		uint8_t	key;		/**< command authorisation key */
+		uint8_t	status;		/**< reply error/status codes */
 	};
-	uint8_t		src;		/* initiator logical address */
-	uint8_t		*rpath;		/* reply path */
-	uint8_t		rpath_len;	/* entries in the reply path */
-	uint16_t	tr_id;		/* transaction identifier */
-	uint32_t	addr;		/* (first) data address */
+	uint8_t		src;		/**< initiator logical address */
+	uint8_t		*rpath;		/**< reply path */
+	uint8_t		rpath_len;	/**< entries in the reply path */
+	uint16_t	tr_id;		/**< transaction identifier */
+	uint32_t	addr;		/**< (first) data address */
 	uint8_t		*data;
-	uint32_t	data_len;	/* lenght of data in bytes */
+	uint32_t	data_len;	/**< length of data in bytes */
 	uint8_t		hdr_crc;
 	uint8_t		data_crc;
 };
diff --git a/lib/cmp_guess.c b/lib/cmp_guess.c
index b13fe7c..aad7328 100644
--- a/lib/cmp_guess.c
+++ b/lib/cmp_guess.c
@@ -27,6 +27,8 @@
 #include <cmp_guess.h>
 #include <my_inttypes.h>
 
+#define CMP_GUESS_MAX_CAL_STEPS 20274
+
 
 /* how often the model is updated before it is rested */
 static int num_model_updates = CMP_GUESS_N_MODEL_UPDATE_DEF;
@@ -153,7 +155,6 @@ static uint32_t pre_cal_method(struct cmp_cfg *cfg)
  * configuration; 0 on error
  */
 
-#define CMP_GUESS_MAX_CAL_STEPS 20274
 static uint32_t brute_force(struct cmp_cfg *cfg)
 {
 	uint32_t g, s;
diff --git a/lib/cmp_icu.c b/lib/cmp_icu.c
index c4bf17a..b5560aa 100644
--- a/lib/cmp_icu.c
+++ b/lib/cmp_icu.c
@@ -1,5 +1,5 @@
 /**
- * @file   icu_cmp.c
+ * @file   cmp_icu.c
  * @author Dominik Loidolt (dominik.loidolt@univie.ac.at),
  * @date   2020
  *
@@ -44,23 +44,29 @@
 extern struct cmp_max_used_bits max_used_bits;
 
 
-/* pointer to a code word generation function */
+/**
+ * @brief pointer to a code word generation function
+ */
+
 typedef uint32_t (*generate_cw_f_pt)(uint32_t value, uint32_t encoder_par1,
 				     uint32_t encoder_par2, uint32_t *cw);
 
 
-/* structure to hold a setup to encode a value */
+/**
+ * @brief structure to hold a setup to encode a value
+ */
+
 struct encoder_setupt {
-	generate_cw_f_pt generate_cw_f; /* function pointer to a code word encoder */
+	generate_cw_f_pt generate_cw_f; /**< function pointer to a code word encoder */
 	int (*encode_method_f)(uint32_t data, uint32_t model, int stream_len,
-			       const struct encoder_setupt *setup); /* pointer to the encoding function */
-	uint32_t *bitstream_adr; /* start address of the compressed data bitstream */
-	uint32_t max_stream_len; /* maximum length of the bitstream/icu_output_buf in bits */
-	uint32_t encoder_par1; /* encoding parameter 1 */
-	uint32_t encoder_par2; /* encoding parameter 2 */
-	uint32_t spillover_par; /* outlier parameter */
-	uint32_t lossy_par; /* lossy compression parameter */
-	uint32_t max_data_bits; /* how many bits are needed to represent the highest possible value */
+			       const struct encoder_setupt *setup); /**< pointer to the encoding function */
+	uint32_t *bitstream_adr; /**< start address of the compressed data bitstream */
+	uint32_t max_stream_len; /**< maximum length of the bitstream/icu_output_buf in bits */
+	uint32_t encoder_par1;   /**< encoding parameter 1 */
+	uint32_t encoder_par2;   /**< encoding parameter 2 */
+	uint32_t spillover_par;  /**< outlier parameter */
+	uint32_t lossy_par;      /**< lossy compression parameter */
+	uint32_t max_data_bits;  /**< how many bits are needed to represent the highest possible value */
 };
 
 
diff --git a/lib/cmp_io.c b/lib/cmp_io.c
index 15be88b..2d3caff 100644
--- a/lib/cmp_io.c
+++ b/lib/cmp_io.c
@@ -1,7 +1,7 @@
 /**
  * @file   cmp_io.c
- * @author Johannes Seelig (johannes.seelig@univie.ac.at)
  * @author Dominik Loidolt (dominik.loidolt@univie.ac.at),
+ * @author Johannes Seelig (johannes.seelig@univie.ac.at)
  * @date   2020
  *
  * @copyright GPLv2
@@ -14,7 +14,7 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
- * @brief compression tool Input/Output library
+ * @brief compression tool input/output library
  * @warning this part of the software is not intended to run on-board on the ICU.
  */
 
@@ -150,11 +150,12 @@ static FILE *open_file(const char *dirname, const char *filename)
 /**
  * @brief write uncompressed input data to an output file
  *
- * @param data		the data to write a file
- * @param data_size	size of the data in bytes
- * @param output_prefix  file name without file extension
- * @param name_extension file extension (with leading point character)
- * @param verbose	print verbose output if not zero
+ * @param data			the data to write a file
+ * @param data_size		size of the data in bytes
+ * @param data_type		compression data type of the data
+ * @param output_prefix		file name without file extension
+ * @param name_extension	extension (with leading point character)
+ * @param verbose		print verbose output if not zero
  *
  * @returns 0 on success, error otherwise
  */
diff --git a/lib/cmp_support.c b/lib/cmp_support.c
index 0849c0f..dd7fbec 100644
--- a/lib/cmp_support.c
+++ b/lib/cmp_support.c
@@ -349,6 +349,7 @@ unsigned int round_inv(unsigned int value, unsigned int round)
  * @param data		data to process
  * @param model		(current) model of the data to process
  * @param model_value	model weighting parameter
+ * @param round		routing parameter
  *
  * @returns (new) updated model
  */
@@ -725,7 +726,7 @@ int cmp_cfg_imagette_is_invalid(const struct cmp_cfg *cfg, enum check_opt opt)
  *	par struct, otherwise error
  */
 
- int cmp_cfg_fx_cob_get_need_pars(enum cmp_data_type data_type, struct fx_cob_par *par)
+int cmp_cfg_fx_cob_get_need_pars(enum cmp_data_type data_type, struct fx_cob_par *par)
 {
 	if (!par)
 		return -1;
diff --git a/lib/decmp.c b/lib/decmp.c
index 18ebe5d..242779f 100644
--- a/lib/decmp.c
+++ b/lib/decmp.c
@@ -38,10 +38,18 @@
 /* maximum used bits registry */
 extern struct cmp_max_used_bits max_used_bits;
 
-/* function pointer to a code word decoder function */
+
+/**
+ * @brief function pointer to a code word decoder function
+ */
+
 typedef int (*decoder_ptr)(uint32_t, unsigned int, unsigned int, uint32_t *);
 
-/* structure to hold a setup to encode a value */
+
+/**
+ * @brief structure to hold a setup to encode a value
+ */
+
 struct decoder_setup {
 	decoder_ptr decode_cw_f; /* pointer to the code word decoder (Golomb/Rice)*/
 	int (*decode_method_f)(uint32_t *decoded_value, int stream_pos,
@@ -2175,6 +2183,8 @@ int decompress_cmp_entiy(struct cmp_entity *ent, void *model_of_data,
  *
  * @param compressed_data	pointer to the RDCU compressed data (without a
  *				compression entity header)
+ * @param info			pointer to a decompression information structure
+ *				consisting the metadata of the compression
  * @param model_of_data		pointer to model data buffer (can be NULL if no
  *				model compression mode is used)
  * @param up_model_buf		pointer to store the updated model for the next model
diff --git a/lib/rdcu_ctrl.c b/lib/rdcu_ctrl.c
index ba892ac..759ad99 100644
--- a/lib/rdcu_ctrl.c
+++ b/lib/rdcu_ctrl.c
@@ -48,7 +48,7 @@
  *	value = get_register_uvw();
  *
  *
- * WARNING: this has not been thoroughly tested and is in need of inspection
+ * @warning this has not been thoroughly tested and is in need of inspection
  *	    with regards to the specification, in order to locate any
  *	    register transcription errors or typos
  *	    In the PLATO-IWF-PL-RS-005 Issue 0.7 (at least the one I have),
diff --git a/lib/rdcu_pkt_to_file.c b/lib/rdcu_pkt_to_file.c
index 61088db..891bd74 100644
--- a/lib/rdcu_pkt_to_file.c
+++ b/lib/rdcu_pkt_to_file.c
@@ -30,11 +30,15 @@
 
 #include <cmp_support.h>
 #include <rdcu_pkt_to_file.h>
-#include <cmp_rdcu_extended.h>
+#include <cmp_rdcu.h>
 #include <rdcu_rmap.h>
 #include <rdcu_ctrl.h>
 #include <rdcu_cmd.h>
 
+
+int rdcu_compress_data_parallel(const struct cmp_cfg *cfg, const struct cmp_info *last_info);
+
+
 /* Name of directory were the RMAP packages are stored */
 static char tc_folder_dir[MAX_TC_FOLDER_DIR_LEN] = "TC_FILES";
 
diff --git a/lib/rdcu_rmap.c b/lib/rdcu_rmap.c
index e4ec4b6..59f220a 100644
--- a/lib/rdcu_rmap.c
+++ b/lib/rdcu_rmap.c
@@ -36,11 +36,11 @@
  * available, please adapt all malloc/free calls to your needs, or ask us
  * to do that for you.
  *
- * NOTE: in order to run this on the GR712RC eval board, we set the SRAM mirror
+ * @note in order to run this on the GR712RC eval board, we set the SRAM mirror
  *	 image to the boards SDRAM in rdcu_ctrl_init() and just malloc() it for
  *	 the PC (see rdcu_ctrl_init)
  *
- *	 The interface requires that you provide an RX and a TX function,
+ * @note The interface requires that you provide an RX and a TX function,
  *	 see rdcu_ctrl_init for the call interface.
  *	 The TX function shall to return 0 on success, everything else
  *	 is considered an error in submission. The RX function shall return
@@ -51,12 +51,12 @@
  *	 your particular SpW interface or just redirect RX/TX to files
  *	 or via a network connection.
  *
- * NOTE: We don't have to serve more than one RDCU at any given time, so we
+ * @note We don't have to serve more than one RDCU at any given time, so we
  *	 track addresses and paths internally in a single instance. This also
  *	 makes the interface less cluttered. Besides, I'm lazy.
  *
  *
- * @warn when operational, we expect to have exclusive control of the SpW link
+ * @warning when operational, we expect to have exclusive control of the SpW link
  *
  * TODO: RMAP command response evaluation
  */
diff --git a/test/cmp_data_types/test_cmp_data_types.c b/test/cmp_data_types/test_cmp_data_types.c
index 2b6abf7..33d907d 100644
--- a/test/cmp_data_types/test_cmp_data_types.c
+++ b/test/cmp_data_types/test_cmp_data_types.c
@@ -1,5 +1,5 @@
 /**
- * @file test_cmp_entity.h
+ * @file test_cmp_data_types.c
  * @author Dominik Loidolt (dominik.loidolt@univie.ac.at),
  * @date   2022
  *
@@ -30,6 +30,7 @@
 void test_cmp_set_max_used_bits(void)
 {
 	struct cmp_max_used_bits set_max_used_bits = cmp_get_max_used_bits();
+
 	cmp_set_max_used_bits(&set_max_used_bits);
 	cmp_set_max_used_bits(NULL);
 }
@@ -101,7 +102,7 @@ void test_size_of_a_sample(void)
 	/* test error cases */
 	size = size_of_a_sample(DATA_TYPE_UNKNOWN);
 	TEST_ASSERT_EQUAL(0, size);
-	size = size_of_a_sample(DATA_TYPE_F_CAM_BACKGROUND +1);
+	size = size_of_a_sample(DATA_TYPE_F_CAM_BACKGROUND+1);
 	TEST_ASSERT_EQUAL(0, size);
 }
 
diff --git a/test/cmp_decmp/test_cmp_decmp.c b/test/cmp_decmp/test_cmp_decmp.c
index 0d49cbc..31ce9e7 100644
--- a/test/cmp_decmp/test_cmp_decmp.c
+++ b/test/cmp_decmp/test_cmp_decmp.c
@@ -13,7 +13,7 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
- * @brief random compression decompression test
+ * @brief random compression decompression tests
  * @details We generate random data and compress them with random parameters.
  *	After that we put the data in a compression entity. We decompress the
  *	compression entity and compare the decompressed data with the original
@@ -113,9 +113,8 @@ static void gen_ima_data(uint16_t *data, uint32_t samples)
 	uint32_t i;
 	struct cmp_max_used_bits max_used_bits = cmp_get_max_used_bits();
 
-	for (i = 0; i < samples; i++) {
+	for (i = 0; i < samples; i++)
 		data[i] = random_between(0, set_n_bits(max_used_bits.nc_imagette));
-	}
 }
 
 
@@ -218,9 +217,8 @@ static void gen_f_fx_data(struct f_fx *data, uint32_t samples)
 	uint32_t i;
 	struct cmp_max_used_bits max_used_bits = cmp_get_max_used_bits();
 
-	for (i = 0; i < samples; i++) {
+	for (i = 0; i < samples; i++)
 		data[i].fx = random_between(0, set_n_bits(max_used_bits.f_fx));
-	}
 }
 
 
@@ -351,10 +349,10 @@ void *generate_random_test_data(uint32_t samples, enum cmp_data_type data_type)
 
 	if (!rdcu_supported_data_type_is_used(data_type)) {
 		int i;
+
 		TEST_ASSERT(data_size > MULTI_ENTRY_HDR_SIZE);
-		for (i = 0; i < MULTI_ENTRY_HDR_SIZE; ++i) {
+		for (i = 0; i < MULTI_ENTRY_HDR_SIZE; ++i)
 			*p++ = random_between(0, UINT8_MAX);
-		}
 		data = p;
 	}
 
diff --git a/test/cmp_icu/test_cmp_icu.c b/test/cmp_icu/test_cmp_icu.c
index 09c0720..a78041f 100644
--- a/test/cmp_icu/test_cmp_icu.c
+++ b/test/cmp_icu/test_cmp_icu.c
@@ -1,3 +1,22 @@
+/**
+ * @file   test_cmp_icu.c
+ * @author Dominik Loidolt (dominik.loidolt@univie.ac.at)
+ * @date   2022
+ *
+ * @copyright GPLv2
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * @brief software compression tests
+ */
+
+
 #include <stdlib.h>
 
 #if defined __has_include
@@ -526,7 +545,7 @@ void test_cmp_cfg_icu_imagette(void)
 	/* spillover_par to small */
 	cfg = cmp_cfg_icu_create(DATA_TYPE_IMAGETTE, CMP_MODE_DIFF_ZERO, 0, CMP_LOSSLESS);
 	cmp_par = MAX_IMA_GOLOMB_PAR;
-	spillover_par = MIN_IMA_SPILL -1 ;
+	spillover_par = MIN_IMA_SPILL-1;
 	error = cmp_cfg_icu_imagette(&cfg, cmp_par, spillover_par);
 	TEST_ASSERT_TRUE(error);
 	/* ignore in RAW MODE */
@@ -2191,7 +2210,7 @@ void test_configure_encoder_setup(void)
 	cfg.cmp_mode = CMP_MODE_MODEL_ZERO;
 	cfg.icu_output_buf = (void *)123;
 	cfg.buffer_length = 2;
-	error = configure_encoder_setup(&setup, cmp_par, spillover,lossy_par,
+	error = configure_encoder_setup(&setup, cmp_par, spillover, lossy_par,
 					max_data_bits, &cfg);
 	TEST_ASSERT_FALSE(error);
 	TEST_ASSERT_EQUAL(golomb_encoder, setup.generate_cw_f); /* pointer to the code word encoder */
@@ -2214,7 +2233,7 @@ void test_configure_encoder_setup(void)
 	cfg.cmp_mode = CMP_MODE_DIFF_MULTI;
 	cfg.icu_output_buf = (void *)123;
 	cfg.buffer_length = 2;
-	error = configure_encoder_setup(&setup, cmp_par, spillover,lossy_par,
+	error = configure_encoder_setup(&setup, cmp_par, spillover, lossy_par,
 					max_data_bits, &cfg);
 	TEST_ASSERT_FALSE(error);
 	TEST_ASSERT_EQUAL(rice_encoder, setup.generate_cw_f); /* pointer to the code word encoder */
@@ -2237,7 +2256,7 @@ void test_configure_encoder_setup(void)
 	cfg.cmp_mode = CMP_MODE_STUFF;
 	cfg.icu_output_buf = (void *)123;
 	cfg.buffer_length = 2;
-	error = configure_encoder_setup(&setup, cmp_par, spillover,lossy_par,
+	error = configure_encoder_setup(&setup, cmp_par, spillover, lossy_par,
 					max_data_bits, &cfg);
 	TEST_ASSERT_FALSE(error);
 	TEST_ASSERT_EQUAL(NULL, setup.generate_cw_f); /* pointer to the code word encoder */
@@ -2260,7 +2279,7 @@ void test_configure_encoder_setup(void)
 	cfg.cmp_mode = CMP_MODE_DIFF_MULTI;
 	cfg.icu_output_buf = (void *)123;
 	cfg.buffer_length = 2;
-	error = configure_encoder_setup(&setup, cmp_par, spillover,lossy_par,
+	error = configure_encoder_setup(&setup, cmp_par, spillover, lossy_par,
 					max_data_bits, &cfg);
 	TEST_ASSERT_TRUE(error);
 	memset(&setup, 0, sizeof(setup));
@@ -2274,7 +2293,7 @@ void test_configure_encoder_setup(void)
 	cfg.cmp_mode = CMP_MODE_DIFF_MULTI;
 	cfg.icu_output_buf = (void *)123;
 	cfg.buffer_length = 2;
-	error = configure_encoder_setup(&setup, cmp_par, spillover,lossy_par,
+	error = configure_encoder_setup(&setup, cmp_par, spillover, lossy_par,
 					max_data_bits, &cfg);
 	TEST_ASSERT_TRUE(error);
 	memset(&setup, 0, sizeof(setup));
@@ -2288,7 +2307,7 @@ void test_configure_encoder_setup(void)
 	cfg.cmp_mode = CMP_MODE_STUFF;
 	cfg.icu_output_buf = (void *)123;
 	cfg.buffer_length = 2;
-	error = configure_encoder_setup(&setup, cmp_par, spillover,lossy_par,
+	error = configure_encoder_setup(&setup, cmp_par, spillover, lossy_par,
 					max_data_bits, &cfg);
 	TEST_ASSERT_FALSE(error);
 	TEST_ASSERT_EQUAL(NULL, setup.generate_cw_f); /* pointer to the code word encoder */
@@ -2311,7 +2330,7 @@ void test_configure_encoder_setup(void)
 	cfg.cmp_mode = CMP_MODE_STUFF+1;
 	cfg.icu_output_buf = (void *)123;
 	cfg.buffer_length = 2;
-	error = configure_encoder_setup(&setup, cmp_par, spillover,lossy_par,
+	error = configure_encoder_setup(&setup, cmp_par, spillover, lossy_par,
 					max_data_bits, &cfg);
 	TEST_ASSERT_TRUE(error);
 	memset(&setup, 0, sizeof(setup));
@@ -2325,7 +2344,7 @@ void test_configure_encoder_setup(void)
 	cfg.cmp_mode = CMP_MODE_MODEL_ZERO;
 	cfg.icu_output_buf = (void *)123;
 	cfg.buffer_length = 2;
-	error = configure_encoder_setup(NULL, cmp_par, spillover,lossy_par,
+	error = configure_encoder_setup(NULL, cmp_par, spillover, lossy_par,
 					max_data_bits, &cfg);
 	TEST_ASSERT_TRUE(error);
 	memset(&setup, 0, sizeof(setup));
@@ -2339,7 +2358,7 @@ void test_configure_encoder_setup(void)
 	cfg.cmp_mode = CMP_MODE_RAW;
 	cfg.icu_output_buf = (void *)123;
 	cfg.buffer_length = 2;
-	error = configure_encoder_setup(&setup, cmp_par, spillover,lossy_par,
+	error = configure_encoder_setup(&setup, cmp_par, spillover, lossy_par,
 					max_data_bits, &cfg);
 	TEST_ASSERT_TRUE(error);
 	memset(&setup, 0, sizeof(setup));
@@ -2349,7 +2368,7 @@ void test_configure_encoder_setup(void)
 	spillover = 23;
 	lossy_par = 0;
 	max_data_bits = 15;
-	error = configure_encoder_setup(&setup, cmp_par, spillover,lossy_par,
+	error = configure_encoder_setup(&setup, cmp_par, spillover, lossy_par,
 					max_data_bits, NULL);
 	TEST_ASSERT_TRUE(error);
 	memset(&setup, 0, sizeof(setup));
@@ -2453,6 +2472,7 @@ void test_compress_imagette_stuff(void)
 		0x00, 0x23, 0x00, 0x42,
 		0x80, 0x00, 0x7F, 0xFF,
 		0xFF, 0xFF, 0x00, 0x00};
+	uint32_t *output_buf_exp_32;
 
 	cfg.data_type = DATA_TYPE_IMAGETTE;
 	cfg.cmp_mode = CMP_MODE_STUFF;
@@ -2464,7 +2484,7 @@ void test_compress_imagette_stuff(void)
 
 	cmp_size = icu_compress_data(&cfg);
 
-	uint32_t *output_buf_exp_32 = (uint32_t *)output_buf_exp;
+	output_buf_exp_32 = (uint32_t *)output_buf_exp;
 	TEST_ASSERT_EQUAL_INT(7*16, cmp_size);
 	TEST_ASSERT_EQUAL_HEX16(output_buf_exp_32[0], output_buf[0]);
 	TEST_ASSERT_EQUAL_HEX16(output_buf_exp_32[1], output_buf[1]);
@@ -2549,6 +2569,7 @@ void test_compress_imagette_error_cases(void)
 	uint32_t output_buf[2] = {0xFFFF, 0xFFFF};
 	struct cmp_cfg cfg = {0};
 	int cmp_size;
+	struct cmp_max_used_bits max_used_bits;
 
 	cfg.data_type = DATA_TYPE_IMAGETTE;
 	cfg.cmp_mode = CMP_MODE_DIFF_ZERO;
@@ -2601,12 +2622,12 @@ void test_compress_imagette_error_cases(void)
 	cmp_size = icu_compress_data(&cfg);
 	TEST_ASSERT_EQUAL_INT(-1, cmp_size);
 
-	cfg.data_type = DATA_TYPE_F_CAM_BACKGROUND +1;
+	cfg.data_type = DATA_TYPE_F_CAM_BACKGROUND+1;
 	cmp_size = icu_compress_data(&cfg);
 	TEST_ASSERT_EQUAL_INT(-1, cmp_size);
 
 	/* error in setup */
-	struct cmp_max_used_bits max_used_bits = cmp_get_max_used_bits();
+	max_used_bits = cmp_get_max_used_bits();
 	max_used_bits.nc_imagette = 33;
 	cmp_set_max_used_bits(&max_used_bits);
 	cfg.data_type = DATA_TYPE_IMAGETTE;
@@ -2713,6 +2734,7 @@ void test_compress_s_fx_raw(void)
 	struct cmp_cfg cfg = {0};
 	int cmp_size, cmp_size_exp;
 	size_t i;
+	struct multi_entry_hdr *hdr;
 
 	cfg.data_type = DATA_TYPE_S_FX;
 	cfg.model_buf = NULL;
@@ -2738,7 +2760,7 @@ void test_compress_s_fx_raw(void)
 	data[6].exp_flags = 0x1;
 	data[6].fx = UINT32_MAX;
 
-	struct multi_entry_hdr *hdr = cfg.input_buf;
+	hdr = cfg.input_buf;
 	memset(hdr, 0x42, sizeof(struct multi_entry_hdr));
 	memcpy(hdr->entry, data, sizeof(data));
 
@@ -3074,7 +3096,7 @@ void test_compress_s_fx_error_cases(void)
 
 	/* compressed data are to small for the compressed_data buffer */
 	max_used_bits.s_exp_flags = 8;
-	max_used_bits.s_fx= 32;
+	max_used_bits.s_fx = 32;
 	cmp_set_max_used_bits(&max_used_bits);
 	memset(data_to_compress, 0xff, sizeof(data_to_compress));
 	cmp_bits = icu_compress_data(&cfg);
@@ -3086,7 +3108,7 @@ void test_compress_s_fx_error_cases(void)
 	TEST_ASSERT_EQUAL_INT(-1, cmp_bits);
 
 	max_used_bits.s_exp_flags = 32;
-	max_used_bits.s_fx= 33; /* more than 32 bits are not allowed */
+	max_used_bits.s_fx = 33; /* more than 32 bits are not allowed */
 	cmp_set_max_used_bits(&max_used_bits);
 	cmp_bits = icu_compress_data(&cfg);
 	TEST_ASSERT_EQUAL_INT(-1, cmp_bits);
@@ -3110,7 +3132,7 @@ void test_compress_s_fx_efx_error_cases(void)
 	uint8_t data_to_compress[MULTI_ENTRY_HDR_SIZE+2*sizeof(struct s_fx_efx)] = {0};
 	uint8_t compressed_data[MULTI_ENTRY_HDR_SIZE+1*sizeof(struct s_fx_efx)] = {0};
 	struct cmp_max_used_bits max_used_bits = {0};
-	struct s_fx_efx *data_p= (struct s_fx_efx *)&data_to_compress[MULTI_ENTRY_HDR_SIZE];
+	struct s_fx_efx *data_p = (struct s_fx_efx *)&data_to_compress[MULTI_ENTRY_HDR_SIZE];
 
 	max_used_bits.s_exp_flags = 2;
 	max_used_bits.s_fx = 21;
@@ -3399,7 +3421,7 @@ void test_compress_f_fx_error_cases(void)
 	cmp_bits = icu_compress_data(&cfg);
 	TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF, cmp_bits);
 
-	max_used_bits.f_fx= 33; /* more than 32 bits are not allowed */
+	max_used_bits.f_fx = 33; /* more than 32 bits are not allowed */
 	cmp_set_max_used_bits(&max_used_bits);
 	cmp_bits = icu_compress_data(&cfg);
 	TEST_ASSERT_EQUAL_INT(-1, cmp_bits);
@@ -3454,13 +3476,13 @@ void test_compress_f_fx_efx_error_cases(void)
 	TEST_ASSERT_EQUAL_INT(CMP_ERROR_HIGH_VALUE, cmp_bits);
 	data_p[0].efx = 0x7FFFFFFF;
 
-	max_used_bits.f_fx= 33; /* more than 32 bits are not allowed */
+	max_used_bits.f_fx = 33; /* more than 32 bits are not allowed */
 	cmp_set_max_used_bits(&max_used_bits);
 	cmp_bits = icu_compress_data(&cfg);
 	TEST_ASSERT_EQUAL_INT(-1, cmp_bits);
 
-	max_used_bits.f_fx= 32;
-	max_used_bits.f_efx= 33; /* more than 32 bits are not allowed */
+	max_used_bits.f_fx = 32;
+	max_used_bits.f_efx = 33; /* more than 32 bits are not allowed */
 	cmp_set_max_used_bits(&max_used_bits);
 	cmp_bits = icu_compress_data(&cfg);
 	TEST_ASSERT_EQUAL_INT(-1, cmp_bits);
@@ -3518,13 +3540,13 @@ void test_compress_f_fx_ncob_error_cases(void)
 	TEST_ASSERT_EQUAL_INT(CMP_ERROR_HIGH_VALUE, cmp_bits);
 	data_p[0].ncob_y = 0x7FFFFF;
 
-	max_used_bits.f_fx= 33; /* more than 32 bits are not allowed */
+	max_used_bits.f_fx = 33; /* more than 32 bits are not allowed */
 	cmp_set_max_used_bits(&max_used_bits);
 	cmp_bits = icu_compress_data(&cfg);
 	TEST_ASSERT_EQUAL_INT(-1, cmp_bits);
 
-	max_used_bits.f_fx= 32;
-	max_used_bits.f_ncob= 33; /* more than 32 bits are not allowed */
+	max_used_bits.f_fx = 32;
+	max_used_bits.f_ncob = 33; /* more than 32 bits are not allowed */
 	cmp_set_max_used_bits(&max_used_bits);
 	cmp_bits = icu_compress_data(&cfg);
 	TEST_ASSERT_EQUAL_INT(-1, cmp_bits);
@@ -4399,6 +4421,7 @@ void test_icu_compress_data_error_cases(void)
 void test_zero_escape_mech_is_used(void)
 {
 	int cmp_mode;
+
 	for (cmp_mode = 0; cmp_mode <= CMP_MODE_STUFF; cmp_mode++) {
 		int res = zero_escape_mech_is_used(cmp_mode);
 
diff --git a/test/cmp_icu/test_decmp.c b/test/cmp_icu/test_decmp.c
index 0862996..f620b29 100644
--- a/test/cmp_icu/test_decmp.c
+++ b/test/cmp_icu/test_decmp.c
@@ -1,3 +1,22 @@
+/**
+ * @file   test_decmp.c
+ * @author Dominik Loidolt (dominik.loidolt@univie.ac.at)
+ * @date   2022
+ *
+ * @copyright GPLv2
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * @brief decompression tests
+ */
+
+
 #include <string.h>
 #include <stdlib.h>
 
@@ -13,6 +32,7 @@
 #define IMAX_BITS(m) ((m)/((m)%255+1) / 255%255*8 + 7-86/((m)%255+12))
 #define RAND_MAX_WIDTH IMAX_BITS(RAND_MAX)
 
+/* TODO: clean up this file */
 
 /**
  * @brief generate a uint32_t random number
@@ -123,10 +143,9 @@ void test_cmp_decmp_n_imagette_raw(void)
 	s = decompress_cmp_entiy(ent, NULL, NULL, decompressed_data);
 	TEST_ASSERT_EQUAL_INT(sizeof(data), s);
 
-	for (i = 0; i < ARRAY_SIZE(data); ++i) {
+	for (i = 0; i < ARRAY_SIZE(data); ++i)
 		TEST_ASSERT_EQUAL_INT(data[i], decompressed_data[i]);
 
-	}
 
 	free(compressed_data);
 	free(ent);
@@ -234,6 +253,7 @@ void test_re_map_to_pos(void)
 
 	for (j = INT16_MIN; j < INT16_MAX; j++) {
 		uint32_t map_val =  map_to_pos(j, 16) & 0xFFFF;
+
 		result = re_map_to_pos(map_val);
 		TEST_ASSERT_EQUAL_INT32(j, result);
 	}
@@ -310,6 +330,7 @@ void test_decode_multi(void)
 	uint32_t cmp_data[] = {0x16B66DF8, 0x84360000};
 	struct decoder_setup setup = {0};
 	struct cmp_cfg cfg = {0};
+	int err;
 
 	cpu_to_be32s(&cmp_data[0]);
 	cpu_to_be32s(&cmp_data[1]);
@@ -319,7 +340,7 @@ void test_decode_multi(void)
 	cfg.icu_output_buf = cmp_data;
 	cfg.buffer_length = 8;
 
-	int err = configure_decoder_setup(&setup, 3, 8, CMP_LOSSLESS, 16, &cfg);
+	err = configure_decoder_setup(&setup, 3, 8, CMP_LOSSLESS, 16, &cfg);
 	TEST_ASSERT_FALSE(err);
 
 	stream_pos = 0;
@@ -390,7 +411,7 @@ void test_cmp_decmp_s_fx_diff(void)
 	struct cmp_entity *ent;
 	const uint32_t MAX_VALUE = ~(~0U << MAX_USED_S_FX_BITS);
 	struct s_fx data_entry[DATA_SAMPLES] = {
-		{0,0}, {1,23}, {2,42}, {3,MAX_VALUE}, {3,MAX_VALUE>>1} };
+		{0, 0}, {1, 23}, {2, 42}, {3, MAX_VALUE}, {3, MAX_VALUE>>1} };
 	uint8_t data_to_compress[MULTI_ENTRY_HDR_SIZE + sizeof(data_entry)];
 	struct s_fx *decompressed_data = NULL;
 	/* uint32_t *compressed_data = NULL; */
@@ -643,7 +664,7 @@ void test_s_fx_model(void)
 		0x00, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x3B, 0xFF, 0xFF, 0xEF, 0xFF, 0xFF, 0x5B, 0xFF, 0xFF, 0xEF, 0xFF, 0xFF, 0x5D, 0x80, 0x00, 0x00,
 	};
-	struct cmp_entity * cmp_entity = (struct cmp_entity *)compressed_data_buf;
+	struct cmp_entity *cmp_entity = (struct cmp_entity *)compressed_data_buf;
 
 	uint8_t model_buf[32];
 	uint8_t decompressed_data[32];
@@ -723,7 +744,7 @@ void test_random_compression_decompression(void)
 	/*      cfg.data_type < DATA_TYPE_F_CAM_BACKGROUND+1; cfg.data_type++) { */
 	for (cfg.data_type = DATA_TYPE_IMAGETTE;
 	     cfg.data_type < DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE+1; cfg.data_type++) {
-		cfg.samples = my_random(1,0x30000);
+		cfg.samples = my_random(1, 0x30000);
 			if (cfg.data_type == DATA_TYPE_OFFSET)
 				puts("FADF");
 
@@ -746,7 +767,7 @@ void test_random_compression_decompression(void)
 		generate_random_test_data(cfg.input_buf, cfg.samples, cfg.data_type);
 		generate_random_test_data(cfg.model_buf, cfg.samples, cfg.data_type);
 
-		cfg.model_value = my_random(0,16);
+		cfg.model_value = my_random(0, 16);
 		/* cfg.round = my_random(0,3); /1* XXX *1/ */
 		cfg.round = 0;
 
diff --git a/test/cmp_tool/cmp_tool_lib_test.c b/test/cmp_tool/cmp_tool_lib_test.c
deleted file mode 100644
index ebdbaf8..0000000
--- a/test/cmp_tool/cmp_tool_lib_test.c
+++ /dev/null
@@ -1,540 +0,0 @@
-/**
- * @file   test_cmp_tool_lib.c
- * @author Dominik Loidolt (dominik.loidolt@univie.ac.at)
- * @date   2020
- *
- * @copyright GPLv2
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * @brief unit tests for cmp_tool_lib.c
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <CUnit/CUnit.h>
-#include <CUnit/TestDB.h>
-#include <CUnit/Basic.h>
-#include <CUnit/Console.h>
-
-#include "../../include/cmp_tool_lib.h"
-#include "../../include/cmp_guess.h"
-
-#define PROGRAM_NAME "cmp_tool"
-
-/* used to redirect stdout to file */
-int fd;
-
-/* used to redirect stdout to file */
-fpos_t pos;
-
-/* @brief The init cmp_tool test suite cleanup functionr. Redirect stdout to
- *	file
- * @see: http://c-faq.com/stdio/undofreopen.html
- * @returns zero on success, non-zero otherwise.
- */
-static int init_cmp_tool(void)
-{
-	fflush(stderr);
-	fgetpos(stderr, &pos);
-	fd = dup(fileno(stderr));
-	if (freopen("tmp_stderr.log", "w", stderr) == NULL) {
-		perror("freopen() failed");
-		return -1;
-	}
-
-	return 0;
-}
-
-
-/* @brief The cmp_tool test suite cleanup function. Closes the temporary file
- *	used by the tests.
- * @returns zero on success, non-zero otherwise.
- */
-static int clean_cmp_tool(void)
-{
-	fflush(stderr);
-	dup2(fd, fileno(stderr));
-	close(fd);
-	clearerr(stderr);
-	fsetpos(stderr, &pos);        /* for C9X */
-
-	return 0;
-}
-
-
-/* returnd memory must be freed after use */
-char *read_std_err_log(void)
-{
-	char *response = NULL;
-	size_t len = 0;
-	FILE *fp = fopen("tmp_stderr.log", "r");
-	static int n_lines_read =0;
-	int i;
-
-	if (!fp) {
-		puts("File opening failed");
-		abort();
-	}
-
-	fflush(stderr);
-	for (i=0; getline(&response, &len, fp) != -1; i++) {
-		if (i == n_lines_read) {
-			n_lines_read++;
-			/* printf("%zu %s\n",len, response); */
-			fclose(fp);
-			return response;
-		} else {
-			free(response);
-			response = NULL;
-		}
-	}
-	free(response);
-	response = malloc(1);
-	if (!response)
-		abort();
-	response[0] = '\0';
-
-	fclose(fp);
-	return response;
-}
-
-
-/* tests */
-
-/**
- * @test cmp_tool
- */
-
-void test_read_file8(void)
-{
-	void *file_name;
-	uint8_t *buf;
-	uint32_t n_word;
-	ssize_t i, size;
-	uint8_t array[33] = {0};
-	char *s;
-
-	/* read in a normal data file */
-	memset(array, 0, sizeof(array));
-	file_name = "test_read_file8_1.txt";
-	buf = array;
-	n_word = 33;
-	size = read_file8(file_name, buf, n_word, 0);
-	CU_ASSERT_EQUAL(size, 33);
-	/* no output on stderr */
-	CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "");
-	free(s);
-
-	/* tests counting the size of a file */
-	file_name = "test_read_file8_2.txt";
-	buf = NULL;
-	n_word = 0;
-	size = read_file8(file_name, buf, n_word, 0);
-	CU_ASSERT_EQUAL(size, 33);
-	/* no output on stderr */
-	CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "");
-	free(s);
-
-	/* test data read in counting comments */
-	file_name = "test_read_file8_2.txt";
-	buf = array;
-	n_word = size;
-	size = read_file8(file_name, buf, n_word, 0);
-	CU_ASSERT_EQUAL(size, 33);
-	for (i = 0; i < size; ++i) {
-		CU_ASSERT_EQUAL(buf[i], i);
-	}
-	/* no output on stderr */
-	CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "");
-	free(s);
-
-	/* tests partially read in */
-	memset(array, 0, sizeof(array));
-	file_name = "test_read_file8_2.txt";
-	buf = array;
-	n_word = 32;
-	size = read_file8(file_name, buf, n_word, 0);
-	CU_ASSERT_EQUAL(size, 32);
-	for (i = 0; i < 33; ++i) {
-		if (i < 32) {
-			CU_ASSERT_EQUAL(buf[i], i);
-		} else {
-			CU_ASSERT_EQUAL(buf[i], 0);
-		}
-	}
-	CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "cmp_tool: test_read_file8_2.txt: Warning: The file may contain more data than specified by the samples or cmp_size parameter.\n");
-	free(s);
-
-	/* tests read 0 words in */
-	memset(array, 0, sizeof(array));
-	file_name = "test_read_file8_2.txt";
-	buf = array;
-	n_word = 0;
-	size = read_file8(file_name, buf, n_word, 0);
-	CU_ASSERT_EQUAL(size, 0);
-	for (i = 0; i < 33; ++i) {
-		CU_ASSERT_EQUAL(buf[i], 0);
-	}
-	CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "cmp_tool: test_read_file8_2.txt: Warning: The file may contain more data than specified by the samples or cmp_size parameter.\n");
-	free(s);
-
-	/* TODO; tests read in 0 empty file */
-
-	/* Error cases */
-	/***************/
-
-	/* file does not contain enough data */
-	memset(array, 0xFF, sizeof(array));
-	file_name = "test_read_file8_2.txt";
-	buf = array;
-	n_word = 34;
-	size = read_file8(file_name, buf, n_word, 0);
-	CU_ASSERT_EQUAL(size, -1);
-	CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "cmp_tool: test_read_file8_2.txt: Error: The files do not contain enough data as requested.\n");
-	free(s);
-	memset(array, 0xFF, sizeof(array));
-
-	/* no file_name */
-	file_name = NULL;
-	buf = array;
-	n_word = 33;
-	size = read_file8(file_name, buf, n_word, 0);
-	CU_ASSERT_EQUAL(size, -1);
-	/* no output on stderr */
-	CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "");
-	free(s);
-
-	/* wrong file_name */
-	file_name = "file_not_exist.txt";
-	buf = array;
-	n_word = 33;
-	size = read_file8(file_name, buf, n_word, 0);
-	CU_ASSERT_EQUAL(size, -1);
-	CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "cmp_tool: file_not_exist.txt: No such file or directory\n");
-	free(s);
-
-	/* wrong data format part 1/2 */
-	file_name = "test_read_file8_3.txt";
-	buf = array;
-	n_word = 33;
-	size = read_file8(file_name, buf, n_word, 0);
-	CU_ASSERT_EQUAL(size, -1);
-	CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "cmp_tool: test_read_file8_3.txt: Error: The data are not correct formatted. Expected format is like: 12 AB 23 CD .. ..\n");
-	free(s);
-
-	/* wrong data format part 2/2 */
-	file_name = "test_read_file8_4.txt";
-	buf = array;
-	n_word = 33;
-	size = read_file8(file_name, buf, n_word, 0);
-	CU_ASSERT_EQUAL(size, -1);
-	CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "cmp_tool: test_read_file8_4.txt: Error: The data are not correct formatted. Expected format is like: 12 AB 23 CD .. ..\n");
-	free(s);
-
-	/* file error */
-	/* TODO: how to trigger a file error indicator error */
-	if (1) {
-		/* static char fname[] = "test_read_file8_5.txt"; */
-		/* FILE *f = fopen(fname, "wb"); */
-		/* fputs("\xff\xff\n", f); // not a valid UTF-8 character sequence */
-		/* fclose(f); */
-		buf = array;
-		n_word = 33;
-		size = read_file8("test_read_file8_5.txt", buf, n_word, 0);
-		CU_ASSERT_EQUAL(size, -1);
-		CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "cmp_tool: test_read_file8_5.txt: Error: File error indicator set.\n");
-		free(s);
-	}
-}
-
-
-#define CMP_TEST_SAMPLES 5
-void test_cmp_guess(void)
-{
-	struct cmp_cfg cfg = {0};
-	uint16_t data[CMP_TEST_SAMPLES] = {2,4,6,8,10};
-	uint16_t data_exp[CMP_TEST_SAMPLES] = {2,4,6,8,10};
-	uint16_t model[CMP_TEST_SAMPLES] = {4,6,8,10,12};
-	uint16_t model_exp[CMP_TEST_SAMPLES] = {4,6,8,10,12};
-	uint32_t cmp_size;
-	int level;
-
-
-	/* test 1d-diff mode */
-	cfg.input_buf = data;
-	cfg.model_buf = NULL;
-	cfg.samples = CMP_TEST_SAMPLES;
-	cfg.cmp_mode = MODE_DIFF_MULTI;
-	level = 2;
-	cmp_size = cmp_guess(&cfg, level);
-	CU_ASSERT_TRUE(cmp_size);
-
-	CU_ASSERT_EQUAL(cmp_size, 25);
-	CU_ASSERT_EQUAL(cfg.cmp_mode, MODE_DIFF_MULTI);
-	CU_ASSERT_EQUAL(cfg.golomb_par, 1);
-	CU_ASSERT_EQUAL(cfg.spill, 2);
-	/* CU_ASSERT_EQUAL(cfg.model_value, ); model_value is not needed */
-	CU_ASSERT_EQUAL(cfg.round, 0);
-	CU_ASSERT_EQUAL(cfg.ap1_golomb_par, 2);
-	CU_ASSERT_EQUAL(cfg.ap1_spill, 2);
-	CU_ASSERT_EQUAL(cfg.ap2_golomb_par, 3);
-	CU_ASSERT_EQUAL(cfg.ap2_spill, 2);
-	CU_ASSERT_NSTRING_EQUAL(cfg.input_buf, data_exp, CMP_TEST_SAMPLES);
-	/* CU_ASSERT_NSTRING_EQUAL(cfg.model_buf, model_exp, CMP_TEST_SAMPLES); model is
-	 * not used*/
-	CU_ASSERT_EQUAL(cfg.samples, CMP_TEST_SAMPLES);
-	CU_ASSERT_EQUAL(cfg.buffer_length, 2);
-
-
-	/* test model mode */
-	memset(&cfg, 0, sizeof(struct cmp_cfg));
-	cfg.input_buf = data;
-	cfg.model_buf = model;
-	cfg.samples = CMP_TEST_SAMPLES;
-	cfg.cmp_mode = MODE_MODEL_ZERO;
-	level =3;
-
-	cmp_guess_set_model_updates(12);
-	cmp_size = cmp_guess(&cfg, level);
-	CU_ASSERT_TRUE(cmp_size);
-
-	CU_ASSERT_EQUAL(cmp_size, 20);
-	CU_ASSERT_EQUAL(cfg.cmp_mode, 1);
-	CU_ASSERT_EQUAL(cfg.golomb_par, 2);
-	CU_ASSERT_EQUAL(cfg.spill, 22);
-	CU_ASSERT_EQUAL(cfg.model_value, 12);
-	CU_ASSERT_EQUAL(cfg.round, 0);
-	CU_ASSERT_EQUAL(cfg.ap1_golomb_par, 1);
-	CU_ASSERT_EQUAL(cfg.ap1_spill, 8);
-	CU_ASSERT_EQUAL(cfg.ap2_golomb_par, 3);
-	CU_ASSERT_EQUAL(cfg.ap2_spill, 35);
-	CU_ASSERT_NSTRING_EQUAL(cfg.input_buf, data_exp, CMP_TEST_SAMPLES);
-	CU_ASSERT_NSTRING_EQUAL(cfg.model_buf, model_exp, CMP_TEST_SAMPLES);
-	CU_ASSERT_EQUAL(cfg.samples, CMP_TEST_SAMPLES);
-	CU_ASSERT_EQUAL(cfg.buffer_length, 2);
-
-
-	/* test diff mode without model buffer*/
-	cmp_guess_set_model_updates(CMP_GUESS_N_MODEL_UPDATE_DEF);
-	memset(&cfg, 0, sizeof(struct cmp_cfg));
-	cfg.input_buf = data;
-	cfg.model_buf = model;
-	cfg.samples = CMP_TEST_SAMPLES;
-	cfg.cmp_mode = MODE_DIFF_MULTI;
-	level = 3;
-
-	cmp_size = cmp_guess(&cfg, level);
-	CU_ASSERT_TRUE(cmp_size);
-
-	CU_ASSERT_EQUAL(cmp_size, 20);
-	CU_ASSERT_EQUAL(cfg.cmp_mode, MODE_DIFF_MULTI);
-	CU_ASSERT_EQUAL(cfg.golomb_par, 2);
-	CU_ASSERT_EQUAL(cfg.spill, 5);
-	CU_ASSERT_EQUAL(cfg.model_value, 11);
-	CU_ASSERT_EQUAL(cfg.round, 0);
-	CU_ASSERT_EQUAL(cfg.ap1_golomb_par, 1);
-	CU_ASSERT_EQUAL(cfg.ap1_spill, 2);
-	CU_ASSERT_EQUAL(cfg.ap2_golomb_par, 3);
-	CU_ASSERT_EQUAL(cfg.ap2_spill, 2);
-	CU_ASSERT_NSTRING_EQUAL(cfg.input_buf, data_exp, CMP_TEST_SAMPLES);
-	CU_ASSERT_NSTRING_EQUAL(cfg.model_buf, model_exp, CMP_TEST_SAMPLES);
-	CU_ASSERT_EQUAL(cfg.samples, CMP_TEST_SAMPLES);
-	CU_ASSERT_EQUAL(cfg.buffer_length, 2);
-
-
-	/* error test cfg = NULL */
-	level = 2;
-	cmp_size = cmp_guess(NULL, level);
-	CU_ASSERT_FALSE(cmp_size);
-
-
-	/* error test unknown guess_level */
-	level = 4;
-	cmp_size = cmp_guess(&cfg, level);
-	CU_ASSERT_FALSE(cmp_size);
-
-
-	/* error test model mode without model buffer*/
-	memset(&cfg, 0, sizeof(struct cmp_cfg));
-	cfg.input_buf = NULL;
-	cfg.model_buf = NULL;
-	cfg.samples = CMP_TEST_SAMPLES;
-	cfg.cmp_mode = MODE_DIFF_MULTI;
-	level = 2;
-
-	cmp_size = cmp_guess(&cfg, level);
-	CU_ASSERT_FALSE(cmp_size);
-
-
-	/* error test model mode without model buffer*/
-	memset(&cfg, 0, sizeof(struct cmp_cfg));
-	cfg.input_buf = data;
-	cfg.model_buf = NULL;
-	cfg.samples = CMP_TEST_SAMPLES;
-	cfg.cmp_mode = MODE_MODEL_MULTI;
-	level = 2;
-
-	cmp_size = cmp_guess(&cfg, level);
-	CU_ASSERT_FALSE(cmp_size);
-
-
-	/* error test not supported cmp_mode */
-	memset(&cfg, 0, sizeof(struct cmp_cfg));
-	cfg.input_buf = data;
-	cfg.model_buf = model;
-	cfg.samples = CMP_TEST_SAMPLES;
-	cfg.cmp_mode = 5;
-	level = 2;
-
-	cmp_size = cmp_guess(&cfg, level);
-	CU_ASSERT_FALSE(cmp_size);
-
-
-	/* error test samples = 0 */
-	memset(&cfg, 0, sizeof(struct cmp_cfg));
-	cfg.input_buf = data;
-	cfg.model_buf = model;
-	cfg.samples = 0;
-	cfg.cmp_mode = MODE_MODEL_MULTI;
-	level = 2;
-
-	cmp_size = cmp_guess(&cfg, level);
-	CU_ASSERT_FALSE(cmp_size);
-}
-
-void test_cmp_guess_model_value(void)
-{
-	uint16_t model_value;
-
-	model_value = cmp_guess_model_value(0);
-	CU_ASSERT_EQUAL(model_value, 8);
-	model_value = cmp_guess_model_value(1);
-	CU_ASSERT_EQUAL(model_value, 8);
-	model_value = cmp_guess_model_value(2);
-	CU_ASSERT_EQUAL(model_value, 8);
-	model_value = cmp_guess_model_value(3);
-	CU_ASSERT_EQUAL(model_value, 10);
-	model_value = cmp_guess_model_value(4);
-	CU_ASSERT_EQUAL(model_value, 10);
-	model_value = cmp_guess_model_value(5);
-	CU_ASSERT_EQUAL(model_value, 10);
-	model_value = cmp_guess_model_value(6);
-	CU_ASSERT_EQUAL(model_value, 11);
-	model_value = cmp_guess_model_value(10);
-	CU_ASSERT_EQUAL(model_value, 11);
-	model_value = cmp_guess_model_value(11);
-	CU_ASSERT_EQUAL(model_value, 11);
-	model_value = cmp_guess_model_value(12);
-	CU_ASSERT_EQUAL(model_value, 12);
-	model_value = cmp_guess_model_value(20);
-	CU_ASSERT_EQUAL(model_value, 12);
-	model_value = cmp_guess_model_value(21);
-	CU_ASSERT_EQUAL(model_value, 12);
-	model_value = cmp_guess_model_value(22);
-	CU_ASSERT_EQUAL(model_value, 13);
-}
-
-
-void test_cmp_mode_parse(void)
-{
-	uint32_t cmp_mode = ~0;
-	int err;
-
-	/* error cases */
-	err = cmp_mode_parse(NULL, NULL);
-	CU_ASSERT_TRUE(err);
-
-	err = cmp_mode_parse(NULL, &cmp_mode);
-	CU_ASSERT_TRUE(err);
-
-	err = cmp_mode_parse("MODE_RAW", NULL);
-	CU_ASSERT_TRUE(err);
-
-	err = cmp_mode_parse("UNKNOWN", &cmp_mode);
-	CU_ASSERT_TRUE(err);
-
-	err = cmp_mode_parse("9999999999999999999", &cmp_mode);
-	CU_ASSERT_TRUE(err);
-
-	/* mode not defined*/
-	err = cmp_mode_parse("424212", &cmp_mode);
-	CU_ASSERT_TRUE(err);
-
-	/* normal operation */
-	err = cmp_mode_parse("MODE_RAW", &cmp_mode);
-	CU_ASSERT_FALSE(err);
-	CU_ASSERT_EQUAL(cmp_mode, MODE_RAW);
-
-	err = cmp_mode_parse("0", &cmp_mode);
-	CU_ASSERT_FALSE(err);
-	CU_ASSERT_EQUAL(cmp_mode, MODE_RAW);
-
-	err = cmp_mode_parse("0 \n", &cmp_mode);
-	CU_ASSERT_FALSE(err);
-	CU_ASSERT_EQUAL(cmp_mode, MODE_RAW);
-
-	err = cmp_mode_parse(" 2 ", &cmp_mode);
-	CU_ASSERT_FALSE(err);
-	CU_ASSERT_EQUAL(cmp_mode, 2);
-
-	err = cmp_mode_parse("MODE_DIFF_MULTI", &cmp_mode);
-	CU_ASSERT_FALSE(err);
-	CU_ASSERT_EQUAL(cmp_mode, MODE_DIFF_MULTI);
-}
-
-CU_ErrorCode cmp_tool_add_tests(CU_pSuite suite)
-{
-	CU_pTest  __attribute__((unused)) test;
-
-	/* add a suite to the registry */
-	suite = CU_add_suite("cmp_tool", init_cmp_tool, clean_cmp_tool);
-	if (suite == NULL) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
-
-	/* add the tests to the suite */
-	if ((NULL == CU_add_test(suite, "test of read_file8()", test_read_file8)) ||
-	    (NULL == CU_add_test(suite, "test of cmp_mode_parse()", test_cmp_mode_parse))||
-	    (NULL == CU_add_test(suite, "test of cmp_guess_model_value()", test_cmp_guess_model_value))||
-	    (NULL == CU_add_test(suite, "test of cmp_guess()", test_cmp_guess))) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
-
-	return CUE_SUCCESS;
-}
-
-
-#if (__MAIN__)
-int main(void)
-{
-	CU_pSuite suite = NULL;
-
-	/* initialize the CUnit test registry */
-	if (CU_initialize_registry() != CUE_SUCCESS)
-		return CU_get_error();
-
-	cmp_tool_add_tests(suite);
-
-	CU_basic_set_mode(CU_BRM_VERBOSE);
-	CU_basic_run_tests();
-
-	printf("\n\n\n");
-
-	CU_basic_show_failures(CU_get_failure_list());
-
-	CU_cleanup_registry();
-
-	return CU_get_error();
-}
-#endif
-- 
GitLab