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

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
parent 6456189e
Branches
Tags
1 merge request!34Update cmp_tool to version v0.13
/**
* @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();
}
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_src = files([
'example_cmp_rdcu.c' 'example_cmp_rdcu.c'
]) ])
......
...@@ -590,67 +590,6 @@ size_t size_of_a_sample(enum cmp_data_type data_type) ...@@ -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) static uint32_t be24_to_cpu(uint32_t a)
{ {
return be32_to_cpu(a) >> 8; return be32_to_cpu(a) >> 8;
......
...@@ -327,8 +327,6 @@ enum cmp_data_type convert_subservice_to_cmp_data_type(uint8_t subservice); ...@@ -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); 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); 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 */ /* endianness functions */
......
...@@ -1782,146 +1782,6 @@ uint32_t cmp_ent_get_cmp_data_size(const struct cmp_entity *ent) ...@@ -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 * @brief write the parameters from the RDCU decompression information structure
* in the compression entity header * 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 ...@@ -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 */ /* 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; return -1;
if (cmp_ent_set_cmp_mode(ent, info->cmp_mode_used)) if (cmp_ent_set_cmp_mode(ent, info->cmp_mode_used))
return -1; return -1;
...@@ -2064,60 +1924,6 @@ uint32_t cmp_ent_create(struct cmp_entity *ent, enum cmp_data_type data_type, ...@@ -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 #ifdef HAS_TIME_H
/* /*
* @brief Convert a calendar time expressed as a struct tm object to time since * @brief Convert a calendar time expressed as a struct tm object to time since
......
...@@ -155,18 +155,6 @@ compile_time_assert(sizeof(struct cmp_entity) == NON_IMAGETTE_HEADER_SIZE, CMP_E ...@@ -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, uint32_t cmp_ent_create(struct cmp_entity *ent, enum cmp_data_type data_type,
int raw_mode_flag, uint32_t cmp_size_byte); 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 * write the parameters from the RDCU decompression information structure in the
* compression entity header * compression entity header
......
...@@ -1990,14 +1990,14 @@ static int cmp_ent_read_header(struct cmp_entity *ent, struct cmp_cfg *cfg) ...@@ -1990,14 +1990,14 @@ static int cmp_ent_read_header(struct cmp_entity *ent, struct cmp_cfg *cfg)
return -1; return -1;
} }
} else { } 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) { if (org_size % sizeof(uint16_t)) {
debug_print("Error: original_size and data product type in the compression header are not compatible."); debug_print("Error: The original size of an imagette product type in the compression header must be a multiple of 2.");
cfg->samples = 0; cfg->samples = 0;
return -1; return -1;
} }
cfg->samples = (uint32_t)samples; cfg->samples = org_size/sizeof(uint16_t);
} }
cfg->icu_output_buf = cmp_ent_get_data_buf(ent); 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, ...@@ -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.data_type != DATA_TYPE_CHUNK) { /* perform a non-chunk decompression */
if (cfg.cmp_mode == CMP_MODE_RAW) { 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) { if (decompressed_data) {
memcpy(decompressed_data, cmp_ent_get_data_buf(ent), data_size); memcpy(decompressed_data, cmp_ent_get_data_buf(ent), data_size);
......
...@@ -588,7 +588,7 @@ static int guess_cmp_pars(struct rdcu_cfg *rcfg, const char *guess_cmp_mode, ...@@ -588,7 +588,7 @@ static int guess_cmp_pars(struct rdcu_cfg *rcfg, const char *guess_cmp_mode,
return -1; return -1;
printf("DONE\n"); 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); printf("Guessed parameters can compress the data with a CR of %.2f.\n", cr);
return 0; return 0;
......
...@@ -206,92 +206,6 @@ void test_size_of_a_sample(void) ...@@ -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) static void check_endianness(void *data, uint16_t size, enum cmp_data_type data_type)
{ {
int error; int error;
......
...@@ -1461,7 +1461,7 @@ void test_cmp_ent_write_rdcu_cmp_pars(void) ...@@ -1461,7 +1461,7 @@ void test_cmp_ent_write_rdcu_cmp_pars(void)
TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_data_type_raw_bit(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(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.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.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(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(0, cmp_ent_get_max_used_bits_version(ent));
...@@ -1488,7 +1488,7 @@ void test_cmp_ent_write_rdcu_cmp_pars(void) ...@@ -1488,7 +1488,7 @@ void test_cmp_ent_write_rdcu_cmp_pars(void)
TEST_ASSERT_EQUAL_INT(1, cmp_ent_get_data_type_raw_bit(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(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.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.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(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(0, cmp_ent_get_max_used_bits_version(ent));
...@@ -1517,7 +1517,7 @@ void test_cmp_ent_write_rdcu_cmp_pars(void) ...@@ -1517,7 +1517,7 @@ void test_cmp_ent_write_rdcu_cmp_pars(void)
TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_data_type_raw_bit(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(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.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.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(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(0, cmp_ent_get_max_used_bits_version(ent));
...@@ -1793,148 +1793,6 @@ void test_cmp_ent_create(void) ...@@ -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 * @test cmp_ent_create_timestamp
*/ */
...@@ -1985,44 +1843,56 @@ void test_cmp_ent_print(void) ...@@ -1985,44 +1843,56 @@ void test_cmp_ent_print(void)
{ {
size_t size; size_t size;
struct cmp_entity *ent; struct cmp_entity *ent;
uint32_t version_id;
uint64_t start_time, end_time; uint32_t version_id = 42;
uint16_t model_id; uint64_t start_timestamp = 100;
uint8_t model_counter; uint64_t end_timestamp = 200;
struct cmp_cfg cfg = {0}; uint16_t model_id = 12;
int cmp_size_bits; uint8_t model_counter = 23;
struct cmp_max_used_bits max_used_bits = {0}; uint32_t data_type = DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE;
uint32_t cmp_mode = CMP_MODE_MODEL_MULTI;
/* set up max used bit version */ uint32_t model_value_used = 11;
max_used_bits.version = 42; uint32_t lossy_cmp_par_used = 2;
cfg.max_used_bits = &max_used_bits; uint32_t original_size = 18;
uint32_t spill = MIN_IMA_SPILL;
version_id = 42; uint32_t golomb_par = MAX_IMA_GOLOMB_PAR;
start_time = 100; uint32_t ap1_spill = 555;
end_time = 200; uint32_t ap1_golomb_par = 14;
model_id = 12; uint32_t ap2_spill = 333;
model_counter = 23; uint32_t ap2_golomb_par = 43;
cfg.data_type = DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE; uint32_t cmp_size_byte = 60;
cfg.cmp_mode = CMP_MODE_MODEL_MULTI; uint8_t max_used_bits_version = 42;
cfg.model_value = 11;
cfg.round = 2; size = cmp_ent_create(NULL, data_type, 0, cmp_size_byte);
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); TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size);
ent = calloc(1, size); TEST_ASSERT_NOT_NULL(ent); ent = calloc(1, size); TEST_ASSERT_NOT_NULL(ent);
size = cmp_ent_build(ent, version_id, start_time, end_time, model_id, size = cmp_ent_create(ent, data_type, 0, cmp_size_byte);
model_counter, &cfg, cmp_size_bits);
TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size); 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); cmp_ent_print(ent);
/* error case */ /* error case */
...@@ -2040,86 +1910,80 @@ void test_cmp_ent_parse(void) ...@@ -2040,86 +1910,80 @@ void test_cmp_ent_parse(void)
{ {
size_t size; size_t size;
struct cmp_entity *ent; struct cmp_entity *ent;
uint32_t version_id;
uint64_t start_time, end_time; uint32_t version_id = 42;
uint16_t model_id; uint64_t start_timestamp = 100;
uint8_t model_counter; uint64_t end_timestamp = 200;
struct cmp_cfg cfg = {0}; uint16_t model_id = 12;
int cmp_size_bits; uint8_t model_counter = 23;
struct cmp_max_used_bits max_used_bits = {0}; uint32_t data_type = DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE;
uint32_t cmp_mode = CMP_MODE_MODEL_MULTI;
/* set up max used bit version */ uint32_t model_value_used = 11;
max_used_bits.version = 42; uint32_t lossy_cmp_par_used = 2;
cfg.max_used_bits = &max_used_bits; uint32_t original_size = 18;
uint32_t spill = MIN_IMA_SPILL;
version_id = 42; uint32_t golomb_par = MAX_IMA_GOLOMB_PAR;
start_time = 100; uint32_t ap1_spill = 555;
end_time = 200; uint32_t ap1_golomb_par = 14;
model_id = 12; uint32_t ap2_spill = 333;
model_counter = 23; uint32_t ap2_golomb_par = 43;
cfg.data_type = DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE; uint32_t cmp_size_byte = 60;
cfg.cmp_mode = CMP_MODE_MODEL_MULTI; uint8_t max_used_bits_version = 42;
cfg.model_value = 11;
cfg.round = 2; size = cmp_ent_create(NULL, data_type, 0, cmp_size_byte);
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); TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size);
ent = calloc(1, size); TEST_ASSERT_NOT_NULL(ent); ent = calloc(1, size); TEST_ASSERT_NOT_NULL(ent);
size = cmp_ent_build(ent, version_id, start_time, end_time, model_id, size = cmp_ent_create(ent, data_type, 0, cmp_size_byte);
model_counter, &cfg, cmp_size_bits);
TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size); 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; cmp_ent_set_cmp_mode(ent, cmp_mode);
size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id, cmp_ent_set_model_value(ent, model_value_used);
model_counter, &cfg, cmp_size_bits); cmp_ent_set_model_id(ent, model_id);
TEST_ASSERT_EQUAL_UINT(IMAGETTE_HEADER_SIZE+60, size); cmp_ent_set_model_counter(ent, model_counter);
ent = calloc(1, size); TEST_ASSERT_NOT_NULL(ent); cmp_ent_set_max_used_bits_version(ent, max_used_bits_version);
size = cmp_ent_build(ent, version_id, start_time, end_time, model_id, cmp_ent_set_lossy_cmp_par(ent, lossy_cmp_par_used);
model_counter, &cfg, cmp_size_bits);
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); TEST_ASSERT_EQUAL_UINT(IMAGETTE_HEADER_SIZE+60, size);
cmp_ent_parse(ent); cmp_ent_parse(ent);
free(ent);
cfg.data_type = DATA_TYPE_IMAGETTE; data_type = DATA_TYPE_IMAGETTE;
cfg.cmp_mode = CMP_MODE_RAW; cmp_mode = CMP_MODE_RAW;
version_id = 0x800F0003; version_id = 0x800F0003;
size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id, size = cmp_ent_create(ent, data_type, cmp_mode == CMP_MODE_RAW, cmp_size_byte);
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);
TEST_ASSERT_EQUAL_UINT(GENERIC_HEADER_SIZE+60, size); 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); cmp_ent_parse(ent);
free(ent);
cfg.data_type = DATA_TYPE_CHUNK; data_type = DATA_TYPE_CHUNK;
cfg.cmp_mode = CMP_MODE_MODEL_ZERO; cmp_mode = CMP_MODE_MODEL_ZERO;
version_id = 0x800F0003; cmp_ent_set_cmp_mode(ent, cmp_mode);
size = cmp_ent_build(NULL, version_id, start_time, end_time, model_id, size = cmp_ent_create(ent, data_type, cmp_mode == CMP_MODE_RAW, cmp_size_byte);
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);
TEST_ASSERT_EQUAL_UINT(NON_IMAGETTE_HEADER_SIZE+60, size); TEST_ASSERT_EQUAL_UINT(NON_IMAGETTE_HEADER_SIZE+60, size);
cmp_ent_parse(ent); cmp_ent_parse(ent);
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment