From 7479ba22bbc0dded0cb5033aa2eb70b57f1b8b45 Mon Sep 17 00:00:00 2001
From: Dominik Loidolt <dominik.loidolt@univie.ac.at>
Date: Fri, 9 Aug 2024 18:58:39 +0200
Subject: [PATCH] Refactor: Remove unused functions

- Removed the following unused functions:
  - cmp_cal_size_of_data
  - cmp_input_size_to_samples
  - cmp_ent_write_cmp_pars
  - cmp_ent_build
---
 examples/example_cmp_icu.c                | 175 -----
 examples/meson.build                      |  11 -
 lib/common/cmp_data_types.c               |  61 --
 lib/common/cmp_data_types.h               |   2 -
 lib/common/cmp_entity.c                   | 196 +----
 lib/common/cmp_entity.h                   |  12 -
 lib/decompress/decmp.c                    |  10 +-
 programs/cmp_tool.c                       |   2 +-
 test/cmp_data_types/test_cmp_data_types.c |  86 ---
 test/cmp_entity/test_cmp_entity.c         | 828 +++++++++-------------
 test/decmp/test_decmp.c                   | 643 -----------------
 11 files changed, 353 insertions(+), 1673 deletions(-)
 delete mode 100644 examples/example_cmp_icu.c

diff --git a/examples/example_cmp_icu.c b/examples/example_cmp_icu.c
deleted file mode 100644
index f0d783e..0000000
--- a/examples/example_cmp_icu.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * @file   example_cmp_icu.c
- * @author Dominik Loidolt (dominik.loidolt@univie.ac.at)
- * @date   Oct 2023
- *
- * @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 demonstration of the use of the software compressor and the
- *	compression entity library
- */
-
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <leon_inttypes.h>
-
-#include <cmp_entity.h>
-#include <cmp_icu.h>
-
-
-#define DATA_SAMPLES 6 /* number of 16 bit samples to compress */
-#define CMP_BUF_LEN_SAMPLES DATA_SAMPLES /* compressed buffer has the same sample size as the data buffer */
-#define CMP_ASW_VERSION_ID 1
-/* The start_time, end_time, model_id and counter have to be managed by the ASW
- * here we use arbitrary values for demonstration */
-#define START_TIME 0
-#define END_TIME 0x23
-#define MODEL_ID 42
-#define MODEL_COUNTER 1
-
-
-static int demo_icu_compression(void)
-{
-	struct cmp_cfg example_cfg;
-	struct cmp_entity *cmp_entity = NULL;
-	uint32_t i, cmp_buf_size, entity_buf_size, entity_size;
-	int cmp_size_bits;
-	void *ent_cmp_data;
-
-	/* declare data buffers with some example data */
-	enum cmp_data_type example_data_type = DATA_TYPE_IMAGETTE;
-	uint16_t example_data[DATA_SAMPLES] = {42, 23, 1, 13, 20, 1000};
-	uint16_t example_model[DATA_SAMPLES] = {0, 22, 3, 42, 23, 16};
-	uint16_t updated_model[DATA_SAMPLES] = {0};
-
-	/* create a compression configuration with default values */
-	example_cfg = cmp_cfg_icu_create(example_data_type, CMP_DEF_IMA_MODEL_CMP_MODE,
-					 CMP_DEF_IMA_MODEL_MODEL_VALUE, CMP_LOSSLESS);
-	if (example_cfg.data_type == DATA_TYPE_UNKNOWN) {
-		printf("Error occurred during cmp_cfg_icu_create()\n");
-		goto fail;
-	}
-
-	/* configure imagette specific compression parameters with default values */
-	if (cmp_cfg_icu_imagette(&example_cfg, CMP_DEF_IMA_MODEL_GOLOMB_PAR,
-				 CMP_DEF_IMA_MODEL_SPILL_PAR)) {
-		printf("Error occurred during cmp_cfg_icu_imagette()\n");
-		goto fail;
-	}
-
-	/* get the size of the buffer for the compressed data in bytes */
-	cmp_buf_size = cmp_cfg_icu_buffers(&example_cfg, example_data,
-					   DATA_SAMPLES, example_model,
-					   updated_model, NULL,
-					   CMP_BUF_LEN_SAMPLES);
-	if (!cmp_buf_size) {
-		printf("Error occurred during cmp_cfg_icu_buffers()\n");
-		goto fail;
-	}
-
-	/* create a compression entity */
-	#define NO_CMP_MODE_RAW_USED 0
-	entity_buf_size = cmp_ent_create(NULL, example_data_type, NO_CMP_MODE_RAW_USED,
-					 cmp_buf_size);
-	if (!entity_buf_size) {
-		printf("Error occurred during cmp_ent_create()\n");
-		goto fail;
-	}
-	cmp_entity = malloc(entity_buf_size); /* allocated memory for the compression entity */
-	if (!cmp_entity) {
-		printf("malloc failed!\n");
-		goto fail;
-	}
-	entity_buf_size = cmp_ent_create(cmp_entity, example_data_type,
-					 NO_CMP_MODE_RAW_USED, cmp_buf_size);
-	if (!entity_buf_size) {
-		printf("Error occurred during cmp_ent_create()\n");
-		goto fail;
-	}
-
-	/*
-	 * Configure the buffer related settings. We put the compressed data directly
-	 * into the compression entity. In this way we do not need to copy the
-	 * compressed data into the compression entity
-	 */
-	ent_cmp_data = cmp_ent_get_data_buf(cmp_entity);
-	if (!ent_cmp_data) {
-		printf("Error occurred during cmp_ent_get_data_buf()\n");
-		goto fail;
-	}
-	cmp_buf_size = cmp_cfg_icu_buffers(&example_cfg, example_data,
-					   DATA_SAMPLES, example_model,
-					   updated_model, ent_cmp_data,
-					   CMP_BUF_LEN_SAMPLES);
-	if (!cmp_buf_size) {
-		printf("Error occurred during cmp_cfg_icu_buffers()\n");
-		goto fail;
-	}
-
-	/* now we compress the data on the ICU */
-	cmp_size_bits = icu_compress_data(&example_cfg);
-	if (cmp_size_bits < 0) {
-		printf("Error occurred during icu_compress_data()\n");
-		if (cmp_size_bits == CMP_ERROR_SMALL_BUF)
-			printf("The compressed data buffer is too small to hold all compressed data!\n");
-		if (cmp_size_bits == CMP_ERROR_HIGH_VALUE)
-			printf("A data or model value is bigger than the max_used_bits parameter "
-			       "allows (set with the cmp_cfg_icu_max_used_bits() function)!\n");
-		goto fail;
-	}
-
-	/* now we set all the parameters in the compression entity header */
-	/*
-	 * NOTE: the size of the compress entity is smaller than the buffer size
-	 * we have allocated for it (entity_buf_size), because the compressed
-	 * data (fortunately) does not use the entire buffer we have provided
-	 * for it
-	 */
-	entity_size = cmp_ent_build(cmp_entity, CMP_ASW_VERSION_ID, START_TIME, END_TIME,
-				    MODEL_ID, MODEL_COUNTER, &example_cfg, cmp_size_bits);
-	if (!entity_size) {
-		printf("Error occurred during cmp_ent_build()\n");
-		goto fail;
-	}
-
-	printf("Here's the compressed entity (size %"PRIu32"):\n"
-	       "=========================================\n", entity_size);
-	for (i = 0; i < entity_size; i++) {
-		uint8_t *p = (uint8_t *)cmp_entity; /* the compression entity is big-endian */
-		printf("%02X ", p[i]);
-		if (i && !((i + 1) % 32))
-			printf("\n");
-	}
-	printf("\n\nHere's the updated model (samples=%u):\n"
-	       "=========================================\n", DATA_SAMPLES);
-	for (i = 0; i < DATA_SAMPLES; i++) {
-		printf("%04X ", updated_model[i]);
-		if (i && !((i + 1) % 20))
-			printf("\n");
-	}
-	printf("\n");
-
-	free(cmp_entity);
-	return 0;
-
-fail:
-	free(cmp_entity);
-	return -1;
-}
-
-
-int main(void)
-{
-	return demo_icu_compression();
-}
diff --git a/examples/meson.build b/examples/meson.build
index d83ac40..460db1d 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -1,14 +1,3 @@
-example_cmp_icu_src = files([
-  'example_cmp_icu.c'
-])
-
-example_cmp_icu_exe = executable('example_cmp_icu',
-  sources : example_cmp_icu_src,
-  include_directories : incdir,
-  link_with : cmp_lib,
-)
-
-
 example_cmp_rdcu_src = files([
   'example_cmp_rdcu.c'
 ])
diff --git a/lib/common/cmp_data_types.c b/lib/common/cmp_data_types.c
index 11ebe41..c044806 100644
--- a/lib/common/cmp_data_types.c
+++ b/lib/common/cmp_data_types.c
@@ -590,67 +590,6 @@ size_t size_of_a_sample(enum cmp_data_type data_type)
 }
 
 
-/**
- * @brief calculate the need bytes for the data
- *
- * @param samples	number of data samples
- * @param data_type	compression data_type
- *
- * @note for non-imagette data program types the collection header size is added
- *
- * @returns the size in bytes to store the data sample; zero on failure
- */
-
-uint32_t cmp_cal_size_of_data(uint32_t samples, enum cmp_data_type data_type)
-{
-	size_t s = size_of_a_sample(data_type);
-	uint64_t x; /* use 64 bit to catch overflow */
-
-	if (!s)
-		return 0;
-
-	x = (uint64_t)s*samples;
-
-	if (!rdcu_supported_data_type_is_used(data_type))
-		x += COLLECTION_HDR_SIZE;
-
-	if (x > UINT_MAX) /* catch overflow */
-		return 0;
-
-	return (unsigned int)x;
-}
-
-
-/**
- * @brief calculates the number of samples for a given data size for the
- *	different compression modes
- *
- * @param size		size of the data in bytes
- * @param data_type	compression data type
- *
- * @returns the number samples for the given compression mode; negative on error
- */
-
-int32_t cmp_input_size_to_samples(uint32_t size, enum cmp_data_type data_type)
-{
-	uint32_t samples_size = (uint32_t)size_of_a_sample(data_type);
-
-	if (!samples_size)
-		return -1;
-
-	if (!rdcu_supported_data_type_is_used(data_type)) {
-		if (size < COLLECTION_HDR_SIZE)
-			return -1;
-		size -= COLLECTION_HDR_SIZE;
-	}
-
-	if (size % samples_size)
-		return -1;
-
-	return (int)(size/samples_size);
-}
-
-
 static uint32_t be24_to_cpu(uint32_t a)
 {
 	return be32_to_cpu(a) >> 8;
diff --git a/lib/common/cmp_data_types.h b/lib/common/cmp_data_types.h
index a64661e..963961d 100644
--- a/lib/common/cmp_data_types.h
+++ b/lib/common/cmp_data_types.h
@@ -327,8 +327,6 @@ enum cmp_data_type convert_subservice_to_cmp_data_type(uint8_t subservice);
 uint8_t convert_cmp_data_type_to_subservice(enum cmp_data_type data_type);
 
 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);
 
 
 /* endianness functions */
diff --git a/lib/common/cmp_entity.c b/lib/common/cmp_entity.c
index 0b4f634..79641e7 100644
--- a/lib/common/cmp_entity.c
+++ b/lib/common/cmp_entity.c
@@ -1782,146 +1782,6 @@ uint32_t cmp_ent_get_cmp_data_size(const struct cmp_entity *ent)
 }
 
 
-/**
- * @brief write the compression parameters from a compression configuration
- *	into the compression entity header
- * @note NO compressed data are put into the entity and NO change of the entity
- *	size
- *
- * @param ent		pointer to a compression entity
- * @param cfg		pointer to a compression configuration
- * @param cmp_size_bits	size of the compressed data in bits
- *
- * @returns 0 on success, negative on error
- */
-
-int cmp_ent_write_cmp_pars(struct cmp_entity *ent, const struct cmp_cfg *cfg,
-			   int cmp_size_bits)
-{
-	uint32_t ent_cmp_data_size;
-
-	if (!cfg)
-		return -1;
-
-	if (cmp_size_bits < 0)
-		return -1;
-
-	if (cfg->data_type != cmp_ent_get_data_type(ent)) {
-		debug_print("Error: The entity data product type dos not match the configuration data product type.");
-		return -1;
-	}
-
-	if (cmp_ent_get_data_type_raw_bit(ent) != (cfg->cmp_mode == CMP_MODE_RAW)) {
-		debug_print("Error: The entity's raw data bit does not match up with the compression mode.");
-		return -1;
-	}
-
-	ent_cmp_data_size = cmp_ent_get_cmp_data_size(ent);
-
-	/* check if the entity can hold the compressed data */
-	if (ent_cmp_data_size < cmp_bit_to_byte((unsigned int)cmp_size_bits)) {
-		debug_print("Error: The entity size is to small to hold the compressed data.");
-		return -2;
-	}
-
-	/* set compression parameter fields in the generic entity header */
-	if (cmp_ent_set_original_size(ent, cmp_cal_size_of_data(cfg->samples,
-								cfg->data_type)))
-		return -1;
-	if (cmp_ent_set_cmp_mode(ent, cfg->cmp_mode))
-		return -1;
-	if (cmp_ent_set_model_value(ent, cfg->model_value))
-		return -1;
-	if (cfg->max_used_bits)
-		cmp_ent_set_max_used_bits_version(ent, cfg->max_used_bits->version);
-	else
-		cmp_ent_set_max_used_bits_version(ent, 0);
-	if (cmp_ent_set_lossy_cmp_par(ent, cfg->round))
-		return -1;
-
-	if (cfg->cmp_mode == CMP_MODE_RAW) /* no specific header is used for raw data we are done */
-		return 0;
-
-	switch (cmp_ent_get_data_type(ent)) {
-	case DATA_TYPE_IMAGETTE_ADAPTIVE:
-	case DATA_TYPE_SAT_IMAGETTE_ADAPTIVE:
-	case DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE:
-		if (cmp_ent_set_ima_ap1_spill(ent, cfg->ap1_spill))
-			return -1;
-		if (cmp_ent_set_ima_ap1_golomb_par(ent, cfg->ap1_golomb_par))
-			return -1;
-		if (cmp_ent_set_ima_ap2_spill(ent, cfg->ap2_spill))
-			return -1;
-		if (cmp_ent_set_ima_ap2_golomb_par(ent, cfg->ap2_golomb_par))
-			return -1;
-		/* fall through */
-	case DATA_TYPE_IMAGETTE:
-	case DATA_TYPE_SAT_IMAGETTE:
-	case DATA_TYPE_F_CAM_IMAGETTE:
-		if (cmp_ent_set_ima_spill(ent, cfg->spill))
-			return -1;
-		if (cmp_ent_set_ima_golomb_par(ent, cfg->golomb_par))
-			return -1;
-		break;
-	case DATA_TYPE_CHUNK:
-		if (cmp_ent_set_non_ima_cmp_par1(ent, cfg->cmp_par_1))
-			return -1;
-		if (cmp_ent_set_non_ima_spill1(ent, cfg->spill_par_1))
-			return -1;
-
-		if (cmp_ent_set_non_ima_cmp_par2(ent, cfg->cmp_par_2))
-			return -1;
-		if (cmp_ent_set_non_ima_spill2(ent, cfg->spill_par_2))
-			return -1;
-
-		if (cmp_ent_set_non_ima_cmp_par3(ent, cfg->cmp_par_3))
-			return -1;
-		if (cmp_ent_set_non_ima_spill3(ent, cfg->spill_par_3))
-			return -1;
-
-		if (cmp_ent_set_non_ima_cmp_par4(ent, cfg->cmp_par_4))
-			return -1;
-		if (cmp_ent_set_non_ima_spill4(ent, cfg->spill_par_4))
-			return -1;
-
-		if (cmp_ent_set_non_ima_cmp_par5(ent, cfg->cmp_par_5))
-			return -1;
-		if (cmp_ent_set_non_ima_spill5(ent, cfg->spill_par_5))
-			return -1;
-
-		if (cmp_ent_set_non_ima_cmp_par6(ent, cfg->cmp_par_6))
-			return -1;
-		if (cmp_ent_set_non_ima_spill6(ent, cfg->spill_par_6))
-			return -1;
-
-		break;
-	/* the compression entity data type field only supports imagette or chunk data types*/
-	case DATA_TYPE_OFFSET:
-	case DATA_TYPE_F_CAM_OFFSET:
-	case DATA_TYPE_BACKGROUND:
-	case DATA_TYPE_F_CAM_BACKGROUND:
-	case DATA_TYPE_SMEARING:
-	case DATA_TYPE_S_FX:
-	case DATA_TYPE_S_FX_EFX:
-	case DATA_TYPE_S_FX_NCOB:
-	case DATA_TYPE_S_FX_EFX_NCOB_ECOB:
-	case DATA_TYPE_L_FX:
-	case DATA_TYPE_L_FX_EFX:
-	case DATA_TYPE_L_FX_NCOB:
-	case DATA_TYPE_L_FX_EFX_NCOB_ECOB:
-	case DATA_TYPE_F_FX:
-	case DATA_TYPE_F_FX_EFX:
-	case DATA_TYPE_F_FX_NCOB:
-	case DATA_TYPE_F_FX_EFX_NCOB_ECOB:
-	case DATA_TYPE_UNKNOWN:
-	default:
-		return -1;
-	}
-
-	return 0;
-}
-
-
 /**
  * @brief write the parameters from the RDCU decompression information structure
  *	in the compression entity header
@@ -1973,7 +1833,7 @@ int cmp_ent_write_rdcu_cmp_pars(struct cmp_entity *ent, const struct cmp_info *i
 	}
 
 	/* set compression parameter fields in the generic entity header */
-	if (cmp_ent_set_original_size(ent, cmp_cal_size_of_data(info->samples_used, DATA_TYPE_IMAGETTE)))
+	if (cmp_ent_set_original_size(ent, info->samples_used * sizeof(uint16_t)))
 		return -1;
 	if (cmp_ent_set_cmp_mode(ent, info->cmp_mode_used))
 		return -1;
@@ -2064,60 +1924,6 @@ uint32_t cmp_ent_create(struct cmp_entity *ent, enum cmp_data_type data_type,
 }
 
 
-/**
- * @brief create a compression entity and set the header fields
- *
- * @note this function simplifies the entity set up by creating an entity and
- *	setting the header fields in one function call
- * @note no compressed data are put into the entity
- *
- * @param ent			pointer to a compression entity; if NULL, the
- *	function returns the needed size
- * @param version_id		applications software version identifier
- * @param start_time		compression start timestamp (coarse and fine)
- * @param end_time		compression end timestamp (coarse and fine)
- * @param model_id		model identifier
- * @param model_counter		model counter
- * @param cfg			pointer to compression configuration (can be NULL)
- * @param cmp_size_bits		length of the compressed data in bits
- *
- * @returns the size of the compression entity or 0 on error
- */
-
-uint32_t cmp_ent_build(struct cmp_entity *ent, uint32_t version_id,
-		       uint64_t start_time, uint64_t end_time, uint16_t model_id,
-		       uint8_t model_counter, const struct cmp_cfg *cfg, int cmp_size_bits)
-{
-	uint32_t cmp_size_bytes = cmp_bit_to_byte((unsigned int)cmp_size_bits);
-	uint32_t hdr_size;
-
-	if (!cfg)
-		return 0;
-
-	if (cmp_size_bits < 0)
-		return 0;
-
-	if (!cmp_ent_create(ent, cfg->data_type, cfg->cmp_mode == CMP_MODE_RAW, cmp_size_bytes))
-		return 0;
-
-	if (ent) {
-		cmp_ent_set_version_id(ent, version_id);
-		if (cmp_ent_set_start_timestamp(ent, start_time))
-			return 0;
-		if (cmp_ent_set_end_timestamp(ent, end_time))
-			return 0;
-		cmp_ent_set_model_id(ent, model_id);
-		cmp_ent_set_model_counter(ent, model_counter);
-		if (cmp_ent_write_cmp_pars(ent, cfg, cmp_size_bits))
-			return 0;
-	}
-
-	hdr_size = cmp_ent_cal_hdr_size(cfg->data_type, cfg->cmp_mode == CMP_MODE_RAW);
-
-	return hdr_size + cmp_size_bytes;
-}
-
-
 #ifdef HAS_TIME_H
 /*
  * @brief Convert a calendar time expressed as a struct tm object to time since
diff --git a/lib/common/cmp_entity.h b/lib/common/cmp_entity.h
index e60c097..909a3bc 100644
--- a/lib/common/cmp_entity.h
+++ b/lib/common/cmp_entity.h
@@ -155,18 +155,6 @@ compile_time_assert(sizeof(struct cmp_entity) == NON_IMAGETTE_HEADER_SIZE, CMP_E
 uint32_t cmp_ent_create(struct cmp_entity *ent, enum cmp_data_type data_type,
 			int raw_mode_flag, uint32_t cmp_size_byte);
 
-/* create a compression entity and set the header fields */
-uint32_t cmp_ent_build(struct cmp_entity *ent, uint32_t version_id,
-		       uint64_t start_time, uint64_t end_time, uint16_t model_id,
-		       uint8_t model_counter, const struct cmp_cfg *cfg, int cmp_size_bits);
-
-/*
- * 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
  * compression entity header
diff --git a/lib/decompress/decmp.c b/lib/decompress/decmp.c
index 0c0548b..0ee3784 100644
--- a/lib/decompress/decmp.c
+++ b/lib/decompress/decmp.c
@@ -1990,14 +1990,14 @@ static int cmp_ent_read_header(struct cmp_entity *ent, struct cmp_cfg *cfg)
 			return -1;
 		}
 	} else {
-		int32_t samples = cmp_input_size_to_samples(cmp_ent_get_original_size(ent), cfg->data_type);
+		uint32_t org_size = cmp_ent_get_original_size(ent);
 
-		if (samples < 0) {
-			debug_print("Error: original_size and data product type in the compression header are not compatible.");
+		if (org_size % sizeof(uint16_t)) {
+			debug_print("Error: The original size of an imagette product type in the compression header must be a multiple of 2.");
 			cfg->samples = 0;
 			return -1;
 		}
-		cfg->samples = (uint32_t)samples;
+		cfg->samples = org_size/sizeof(uint16_t);
 	}
 
 	cfg->icu_output_buf = cmp_ent_get_data_buf(ent);
@@ -2269,7 +2269,7 @@ int decompress_cmp_entiy(struct cmp_entity *ent, void *model_of_data,
 
 	if (cfg.data_type != DATA_TYPE_CHUNK) { /* perform a non-chunk decompression */
 		if (cfg.cmp_mode == CMP_MODE_RAW) {
-			uint32_t data_size = cmp_cal_size_of_data(cfg.samples, cfg.data_type);
+			uint32_t data_size = cfg.samples * sizeof(uint16_t);
 
 			if (decompressed_data) {
 				memcpy(decompressed_data, cmp_ent_get_data_buf(ent), data_size);
diff --git a/programs/cmp_tool.c b/programs/cmp_tool.c
index 5043fd2..acb5239 100644
--- a/programs/cmp_tool.c
+++ b/programs/cmp_tool.c
@@ -588,7 +588,7 @@ static int guess_cmp_pars(struct rdcu_cfg *rcfg, const char *guess_cmp_mode,
 		return -1;
 	printf("DONE\n");
 
-	cr = (8.0 * cmp_cal_size_of_data(rcfg->samples, data_type))/cmp_size_bit;
+	cr = (8.0 * rcfg->samples * sizeof(uint16_t))/cmp_size_bit;
 	printf("Guessed parameters can compress the data with a CR of %.2f.\n", cr);
 
 	return 0;
diff --git a/test/cmp_data_types/test_cmp_data_types.c b/test/cmp_data_types/test_cmp_data_types.c
index ebb8588..94e2029 100644
--- a/test/cmp_data_types/test_cmp_data_types.c
+++ b/test/cmp_data_types/test_cmp_data_types.c
@@ -206,92 +206,6 @@ void test_size_of_a_sample(void)
 }
 
 
-/**
- * @test cmp_cal_size_of_data
- */
-
-void test_cmp_cal_size_of_data(void)
-{
-	uint32_t s;
-
-	s = cmp_cal_size_of_data(1, DATA_TYPE_IMAGETTE);
-	TEST_ASSERT_EQUAL_UINT(sizeof(uint16_t), s);
-
-	s = cmp_cal_size_of_data(32, DATA_TYPE_IMAGETTE);
-	TEST_ASSERT_EQUAL_UINT(32 * sizeof(uint16_t), s);
-
-	s = cmp_cal_size_of_data(1, DATA_TYPE_F_FX);
-	TEST_ASSERT_EQUAL_UINT(sizeof(struct f_fx)+COLLECTION_HDR_SIZE, s);
-
-	s = cmp_cal_size_of_data(4, DATA_TYPE_F_FX);
-	TEST_ASSERT_EQUAL_UINT(4*sizeof(struct f_fx)+COLLECTION_HDR_SIZE, s);
-
-	/* error cases */
-	s = cmp_cal_size_of_data(33, DATA_TYPE_UNKNOWN);
-	TEST_ASSERT_EQUAL_UINT(0, s);
-
-	/* overflow tests */
-	s = cmp_cal_size_of_data(0x1999999A, DATA_TYPE_BACKGROUND);
-	TEST_ASSERT_EQUAL_UINT(0, s);
-	s = cmp_cal_size_of_data(0x19999999, DATA_TYPE_BACKGROUND);
-	TEST_ASSERT_EQUAL_UINT(0, s);
-	s = cmp_cal_size_of_data(UINT_MAX, DATA_TYPE_L_FX_EFX_NCOB_ECOB);
-	TEST_ASSERT_EQUAL_UINT(0, s);
-}
-
-
-/**
- * @test cmp_input_size_to_samples
- */
-
-void test_cmp_input_size_to_samples(void)
-{
-	enum cmp_data_type data_type;
-	uint32_t size, samples;
-	int32_t samples_get;
-
-	data_type = DATA_TYPE_IMAGETTE;
-	samples = 42;
-	size = cmp_cal_size_of_data(samples, data_type);
-	samples_get = cmp_input_size_to_samples(size, data_type);
-	TEST_ASSERT_EQUAL(samples, samples_get);
-
-	data_type = DATA_TYPE_IMAGETTE;
-	samples = 0;
-	size = cmp_cal_size_of_data(samples, data_type);
-	samples_get = cmp_input_size_to_samples(size, data_type);
-	TEST_ASSERT_EQUAL(samples, samples_get);
-
-	data_type = DATA_TYPE_S_FX_NCOB;
-	samples = 42;
-	size = cmp_cal_size_of_data(samples, data_type);
-	samples_get = cmp_input_size_to_samples(size, data_type);
-	TEST_ASSERT_EQUAL(samples, samples_get);
-
-	data_type = DATA_TYPE_S_FX_NCOB;
-	samples = 0;
-	size = cmp_cal_size_of_data(samples, data_type);
-	samples_get = cmp_input_size_to_samples(size, data_type);
-	TEST_ASSERT_EQUAL(samples, samples_get);
-
-	/* error cases */
-	data_type = DATA_TYPE_S_FX_NCOB;
-	size = COLLECTION_HDR_SIZE - 1;
-	samples_get = cmp_input_size_to_samples(size, data_type);
-	TEST_ASSERT_EQUAL(-1, samples_get);
-	data_type = DATA_TYPE_S_FX_NCOB;
-
-	size = COLLECTION_HDR_SIZE + 4*sizeof(struct s_fx_ncob) - 1;
-	samples_get = cmp_input_size_to_samples(size, data_type);
-	TEST_ASSERT_EQUAL(-1, samples_get);
-
-	data_type = DATA_TYPE_UNKNOWN;
-	size = 32;
-	samples_get = cmp_input_size_to_samples(size, data_type);
-	TEST_ASSERT_EQUAL(-1, samples_get);
-}
-
-
 static void check_endianness(void *data, uint16_t size, enum cmp_data_type data_type)
 {
 	int error;
diff --git a/test/cmp_entity/test_cmp_entity.c b/test/cmp_entity/test_cmp_entity.c
index cd2384c..de42607 100644
--- a/test/cmp_entity/test_cmp_entity.c
+++ b/test/cmp_entity/test_cmp_entity.c
@@ -1432,253 +1432,253 @@ void test_cmp_ent_get_cmp_data_size(void)
 
 void test_cmp_ent_write_rdcu_cmp_pars(void)
 {
-	int error;
-	uint32_t size;
-	struct cmp_entity *ent;
-	struct cmp_info info;
-	struct rdcu_cfg rcfg;
-
-	info.cmp_mode_used = CMP_MODE_DIFF_ZERO;
-	info.spill_used = 42;
-	info.golomb_par_used = 23;
-	info.samples_used = 9;
-	info.cmp_size = 96;
-	info.model_value_used = 6;
-	info.round_used = 1;
-	info.cmp_err = 0;
-
-	/* create a imagette compression entity */
-	size = cmp_ent_create(NULL, DATA_TYPE_IMAGETTE, info.cmp_mode_used == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-	ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_create(ent, DATA_TYPE_IMAGETTE, info.cmp_mode_used == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, NULL);
-	TEST_ASSERT_FALSE(error);
-
-	TEST_ASSERT_EQUAL_INT(DATA_TYPE_IMAGETTE, cmp_ent_get_data_type(ent));
-	TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_data_type_raw_bit(ent));
-	TEST_ASSERT_EQUAL_INT(12, cmp_ent_get_cmp_data_size(ent));
-
-	TEST_ASSERT_EQUAL_INT(cmp_cal_size_of_data(info.samples_used, DATA_TYPE_IMAGETTE), cmp_ent_get_original_size(ent));
-	TEST_ASSERT_EQUAL_INT(info.cmp_mode_used, cmp_ent_get_cmp_mode(ent));
-	TEST_ASSERT_EQUAL_INT(info.model_value_used, cmp_ent_get_model_value(ent));
-	TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_max_used_bits_version(ent));
-	TEST_ASSERT_EQUAL_INT(info.round_used, cmp_ent_get_lossy_cmp_par(ent));
-
-	TEST_ASSERT_EQUAL_INT(info.spill_used, cmp_ent_get_ima_spill(ent));
-	TEST_ASSERT_EQUAL_INT(info.golomb_par_used, cmp_ent_get_ima_golomb_par(ent));
-
-	free(ent);
-
-	/* raw mode test */
-	/* create a raw imagette compression entity */
-	info.cmp_mode_used = CMP_MODE_RAW;
-	size = cmp_ent_create(NULL, DATA_TYPE_IMAGETTE, info.cmp_mode_used == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-	ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_create(ent, DATA_TYPE_IMAGETTE, info.cmp_mode_used == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, NULL);
-	TEST_ASSERT_FALSE(error);
-
-	TEST_ASSERT_EQUAL_INT(DATA_TYPE_IMAGETTE, cmp_ent_get_data_type(ent));
-	TEST_ASSERT_EQUAL_INT(1, cmp_ent_get_data_type_raw_bit(ent));
-	TEST_ASSERT_EQUAL_INT(12, cmp_ent_get_cmp_data_size(ent));
-
-	TEST_ASSERT_EQUAL_INT(cmp_cal_size_of_data(info.samples_used, DATA_TYPE_IMAGETTE), cmp_ent_get_original_size(ent));
-	TEST_ASSERT_EQUAL_INT(info.cmp_mode_used, cmp_ent_get_cmp_mode(ent));
-	TEST_ASSERT_EQUAL_INT(info.model_value_used, cmp_ent_get_model_value(ent));
-	TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_max_used_bits_version(ent));
-	TEST_ASSERT_EQUAL_INT(info.round_used, cmp_ent_get_lossy_cmp_par(ent));
-
-	free(ent);
-
-	/* adaptive configuration */
-	info.cmp_mode_used = CMP_MODE_MODEL_MULTI;
-	rcfg.ap1_golomb_par = 0xFF;
-	rcfg.ap1_spill = 1;
-	rcfg.ap2_golomb_par = 0x32;
-	rcfg.ap2_spill = 201;
-
-	/* create a adaptive imagette compression entity */
-	size = cmp_ent_create(NULL, DATA_TYPE_IMAGETTE_ADAPTIVE, info.cmp_mode_used == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-	ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_create(ent, DATA_TYPE_IMAGETTE_ADAPTIVE, info.cmp_mode_used == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	TEST_ASSERT_EQUAL_INT(DATA_TYPE_IMAGETTE_ADAPTIVE, cmp_ent_get_data_type(ent));
-	TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_data_type_raw_bit(ent));
-	TEST_ASSERT_EQUAL_INT(12, cmp_ent_get_cmp_data_size(ent));
-
-	TEST_ASSERT_EQUAL_INT(cmp_cal_size_of_data(info.samples_used, DATA_TYPE_IMAGETTE_ADAPTIVE), cmp_ent_get_original_size(ent));
-	TEST_ASSERT_EQUAL_INT(info.cmp_mode_used, cmp_ent_get_cmp_mode(ent));
-	TEST_ASSERT_EQUAL_INT(info.model_value_used, cmp_ent_get_model_value(ent));
-	TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_max_used_bits_version(ent));
-	TEST_ASSERT_EQUAL_INT(info.round_used, cmp_ent_get_lossy_cmp_par(ent));
-
-	TEST_ASSERT_EQUAL_INT(info.spill_used, cmp_ent_get_ima_spill(ent));
-	TEST_ASSERT_EQUAL_INT(info.golomb_par_used, cmp_ent_get_ima_golomb_par(ent));
-	TEST_ASSERT_EQUAL_INT(rcfg.ap1_spill, cmp_ent_get_ima_ap1_spill(ent));
-	TEST_ASSERT_EQUAL_INT(rcfg.ap1_golomb_par, cmp_ent_get_ima_ap1_golomb_par(ent));
-	TEST_ASSERT_EQUAL_INT(rcfg.ap2_spill, cmp_ent_get_ima_ap2_spill(ent));
-	TEST_ASSERT_EQUAL_INT(rcfg.ap2_golomb_par, cmp_ent_get_ima_ap2_golomb_par(ent));
-
-
-	/** error cases **/
-
-	/* ent = NULL */
-	error = cmp_ent_write_rdcu_cmp_pars(NULL, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-
-	/* info = NULL */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, NULL, &rcfg);
-	TEST_ASSERT_TRUE(error);
-
-	/* cfg = NULL and adaptive data type */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, NULL);
-	TEST_ASSERT_TRUE(error);
-
-	/* compressed data are to big for the compression entity */
-	info.cmp_size = 12*8 + 1;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	info.cmp_size = 1;
-
-	/* wrong data_type */
-	cmp_ent_set_data_type(ent, DATA_TYPE_S_FX, 0);
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	cmp_ent_set_data_type(ent, DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE, 0);
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* original_size to high */
-	info.samples_used = 0x800000;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	info.samples_used = 0x7FFFFF;
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* cmp_mode to high */
-	info.cmp_mode_used = 0x100;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	info.cmp_mode_used = 0xFF;
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	TEST_ASSERT_EQUAL_INT(1, sizeof(info.model_value_used));
-	TEST_ASSERT_EQUAL_INT(1, sizeof(info.round_used));
+        int error;
+        uint32_t size;
+        struct cmp_entity *ent;
+        struct cmp_info info;
+        struct rdcu_cfg rcfg;
+
+        info.cmp_mode_used = CMP_MODE_DIFF_ZERO;
+        info.spill_used = 42;
+        info.golomb_par_used = 23;
+        info.samples_used = 9;
+        info.cmp_size = 96;
+        info.model_value_used = 6;
+        info.round_used = 1;
+        info.cmp_err = 0;
+
+        /* create a imagette compression entity */
+        size = cmp_ent_create(NULL, DATA_TYPE_IMAGETTE, info.cmp_mode_used == CMP_MODE_RAW, 12);
+        TEST_ASSERT_NOT_EQUAL_INT(0, size);
+        ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
+        size = cmp_ent_create(ent, DATA_TYPE_IMAGETTE, info.cmp_mode_used == CMP_MODE_RAW, 12);
+        TEST_ASSERT_NOT_EQUAL_INT(0, size);
+
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, NULL);
+        TEST_ASSERT_FALSE(error);
+
+        TEST_ASSERT_EQUAL_INT(DATA_TYPE_IMAGETTE, cmp_ent_get_data_type(ent));
+        TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_data_type_raw_bit(ent));
+        TEST_ASSERT_EQUAL_INT(12, cmp_ent_get_cmp_data_size(ent));
+
+        TEST_ASSERT_EQUAL_INT(info.samples_used * sizeof(uint16_t), cmp_ent_get_original_size(ent));
+        TEST_ASSERT_EQUAL_INT(info.cmp_mode_used, cmp_ent_get_cmp_mode(ent));
+        TEST_ASSERT_EQUAL_INT(info.model_value_used, cmp_ent_get_model_value(ent));
+        TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_max_used_bits_version(ent));
+        TEST_ASSERT_EQUAL_INT(info.round_used, cmp_ent_get_lossy_cmp_par(ent));
+
+        TEST_ASSERT_EQUAL_INT(info.spill_used, cmp_ent_get_ima_spill(ent));
+        TEST_ASSERT_EQUAL_INT(info.golomb_par_used, cmp_ent_get_ima_golomb_par(ent));
+
+        free(ent);
+
+        /* raw mode test */
+        /* create a raw imagette compression entity */
+        info.cmp_mode_used = CMP_MODE_RAW;
+        size = cmp_ent_create(NULL, DATA_TYPE_IMAGETTE, info.cmp_mode_used == CMP_MODE_RAW, 12);
+        TEST_ASSERT_NOT_EQUAL_INT(0, size);
+        ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
+        size = cmp_ent_create(ent, DATA_TYPE_IMAGETTE, info.cmp_mode_used == CMP_MODE_RAW, 12);
+        TEST_ASSERT_NOT_EQUAL_INT(0, size);
+
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, NULL);
+        TEST_ASSERT_FALSE(error);
+
+        TEST_ASSERT_EQUAL_INT(DATA_TYPE_IMAGETTE, cmp_ent_get_data_type(ent));
+        TEST_ASSERT_EQUAL_INT(1, cmp_ent_get_data_type_raw_bit(ent));
+        TEST_ASSERT_EQUAL_INT(12, cmp_ent_get_cmp_data_size(ent));
+
+        TEST_ASSERT_EQUAL_INT(info.samples_used * sizeof(uint16_t), cmp_ent_get_original_size(ent));
+        TEST_ASSERT_EQUAL_INT(info.cmp_mode_used, cmp_ent_get_cmp_mode(ent));
+        TEST_ASSERT_EQUAL_INT(info.model_value_used, cmp_ent_get_model_value(ent));
+        TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_max_used_bits_version(ent));
+        TEST_ASSERT_EQUAL_INT(info.round_used, cmp_ent_get_lossy_cmp_par(ent));
+
+        free(ent);
+
+        /* adaptive configuration */
+        info.cmp_mode_used = CMP_MODE_MODEL_MULTI;
+        rcfg.ap1_golomb_par = 0xFF;
+        rcfg.ap1_spill = 1;
+        rcfg.ap2_golomb_par = 0x32;
+        rcfg.ap2_spill = 201;
+
+        /* create a adaptive imagette compression entity */
+        size = cmp_ent_create(NULL, DATA_TYPE_IMAGETTE_ADAPTIVE, info.cmp_mode_used == CMP_MODE_RAW, 12);
+        TEST_ASSERT_NOT_EQUAL_INT(0, size);
+        ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
+        size = cmp_ent_create(ent, DATA_TYPE_IMAGETTE_ADAPTIVE, info.cmp_mode_used == CMP_MODE_RAW, 12);
+        TEST_ASSERT_NOT_EQUAL_INT(0, size);
+
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        TEST_ASSERT_EQUAL_INT(DATA_TYPE_IMAGETTE_ADAPTIVE, cmp_ent_get_data_type(ent));
+        TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_data_type_raw_bit(ent));
+        TEST_ASSERT_EQUAL_INT(12, cmp_ent_get_cmp_data_size(ent));
+
+        TEST_ASSERT_EQUAL_INT(info.samples_used * sizeof(uint16_t), cmp_ent_get_original_size(ent));
+        TEST_ASSERT_EQUAL_INT(info.cmp_mode_used, cmp_ent_get_cmp_mode(ent));
+        TEST_ASSERT_EQUAL_INT(info.model_value_used, cmp_ent_get_model_value(ent));
+        TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_max_used_bits_version(ent));
+        TEST_ASSERT_EQUAL_INT(info.round_used, cmp_ent_get_lossy_cmp_par(ent));
+
+        TEST_ASSERT_EQUAL_INT(info.spill_used, cmp_ent_get_ima_spill(ent));
+        TEST_ASSERT_EQUAL_INT(info.golomb_par_used, cmp_ent_get_ima_golomb_par(ent));
+        TEST_ASSERT_EQUAL_INT(rcfg.ap1_spill, cmp_ent_get_ima_ap1_spill(ent));
+        TEST_ASSERT_EQUAL_INT(rcfg.ap1_golomb_par, cmp_ent_get_ima_ap1_golomb_par(ent));
+        TEST_ASSERT_EQUAL_INT(rcfg.ap2_spill, cmp_ent_get_ima_ap2_spill(ent));
+        TEST_ASSERT_EQUAL_INT(rcfg.ap2_golomb_par, cmp_ent_get_ima_ap2_golomb_par(ent));
+
+
+        /** error cases **/
+
+        /* ent = NULL */
+        error = cmp_ent_write_rdcu_cmp_pars(NULL, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+
+        /* info = NULL */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, NULL, &rcfg);
+        TEST_ASSERT_TRUE(error);
+
+        /* cfg = NULL and adaptive data type */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, NULL);
+        TEST_ASSERT_TRUE(error);
+
+        /* compressed data are to big for the compression entity */
+        info.cmp_size = 12*8 + 1;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        info.cmp_size = 1;
+
+        /* wrong data_type */
+        cmp_ent_set_data_type(ent, DATA_TYPE_S_FX, 0);
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        cmp_ent_set_data_type(ent, DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE, 0);
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        /* original_size to high */
+        info.samples_used = 0x800000;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        info.samples_used = 0x7FFFFF;
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        /* cmp_mode to high */
+        info.cmp_mode_used = 0x100;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        info.cmp_mode_used = 0xFF;
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        TEST_ASSERT_EQUAL_INT(1, sizeof(info.model_value_used));
+        TEST_ASSERT_EQUAL_INT(1, sizeof(info.round_used));
 #if 0
-	/* max model_value to high */
-	info.model_value_used = 0x100;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &cfg);
-	TEST_ASSERT_TRUE(error);
-	info.model_value_used = 0xFF;
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &cfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* max lossy_cmp_par to high */
-	info.round = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	info.round = 0xFFFF;
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &cfg);
-	TEST_ASSERT_FALSE(error);
+        /* max model_value to high */
+        info.model_value_used = 0x100;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &cfg);
+        TEST_ASSERT_TRUE(error);
+        info.model_value_used = 0xFF;
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &cfg);
+        TEST_ASSERT_FALSE(error);
+
+        /* max lossy_cmp_par to high */
+        info.round = 0x10000;
+        error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
+        TEST_ASSERT_TRUE(error);
+        info.round = 0xFFFF;
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &cfg);
+        TEST_ASSERT_FALSE(error);
 #endif
 
-	/* spill to high */
-	info.spill_used = 0x10000;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	info.spill_used = 0xFFFF;
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* golomb_par to high */
-	info.golomb_par_used = 0x100;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	info.golomb_par_used = 0xFF;
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* adaptive 1 spill to high */
-	rcfg.ap1_spill = 0x10000;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	rcfg.ap1_spill = 0xFFFF;
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* adaptive 1  golomb_par to high */
-	rcfg.ap1_golomb_par = 0x100;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	rcfg.ap1_golomb_par = 0xFF;
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* adaptive 2 spill to high */
-	rcfg.ap2_spill = 0x10000;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	rcfg.ap2_spill = 0xFFFF;
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* adaptive 2  golomb_par to high */
-	rcfg.ap2_golomb_par = 0x100;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	rcfg.ap2_golomb_par = 0xFF;
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* The entity's raw data bit is not set, but the configuration contains raw data */
-	info.cmp_mode_used = CMP_MODE_RAW;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	info.cmp_mode_used = CMP_MODE_MODEL_MULTI;
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* The entity's raw data bit is set, but the configuration contains no raw data */
-	cmp_ent_set_data_type(ent, DATA_TYPE_IMAGETTE_ADAPTIVE, 1); /* set raw bit */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	cmp_ent_set_data_type(ent, DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE, 0);
-	/* this should work */
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* compression error set */
-	info.cmp_err = 1;
-	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
-	TEST_ASSERT_TRUE(error);
-	info.cmp_err = 0;
-
-	free(ent);
+        /* spill to high */
+        info.spill_used = 0x10000;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        info.spill_used = 0xFFFF;
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        /* golomb_par to high */
+        info.golomb_par_used = 0x100;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        info.golomb_par_used = 0xFF;
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        /* adaptive 1 spill to high */
+        rcfg.ap1_spill = 0x10000;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        rcfg.ap1_spill = 0xFFFF;
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        /* adaptive 1  golomb_par to high */
+        rcfg.ap1_golomb_par = 0x100;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        rcfg.ap1_golomb_par = 0xFF;
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        /* adaptive 2 spill to high */
+        rcfg.ap2_spill = 0x10000;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        rcfg.ap2_spill = 0xFFFF;
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        /* adaptive 2  golomb_par to high */
+        rcfg.ap2_golomb_par = 0x100;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        rcfg.ap2_golomb_par = 0xFF;
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        /* The entity's raw data bit is not set, but the configuration contains raw data */
+        info.cmp_mode_used = CMP_MODE_RAW;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        info.cmp_mode_used = CMP_MODE_MODEL_MULTI;
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        /* The entity's raw data bit is set, but the configuration contains no raw data */
+        cmp_ent_set_data_type(ent, DATA_TYPE_IMAGETTE_ADAPTIVE, 1); /* set raw bit */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        cmp_ent_set_data_type(ent, DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE, 0);
+        /* this should work */
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_FALSE(error);
+
+        /* compression error set */
+        info.cmp_err = 1;
+        error = cmp_ent_write_rdcu_cmp_pars(ent, &info, &rcfg);
+        TEST_ASSERT_TRUE(error);
+        info.cmp_err = 0;
+
+        free(ent);
 }
 
 
@@ -1793,148 +1793,6 @@ void test_cmp_ent_create(void)
 }
 
 
-/**
- * @test cmp_ent_build
- */
-
-void test_cmp_ent_build(void)
-{
-	size_t size;
-	struct cmp_entity *ent;
-	uint32_t version_id;
-	uint64_t start_time, end_time;
-	uint16_t model_id;
-	uint8_t model_counter;
-	struct cmp_cfg cfg;
-	int cmp_size_bits;
-	struct cmp_max_used_bits max_used_bits = {0};
-
-	/* set up max used bit version */
-	max_used_bits.version = 42;
-	cfg.max_used_bits = &max_used_bits;
-
-	version_id = 42;
-	start_time = 100;
-	end_time = 200;
-	model_id = 12;
-	model_counter = 23;
-	cfg.data_type = DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE;
-	cfg.cmp_mode = CMP_MODE_MODEL_MULTI;
-	cfg.model_value = 11;
-	cfg.round = 2;
-	cfg.samples = 9;
-	cfg.spill = MIN_IMA_SPILL;
-	cfg.golomb_par = MAX_IMA_GOLOMB_PAR;
-	cfg.ap1_spill = 555;
-	cfg.ap1_golomb_par = 14;
-	cfg.ap2_spill = 333;
-	cfg.ap2_golomb_par = 43;
-	cmp_size_bits = 60*8;
-
-	size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size);
-	ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size);
-
-	TEST_ASSERT_EQUAL_INT(version_id, cmp_ent_get_version_id(ent));
-	TEST_ASSERT_EQUAL_INT(60, cmp_ent_get_cmp_data_size(ent));
-	TEST_ASSERT_EQUAL_INT(cmp_cal_size_of_data(cfg.samples, cfg.data_type), cmp_ent_get_original_size(ent));
-	TEST_ASSERT_EQUAL_INT(start_time, cmp_ent_get_start_timestamp(ent));
-	TEST_ASSERT_EQUAL_INT(end_time, cmp_ent_get_end_timestamp(ent));
-	TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_data_type_raw_bit(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.data_type, cmp_ent_get_data_type(ent));
-
-	TEST_ASSERT_EQUAL_INT(cfg.cmp_mode, cmp_ent_get_cmp_mode(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.model_value, cmp_ent_get_model_value(ent));
-	TEST_ASSERT_EQUAL_INT(model_id, cmp_ent_get_model_id(ent));
-	TEST_ASSERT_EQUAL_INT(model_counter, cmp_ent_get_model_counter(ent));
-	TEST_ASSERT_EQUAL_INT(max_used_bits.version, cmp_ent_get_max_used_bits_version(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.round, cmp_ent_get_lossy_cmp_par(ent));
-
-	TEST_ASSERT_EQUAL_INT(cfg.spill, cmp_ent_get_ima_spill(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.golomb_par, cmp_ent_get_ima_golomb_par(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.ap1_spill, cmp_ent_get_ima_ap1_spill(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.ap1_golomb_par, cmp_ent_get_ima_ap1_golomb_par(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.ap2_spill, cmp_ent_get_ima_ap2_spill(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.ap2_golomb_par, cmp_ent_get_ima_ap2_golomb_par(ent));
-
-	/* entity size is smaller than */
-	cmp_size_bits = 2;
-	size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+cmp_bit_to_byte((unsigned int)cmp_size_bits), size);
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+cmp_bit_to_byte((unsigned int)cmp_size_bits), size);
-
-	/** error cases **/
-	/* cfg = NULL */
-	size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id,
-			     model_counter, NULL, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(0, size);
-
-	/* cmp_size_bits negative */
-	cmp_size_bits = -1;
-	size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(0, size);
-	cmp_size_bits = 60*8;
-
-	/* unknown data type */
-	cfg.data_type = DATA_TYPE_UNKNOWN;
-	size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(0, size);
-	cfg.data_type = DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE;
-
-#if 0
-	/* version id to high */
-	version_id = 0x100000000;
-	size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(0, size);
-#endif
-
-	/* start_time to high */
-	start_time = 0x1000000000000ULL;
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(0, size);
-	/* this should work */
-	start_time = 0xFFFFFFFFFFFFULL;
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size);
-
-	/* end_time to high */
-	end_time = 0x1000000000000ULL;
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(0, size);
-	/* this should work */
-	end_time = 0xFFFFFFFFFFFFULL;
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size);
-
-	/* golomb_par to high */
-	cfg.golomb_par = 0x100;
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(0, size);
-	/* this should work */
-	cfg.golomb_par = 0xFF;
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size);
-
-	free(ent);
-}
-
-
 /**
  * @test cmp_ent_create_timestamp
  */
@@ -1985,44 +1843,56 @@ void test_cmp_ent_print(void)
 {
 	size_t size;
 	struct cmp_entity *ent;
-	uint32_t version_id;
-	uint64_t start_time, end_time;
-	uint16_t model_id;
-	uint8_t model_counter;
-	struct cmp_cfg cfg = {0};
-	int cmp_size_bits;
-	struct cmp_max_used_bits max_used_bits = {0};
-
-	/* set up max used bit version */
-	max_used_bits.version = 42;
-	cfg.max_used_bits = &max_used_bits;
-
-	version_id = 42;
-	start_time = 100;
-	end_time = 200;
-	model_id = 12;
-	model_counter = 23;
-	cfg.data_type = DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE;
-	cfg.cmp_mode = CMP_MODE_MODEL_MULTI;
-	cfg.model_value = 11;
-	cfg.round = 2;
-	cfg.samples = 9;
-	cfg.spill = MIN_IMA_SPILL;
-	cfg.golomb_par = MAX_IMA_GOLOMB_PAR;
-	cfg.ap1_spill = 555;
-	cfg.ap1_golomb_par = 14;
-	cfg.ap2_spill = 333;
-	cfg.ap2_golomb_par = 43;
-	cmp_size_bits = 60*8;
-
-	size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
+
+	uint32_t version_id = 42;
+	uint64_t start_timestamp = 100;
+	uint64_t end_timestamp = 200;
+	uint16_t model_id = 12;
+	uint8_t model_counter = 23;
+	uint32_t data_type = DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE;
+	uint32_t cmp_mode = CMP_MODE_MODEL_MULTI;
+	uint32_t model_value_used = 11;
+	uint32_t lossy_cmp_par_used = 2;
+	uint32_t original_size = 18;
+	uint32_t spill = MIN_IMA_SPILL;
+	uint32_t golomb_par = MAX_IMA_GOLOMB_PAR;
+	uint32_t ap1_spill = 555;
+	uint32_t ap1_golomb_par = 14;
+	uint32_t ap2_spill = 333;
+	uint32_t ap2_golomb_par = 43;
+	uint32_t cmp_size_byte = 60;
+	uint8_t max_used_bits_version = 42;
+
+	size = cmp_ent_create(NULL, data_type, 0, cmp_size_byte);
 	TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size);
 	ent = calloc(1, size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
+	size = cmp_ent_create(ent, data_type, 0, cmp_size_byte);
 	TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size);
 
+	cmp_ent_set_version_id(ent, version_id);
+
+	cmp_ent_set_original_size(ent, original_size);
+
+	cmp_ent_set_start_timestamp(ent, start_timestamp);
+	cmp_ent_set_end_timestamp(ent, end_timestamp);
+
+	cmp_ent_set_cmp_mode(ent, cmp_mode);
+	cmp_ent_set_model_value(ent, model_value_used);
+	cmp_ent_set_model_id(ent, model_id);
+	cmp_ent_set_model_counter(ent, model_counter);
+	cmp_ent_set_max_used_bits_version(ent, max_used_bits_version);
+	cmp_ent_set_lossy_cmp_par(ent, lossy_cmp_par_used);
+
+	cmp_ent_set_ima_spill(ent, spill);
+	cmp_ent_set_ima_golomb_par(ent, golomb_par);
+
+	cmp_ent_set_ima_ap1_spill(ent, ap1_spill);
+	cmp_ent_set_ima_ap1_golomb_par(ent, ap1_golomb_par);
+
+	cmp_ent_set_ima_ap2_spill(ent, ap2_spill);
+	cmp_ent_set_ima_ap2_golomb_par(ent, ap2_golomb_par);
+
+
 	cmp_ent_print(ent);
 
 	/* error case */
@@ -2040,86 +1910,80 @@ void test_cmp_ent_parse(void)
 {
 	size_t size;
 	struct cmp_entity *ent;
-	uint32_t version_id;
-	uint64_t start_time, end_time;
-	uint16_t model_id;
-	uint8_t model_counter;
-	struct cmp_cfg cfg = {0};
-	int cmp_size_bits;
-	struct cmp_max_used_bits max_used_bits = {0};
-
-	/* set up max used bit version */
-	max_used_bits.version = 42;
-	cfg.max_used_bits = &max_used_bits;
-
-	version_id = 42;
-	start_time = 100;
-	end_time = 200;
-	model_id = 12;
-	model_counter = 23;
-	cfg.data_type = DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE;
-	cfg.cmp_mode = CMP_MODE_MODEL_MULTI;
-	cfg.model_value = 11;
-	cfg.round = 2;
-	cfg.samples = 9;
-	cfg.spill = MIN_IMA_SPILL;
-	cfg.golomb_par = MAX_IMA_GOLOMB_PAR;
-	cfg.ap1_spill = 555;
-	cfg.ap1_golomb_par = 14;
-	cfg.ap2_spill = 333;
-	cfg.ap2_golomb_par = 43;
-	cmp_size_bits = 60*8;
-
-	size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
+
+	uint32_t version_id = 42;
+	uint64_t start_timestamp = 100;
+	uint64_t end_timestamp = 200;
+	uint16_t model_id = 12;
+	uint8_t model_counter = 23;
+	uint32_t data_type = DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE;
+	uint32_t cmp_mode = CMP_MODE_MODEL_MULTI;
+	uint32_t model_value_used = 11;
+	uint32_t lossy_cmp_par_used = 2;
+	uint32_t original_size = 18;
+	uint32_t spill = MIN_IMA_SPILL;
+	uint32_t golomb_par = MAX_IMA_GOLOMB_PAR;
+	uint32_t ap1_spill = 555;
+	uint32_t ap1_golomb_par = 14;
+	uint32_t ap2_spill = 333;
+	uint32_t ap2_golomb_par = 43;
+	uint32_t cmp_size_byte = 60;
+	uint8_t max_used_bits_version = 42;
+
+	size = cmp_ent_create(NULL, data_type, 0, cmp_size_byte);
 	TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size);
 	ent = calloc(1, size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
+	size = cmp_ent_create(ent, data_type, 0, cmp_size_byte);
 	TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size);
 
-	cmp_ent_parse(ent);
+	cmp_ent_set_version_id(ent, version_id);
 
-	free(ent);
+	cmp_ent_set_original_size(ent, original_size);
 
+	cmp_ent_set_start_timestamp(ent, start_timestamp);
+	cmp_ent_set_end_timestamp(ent, end_timestamp);
 
-	cfg.data_type = DATA_TYPE_IMAGETTE;
-	size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(IMAGETTE_HEADER_SIZE+60, size);
-	ent = calloc(1, size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
+	cmp_ent_set_cmp_mode(ent, cmp_mode);
+	cmp_ent_set_model_value(ent, model_value_used);
+	cmp_ent_set_model_id(ent, model_id);
+	cmp_ent_set_model_counter(ent, model_counter);
+	cmp_ent_set_max_used_bits_version(ent, max_used_bits_version);
+	cmp_ent_set_lossy_cmp_par(ent, lossy_cmp_par_used);
+
+	cmp_ent_set_ima_spill(ent, spill);
+	cmp_ent_set_ima_golomb_par(ent, golomb_par);
+
+	cmp_ent_set_ima_ap1_spill(ent, ap1_spill);
+	cmp_ent_set_ima_ap1_golomb_par(ent, ap1_golomb_par);
+
+	cmp_ent_set_ima_ap2_spill(ent, ap2_spill);
+	cmp_ent_set_ima_ap2_golomb_par(ent, ap2_golomb_par);
+
+	cmp_ent_parse(ent);
+
+
+	data_type = DATA_TYPE_IMAGETTE;
+	size = cmp_ent_create(ent, data_type, 0, cmp_size_byte);
 	TEST_ASSERT_EQUAL_UINT(IMAGETTE_HEADER_SIZE+60, size);
 
 	cmp_ent_parse(ent);
 
-	free(ent);
 
-	cfg.data_type = DATA_TYPE_IMAGETTE;
-	cfg.cmp_mode = CMP_MODE_RAW;
+	data_type = DATA_TYPE_IMAGETTE;
+	cmp_mode = CMP_MODE_RAW;
 	version_id = 0x800F0003;
-	size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(GENERIC_HEADER_SIZE+60, size);
-	ent = calloc(1, size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
+	size = cmp_ent_create(ent, data_type, cmp_mode == CMP_MODE_RAW, cmp_size_byte);
 	TEST_ASSERT_EQUAL_UINT(GENERIC_HEADER_SIZE+60, size);
+	cmp_ent_set_version_id(ent, version_id);
+	cmp_ent_set_cmp_mode(ent, cmp_mode);
 
 	cmp_ent_parse(ent);
 
-	free(ent);
 
-	cfg.data_type = DATA_TYPE_CHUNK;
-	cfg.cmp_mode = CMP_MODE_MODEL_ZERO;
-	version_id = 0x800F0003;
-	size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
-	TEST_ASSERT_EQUAL_UINT(NON_IMAGETTE_HEADER_SIZE+60, size);
-	ent = calloc(1, size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_build(ent, version_id, start_time, end_time, model_id,
-			     model_counter, &cfg, cmp_size_bits);
+	data_type = DATA_TYPE_CHUNK;
+	cmp_mode = CMP_MODE_MODEL_ZERO;
+	cmp_ent_set_cmp_mode(ent, cmp_mode);
+	size = cmp_ent_create(ent, data_type, cmp_mode == CMP_MODE_RAW, cmp_size_byte);
 	TEST_ASSERT_EQUAL_UINT(NON_IMAGETTE_HEADER_SIZE+60, size);
 
 	cmp_ent_parse(ent);
diff --git a/test/decmp/test_decmp.c b/test/decmp/test_decmp.c
index a363784..4b40493 100644
--- a/test/decmp/test_decmp.c
+++ b/test/decmp/test_decmp.c
@@ -1049,649 +1049,6 @@ void test_decompress_imagette_model(void)
 }
 
 
-/**
- * @test cmp_ent_write_cmp_pars
- * @test cmp_ent_read_header
- */
-
-void test_cmp_ent_write_cmp_pars(void)
-{
-	int error;
-	struct cmp_entity *ent;
-	struct cmp_cfg cfg = {0}, cfg_read = {0};
-	int cmp_size_bits;
-	uint32_t size;
-	struct cmp_max_used_bits max_used_bits = MAX_USED_BITS_SAFE;
-
-	/* set up max used bit version */
-	max_used_bits.version = 42;
-	cmp_max_used_bits_list_add(&max_used_bits);
-
-	cmp_size_bits = 93;
-	/** RAW mode test **/
-	/* create imagette raw mode configuration */
-	cfg.data_type = DATA_TYPE_IMAGETTE;
-	cfg.cmp_mode = CMP_MODE_RAW;
-	cfg.model_value = 11;
-	cfg.round = 2;
-	cfg.samples = 9;
-	cfg.max_used_bits = cmp_max_used_bits_list_get(42);
-
-	/* create a compression entity */
-	size = cmp_ent_create(NULL, cfg.data_type, cfg.cmp_mode == CMP_MODE_RAW, cmp_cal_size_of_data(cfg.samples, cfg.data_type));
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-	ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_create(ent, cfg.data_type, cfg.cmp_mode == CMP_MODE_RAW, cmp_cal_size_of_data(cfg.samples, cfg.data_type));
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_FALSE(error);
-
-	TEST_ASSERT_EQUAL_INT(cfg.data_type, cmp_ent_get_data_type(ent));
-	TEST_ASSERT_EQUAL_INT(1, cmp_ent_get_data_type_raw_bit(ent));
-	TEST_ASSERT_EQUAL_INT(cmp_cal_size_of_data(cfg.samples, cfg.data_type), cmp_ent_get_cmp_data_size(ent));
-
-	TEST_ASSERT_EQUAL_INT(cmp_cal_size_of_data(cfg.samples, cfg.data_type), cmp_ent_get_original_size(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.cmp_mode, cmp_ent_get_cmp_mode(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.model_value, cmp_ent_get_model_value(ent));
-	TEST_ASSERT_EQUAL_INT(max_used_bits.version, cmp_ent_get_max_used_bits_version(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.round, cmp_ent_get_lossy_cmp_par(ent));
-
-	error = cmp_ent_read_header(ent, &cfg_read);
-	TEST_ASSERT_FALSE(error);
-	cfg.icu_output_buf = cmp_ent_get_data_buf(ent); /* quick fix that both cfg are equal */
-	cfg.buffer_length = 18; /* quick fix that both cfg are equal */
-	TEST_ASSERT_EQUAL_MEMORY(&cfg, &cfg_read, sizeof(struct cmp_cfg));
-
-	free(ent);
-	memset(&cfg, 0, sizeof(struct cmp_cfg));
-	memset(&cfg_read, 0, sizeof(struct cmp_cfg));
-
-	/** imagette test **/
-	/* create imagette mode configuration */
-	cfg.data_type = DATA_TYPE_IMAGETTE;
-	cfg.cmp_mode = CMP_MODE_MODEL_ZERO;
-	cfg.model_value = 11;
-	cfg.round = 2;
-	cfg.samples = 9;
-	cfg.spill = MIN_IMA_SPILL;
-	cfg.golomb_par = MAX_IMA_GOLOMB_PAR;
-	cfg.max_used_bits = cmp_max_used_bits_list_get(42);
-
-	/* create a compression entity */
-	size = cmp_ent_create(NULL, cfg.data_type, cfg.cmp_mode == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-	ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_create(ent, cfg.data_type, cfg.cmp_mode == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_FALSE(error);
-
-	TEST_ASSERT_EQUAL_INT(cfg.data_type, cmp_ent_get_data_type(ent));
-	TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_data_type_raw_bit(ent));
-	TEST_ASSERT_EQUAL_INT(12, cmp_ent_get_cmp_data_size(ent));
-
-	TEST_ASSERT_EQUAL_INT(cmp_cal_size_of_data(cfg.samples, cfg.data_type), cmp_ent_get_original_size(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.cmp_mode, cmp_ent_get_cmp_mode(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.model_value, cmp_ent_get_model_value(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.max_used_bits->version, cmp_ent_get_max_used_bits_version(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.round, cmp_ent_get_lossy_cmp_par(ent));
-
-	TEST_ASSERT_EQUAL_INT(cfg.spill, cmp_ent_get_ima_spill(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.golomb_par, cmp_ent_get_ima_golomb_par(ent));
-
-	error = cmp_ent_read_header(ent, &cfg_read);
-	TEST_ASSERT_FALSE(error);
-	cfg.icu_output_buf = cmp_ent_get_data_buf(ent); /* quick fix that both cfg are equal */
-	cfg.buffer_length = 12; /* quick fix that both cfg are equal */
-	TEST_ASSERT_EQUAL_MEMORY(&cfg, &cfg_read, sizeof(struct cmp_cfg));
-
-	free(ent);
-	memset(&cfg, 0, sizeof(struct cmp_cfg));
-	memset(&cfg_read, 0, sizeof(struct cmp_cfg));
-
-	/** adaptive imagette test **/
-	/* create a configuration */
-	cfg.data_type = DATA_TYPE_IMAGETTE_ADAPTIVE;
-	cfg.cmp_mode = CMP_MODE_MODEL_ZERO;
-	cfg.model_value = 11;
-	cfg.round = 2;
-	cfg.samples = 9;
-	cfg.spill = MIN_IMA_SPILL;
-	cfg.golomb_par = MAX_IMA_GOLOMB_PAR;
-	cfg.ap1_spill = 555;
-	cfg.ap1_golomb_par = 14;
-	cfg.ap2_spill = 333;
-	cfg.ap2_golomb_par = 43;
-	cfg.max_used_bits = NULL; /* no max_used_bits is set */
-
-	/* create a compression entity */
-	size = cmp_ent_create(NULL, cfg.data_type, cfg.cmp_mode == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-	ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_create(ent, cfg.data_type, cfg.cmp_mode == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_FALSE(error);
-
-	TEST_ASSERT_EQUAL_INT(cfg.data_type, cmp_ent_get_data_type(ent));
-	TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_data_type_raw_bit(ent));
-	TEST_ASSERT_EQUAL_INT(12, cmp_ent_get_cmp_data_size(ent));
-
-	TEST_ASSERT_EQUAL_INT(cmp_cal_size_of_data(cfg.samples, cfg.data_type), cmp_ent_get_original_size(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.cmp_mode, cmp_ent_get_cmp_mode(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.model_value, cmp_ent_get_model_value(ent));
-	/* zero is expected when max_used_bits = NULL */
-	TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_max_used_bits_version(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.round, cmp_ent_get_lossy_cmp_par(ent));
-
-	TEST_ASSERT_EQUAL_INT(cfg.spill, cmp_ent_get_ima_spill(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.golomb_par, cmp_ent_get_ima_golomb_par(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.ap1_spill, cmp_ent_get_ima_ap1_spill(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.ap1_golomb_par, cmp_ent_get_ima_ap1_golomb_par(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.ap2_spill, cmp_ent_get_ima_ap2_spill(ent));
-	TEST_ASSERT_EQUAL_INT(cfg.ap2_golomb_par, cmp_ent_get_ima_ap2_golomb_par(ent));
-
-	error = cmp_ent_read_header(ent, &cfg_read);
-	TEST_ASSERT_FALSE(error);
-	cfg.icu_output_buf = cmp_ent_get_data_buf(ent); /* quick fix that both cfg are equal */
-	cfg.buffer_length = 12; /* quick fix that both cfg are equal */
-	cfg.max_used_bits = &MAX_USED_BITS_SAFE;
-	TEST_ASSERT_EQUAL_MEMORY(&cfg, &cfg_read, sizeof(struct cmp_cfg));
-
-	free(ent);
-	memset(&cfg, 0, sizeof(struct cmp_cfg));
-	memset(&cfg_read, 0, sizeof(struct cmp_cfg));
-
-	/** Error Cases **/
-	/* create imagette raw mode configuration */
-	cfg.data_type = DATA_TYPE_IMAGETTE;
-	cfg.cmp_mode = CMP_MODE_MODEL_ZERO;
-	cfg.model_value = 11;
-	cfg.round = 2;
-	cfg.samples = 9;
-	cfg.max_used_bits = cmp_max_used_bits_list_get(42);
-
-	/* create a compression entity */
-	size = cmp_ent_create(NULL, cfg.data_type, cfg.cmp_mode == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-	ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_create(ent, cfg.data_type, cfg.cmp_mode == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-
-
-	/* ent = NULL */
-	error = cmp_ent_write_cmp_pars(NULL, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-
-	/* cfg = NULL */
-	error = cmp_ent_write_cmp_pars(ent, NULL, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-
-	/* cmp_size_bits negative */
-	error = cmp_ent_write_cmp_pars(ent, &cfg, -1);
-	TEST_ASSERT_TRUE(error);
-
-	/* data_type mismatch */
-	cfg.data_type = DATA_TYPE_S_FX;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.data_type = DATA_TYPE_IMAGETTE;
-
-	/* compressed data to big for compression entity */
-	error = cmp_ent_write_cmp_pars(ent, &cfg, 97);
-	TEST_ASSERT_TRUE(error);
-
-	/* original_size to high */
-	cfg.samples = 0x800000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.samples = 0x7FFFFF;
-
-	/* cmp_mode to high */
-	cfg.cmp_mode = 0x100;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_mode = 0xFF;
-
-	/* max model_value to high */
-	cfg.model_value = 0x100;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.model_value = 0xFF;
-
-	/*  max used bit version to high */
-	TEST_ASSERT_EQUAL_INT(1, sizeof(max_used_bits.version));
-
-	/* max lossy_cmp_par to high */
-	cfg.round = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.round = 0xFFFF;
-
-	/* The entity's raw data bit is not set, but the configuration contains raw data */
-	cfg.cmp_mode = CMP_MODE_RAW;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_mode = CMP_MODE_MODEL_MULTI;
-
-	/* The entity's raw data bit is set, but the configuration contains no raw data */
-	cmp_ent_set_data_type(ent, cfg.data_type, 1); /* set raw bit */
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cmp_ent_set_data_type(ent, cfg.data_type, 0);
-
-	/* spill to high */
-	cfg.spill = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill = 0xFFFF;
-
-	/* golomb_par to high */
-	cfg.golomb_par = 0x100;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.golomb_par = 0xFF;
-
-
-	cmp_ent_set_data_type(ent, DATA_TYPE_SAT_IMAGETTE_ADAPTIVE, 0);
-	cfg.data_type = DATA_TYPE_SAT_IMAGETTE_ADAPTIVE;
-	cmp_size_bits = 1;
-	/* adaptive 1 spill to high */
-	cfg.ap1_spill = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.ap1_spill = 0xFFFF;
-
-	/* adaptive 1  golomb_par to high */
-	cfg.ap1_golomb_par = 0x100;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.ap1_golomb_par = 0xFF;
-
-	/* adaptive 2 spill to high */
-	cfg.ap2_spill = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.ap2_spill = 0xFFFF;
-
-	/* adaptive 2  golomb_par to high */
-	cfg.ap2_golomb_par = 0x100;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.ap2_golomb_par = 0xFF;
-
-	cmp_ent_set_data_type(ent, DATA_TYPE_OFFSET, 0);
-	cfg.data_type = DATA_TYPE_OFFSET;
-
-	free(ent);
-
-	/* create a compression entity */
-	cfg.data_type = DATA_TYPE_F_CAM_BACKGROUND;
-	cfg.samples = 9;
-	size = cmp_ent_create(NULL, cfg.data_type, cfg.cmp_mode == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-	ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_create(ent, cfg.data_type, cfg.cmp_mode == CMP_MODE_RAW, 12);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-
-	/* mean cmp_par to high */
-	cfg.cmp_par_background_mean = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_background_mean = 0xFFFF;
-
-	/* mean spill to high */
-	cfg.spill_background_mean = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_background_mean = 0xFFFFFF;
-
-	/* variance cmp_par to high */
-	cfg.cmp_par_background_variance = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_background_variance = 0xFFFF;
-
-	/* variance spill to high */
-	cfg.spill_background_variance = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_background_variance = 0xFFFFFF;
-
-	/* pixels_error cmp_par to high */
-	cfg.cmp_par_background_pixels_error = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_background_pixels_error = 0xFFFF;
-
-	/* pixels_error spill to high */
-	cfg.spill_background_pixels_error = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_background_pixels_error = 0xFFFFFF;
-
-
-	cmp_ent_set_data_type(ent, DATA_TYPE_F_FX_EFX_NCOB_ECOB, 0);
-	cfg.data_type = DATA_TYPE_F_FX_EFX_NCOB_ECOB;
-
-	/* exp_flags cmp_par to high */
-	cfg.cmp_par_exp_flags = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_exp_flags = 0xFFFF;
-
-	/* exp_flags spill to high */
-	cfg.spill_exp_flags = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_exp_flags = 0xFFFFFF;
-
-	/* fx cmp_par to high */
-	cfg.cmp_par_fx = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_fx = 0xFFFF;
-
-	/* fx spill to high */
-	cfg.spill_fx = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_fx = 0xFFFFFF;
-
-	/* ncob cmp_par to high */
-	cfg.cmp_par_ncob = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_ncob = 0xFFFF;
-
-	/* ncob spill to high */
-	cfg.spill_ncob = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_ncob = 0xFFFFFF;
-
-	/* efx cmp_par to high */
-	cfg.cmp_par_efx = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_efx = 0xFFFF;
-
-	/* efx spill to high */
-	cfg.spill_efx = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_efx = 0xFFFFFF;
-
-	/* ecob cmp_par to high */
-	cfg.cmp_par_ecob = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_ecob = 0xFFFF;
-
-	/* ecob spill to high */
-	cfg.spill_ecob = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_ecob = 0xFFFFFF;
-
-	/* fx_cob_variance cmp_par to high */
-	cfg.cmp_par_fx_cob_variance = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_fx_cob_variance = 0xFFFF;
-
-	/* fx_cob_variance spill to high */
-	cfg.spill_fx_cob_variance = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_fx_cob_variance = 0xFFFFFF;
-
-	/* test data type = DATA_TYPE_UNKNOWN */
-	cmp_ent_set_data_type(ent, DATA_TYPE_UNKNOWN, 0);
-	cfg.data_type = DATA_TYPE_UNKNOWN;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-
-	/* test data type = DATA_TYPE_F_CAM_BACKGROUND +1 */
-	cmp_ent_set_data_type(ent, DATA_TYPE_F_CAM_BACKGROUND + 10, 0);
-	cfg.data_type = DATA_TYPE_F_CAM_BACKGROUND + 10;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	free(ent);
-	cmp_max_used_bits_list_empty();
-}
-
-
-/**
- * @test cmp_ent_read_header
- */
-
-void test_cmp_ent_read_header_error_cases(void)
-{
-	int error;
-	uint32_t size;
-	struct cmp_entity *ent;
-	struct cmp_cfg cfg;
-	int cmp_size_bits = 10*8;
-
-	/* create a imagette entity */
-	size = cmp_ent_create(NULL, DATA_TYPE_IMAGETTE, 0, 10);
-	/* created size smaller than max entity size -> returns max entity size */
-	TEST_ASSERT_EQUAL_UINT32(sizeof(struct cmp_entity), size);
-	ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_create(ent, DATA_TYPE_IMAGETTE, 0, 10);
-	TEST_ASSERT_EQUAL_UINT32(sizeof(struct cmp_entity), size);
-	error = cmp_ent_set_cmp_mode(ent, CMP_MODE_DIFF_ZERO);
-	TEST_ASSERT_FALSE(error);
-
-	/* ent = NULL */
-	error = cmp_ent_read_header(NULL, &cfg);
-	TEST_ASSERT_TRUE(error);
-	/* this should work */
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* cfg = NULL */
-	error = cmp_ent_read_header(ent, NULL);
-	TEST_ASSERT_TRUE(error);
-	/* this should work */
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* unknown data type */
-	cmp_ent_set_data_type(ent, DATA_TYPE_UNKNOWN, 0);
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_TRUE(error);
-	cmp_ent_set_data_type(ent, (enum cmp_data_type)1000, 0);
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_TRUE(error);
-	/* unknown data type */
-	cmp_ent_set_data_type(ent, DATA_TYPE_F_CAM_BACKGROUND+1, 0);
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_TRUE(error);
-	/* this should work */
-	cmp_ent_set_data_type(ent, DATA_TYPE_IMAGETTE, 0);
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* original_size and data product type not compatible */
-	cmp_ent_set_original_size(ent, 11);
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_TRUE(error);
-
-	/* this should work */
-	cmp_ent_set_original_size(ent, 12);
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_FALSE(error);
-
-
-	/* create a raw entity */
-	size = cmp_ent_create(ent, DATA_TYPE_IMAGETTE, 1, 10);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-
-	/* mean cmp_par to high */
-	cfg.cmp_par_background_mean = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_background_mean = 0xFFFF;
-
-	/* mean spill to high */
-	cfg.spill_background_mean = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_background_mean = 0xFFFFFF;
-
-	/* variance cmp_par to high */
-	cfg.cmp_par_background_variance = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_background_variance = 0xFFFF;
-
-	/* variance spill to high */
-	cfg.spill_background_variance = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_background_variance = 0xFFFFFF;
-
-	/* pixels_error cmp_par to high */
-	cfg.cmp_par_background_pixels_error = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_background_pixels_error = 0xFFFF;
-
-	/* pixels_error spill to high */
-	cfg.spill_background_pixels_error = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_background_pixels_error = 0xFFFFFF;
-
-
-	cmp_ent_set_data_type(ent, DATA_TYPE_F_FX_EFX_NCOB_ECOB, 0);
-	cfg.data_type = DATA_TYPE_F_FX_EFX_NCOB_ECOB;
-
-	/* exp_flags cmp_par to high */
-	cfg.cmp_par_exp_flags = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_exp_flags = 0xFFFF;
-
-	/* exp_flags spill to high */
-	cfg.spill_exp_flags = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_exp_flags = 0xFFFFFF;
-
-	/* fx cmp_par to high */
-	cfg.cmp_par_fx = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_fx = 0xFFFF;
-
-	/* fx spill to high */
-	cfg.spill_fx = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_fx = 0xFFFFFF;
-
-	/* ncob cmp_par to high */
-	cfg.cmp_par_ncob = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_ncob = 0xFFFF;
-
-	/* ncob spill to high */
-	cfg.spill_ncob = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_ncob = 0xFFFFFF;
-
-	/* efx cmp_par to high */
-	cfg.cmp_par_efx = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_efx = 0xFFFF;
-
-	/* efx spill to high */
-	cfg.spill_efx = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_efx = 0xFFFFFF;
-
-	/* ecob cmp_par to high */
-	cfg.cmp_par_ecob = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_ecob = 0xFFFF;
-
-	/* ecob spill to high */
-	cfg.spill_ecob = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_ecob = 0xFFFFFF;
-
-	/* fx_cob_variance cmp_par to high */
-	cfg.cmp_par_fx_cob_variance = 0x10000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.cmp_par_fx_cob_variance = 0xFFFF;
-
-	/* fx_cob_variance spill to high */
-	cfg.spill_fx_cob_variance = 0x1000000;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	cfg.spill_fx_cob_variance = 0xFFFFFF;
-
-	/* test data type = DATA_TYPE_UNKNOWN */
-	cmp_ent_set_data_type(ent, DATA_TYPE_UNKNOWN, 0);
-	cfg.data_type = DATA_TYPE_UNKNOWN;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-
-	/* test data type = DATA_TYPE_F_CAM_BACKGROUND +1 */
-	cmp_ent_set_data_type(ent, DATA_TYPE_F_CAM_BACKGROUND + 1, 0);
-	cfg.data_type = DATA_TYPE_F_CAM_BACKGROUND + 1;
-	error = cmp_ent_write_cmp_pars(ent, &cfg, cmp_size_bits);
-	TEST_ASSERT_TRUE(error);
-	free(ent);
-	ent = NULL;
-	cmp_max_used_bits_list_empty();
-
-
-	/* create a imagette entity */
-	size = cmp_ent_create(NULL, DATA_TYPE_IMAGETTE, 1, 10);
-	ent = malloc(size); TEST_ASSERT_NOT_NULL(ent);
-	size = cmp_ent_create(ent, DATA_TYPE_IMAGETTE, 1, 10);
-	TEST_ASSERT_NOT_EQUAL_INT(0, size);
-	cmp_ent_set_cmp_mode(ent, CMP_MODE_RAW);
-	cmp_ent_set_original_size(ent, 10);
-
-	/* this should work */
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* cmp_mode CMP_MODE_RAW and no raw data bit */
-	cmp_ent_set_data_type(ent, DATA_TYPE_IMAGETTE, 0);
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_TRUE(error);
-
-	/* this should work */
-	cmp_ent_set_data_type(ent, DATA_TYPE_IMAGETTE, 1);
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_FALSE(error);
-
-	/* cmp_mode CMP_MODE_RAW cmp_data_size != original_size */
-	cmp_ent_set_data_type(ent, DATA_TYPE_IMAGETTE, 0);
-	cmp_ent_set_original_size(ent, 8);
-	error = cmp_ent_read_header(ent, &cfg);
-	TEST_ASSERT_TRUE(error);
-
-	free(ent);
-}
-
-
 /**
  * @test decompress_cmp_entiy
  */
-- 
GitLab