diff --git a/lib/common/cmp_entity.c b/lib/common/cmp_entity.c index 4a710d63457a4b716e659478c3a8df0b35bbdf33..644a7e911ed99feb176952e14e521b68eb9ecbca 100644 --- a/lib/common/cmp_entity.c +++ b/lib/common/cmp_entity.c @@ -446,21 +446,20 @@ int cmp_ent_set_model_counter(struct cmp_entity *ent, uint32_t model_counter) /** - * @brief set version identifier for the maximum used bits registry in the - * compression entity header + * @brief set reserved field in the compression entity header * - * @param ent pointer to a compression entity - * @param max_used_bits_version the identifier for the maximum used bits registry + * @param ent pointer to a compression entity + * @param reserved intentionally reserved * * @returns 0 on success, otherwise error */ -int cmp_ent_set_max_used_bits_version(struct cmp_entity *ent, uint8_t max_used_bits_version) +int cmp_ent_set_reserved(struct cmp_entity *ent, uint8_t reserved) { if (!ent) return -1; - ent->max_used_bits_version = max_used_bits_version; + ent->reserved = reserved; return 0; } @@ -1239,21 +1238,19 @@ uint8_t cmp_ent_get_model_counter(const struct cmp_entity *ent) /** - * @brief get the version identifier for the maximum used bits registry from the - * compression entity header + * @brief get the reserved field from the compression entity header * * @param ent pointer to a compression entity * - * @returns the version identifier for the maximum used bits registry on success, - * 0 on error + * @returns the reserved filed on success, 0 on error */ -uint8_t cmp_ent_get_max_used_bits_version(const struct cmp_entity *ent) +uint8_t cmp_ent_get_reserved(const struct cmp_entity *ent) { if (!ent) return 0; - return ent->max_used_bits_version; + return ent->reserved; } @@ -1840,9 +1837,8 @@ int cmp_ent_write_rdcu_cmp_pars(struct cmp_entity *ent, const struct cmp_info *i if (cmp_ent_set_cmp_mode(ent, info->cmp_mode_used)) return -1; cmp_ent_set_model_value(ent, info->model_value_used); - /* The RDCU data compressor does not have the maximum used bit feature, - * so the field is set to 0. */ - cmp_ent_set_max_used_bits_version(ent, 0); + + cmp_ent_set_reserved(ent, 0); cmp_ent_set_lossy_cmp_par(ent, info->round_used); @@ -2078,7 +2074,7 @@ void cmp_ent_print(struct cmp_entity *ent) static void cmp_ent_parse_generic_header(const struct cmp_entity *ent) { MAYBE_UNUSED uint32_t version_id, cmp_ent_size, original_size, cmp_mode_used, - model_value_used, model_id, model_counter, max_used_bits_version, + model_value_used, model_id, model_counter, reserved, lossy_cmp_par_used, start_coarse_time, end_coarse_time; MAYBE_UNUSED uint16_t start_fine_time, end_fine_time; MAYBE_UNUSED enum cmp_data_type data_type; @@ -2140,8 +2136,8 @@ static void cmp_ent_parse_generic_header(const struct cmp_entity *ent) model_counter = cmp_ent_get_model_counter(ent); debug_print("Model Counter: %" PRIu32, model_counter); - max_used_bits_version = cmp_ent_get_max_used_bits_version(ent); - debug_print("Maximum Used Bits Registry Version: %" PRIu32, max_used_bits_version); + reserved = cmp_ent_get_reserved(ent); + debug_print("Reserved Field: %" PRIu32, reserved); lossy_cmp_par_used = cmp_ent_get_lossy_cmp_par(ent); debug_print("Used Lossy Compression Parameters: %" PRIu32, lossy_cmp_par_used); diff --git a/lib/common/cmp_entity.h b/lib/common/cmp_entity.h index 909a3bc7216202d8d9afcce004cf4545438030d7..8a839d9d49c953ab158eed9a0b7ebc154ff68f5e 100644 --- a/lib/common/cmp_entity.h +++ b/lib/common/cmp_entity.h @@ -137,7 +137,7 @@ struct cmp_entity { uint8_t model_value_used; /**< used Model Updating Weighing Value */ uint16_t model_id; /**< Model ID */ uint8_t model_counter; /**< Model Counter */ - uint8_t max_used_bits_version; + uint8_t reserved; uint16_t lossy_cmp_par_used; /**< used Lossy Compression Parameters */ union { /* specific Compression Entity Header for the different Data Product Types */ struct imagette_header ima; @@ -183,7 +183,7 @@ int cmp_ent_set_cmp_mode(struct cmp_entity *ent, enum cmp_mode cmp_mode_used); int cmp_ent_set_model_value(struct cmp_entity *ent, uint32_t model_value_used); int cmp_ent_set_model_id(struct cmp_entity *ent, uint32_t model_id); int cmp_ent_set_model_counter(struct cmp_entity *ent, uint32_t model_counter); -int cmp_ent_set_max_used_bits_version(struct cmp_entity *ent, uint8_t max_used_bits_version); +int cmp_ent_set_reserved(struct cmp_entity *ent, uint8_t reserved); int cmp_ent_set_lossy_cmp_par(struct cmp_entity *ent, uint32_t lossy_cmp_par_used); @@ -247,7 +247,7 @@ uint8_t cmp_ent_get_model_value(const struct cmp_entity *ent); uint16_t cmp_ent_get_model_id(const struct cmp_entity *ent); uint8_t cmp_ent_get_model_counter(const struct cmp_entity *ent); -uint8_t cmp_ent_get_max_used_bits_version(const struct cmp_entity *ent); +uint8_t cmp_ent_get_reserved(const struct cmp_entity *ent); uint16_t cmp_ent_get_lossy_cmp_par(const struct cmp_entity *ent); diff --git a/lib/common/cmp_error.c b/lib/common/cmp_error.c index d3f53c744bd5741e5c4d541967cd2c50c0b2e4fb..2a78dd6ab7251955e875755a8d1efacfa0f4b4c1 100644 --- a/lib/common/cmp_error.c +++ b/lib/common/cmp_error.c @@ -86,8 +86,6 @@ const char* cmp_get_error_string(enum cmp_error code) return "Specific compression parameters or combination is unsupported"; case CMP_ERROR_PAR_BUFFERS: return "Buffer related parameter is not valid"; - case CMP_ERROR_PAR_MAX_USED_BITS: - return "Maximum used bits parameters are not valid"; case CMP_ERROR_PAR_NULL: return "Pointer to the compression parameters structure is NULL"; diff --git a/lib/common/cmp_error_list.h b/lib/common/cmp_error_list.h index 93448571de835d50cd4e2eff94e135e3278102f4..06fa16875123f77443daa6cb3c9e6625c6f5b1b4 100644 --- a/lib/common/cmp_error_list.h +++ b/lib/common/cmp_error_list.h @@ -34,7 +34,6 @@ enum cmp_error { CMP_ERROR_PAR_GENERIC = 20, CMP_ERROR_PAR_SPECIFIC = 21, CMP_ERROR_PAR_BUFFERS = 22, - CMP_ERROR_PAR_MAX_USED_BITS = 23, CMP_ERROR_PAR_NULL = 24, /* chunk errors */ CMP_ERROR_CHUNK_NULL = 40, diff --git a/lib/common/cmp_max_used_bits.c b/lib/common/cmp_max_used_bits.c deleted file mode 100644 index eaedea3d83e203a960ef056e4bd7fd9c99bbeffa..0000000000000000000000000000000000000000 --- a/lib/common/cmp_max_used_bits.c +++ /dev/null @@ -1,145 +0,0 @@ -/** - * @file cmp_max_used_bits.c - * @author Dominik Loidolt (dominik.loidolt@univie.ac.at) - * @date 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 definition and consents of the cmp_max_used_bits structure - */ - - -#include <stdint.h> - -#include "cmp_data_types.h" - - -#define MAX_USED_NC_IMAGETTE_BITS 16 -#define MAX_USED_SATURATED_IMAGETTE_BITS 16 /* TBC */ -#define MAX_USED_FC_IMAGETTE_BITS 16 /* TBC */ - -#define MAX_USED_F_FX_BITS 21 /* max exp. int value: (1.078*10^5)/0.1 = 1,078,000 -> 21 bits */ -#define MAX_USED_F_EFX_BITS MAX_USED_F_FX_BITS /* we use the same as f_fx */ -#define MAX_USED_F_NCOB_BITS 20 /* max exp. int value: 6/10^−5 = 6*10^5 -> 20 bits */ -#define MAX_USED_F_ECOB_BITS 32 /* TBC */ - -#define MAX_USED_S_FX_EXPOSURE_FLAGS_BITS 2 /* 2 flags + 6 spare bits */ -#define MAX_USED_S_FX_BITS 24 /* max exp. int value: (1.078*10^5-34.71)/0.01 = 10,780,000-> 24 bits */ -#define MAX_USED_S_EFX_BITS MAX_USED_S_FX_BITS /* we use the same as s_fx */ -#define MAX_USED_S_NCOB_BITS MAX_USED_F_NCOB_BITS -#define MAX_USED_S_ECOB_BITS 32 /* TBC */ - -#define MAX_USED_L_FX_EXPOSURE_FLAGS_BITS 24 /* 24 flags */ -#define MAX_USED_L_FX_BITS MAX_USED_S_FX_BITS -#define MAX_USED_L_FX_VARIANCE_BITS 32 /* no maximum value is given in PLATO-LESIA-PDC-TN-0054 */ -#define MAX_USED_L_EFX_BITS MAX_USED_L_FX_BITS /* we use the same as l_fx */ -#define MAX_USED_L_NCOB_BITS MAX_USED_F_NCOB_BITS -#define MAX_USED_L_ECOB_BITS 32 /* TBC */ -#define MAX_USED_L_COB_VARIANCE_BITS 25 /* max exp int value: 0.1739/10^−8 = 17390000 -> 25 bits */ - -#define MAX_USED_NC_OFFSET_MEAN_BITS 2 /* no maximum value is given in PLATO-LESIA-PDC-TN-0054 */ -#define MAX_USED_NC_OFFSET_VARIANCE_BITS 10 /* max exp. int value: 9.31/0.01 = 931 -> 10 bits */ - -#define MAX_USED_NC_BACKGROUND_MEAN_BITS 16 /* max exp. int value: (391.8-(-50))/0.01 = 44,180 -> 16 bits */ -#define MAX_USED_NC_BACKGROUND_VARIANCE_BITS 16 /* max exp. int value: 6471/0.1 = 64710 -> 16 bit */ -#define MAX_USED_NC_BACKGROUND_OUTLIER_PIXELS_BITS 5 /* maximum = 16 -> 5 bits */ - -#define MAX_USED_SMEARING_MEAN_BITS 15 /* max exp. int value: (219.9 - -50)/0.01 = 26.990 */ -#define MAX_USED_SMEARING_VARIANCE_MEAN_BITS 16 /* no maximum value is given in PLATO-LESIA-PDC-TN-0054 */ -#define MAX_USED_SMEARING_OUTLIER_PIXELS_BITS 11 /* maximum = 1200 -> 11 bits */ - -#define MAX_USED_FC_OFFSET_MEAN_BITS 32 /* no maximum value is given in PLATO-LESIA-PDC-TN-0054 */ -#define MAX_USED_FC_OFFSET_VARIANCE_BITS 9 /* max exp. int value: 342/1 = 342 -> 9 bits */ -#define MAX_USED_FC_OFFSET_PIXEL_IN_ERROR_BITS 16 /* TBC */ - -#define MAX_USED_FC_BACKGROUND_MEAN_BITS 10 /* max exp. int value: (35.76-(-50))/0.1 = 858 -> 10 bits*/ -#define MAX_USED_FC_BACKGROUND_VARIANCE_BITS 6 /* max exp. int value: 53.9/1 = 54 -> 6 bits */ -#define MAX_USED_FC_BACKGROUND_OUTLIER_PIXELS_BITS 16 /* TBC */ - - -#define member_bit_size(type, member) (sizeof(((type *)0)->member)*8) - - -/* a safe the different data products types in bits */ -const struct cmp_max_used_bits MAX_USED_BITS_SAFE = { - 0, /* default version */ - member_bit_size(struct s_fx_efx_ncob_ecob, exp_flags), /* s_fx_exp_flags */ - member_bit_size(struct s_fx_efx_ncob_ecob, fx), /* s_fx */ - member_bit_size(struct s_fx_efx_ncob_ecob, efx), /* s_efx */ - member_bit_size(struct s_fx_efx_ncob_ecob, ncob_x), /* s_ncob_x and s_ncob_y */ - member_bit_size(struct s_fx_efx_ncob_ecob, ecob_x), /* s_ecob_x and s_ncob_y */ - member_bit_size(struct f_fx_efx_ncob_ecob, fx), /* f_fx */ - member_bit_size(struct f_fx_efx_ncob_ecob, efx), /* f_efx */ - member_bit_size(struct f_fx_efx_ncob_ecob, ncob_x), /* f_ncob_x and f_ncob_y */ - member_bit_size(struct f_fx_efx_ncob_ecob, ecob_x), /* f_ecob_x and f_ncob_y */ - 24, /* member_bit_size(struct l_fx_efx_ncob_ecob, exp_flags), /1* l_fx_exp_flags *1/ */ - member_bit_size(struct l_fx_efx_ncob_ecob, fx), /* l_fx */ - member_bit_size(struct l_fx_efx_ncob_ecob, fx_variance), /* l_fx_variance */ - member_bit_size(struct l_fx_efx_ncob_ecob, efx), /* l_efx */ - member_bit_size(struct l_fx_efx_ncob_ecob, ncob_x), /* l_ncob_x and l_ncob_y */ - member_bit_size(struct l_fx_efx_ncob_ecob, ecob_x), /* l_ecob_x and l_ncob_y */ - member_bit_size(struct l_fx_efx_ncob_ecob, cob_x_variance), /* l_cob_x_variance and l_cob_y_variance */ - sizeof(uint16_t)*8, /* nc_imagette */ - sizeof(uint16_t)*8, /* saturated_imagette */ - member_bit_size(struct offset, mean), /* nc_offset_mean */ - member_bit_size(struct offset, variance), /* nc_offset_variance */ - member_bit_size(struct background, mean), /* nc_background_mean */ - member_bit_size(struct background, variance), /* nc_background_variance */ - member_bit_size(struct background, outlier_pixels), /* nc_background_outlier_pixels */ - member_bit_size(struct smearing, mean), /* smearing_mean */ - member_bit_size(struct smearing, variance_mean), /* smearing_variance_mean */ - member_bit_size(struct smearing, outlier_pixels), /* smearing_outlier_pixels */ - sizeof(uint16_t)*8, /* fc_imagette */ - member_bit_size(struct offset, mean), /* fc_offset_mean */ - member_bit_size(struct offset, variance), /* fc_offset_variance */ - member_bit_size(struct background, mean), /* fc_background_mean */ - member_bit_size(struct background, variance), /* fc_background_variance */ - member_bit_size(struct background, outlier_pixels), /* fc_background_outlier_pixels */ -}; - - -/* the maximum length of the different data products types in bits */ -const struct cmp_max_used_bits MAX_USED_BITS_V1 = { - 1, /* default version */ - MAX_USED_S_FX_EXPOSURE_FLAGS_BITS, /* s_fx_exp_flags */ - MAX_USED_S_FX_BITS, /* s_fx */ - MAX_USED_S_EFX_BITS, /* s_efx */ - MAX_USED_S_NCOB_BITS, /* s_ncob_x and s_ncob_y */ - MAX_USED_S_ECOB_BITS, /* s_ecob_x and s_ncob_y */ - MAX_USED_F_FX_BITS, /* f_fx */ - MAX_USED_F_EFX_BITS, /* f_efx */ - MAX_USED_F_NCOB_BITS, /* f_ncob_x and f_ncob_y */ - MAX_USED_F_ECOB_BITS, /* f_ecob_x and f_ncob_y */ - MAX_USED_L_FX_EXPOSURE_FLAGS_BITS, /* l_fx_exp_flags */ - MAX_USED_L_FX_BITS, /* l_fx */ - MAX_USED_L_FX_VARIANCE_BITS, /* l_fx_variance */ - MAX_USED_L_EFX_BITS, /* l_efx */ - MAX_USED_L_NCOB_BITS, /* l_ncob_x and l_ncob_y */ - MAX_USED_L_ECOB_BITS, /* l_ecob_x and l_ncob_y */ - MAX_USED_L_COB_VARIANCE_BITS, /* l_cob_x_variance and l_cob_y_variance */ - MAX_USED_NC_IMAGETTE_BITS, /* nc_imagette */ - MAX_USED_SATURATED_IMAGETTE_BITS, /* saturated_imagette */ - MAX_USED_NC_OFFSET_MEAN_BITS, /* nc_offset_mean */ - MAX_USED_NC_OFFSET_VARIANCE_BITS, /* nc_offset_variance */ - MAX_USED_NC_BACKGROUND_MEAN_BITS, /* nc_background_mean */ - MAX_USED_NC_BACKGROUND_VARIANCE_BITS, /* nc_background_variance */ - MAX_USED_NC_BACKGROUND_OUTLIER_PIXELS_BITS, /* nc_background_outlier_pixels */ - MAX_USED_SMEARING_MEAN_BITS, /* smearing_mean */ - MAX_USED_SMEARING_VARIANCE_MEAN_BITS, /* smearing_variance_mean */ - MAX_USED_SMEARING_OUTLIER_PIXELS_BITS, /* smearing_outlier_pixels */ - MAX_USED_FC_IMAGETTE_BITS, /* fc_imagette */ - MAX_USED_FC_OFFSET_MEAN_BITS, /* fc_offset_mean */ - MAX_USED_FC_OFFSET_VARIANCE_BITS, /* fc_offset_variance */ - MAX_USED_FC_BACKGROUND_MEAN_BITS, /* fc_background_mean */ - MAX_USED_FC_BACKGROUND_VARIANCE_BITS, /* fc_background_variance */ - MAX_USED_FC_BACKGROUND_OUTLIER_PIXELS_BITS /* fc_background_outlier_pixels */ -}; - diff --git a/lib/common/cmp_max_used_bits.h b/lib/common/cmp_max_used_bits.h index c13a6d619d83d3ab40fe4a2f6d547c56b7d23e07..b03c69d16c7ba203b34c572c98869523d746e37a 100644 --- a/lib/common/cmp_max_used_bits.h +++ b/lib/common/cmp_max_used_bits.h @@ -21,23 +21,27 @@ #include <stdint.h> +#include "cmp_data_types.h" -/* Up to this number (not included), the maximum used bits registry versions cannot be used by the user. */ -#define CMP_MAX_USED_BITS_RESERVED_VERSIONS 32 +/** + * @brief macro to calculate the bit size of a member in a structure. + * + * @param type type of the structure + * @param member member of the structure + * + * @returns the size of the member in bits + */ -/* predefined maximum used bits registry constants */ -extern const struct cmp_max_used_bits MAX_USED_BITS_SAFE; -extern const struct cmp_max_used_bits MAX_USED_BITS_V1; -#define MAX_USED_BITS MAX_USED_BITS_SAFE +#define member_bit_size(type, member) (sizeof(((type *)0)->member)*8) /** - * @brief Structure holding the maximum length of the different data product types in bits + * @brief Structure holding the maximum length of the different data product + * types in bits */ struct cmp_max_used_bits { - uint8_t version; unsigned int s_exp_flags; unsigned int s_fx; unsigned int s_efx; @@ -72,4 +76,46 @@ struct cmp_max_used_bits { unsigned int fc_background_outlier_pixels; }; + +/** + * @brief This structure is used to define the maximum number of bits required + * to read different data product type fields + */ + +static const struct cmp_max_used_bits MAX_USED_BITS = { + member_bit_size(struct s_fx_efx_ncob_ecob, exp_flags), /* s_fx_exp_flags */ + member_bit_size(struct s_fx_efx_ncob_ecob, fx), /* s_fx */ + member_bit_size(struct s_fx_efx_ncob_ecob, efx), /* s_efx */ + member_bit_size(struct s_fx_efx_ncob_ecob, ncob_x), /* s_ncob_x and s_ncob_y */ + member_bit_size(struct s_fx_efx_ncob_ecob, ecob_x), /* s_ecob_x and s_ncob_y */ + member_bit_size(struct f_fx_efx_ncob_ecob, fx), /* f_fx */ + member_bit_size(struct f_fx_efx_ncob_ecob, efx), /* f_efx */ + member_bit_size(struct f_fx_efx_ncob_ecob, ncob_x), /* f_ncob_x and f_ncob_y */ + member_bit_size(struct f_fx_efx_ncob_ecob, ecob_x), /* f_ecob_x and f_ncob_y */ + 24, /* member_bit_size(struct l_fx_efx_ncob_ecob, exp_flags), /1* l_fx_exp_flags *1/ */ + member_bit_size(struct l_fx_efx_ncob_ecob, fx), /* l_fx */ + member_bit_size(struct l_fx_efx_ncob_ecob, fx_variance), /* l_fx_variance */ + member_bit_size(struct l_fx_efx_ncob_ecob, efx), /* l_efx */ + member_bit_size(struct l_fx_efx_ncob_ecob, ncob_x), /* l_ncob_x and l_ncob_y */ + member_bit_size(struct l_fx_efx_ncob_ecob, ecob_x), /* l_ecob_x and l_ncob_y */ + member_bit_size(struct l_fx_efx_ncob_ecob, cob_x_variance), /* l_cob_x_variance and l_cob_y_variance */ + sizeof(uint16_t)*8, /* nc_imagette */ + sizeof(uint16_t)*8, /* saturated_imagette */ + member_bit_size(struct offset, mean), /* nc_offset_mean */ + member_bit_size(struct offset, variance), /* nc_offset_variance */ + member_bit_size(struct background, mean), /* nc_background_mean */ + member_bit_size(struct background, variance), /* nc_background_variance */ + member_bit_size(struct background, outlier_pixels), /* nc_background_outlier_pixels */ + member_bit_size(struct smearing, mean), /* smearing_mean */ + member_bit_size(struct smearing, variance_mean), /* smearing_variance_mean */ + member_bit_size(struct smearing, outlier_pixels), /* smearing_outlier_pixels */ + sizeof(uint16_t)*8, /* fc_imagette */ + member_bit_size(struct offset, mean), /* fc_offset_mean */ + member_bit_size(struct offset, variance), /* fc_offset_variance */ + member_bit_size(struct background, mean), /* fc_background_mean */ + member_bit_size(struct background, variance), /* fc_background_variance */ + member_bit_size(struct background, outlier_pixels), /* fc_background_outlier_pixels */ +}; + + #endif /* CMP_MAX_USED_BITS_H */ diff --git a/lib/common/cmp_support.c b/lib/common/cmp_support.c index 1beaec2a66327e7cafae90a2885d36e3ce7e7b13..1b2ccd1f49910988344b1794ac76f82270eaff2b 100644 --- a/lib/common/cmp_support.c +++ b/lib/common/cmp_support.c @@ -472,71 +472,6 @@ int cmp_cfg_icu_buffers_is_invalid(const struct cmp_cfg *cfg) } -/** - * @brief check if all entries in the max_used_bits structure are in the allowed range - * - * @param max_used_bits pointer to max_used_bits structure to check - * - * @returns 0 if all entries are valid, otherwise one or more entries are invalid - */ - - -int cmp_cfg_icu_max_used_bits_out_of_limit(const struct cmp_max_used_bits *max_used_bits) -{ -#define CHECK_MAX_USED_BITS_LIMIT(entry) \ - do { \ - if (max_used_bits->entry > MAX_USED_BITS_SAFE.entry) { \ - debug_print("Error: The " #entry " entry in the max_used_bits structure is too large (actual: %x, max: %x).", max_used_bits->entry, MAX_USED_BITS_SAFE.entry); \ - error++; \ - } \ - } while (0) - - int error = 0; - - if (!max_used_bits) { - debug_print("Error: The pointer to the max_used_bits structure is NULL."); - return 1; - } - - CHECK_MAX_USED_BITS_LIMIT(s_exp_flags); - CHECK_MAX_USED_BITS_LIMIT(s_fx); - CHECK_MAX_USED_BITS_LIMIT(s_efx); - CHECK_MAX_USED_BITS_LIMIT(s_ncob); - CHECK_MAX_USED_BITS_LIMIT(s_ecob); - CHECK_MAX_USED_BITS_LIMIT(f_fx); - CHECK_MAX_USED_BITS_LIMIT(f_efx); - CHECK_MAX_USED_BITS_LIMIT(f_ncob); - CHECK_MAX_USED_BITS_LIMIT(f_ecob); - CHECK_MAX_USED_BITS_LIMIT(l_exp_flags); - CHECK_MAX_USED_BITS_LIMIT(l_fx); - CHECK_MAX_USED_BITS_LIMIT(l_fx_variance); - CHECK_MAX_USED_BITS_LIMIT(l_efx); - CHECK_MAX_USED_BITS_LIMIT(l_ncob); - CHECK_MAX_USED_BITS_LIMIT(l_ecob); - CHECK_MAX_USED_BITS_LIMIT(l_cob_variance); - CHECK_MAX_USED_BITS_LIMIT(nc_imagette); - CHECK_MAX_USED_BITS_LIMIT(saturated_imagette); - CHECK_MAX_USED_BITS_LIMIT(nc_offset_mean); - CHECK_MAX_USED_BITS_LIMIT(nc_offset_variance); - CHECK_MAX_USED_BITS_LIMIT(nc_background_mean); - CHECK_MAX_USED_BITS_LIMIT(nc_background_variance); - CHECK_MAX_USED_BITS_LIMIT(nc_background_outlier_pixels); - CHECK_MAX_USED_BITS_LIMIT(smearing_mean); - CHECK_MAX_USED_BITS_LIMIT(smearing_variance_mean); - CHECK_MAX_USED_BITS_LIMIT(smearing_outlier_pixels); - CHECK_MAX_USED_BITS_LIMIT(fc_imagette); - CHECK_MAX_USED_BITS_LIMIT(fc_offset_mean); - CHECK_MAX_USED_BITS_LIMIT(fc_offset_variance); - CHECK_MAX_USED_BITS_LIMIT(fc_background_mean); - CHECK_MAX_USED_BITS_LIMIT(fc_background_variance); - CHECK_MAX_USED_BITS_LIMIT(fc_background_outlier_pixels); - - return error; - -#undef CHECK_MAX_USED_BITS_LIMIT -} - - /** * @brief check if the combination of the different compression parameters is invalid * @@ -819,9 +754,6 @@ int cmp_cfg_icu_is_invalid(const struct cmp_cfg *cfg) cfg_invalid += cmp_cfg_icu_buffers_is_invalid(cfg); - if (cfg->cmp_mode != CMP_MODE_RAW) - cfg_invalid += cmp_cfg_icu_max_used_bits_out_of_limit(cfg->max_used_bits); - if (cmp_imagette_data_type_is_used(cfg->data_type)) cfg_invalid += cmp_cfg_imagette_is_invalid(cfg); else if (cmp_fx_cob_data_type_is_used(cfg->data_type)) diff --git a/lib/common/cmp_support.h b/lib/common/cmp_support.h index 11eec690589b281366ac2edf087064ebe44a8a1d..01553bdb39196a64a4aef7f336f379fef93dc38f 100644 --- a/lib/common/cmp_support.h +++ b/lib/common/cmp_support.h @@ -22,7 +22,6 @@ #include <stdint.h> #include <stddef.h> -#include "cmp_max_used_bits.h" #include "cmp_cal_up_model.h" #define CMP_COLLECTION_FILD_SIZE 2 @@ -237,7 +236,6 @@ struct cmp_cfg { uint32_t spill_background_pixels_error; /**< Spillover threshold parameter for auxiliary science outlier pixels number compression */ uint32_t spill_smearing_pixels_error; /**< Spillover threshold parameter for auxiliary science outlier pixels number compression */ }; - const struct cmp_max_used_bits *max_used_bits; /**< the maximum length of the different data product types in bits */ }; @@ -338,7 +336,6 @@ unsigned int cmp_bit_to_byte(unsigned int cmp_size_bit); int cmp_cfg_icu_is_invalid(const struct cmp_cfg *cfg); int cmp_cfg_gen_par_is_invalid(const struct cmp_cfg *cfg); int cmp_cfg_icu_buffers_is_invalid(const struct cmp_cfg *cfg); -int cmp_cfg_icu_max_used_bits_out_of_limit(const struct cmp_max_used_bits *max_used_bits); int cmp_cfg_imagette_is_invalid(const struct cmp_cfg *cfg); int cmp_cfg_fx_cob_is_invalid(const struct cmp_cfg *cfg); int cmp_cfg_aux_is_invalid(const struct cmp_cfg *cfg); diff --git a/lib/common/list.h b/lib/common/list.h deleted file mode 100644 index 1d529cc44655850b0022dbf73a87a549a820c82d..0000000000000000000000000000000000000000 --- a/lib/common/list.h +++ /dev/null @@ -1,438 +0,0 @@ -/** - * @file list.h - * @ingroup linked_list - * - * @note This list implementation was shamelessly stolen and modified from the - * linux kernel's include/linux/list.h - * Its API (if you will) is used in this (currently non-GPL) project as - * under the assumption that the inclusion of header files does not - * automatically imply derivative work, see - * http://lkml.iu.edu//hypermail/linux/kernel/0301.1/0362.html - * - * No explicit copyright or author statement is given in the original - * file, so we assume per the Linux COPYING file: - * - * @author Linus Torvalds (and others who actually wrote the linux kernel - * version) - * @author Armin Luntzer (armin.luntzer@univie.ac.at) (local modifications or - * extensions) - * - * @copyright - * - * 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. - * - * @defgroup linked_list Linked Lists - * @brief a modified doubly-linked list implementation from the linux kernel - * - * - * This is a (slightly modified) doubly-linked list implementation from the - * Linux kernel. An easy to understand explanation of - * how it works and is used can be found here - * http://kernelnewbies.org/FAQ/LinkedLists - * - * Be smart - * ----- - * It is a valid to criticise linked lists as generally performing badly - * if you traverse their entries at high frequency rather than just - * manipulating them. This can be especially true (and has been demonstrated - * numerous times) for implementations like std:list. - * - * Please consider the following though: linked lists are not inherently - * slow because of how they work algorithmically (*the opposite is true*), - * but rather because how their cache hit (or miss) rate is in - * configurations where entries are randomly scattered in memory rather - * than laid out in one big chunk. - * - * Be smart. Don't do that. Allocate a pool in a __single chunk__ and enjoy the - * cache performance. Do not use larger chunks than the page size of your - * platform if you have MMU support. If you need more than that, you probably - * need to redesign your program anyways. - * - * This does of course not apply as long as you do access your lists only - * at slow rates (i.e. in the order of several tens of ms) or if performance - * is not at all critical. - * - */ - - -#ifndef LIST_H -#define LIST_H - -#ifdef LIST_HEAD -#undef LIST_HEAD -#endif - -struct list_head { - struct list_head *next, *prev; -}; - -#define LIST_HEAD_INIT(name) { &(name), &(name) } - -#define LIST_HEAD(name) \ - struct list_head name = LIST_HEAD_INIT(name) - -static __inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) -{ - next->prev = new; - new->next = next; - new->prev = prev; - prev->next = new; -} - -/** - * @brief add a new entry - * @param new new entry to be added - * @param head list head to add it after - * - * Insert a new entry after the specified head. - * This is good for implementing stacks. - */ - -static __inline void list_add(struct list_head *new, struct list_head *head) -{ - __list_add(new, head, head->next); -} - -static __inline void INIT_LIST_HEAD(struct list_head *list) -{ - list->next = list; - list->prev = list; -} - - -/** - * @brief get the struct for this entry - * @param ptr the &struct list_head pointer. - * @param type the type of the struct this is embedded in. - * @param member the name of the list_struct within the struct. - * @note add (void *) cast to suppress wcast-align warning - */ -#define list_entry(ptr, type, member) \ - ((type *)((void *)((char *)(ptr)-__builtin_offsetof(type, member)))) - -/** - * list_first_entry - get the first element from a list - * @param ptr the list head to take the element from. - * @param type the type of the struct this is embedded in. - * @param member the name of the list_head within the struct. - * - * Note, that list is expected to be not empty. - */ -#define list_first_entry(ptr, type, member) \ - list_entry((ptr)->next, type, member) - -/** - * list_last_entry - get the last element from a list - * @param ptr the list head to take the element from. - * @param type the type of the struct this is embedded in. - * @param member the name of the list_head within the struct. - * - * Note, that list is expected to be not empty. - */ -#define list_last_entry(ptr, type, member) \ - list_entry((ptr)->prev, type, member) - -/** - * list_first_entry_or_null - get the first element from a list - * @param ptr the list head to take the element from. - * @param type the type of the struct this is embedded in. - * @param member the name of the list_head within the struct. - * - * Note that if the list is empty, it returns NULL. - */ -#define list_first_entry_or_null(ptr, type, member) ({ \ - struct list_head *head__ = (ptr); \ - struct list_head *pos__ = READ_ONCE(head__->next); \ - pos__ != head__ ? list_entry(pos__, type, member) : NULL; \ -}) - -/** - * list_next_entry - get the next element in list - * @param pos the type * to cursor - * @param member the name of the list_head within the struct. - * @note modified to use __typeof__() - */ -#define list_next_entry(pos, member) \ - list_entry((pos)->member.next, __typeof__(*(pos)), member) - -/** - * list_prev_entry - get the prev element in list - * @param pos the type * to cursor - * @param member the name of the list_head within the struct. - */ -#define list_prev_entry(pos, member) \ - list_entry((pos)->member.prev, __typeof__(*(pos)), member) - -/** - * list_for_each - iterate over a list - * @pos the &struct list_head to use as a loop cursor. - * @head the head for your list. - */ -#define list_for_each(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) - -/** - * @brief iterate over list of given type - * @param pos the type * to use as a loop counter. - * @param head the head for your list. - * @param member the name of the list_struct within the struct. - * @note modified to use __typeof__() - */ - -#define list_for_each_entry(pos, head, member) \ - for (pos = list_first_entry(head, __typeof__(*pos), member); \ - &pos->member != (head); \ - pos = list_next_entry(pos, member)) - -/** - * @brief iterate over list of given type safe against removal of list entry - * @param pos the type * to use as a loop counter. - * @param n another type * to use as temporary storage - * @param head the head for your list. - * @param member the name of the list_struct within the struct. - */ - -#define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, __typeof__(*pos), member), \ - n = list_entry(pos->member.next, __typeof__(*pos), member);\ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, __typeof__(*pos), member)) - - -/** - * @brief iterator wrapper start - * @param pos the type * to use as a loop counter. - * @param head the head for your list. - * @param member the name of the list_struct within the struct. - * @param type the type of struct - * @warning requires list_entry_while() to close statement - * @note this construction is necessary for a truly circular list that is "headless" - * and can be iterated from any starting element without additional overhead - * compared to the LIST_HEAD/list_for_each_entry approach - * TODO: check if this is functional for all targets (confirmed: gcc 4.8.2) - */ - -#define list_entry_do(pos, head, member, type) \ - { \ - pos = list_entry((head), type, member); \ - do \ - { \ - -/** - * @brief list iterator wrapper stop - * @param pos the type * to use as a loop counter. - * @param head the head for your list. - * @param member the name of the list_struct within the struct. - * @param type the type of struct - * @warning requires list_entry_do() to open statement - * @note see list_entry_while() - */ - -#define list_entry_while(pos, head, member, type) \ - } \ - while (pos = list_entry(pos->member.next, type, member),\ - &pos->member != head); \ - } - -/** - * @brief the list entry do-while equivalent for a code block - * @param pos the type * to use as a loop counter. - * @param head the head for your list. - * @param member the name of the list_struct within the struct. - * @param type the type of struct - * @param _CODE_ a code segment - * @note see list_entry_while(), list_entry_do() - */ - -#define list_entry_do_while(pos, head, member, type, _CODE_) \ - list_entry_do(pos, head, member, type) \ - { \ - _CODE_; \ - } list_entry_while(pos, head, member, type) - -/** - * @brief reverse iterate over list of given type - * @param pos the type * to use as a loop counter. - * @param head the head for your list. - * @param member the name of the list_struct within the struct. - * @note slightly modified in case there is no typeof() functionality in target compiler - */ - -#define list_for_each_entry_rev(pos, head, member) \ - for (pos = list_entry((head)->prev, __typeof__(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.prev, __typeof__(*pos), member)) - - -/* - * @brief delete a list entry by making the prev/next entries - * point to each other. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static __inline void __list_del(struct list_head *prev, struct list_head *next) -{ - next->prev = prev; - prev->next = next; -} - - -/** - * @brief deletes entry from list. - * @param entry the element to delete from the list. - * @note list_empty on entry does not return true after this, - * the entry is in an undefined state. - */ - -static __inline void list_del(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); - entry->next = (void *) 0; - entry->prev = (void *) 0; -} - - -/** - * @brief deletes entry from list. - * @param entry the element to delete from the list. - * @note list_empty() on entry does not return true after this, the entry is - * in an undefined state. - */ - -static __inline void __list_del_entry(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); -} - -/** - * @brief deletes entry from list and reinitialize it. - * @param entry the element to delete from the list. - */ -static __inline void list_del_init(struct list_head *entry) -{ - __list_del_entry(entry); - INIT_LIST_HEAD(entry); -} - -/** - * @brief delete from one list and add as another's head - * @param list the entry to move - * @param head the head that will precede our entry - */ -static __inline void list_move(struct list_head *list, struct list_head *head) -{ - __list_del_entry(list); - list_add(list, head); -} - - -/** - * @brief add a new entry - * @param new new entry to be added - * @param head list head to add it before - * - * Insert a new entry before the specified head. - * This is useful for implementing queues. - */ - -static __inline void list_add_tail(struct list_head *new, struct list_head *head) -{ - __list_add(new, head->prev, head); -} - - -/** - * @brief replace old entry by new one - * @param old the element to be replaced - * @param new the new element to insert - * - * If the old parameter was empty, it will be overwritten. - */ - -static __inline void list_replace(struct list_head *old, - struct list_head *new) -{ - new->next = old->next; - new->next->prev = new; - new->prev = old->prev; - new->prev->next = new; -} - - -/** - * @brief replace entry1 with entry2 and re-add entry1 at entry2's position - * @param entry1 the location to place entry2 - * @param entry2 the location to place entry1 - */ -static __inline void list_swap(struct list_head *entry1, - struct list_head *entry2) -{ - struct list_head *pos = entry2->prev; - - list_del(entry2); - list_replace(entry1, entry2); - if (pos == entry1) - pos = entry2; - list_add(entry1, pos); -} - -/** - * @brief tests whether a list is empty - * @param head the list to test. - */ - -static __inline int list_empty(struct list_head *head) -{ - return head->next == head; -} - -/** - * @brief tests whether there is at least one element in the list - * @param head the list to test. - */ - -static __inline int list_filled(struct list_head *head) -{ - return head->next != head; -} - - -/** - * @brief delete from one list and add as another's tail - * @param list the entry to move - * @param head the head that will follow our entry - */ - -static __inline void list_move_tail(struct list_head *list, - struct list_head *head) -{ - __list_del(list->prev, list->next); - list_add_tail(list, head); -} - - -/** - * @brief rotate the list to the left - * @param head the head of the list - */ - -static __inline void list_rotate_left(struct list_head *head) -{ - struct list_head *first; - - if (!list_empty(head)) { - first = head->next; - list_move_tail(first, head); - } -} - - -#endif diff --git a/lib/common/meson.build b/lib/common/meson.build index 1214439e01f215e2fd00920b6032b281209258a5..a4e99c2ff1d0f7191d2ef5cb0c72cf69d3f8abbd 100644 --- a/lib/common/meson.build +++ b/lib/common/meson.build @@ -3,7 +3,6 @@ common_sources = files([ 'cmp_debug.c', 'cmp_entity.c', 'cmp_error.c', - 'cmp_max_used_bits.c', 'cmp_support.c', 'vsnprintf.c' ]) diff --git a/lib/decompress/cmp_max_used_bits_list.c b/lib/decompress/cmp_max_used_bits_list.c deleted file mode 100644 index 31c14b2b92cbc76304b1ab4d52f23b968eadc4b3..0000000000000000000000000000000000000000 --- a/lib/decompress/cmp_max_used_bits_list.c +++ /dev/null @@ -1,142 +0,0 @@ -/** - * @file cmp_max_used_bits_list.c - * @author Dominik Loidolt (dominik.loidolt@univie.ac.at) - * @date 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 Implement a list that can hold an arbitrary number of different - * cmp_max_used_bits structs - * - * @warning not intended for use with the flight software - */ - - -#include <stdlib.h> - -#include "../common/list.h" -#include "../common/cmp_max_used_bits.h" -#include "cmp_max_used_bits_list.h" - - -struct list_item { - struct list_head list; - struct cmp_max_used_bits data; -}; - -static LIST_HEAD(max_used_bits_list); - - -/** - * @brief get an item from the max_used_bits list - * - * @param version version identifier of the max_used_bits list item - * - * @returns a pointer to the max_used_bits structure with the corresponding version - * on success; NULL if no list item has the version number - */ - -const struct cmp_max_used_bits *cmp_max_used_bits_list_get(uint8_t version) -{ - struct list_item *list_ptr = NULL; - - switch (version) { - case 0: - return &MAX_USED_BITS_SAFE; - case 1: - return &MAX_USED_BITS_V1; - - } - - list_for_each_entry(list_ptr, &max_used_bits_list, list) { - if (list_ptr->data.version == version) - return &list_ptr->data; - } - return NULL; -} - - -/** - * @brief add a max_used_bits item to the list - * - * @param item pointer to the cmp_max_used_bits struct to add to the list - * - * @note if there is an item in the list with the same version number, it will - * be overwritten - * @returns 0 on success; 1 if an existing entry is overwritten; -1 on error - */ - -int cmp_max_used_bits_list_add(struct cmp_max_used_bits const *item) -{ - struct list_item *item_ptr = NULL; - - if (!item) - return -1; - if (item->version < CMP_MAX_USED_BITS_RESERVED_VERSIONS) - return -1; - - /* check for an existing entry */ - list_for_each_entry(item_ptr, &max_used_bits_list, list) { - if (item_ptr->data.version == item->version) { - item_ptr->data = *item; /* replace existing list entry */ - return 1; - } - } - - item_ptr = (struct list_item *)malloc(sizeof(struct list_item)); - if (!item_ptr) - return -1; - - item_ptr->data = *item; - list_add(&item_ptr->list, &max_used_bits_list); - - return 0; -} - - -/** - * @brief delete a max_used_bits item from the list - * - * @param version version identifier of the max_used_bits list entry to be deleted - * - * @note if no max_used_bits list item has the version identifier, nothing happens - */ - -void cmp_max_used_bits_list_delet(uint8_t version) -{ - struct list_item *list_ptr = NULL; - struct list_item *tmp = NULL; - - list_for_each_entry_safe(list_ptr, tmp, &max_used_bits_list, list) { - if (list_ptr->data.version == version) { - list_del(&list_ptr->list); - free(list_ptr); - list_ptr = NULL; - } - } -} - - -/** - * @brief delete all max_used_bits item from the list - */ - -void cmp_max_used_bits_list_empty(void) -{ - struct list_item *list_ptr = NULL; - struct list_item *tmp = NULL; - - list_for_each_entry_safe(list_ptr, tmp, &max_used_bits_list, list) { - list_del(&list_ptr->list); - free(list_ptr); - list_ptr = NULL; - } -} diff --git a/lib/decompress/cmp_max_used_bits_list.h b/lib/decompress/cmp_max_used_bits_list.h deleted file mode 100644 index 317c7163fab7894654fb3d06e9911c9d64d63da2..0000000000000000000000000000000000000000 --- a/lib/decompress/cmp_max_used_bits_list.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file cmp_max_used_bits_list.h - * @author Dominik Loidolt (dominik.loidolt@univie.ac.at) - * @date 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 Implement a list that can hold an arbitrary number of different - * cmp_max_used_bits structs - * - * @warning not intended for use with the flight software - */ - - -#ifndef CMP_MAX_USED_LIST_H -#define CMP_MAX_USED_LIST_H - -#include <stdint.h> - -#include "../common/cmp_data_types.h" - - -const struct cmp_max_used_bits *cmp_max_used_bits_list_get(uint8_t version); - -int cmp_max_used_bits_list_add(struct cmp_max_used_bits const *item); - -void cmp_max_used_bits_list_delet(uint8_t version); - -void cmp_max_used_bits_list_empty(void); - -#endif /* CMP_MAX_USED_LIST_H */ diff --git a/lib/decompress/decmp.c b/lib/decompress/decmp.c index 482677ba76cad56847f2eb492ecf59980461a854..b36879bd17f79eb0738b56909898b397597be8b8 100644 --- a/lib/decompress/decmp.c +++ b/lib/decompress/decmp.c @@ -32,7 +32,7 @@ #include "../common/compiler.h" #include "read_bitstream.h" -#include "cmp_max_used_bits_list.h" +#include "../common/cmp_data_types.h" #include "../decmp.h" #include "../common/cmp_debug.h" #include "../common/cmp_support.h" @@ -432,16 +432,16 @@ static int decompress_imagette(const struct cmp_cfg *cfg, struct bit_decoder *de switch (cfg->data_type) { case DATA_TYPE_IMAGETTE: case DATA_TYPE_IMAGETTE_ADAPTIVE: - max_data_bits = cfg->max_used_bits->nc_imagette; + max_data_bits = MAX_USED_BITS.nc_imagette; break; case DATA_TYPE_SAT_IMAGETTE: case DATA_TYPE_SAT_IMAGETTE_ADAPTIVE: - max_data_bits = cfg->max_used_bits->saturated_imagette; + max_data_bits = MAX_USED_BITS.saturated_imagette; break; default: case DATA_TYPE_F_CAM_IMAGETTE: case DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE: - max_data_bits = cfg->max_used_bits->fc_imagette; + max_data_bits = MAX_USED_BITS.fc_imagette; break; } @@ -544,9 +544,9 @@ static int decompress_s_fx(const struct cmp_cfg *cfg, struct bit_decoder *dec) } configure_decoder_setup(&setup_exp_flags, dec, cfg->cmp_mode, cfg->cmp_par_exp_flags, - cfg->spill_exp_flags, cfg->round, cfg->max_used_bits->s_exp_flags); + cfg->spill_exp_flags, cfg->round, MAX_USED_BITS.s_exp_flags); configure_decoder_setup(&setup_fx, dec, cfg->cmp_mode, cfg->cmp_par_fx, - cfg->spill_fx, cfg->round, cfg->max_used_bits->s_fx); + cfg->spill_fx, cfg->round, MAX_USED_BITS.s_fx); for (i = 0; ; i++) { err = decode_value(&setup_exp_flags, &decoded_value, model.exp_flags); @@ -607,11 +607,11 @@ static int decompress_s_fx_efx(const struct cmp_cfg *cfg, struct bit_decoder *de } configure_decoder_setup(&setup_exp_flags, dec, cfg->cmp_mode, cfg->cmp_par_exp_flags, - cfg->spill_exp_flags, cfg->round, cfg->max_used_bits->s_exp_flags); + cfg->spill_exp_flags, cfg->round, MAX_USED_BITS.s_exp_flags); configure_decoder_setup(&setup_fx, dec, cfg->cmp_mode, cfg->cmp_par_fx, - cfg->spill_fx, cfg->round, cfg->max_used_bits->s_fx); + cfg->spill_fx, cfg->round, MAX_USED_BITS.s_fx); configure_decoder_setup(&setup_efx, dec, cfg->cmp_mode, cfg->cmp_par_efx, - cfg->spill_efx, cfg->round, cfg->max_used_bits->s_efx); + cfg->spill_efx, cfg->round, MAX_USED_BITS.s_efx); for (i = 0; ; i++) { err = decode_value(&setup_exp_flags, &decoded_value, model.exp_flags); @@ -679,11 +679,11 @@ static int decompress_s_fx_ncob(const struct cmp_cfg *cfg, struct bit_decoder *d } configure_decoder_setup(&setup_exp_flags, dec, cfg->cmp_mode, cfg->cmp_par_exp_flags, - cfg->spill_exp_flags, cfg->round, cfg->max_used_bits->s_exp_flags); + cfg->spill_exp_flags, cfg->round, MAX_USED_BITS.s_exp_flags); configure_decoder_setup(&setup_fx, dec, cfg->cmp_mode, cfg->cmp_par_fx, - cfg->spill_fx, cfg->round, cfg->max_used_bits->s_fx); + cfg->spill_fx, cfg->round, MAX_USED_BITS.s_fx); configure_decoder_setup(&setup_ncob, dec, cfg->cmp_mode, cfg->cmp_par_ncob, - cfg->spill_ncob, cfg->round, cfg->max_used_bits->s_ncob); + cfg->spill_ncob, cfg->round, MAX_USED_BITS.s_ncob); for (i = 0; ; i++) { err = decode_value(&setup_exp_flags, &decoded_value, model.exp_flags); @@ -758,15 +758,15 @@ static int decompress_s_fx_efx_ncob_ecob(const struct cmp_cfg *cfg, struct bit_d } configure_decoder_setup(&setup_exp_flags, dec, cfg->cmp_mode, cfg->cmp_par_exp_flags, - cfg->spill_exp_flags, cfg->round, cfg->max_used_bits->s_exp_flags); + cfg->spill_exp_flags, cfg->round, MAX_USED_BITS.s_exp_flags); configure_decoder_setup(&setup_fx, dec, cfg->cmp_mode, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->s_fx); + cfg->round, MAX_USED_BITS.s_fx); configure_decoder_setup(&setup_ncob, dec, cfg->cmp_mode, cfg->cmp_par_ncob, cfg->spill_ncob, - cfg->round, cfg->max_used_bits->s_ncob); + cfg->round, MAX_USED_BITS.s_ncob); configure_decoder_setup(&setup_efx, dec, cfg->cmp_mode, cfg->cmp_par_efx, cfg->spill_efx, - cfg->round, cfg->max_used_bits->s_efx); + cfg->round, MAX_USED_BITS.s_efx); configure_decoder_setup(&setup_ecob, dec, cfg->cmp_mode, cfg->cmp_par_ecob, cfg->spill_ecob, - cfg->round, cfg->max_used_bits->s_ecob); + cfg->round, MAX_USED_BITS.s_ecob); for (i = 0; ; i++) { err = decode_value(&setup_exp_flags, &decoded_value, model.exp_flags); @@ -862,11 +862,11 @@ static int decompress_l_fx(const struct cmp_cfg *cfg, struct bit_decoder *dec) } configure_decoder_setup(&setup_exp_flags, dec, cfg->cmp_mode, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->l_exp_flags); + cfg->round, MAX_USED_BITS.l_exp_flags); configure_decoder_setup(&setup_fx, dec, cfg->cmp_mode, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->l_fx); + cfg->round, MAX_USED_BITS.l_fx); configure_decoder_setup(&setup_fx_var, dec, cfg->cmp_mode, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_fx_variance); + cfg->round, MAX_USED_BITS.l_fx_variance); for (i = 0; ; i++) { err = decode_value(&setup_exp_flags, &decoded_value, model.exp_flags); @@ -934,13 +934,13 @@ static int decompress_l_fx_efx(const struct cmp_cfg *cfg, struct bit_decoder *de } configure_decoder_setup(&setup_exp_flags, dec, cfg->cmp_mode, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->l_exp_flags); + cfg->round, MAX_USED_BITS.l_exp_flags); configure_decoder_setup(&setup_fx, dec, cfg->cmp_mode, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->l_fx); + cfg->round, MAX_USED_BITS.l_fx); configure_decoder_setup(&setup_efx, dec, cfg->cmp_mode, cfg->cmp_par_efx, cfg->spill_efx, - cfg->round, cfg->max_used_bits->l_efx); + cfg->round, MAX_USED_BITS.l_efx); configure_decoder_setup(&setup_fx_var, dec, cfg->cmp_mode, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_fx_variance); + cfg->round, MAX_USED_BITS.l_fx_variance); for (i = 0; ; i++) { err = decode_value(&setup_exp_flags, &decoded_value, model.exp_flags); @@ -1016,15 +1016,15 @@ static int decompress_l_fx_ncob(const struct cmp_cfg *cfg, struct bit_decoder *d } configure_decoder_setup(&setup_exp_flags, dec, cfg->cmp_mode, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->l_exp_flags); + cfg->round, MAX_USED_BITS.l_exp_flags); configure_decoder_setup(&setup_fx, dec, cfg->cmp_mode, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->l_fx); + cfg->round, MAX_USED_BITS.l_fx); configure_decoder_setup(&setup_ncob, dec, cfg->cmp_mode, cfg->cmp_par_ncob, cfg->spill_ncob, - cfg->round, cfg->max_used_bits->l_ncob); + cfg->round, MAX_USED_BITS.l_ncob); configure_decoder_setup(&setup_fx_var, dec, cfg->cmp_mode, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_fx_variance); + cfg->round, MAX_USED_BITS.l_fx_variance); configure_decoder_setup(&setup_cob_var, dec, cfg->cmp_mode, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_cob_variance); + cfg->round, MAX_USED_BITS.l_cob_variance); for (i = 0; ; i++) { err = decode_value(&setup_exp_flags, &decoded_value, model.exp_flags); @@ -1121,19 +1121,19 @@ static int decompress_l_fx_efx_ncob_ecob(const struct cmp_cfg *cfg, struct bit_d } configure_decoder_setup(&setup_exp_flags, dec, cfg->cmp_mode, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->l_exp_flags); + cfg->round, MAX_USED_BITS.l_exp_flags); configure_decoder_setup(&setup_fx, dec, cfg->cmp_mode, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->l_fx); + cfg->round, MAX_USED_BITS.l_fx); configure_decoder_setup(&setup_ncob, dec, cfg->cmp_mode, cfg->cmp_par_ncob, cfg->spill_ncob, - cfg->round, cfg->max_used_bits->l_ncob); + cfg->round, MAX_USED_BITS.l_ncob); configure_decoder_setup(&setup_efx, dec, cfg->cmp_mode, cfg->cmp_par_efx, cfg->spill_efx, - cfg->round, cfg->max_used_bits->l_efx); + cfg->round, MAX_USED_BITS.l_efx); configure_decoder_setup(&setup_ecob, dec, cfg->cmp_mode, cfg->cmp_par_ecob, cfg->spill_ecob, - cfg->round, cfg->max_used_bits->l_ecob); + cfg->round, MAX_USED_BITS.l_ecob); configure_decoder_setup(&setup_fx_var, dec, cfg->cmp_mode, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_fx_variance); + cfg->round, MAX_USED_BITS.l_fx_variance); configure_decoder_setup(&setup_cob_var, dec, cfg->cmp_mode, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_cob_variance); + cfg->round, MAX_USED_BITS.l_cob_variance); for (i = 0; ; i++) { err = decode_value(&setup_exp_flags, &decoded_value, model.exp_flags); @@ -1254,13 +1254,13 @@ static int decompress_offset(const struct cmp_cfg *cfg, struct bit_decoder *dec) switch (cfg->data_type) { case DATA_TYPE_F_CAM_OFFSET: - mean_bits_used = cfg->max_used_bits->fc_offset_mean; - variance_bits_used = cfg->max_used_bits->fc_offset_variance; + mean_bits_used = MAX_USED_BITS.fc_offset_mean; + variance_bits_used = MAX_USED_BITS.fc_offset_variance; break; case DATA_TYPE_OFFSET: default: - mean_bits_used = cfg->max_used_bits->nc_offset_mean; - variance_bits_used = cfg->max_used_bits->nc_offset_variance; + mean_bits_used = MAX_USED_BITS.nc_offset_mean; + variance_bits_used = MAX_USED_BITS.nc_offset_variance; break; } configure_decoder_setup(&setup_mean, dec, cfg->cmp_mode, cfg->cmp_par_offset_mean, cfg->spill_offset_mean, @@ -1333,15 +1333,15 @@ static int decompress_background(const struct cmp_cfg *cfg, struct bit_decoder * switch (cfg->data_type) { case DATA_TYPE_F_CAM_BACKGROUND: - mean_used_bits = cfg->max_used_bits->fc_background_mean; - variance_used_bits = cfg->max_used_bits->fc_background_variance; - outlier_pixels_used_bits = cfg->max_used_bits->fc_background_outlier_pixels; + mean_used_bits = MAX_USED_BITS.fc_background_mean; + variance_used_bits = MAX_USED_BITS.fc_background_variance; + outlier_pixels_used_bits = MAX_USED_BITS.fc_background_outlier_pixels; break; case DATA_TYPE_BACKGROUND: default: - mean_used_bits = cfg->max_used_bits->nc_background_mean; - variance_used_bits = cfg->max_used_bits->nc_background_variance; - outlier_pixels_used_bits = cfg->max_used_bits->nc_background_outlier_pixels; + mean_used_bits = MAX_USED_BITS.nc_background_mean; + variance_used_bits = MAX_USED_BITS.nc_background_variance; + outlier_pixels_used_bits = MAX_USED_BITS.nc_background_outlier_pixels; break; } @@ -1422,11 +1422,11 @@ static int decompress_smearing(const struct cmp_cfg *cfg, struct bit_decoder *de } configure_decoder_setup(&setup_mean, dec, cfg->cmp_mode, cfg->cmp_par_smearing_mean, cfg->spill_smearing_mean, - cfg->round, cfg->max_used_bits->smearing_mean); + cfg->round, MAX_USED_BITS.smearing_mean); configure_decoder_setup(&setup_var, dec, cfg->cmp_mode, cfg->cmp_par_smearing_variance, cfg->spill_smearing_variance, - cfg->round, cfg->max_used_bits->smearing_variance_mean); + cfg->round, MAX_USED_BITS.smearing_variance_mean); configure_decoder_setup(&setup_pix, dec, cfg->cmp_mode, cfg->cmp_par_smearing_pixels_error, cfg->spill_smearing_pixels_error, - cfg->round, cfg->max_used_bits->smearing_outlier_pixels); + cfg->round, MAX_USED_BITS.smearing_outlier_pixels); for (i = 0; ; i++) { err = decode_value(&setup_mean, &decoded_value, model.mean); @@ -1514,9 +1514,6 @@ static int decompressed_data_internal(const struct cmp_cfg *cfg, enum decmp_type if (!cfg->icu_output_buf) return -1; - if (!cfg->max_used_bits) - return -1; - if (cmp_imagette_data_type_is_used(cfg->data_type)) { if (cmp_cfg_imagette_is_invalid(cfg)) return -1; @@ -1712,9 +1709,8 @@ static int cmp_ent_read_header(struct cmp_entity *ent, struct cmp_cfg *cfg) cfg->icu_output_buf = cmp_ent_get_data_buf(ent); - cfg->max_used_bits = cmp_max_used_bits_list_get(cmp_ent_get_max_used_bits_version(ent)); - if (!cfg->max_used_bits) { - debug_print("Error: The Max. Used Bits Registry Version in the compression header is unknown."); + if (cmp_ent_get_reserved(ent)) { + debug_print("Error: The reserved field in the compressed header should be zero. Compressed data may be corrupted."); return -1; } @@ -2093,7 +2089,6 @@ int decompress_rdcu_data(uint32_t *compressed_data, const struct cmp_info *info, cfg.samples = info->samples_used; cfg.icu_output_buf = compressed_data; cfg.buffer_length = (info->cmp_size+7)/8; - cfg.max_used_bits = &MAX_USED_BITS_SAFE; return decompressed_data_internal(&cfg, RDCU_DECOMPRESSION); } diff --git a/lib/decompress/meson.build b/lib/decompress/meson.build index 08da610cfc6ae1e4af843f77c64ed70254d884c0..62ab3972090c12fdefde16946cda6ca4f92e36e0 100644 --- a/lib/decompress/meson.build +++ b/lib/decompress/meson.build @@ -1,4 +1,3 @@ decompress_sources = files([ - 'cmp_max_used_bits_list.c', 'decmp.c' ]) diff --git a/lib/icu_compress/cmp_icu.c b/lib/icu_compress/cmp_icu.c index 985beb8cad78df9220a014ddfdd86926ed1b9781..bb8df0f5370716b2fa7376f130f2ac1d7ee40e66 100644 --- a/lib/icu_compress/cmp_icu.c +++ b/lib/icu_compress/cmp_icu.c @@ -26,6 +26,7 @@ #include "../common/cmp_debug.h" #include "../common/cmp_data_types.h" #include "../common/cmp_support.h" +#include "../common/cmp_max_used_bits.h" #include "../common/cmp_entity.h" #include "../common/cmp_error.h" #include "../common/leon_inttypes.h" @@ -535,16 +536,16 @@ static uint32_t compress_imagette(const struct cmp_cfg *cfg, uint32_t stream_len switch (cfg->data_type) { case DATA_TYPE_IMAGETTE: case DATA_TYPE_IMAGETTE_ADAPTIVE: - max_data_bits = cfg->max_used_bits->nc_imagette; + max_data_bits = MAX_USED_BITS.nc_imagette; break; case DATA_TYPE_SAT_IMAGETTE: case DATA_TYPE_SAT_IMAGETTE_ADAPTIVE: - max_data_bits = cfg->max_used_bits->saturated_imagette; + max_data_bits = MAX_USED_BITS.saturated_imagette; break; default: case DATA_TYPE_F_CAM_IMAGETTE: case DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE: - max_data_bits = cfg->max_used_bits->fc_imagette; + max_data_bits = MAX_USED_BITS.fc_imagette; break; } @@ -602,9 +603,9 @@ static uint32_t compress_s_fx(const struct cmp_cfg *cfg, uint32_t stream_len) } configure_encoder_setup(&setup_exp_flag, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->s_exp_flags, cfg); + cfg->round, MAX_USED_BITS.s_exp_flags, cfg); configure_encoder_setup(&setup_fx, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->s_fx, cfg); + cfg->round, MAX_USED_BITS.s_fx, cfg); for (i = 0;; i++) { stream_len = encode_value(data_buf[i].exp_flags, model.exp_flags, @@ -663,11 +664,11 @@ static uint32_t compress_s_fx_efx(const struct cmp_cfg *cfg, uint32_t stream_len } configure_encoder_setup(&setup_exp_flag, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->s_exp_flags, cfg); + cfg->round, MAX_USED_BITS.s_exp_flags, cfg); configure_encoder_setup(&setup_fx, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->s_fx, cfg); + cfg->round, MAX_USED_BITS.s_fx, cfg); configure_encoder_setup(&setup_efx, cfg->cmp_par_efx, cfg->spill_efx, - cfg->round, cfg->max_used_bits->s_efx, cfg); + cfg->round, MAX_USED_BITS.s_efx, cfg); for (i = 0;; i++) { stream_len = encode_value(data_buf[i].exp_flags, model.exp_flags, @@ -732,11 +733,11 @@ static uint32_t compress_s_fx_ncob(const struct cmp_cfg *cfg, uint32_t stream_le } configure_encoder_setup(&setup_exp_flag, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->s_exp_flags, cfg); + cfg->round, MAX_USED_BITS.s_exp_flags, cfg); configure_encoder_setup(&setup_fx, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->s_fx, cfg); + cfg->round, MAX_USED_BITS.s_fx, cfg); configure_encoder_setup(&setup_ncob, cfg->cmp_par_ncob, cfg->spill_ncob, - cfg->round, cfg->max_used_bits->s_ncob, cfg); + cfg->round, MAX_USED_BITS.s_ncob, cfg); for (i = 0;; i++) { stream_len = encode_value(data_buf[i].exp_flags, model.exp_flags, @@ -808,15 +809,15 @@ static uint32_t compress_s_fx_efx_ncob_ecob(const struct cmp_cfg *cfg, uint32_t } configure_encoder_setup(&setup_exp_flag, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->s_exp_flags, cfg); + cfg->round, MAX_USED_BITS.s_exp_flags, cfg); configure_encoder_setup(&setup_fx, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->s_fx, cfg); + cfg->round, MAX_USED_BITS.s_fx, cfg); configure_encoder_setup(&setup_ncob, cfg->cmp_par_ncob, cfg->spill_ncob, - cfg->round, cfg->max_used_bits->s_ncob, cfg); + cfg->round, MAX_USED_BITS.s_ncob, cfg); configure_encoder_setup(&setup_efx, cfg->cmp_par_efx, cfg->spill_efx, - cfg->round, cfg->max_used_bits->s_efx, cfg); + cfg->round, MAX_USED_BITS.s_efx, cfg); configure_encoder_setup(&setup_ecob, cfg->cmp_par_ecob, cfg->spill_ecob, - cfg->round, cfg->max_used_bits->s_ecob, cfg); + cfg->round, MAX_USED_BITS.s_ecob, cfg); for (i = 0;; i++) { stream_len = encode_value(data_buf[i].exp_flags, model.exp_flags, @@ -905,11 +906,11 @@ static uint32_t compress_l_fx(const struct cmp_cfg *cfg, uint32_t stream_len) } configure_encoder_setup(&setup_exp_flag, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->l_exp_flags, cfg); + cfg->round, MAX_USED_BITS.l_exp_flags, cfg); configure_encoder_setup(&setup_fx, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->l_fx, cfg); + cfg->round, MAX_USED_BITS.l_fx, cfg); configure_encoder_setup(&setup_fx_var, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_fx_variance, cfg); + cfg->round, MAX_USED_BITS.l_fx_variance, cfg); for (i = 0;; i++) { stream_len = encode_value(data_buf[i].exp_flags, model.exp_flags, @@ -974,13 +975,13 @@ static uint32_t compress_l_fx_efx(const struct cmp_cfg *cfg, uint32_t stream_len } configure_encoder_setup(&setup_exp_flag, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->l_exp_flags, cfg); + cfg->round, MAX_USED_BITS.l_exp_flags, cfg); configure_encoder_setup(&setup_fx, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->l_fx, cfg); + cfg->round, MAX_USED_BITS.l_fx, cfg); configure_encoder_setup(&setup_efx, cfg->cmp_par_efx, cfg->spill_efx, - cfg->round, cfg->max_used_bits->l_efx, cfg); + cfg->round, MAX_USED_BITS.l_efx, cfg); configure_encoder_setup(&setup_fx_var, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_fx_variance, cfg); + cfg->round, MAX_USED_BITS.l_fx_variance, cfg); for (i = 0;; i++) { stream_len = encode_value(data_buf[i].exp_flags, model.exp_flags, @@ -1052,16 +1053,16 @@ static uint32_t compress_l_fx_ncob(const struct cmp_cfg *cfg, uint32_t stream_le } configure_encoder_setup(&setup_exp_flag, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->l_exp_flags, cfg); + cfg->round, MAX_USED_BITS.l_exp_flags, cfg); configure_encoder_setup(&setup_fx, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->l_fx, cfg); + cfg->round, MAX_USED_BITS.l_fx, cfg); configure_encoder_setup(&setup_ncob, cfg->cmp_par_ncob, cfg->spill_ncob, - cfg->round, cfg->max_used_bits->l_ncob, cfg); + cfg->round, MAX_USED_BITS.l_ncob, cfg); /* we use the cmp_par_fx_cob_variance parameter for fx and cob variance data */ configure_encoder_setup(&setup_fx_var, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_fx_variance, cfg); + cfg->round, MAX_USED_BITS.l_fx_variance, cfg); configure_encoder_setup(&setup_cob_var, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_cob_variance, cfg); + cfg->round, MAX_USED_BITS.l_cob_variance, cfg); for (i = 0;; i++) { stream_len = encode_value(data_buf[i].exp_flags, model.exp_flags, @@ -1151,20 +1152,20 @@ static uint32_t compress_l_fx_efx_ncob_ecob(const struct cmp_cfg *cfg, uint32_t } configure_encoder_setup(&setup_exp_flag, cfg->cmp_par_exp_flags, cfg->spill_exp_flags, - cfg->round, cfg->max_used_bits->l_exp_flags, cfg); + cfg->round, MAX_USED_BITS.l_exp_flags, cfg); configure_encoder_setup(&setup_fx, cfg->cmp_par_fx, cfg->spill_fx, - cfg->round, cfg->max_used_bits->l_fx, cfg); + cfg->round, MAX_USED_BITS.l_fx, cfg); configure_encoder_setup(&setup_ncob, cfg->cmp_par_ncob, cfg->spill_ncob, - cfg->round, cfg->max_used_bits->l_ncob, cfg); + cfg->round, MAX_USED_BITS.l_ncob, cfg); configure_encoder_setup(&setup_efx, cfg->cmp_par_efx, cfg->spill_efx, - cfg->round, cfg->max_used_bits->l_efx, cfg); + cfg->round, MAX_USED_BITS.l_efx, cfg); configure_encoder_setup(&setup_ecob, cfg->cmp_par_ecob, cfg->spill_ecob, - cfg->round, cfg->max_used_bits->l_ecob, cfg); + cfg->round, MAX_USED_BITS.l_ecob, cfg); /* we use compression parameters for both variance data fields */ configure_encoder_setup(&setup_fx_var, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_fx_variance, cfg); + cfg->round, MAX_USED_BITS.l_fx_variance, cfg); configure_encoder_setup(&setup_cob_var, cfg->cmp_par_fx_cob_variance, cfg->spill_fx_cob_variance, - cfg->round, cfg->max_used_bits->l_cob_variance, cfg); + cfg->round, MAX_USED_BITS.l_cob_variance, cfg); for (i = 0;; i++) { stream_len = encode_value(data_buf[i].exp_flags, model.exp_flags, @@ -1274,13 +1275,13 @@ static uint32_t compress_offset(const struct cmp_cfg *cfg, uint32_t stream_len) switch (cfg->data_type) { case DATA_TYPE_F_CAM_OFFSET: - mean_bits_used = cfg->max_used_bits->fc_offset_mean; - variance_bits_used = cfg->max_used_bits->fc_offset_variance; + mean_bits_used = MAX_USED_BITS.fc_offset_mean; + variance_bits_used = MAX_USED_BITS.fc_offset_variance; break; case DATA_TYPE_OFFSET: default: - mean_bits_used = cfg->max_used_bits->nc_offset_mean; - variance_bits_used = cfg->max_used_bits->nc_offset_variance; + mean_bits_used = MAX_USED_BITS.nc_offset_mean; + variance_bits_used = MAX_USED_BITS.nc_offset_variance; break; } configure_encoder_setup(&setup_mean, cfg->cmp_par_offset_mean, cfg->spill_offset_mean, @@ -1349,15 +1350,15 @@ static uint32_t compress_background(const struct cmp_cfg *cfg, uint32_t stream_l switch (cfg->data_type) { case DATA_TYPE_F_CAM_BACKGROUND: - mean_used_bits = cfg->max_used_bits->fc_background_mean; - varinace_used_bits = cfg->max_used_bits->fc_background_variance; - pixels_error_used_bits = cfg->max_used_bits->fc_background_outlier_pixels; + mean_used_bits = MAX_USED_BITS.fc_background_mean; + varinace_used_bits = MAX_USED_BITS.fc_background_variance; + pixels_error_used_bits = MAX_USED_BITS.fc_background_outlier_pixels; break; case DATA_TYPE_BACKGROUND: default: - mean_used_bits = cfg->max_used_bits->nc_background_mean; - varinace_used_bits = cfg->max_used_bits->nc_background_variance; - pixels_error_used_bits = cfg->max_used_bits->nc_background_outlier_pixels; + mean_used_bits = MAX_USED_BITS.nc_background_mean; + varinace_used_bits = MAX_USED_BITS.nc_background_variance; + pixels_error_used_bits = MAX_USED_BITS.nc_background_outlier_pixels; break; } configure_encoder_setup(&setup_mean, cfg->cmp_par_background_mean, cfg->spill_background_mean, @@ -1431,11 +1432,11 @@ static uint32_t compress_smearing(const struct cmp_cfg *cfg, uint32_t stream_len } configure_encoder_setup(&setup_mean, cfg->cmp_par_smearing_mean, cfg->spill_smearing_mean, - cfg->round, cfg->max_used_bits->smearing_mean, cfg); + cfg->round, MAX_USED_BITS.smearing_mean, cfg); configure_encoder_setup(&setup_var_mean, cfg->cmp_par_smearing_variance, cfg->spill_smearing_variance, - cfg->round, cfg->max_used_bits->smearing_variance_mean, cfg); + cfg->round, MAX_USED_BITS.smearing_variance_mean, cfg); configure_encoder_setup(&setup_pix, cfg->cmp_par_smearing_pixels_error, cfg->spill_smearing_pixels_error, - cfg->round, cfg->max_used_bits->smearing_outlier_pixels, cfg); + cfg->round, MAX_USED_BITS.smearing_outlier_pixels, cfg); for (i = 0;; i++) { stream_len = encode_value(data_buf[i].mean, model.mean, @@ -1484,9 +1485,6 @@ static uint32_t cmp_cfg_icu_is_invalid_error_code(const struct cmp_cfg *cfg) RETURN_ERROR_IF(cmp_cfg_gen_par_is_invalid(cfg) , PAR_GENERIC, ""); RETURN_ERROR_IF(cmp_cfg_icu_buffers_is_invalid(cfg), PAR_BUFFERS, ""); - if (cfg->cmp_mode != CMP_MODE_RAW) - RETURN_ERROR_IF(cmp_cfg_icu_max_used_bits_out_of_limit(cfg->max_used_bits), PAR_MAX_USED_BITS, ""); - if (cmp_imagette_data_type_is_used(cfg->data_type)) { RETURN_ERROR_IF(cmp_cfg_imagette_is_invalid(cfg), PAR_SPECIFIC, ""); } else if (cmp_fx_cob_data_type_is_used(cfg->data_type)) { @@ -1831,10 +1829,7 @@ static uint32_t cmp_ent_build_chunk_header(uint32_t *entity, uint32_t chunk_size /* model id/counter are set by the user with the compress_chunk_set_model_id_and_counter() */ err |= cmp_ent_set_model_id(ent, 0); err |= cmp_ent_set_model_counter(ent, 0); - if (cfg->max_used_bits) - err |= cmp_ent_set_max_used_bits_version(ent, cfg->max_used_bits->version); - else - err |= cmp_ent_set_max_used_bits_version(ent, 0); + err |= cmp_ent_set_reserved(ent, 0); err |= cmp_ent_set_lossy_cmp_par(ent, cfg->round); if (cfg->cmp_mode != CMP_MODE_RAW) { err |= cmp_ent_set_non_ima_spill1(ent, cfg->spill_par_1); @@ -1960,7 +1955,6 @@ static void init_cmp_cfg_from_cmp_par(const struct cmp_par *par, enum chunk_type cfg->cmp_mode = par->cmp_mode; cfg->model_value = par->model_value; cfg->round = par->lossy_par; - cfg->max_used_bits = &MAX_USED_BITS_SAFE; switch (chunk_type) { case CHUNK_TYPE_NCAM_IMAGETTE: @@ -2243,7 +2237,6 @@ int32_t compress_like_rdcu(const struct rdcu_cfg *rcfg, struct cmp_info *info) return (int32_t)compress_data_internal(NULL, 0); cfg.data_type = DATA_TYPE_IMAGETTE; - cfg.max_used_bits = &MAX_USED_BITS_SAFE; cfg.input_buf = rcfg->input_buf; cfg.model_buf = rcfg->model_buf; diff --git a/test/cmp_decmp/test_cmp_decmp.c b/test/cmp_decmp/test_cmp_decmp.c index 915a8cfd570604e58455bc8633ac330f145a8796..461f0cf1d22f73802f2419f58665ebc5dd199002 100644 --- a/test/cmp_decmp/test_cmp_decmp.c +++ b/test/cmp_decmp/test_cmp_decmp.c @@ -36,6 +36,7 @@ #include <leon_inttypes.h> #include <byteorder.h> #include <cmp_error.h> +#include <cmp_max_used_bits.h> #if defined __has_include # if __has_include(<time.h>) diff --git a/test/cmp_entity/test_cmp_entity.c b/test/cmp_entity/test_cmp_entity.c index 8a01b0b51292e7fd136547384a7535780d06fbd7..64d3a62eaa7470679d3b56fe6cf074838c66479e 100644 --- a/test/cmp_entity/test_cmp_entity.c +++ b/test/cmp_entity/test_cmp_entity.c @@ -610,32 +610,32 @@ void test_ent_model_counter(void) /** - * @test cmp_ent_set_max_used_bits_version - * @test cmp_ent_get_max_used_bits_version + * @test cmp_ent_set_reserved + * @test cmp_ent_get_reserved */ -void test_ent_max_used_bits_version(void) +void test_ent_reserved(void) { int error; struct cmp_entity ent = {0}; - uint8_t max_used_bits_version, max_used_bits_version_read; + uint8_t reserved, reserved_read; uint8_t *entity_p = (uint8_t *)&ent; - max_used_bits_version = 0x12; - error = cmp_ent_set_max_used_bits_version(&ent, max_used_bits_version); + reserved = 0x12; + error = cmp_ent_set_reserved(&ent, reserved); TEST_ASSERT_FALSE(error); - max_used_bits_version_read = cmp_ent_get_max_used_bits_version(&ent); - TEST_ASSERT_EQUAL_UINT32(max_used_bits_version, max_used_bits_version_read); + reserved_read = cmp_ent_get_reserved(&ent); + TEST_ASSERT_EQUAL_UINT32(reserved, reserved_read); /* check the right position in the header */ TEST_ASSERT_EQUAL_HEX(0x12, entity_p[29]); /* error cases */ - error = cmp_ent_set_max_used_bits_version(NULL, max_used_bits_version); + error = cmp_ent_set_reserved(NULL, reserved); TEST_ASSERT_TRUE(error); - max_used_bits_version_read = cmp_ent_get_max_used_bits_version(NULL); - TEST_ASSERT_EQUAL_UINT32(0, max_used_bits_version_read); + reserved_read = cmp_ent_get_reserved(NULL); + TEST_ASSERT_EQUAL_UINT32(0, reserved_read); } @@ -1464,7 +1464,7 @@ void test_cmp_ent_write_rdcu_cmp_pars(void) 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(0, cmp_ent_get_reserved(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)); @@ -1491,7 +1491,7 @@ void test_cmp_ent_write_rdcu_cmp_pars(void) 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(0, cmp_ent_get_reserved(ent)); TEST_ASSERT_EQUAL_INT(info.round_used, cmp_ent_get_lossy_cmp_par(ent)); free(ent); @@ -1520,7 +1520,7 @@ void test_cmp_ent_write_rdcu_cmp_pars(void) 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(0, cmp_ent_get_reserved(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)); @@ -1712,7 +1712,7 @@ void test_cmp_ent_create(void) TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_original_size(ent)); TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_cmp_mode(ent)); TEST_ASSERT_EQUAL_INT(0, 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_reserved(ent)); TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_lossy_cmp_par(ent)); TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_ima_spill(ent)); @@ -1736,7 +1736,7 @@ void test_cmp_ent_create(void) TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_original_size(ent)); TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_cmp_mode(ent)); TEST_ASSERT_EQUAL_INT(0, 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_reserved(ent)); TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_lossy_cmp_par(ent)); TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_ima_spill(ent)); @@ -1760,7 +1760,7 @@ void test_cmp_ent_create(void) TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_original_size(ent)); TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_cmp_mode(ent)); TEST_ASSERT_EQUAL_INT(0, 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_reserved(ent)); TEST_ASSERT_EQUAL_INT(0, cmp_ent_get_lossy_cmp_par(ent)); free(ent); @@ -1861,7 +1861,7 @@ void test_cmp_ent_print(void) uint32_t ap2_spill = 333; uint32_t ap2_golomb_par = 43; uint32_t cmp_size_byte = 60; - uint8_t max_used_bits_version = 42; + uint8_t reserved = 42; size = cmp_ent_create(NULL, data_type, 0, cmp_size_byte); TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size); @@ -1880,7 +1880,7 @@ void test_cmp_ent_print(void) 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_reserved(ent, reserved); cmp_ent_set_lossy_cmp_par(ent, lossy_cmp_par_used); cmp_ent_set_ima_spill(ent, spill); @@ -1928,7 +1928,7 @@ void test_cmp_ent_parse(void) uint32_t ap2_spill = 333; uint32_t ap2_golomb_par = 43; uint32_t cmp_size_byte = 60; - uint8_t max_used_bits_version = 42; + uint8_t resvered = 42; size = cmp_ent_create(NULL, data_type, 0, cmp_size_byte); TEST_ASSERT_EQUAL_UINT(IMAGETTE_ADAPTIVE_HEADER_SIZE+60, size); @@ -1947,7 +1947,7 @@ void test_cmp_ent_parse(void) 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_reserved(ent, resvered); cmp_ent_set_lossy_cmp_par(ent, lossy_cmp_par_used); cmp_ent_set_ima_spill(ent, spill); diff --git a/test/cmp_max_used_bits/meson.build b/test/cmp_max_used_bits/meson.build deleted file mode 100644 index b863442cc615cdd233797020fc204b22638e2da3..0000000000000000000000000000000000000000 --- a/test/cmp_max_used_bits/meson.build +++ /dev/null @@ -1 +0,0 @@ -test_cases += [[files('test_cmp_max_used_bits_list.c'), 'max_used_bits List Unit Tests']] diff --git a/test/cmp_max_used_bits/test_cmp_max_used_bits_list.c b/test/cmp_max_used_bits/test_cmp_max_used_bits_list.c deleted file mode 100644 index 21e6c08e71e17dd324fe4c11a48fb2f377ec4a81..0000000000000000000000000000000000000000 --- a/test/cmp_max_used_bits/test_cmp_max_used_bits_list.c +++ /dev/null @@ -1,195 +0,0 @@ -/** - * @file test_cmp_max_used_bits_list.c - * @author Dominik Loidolt (dominik.loidolt@univie.ac.at) - * @date 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 max_used_bits list tests - */ - - -#if !defined(__sparc__) && !defined(_WIN32) && !defined(_WIN64) -# define MAKE_MALLOC_FAIL_TEST -# define _GNU_SOURCE -# include <dlfcn.h> -# include <stdlib.h> -#endif - -#include <string.h> - -#include <unity.h> - -#include <cmp_max_used_bits_list.h> - -#ifdef MAKE_MALLOC_FAIL_TEST -/* if set the mock malloc will fail (return NULL) */ -static int malloc_fail; - - -/* - * mock of the malloc function; can controlled with the global malloc_fail variable - * see: https://jayconrod.com/posts/23/tutorial--function-interposition-in-linux - */ - -void* malloc(size_t size) -{ - static void* (*real_malloc)(size_t size) = NULL; - - if(malloc_fail) - return NULL; - - if (!real_malloc) { - *(void **)(&real_malloc) = dlsym(RTLD_NEXT, "malloc"); - /* The cast removes a gcc warning https://stackoverflow.com/a/31528674 */ - TEST_ASSERT_NOT_NULL(real_malloc); - } - - return real_malloc(size); -} -#endif - - -/** - * @test cmp_max_used_bits_list_add - * @test cmp_max_used_bits_list_get - * @test cmp_max_used_bits_list_delet - * @test cmp_max_used_bits_list_empty - */ - -void test_cmp_max_used_bits_list(void) -{ - struct cmp_max_used_bits i_32, i_34, i_35, i_36, i_255, i_0; - const struct cmp_max_used_bits *p; - int return_val; - - /* set up max_used_bits item */ - memset(&i_32, 32, sizeof(struct cmp_max_used_bits)); - i_32.version = 32; - memset(&i_34, 34, sizeof(struct cmp_max_used_bits)); - i_34.version = 34; - memset(&i_35, 35, sizeof(struct cmp_max_used_bits)); - i_35.version = 35; - memset(&i_36, 36, sizeof(struct cmp_max_used_bits)); - i_36.version = 36; - memset(&i_255, 0xFF, sizeof(struct cmp_max_used_bits)); - i_255.version = 255; - memset(&i_0, 0, sizeof(struct cmp_max_used_bits)); - i_0.version = 0; - - return_val = cmp_max_used_bits_list_add(&i_32); - TEST_ASSERT_EQUAL_INT(return_val, 0); - return_val = cmp_max_used_bits_list_add(&i_34); - TEST_ASSERT_EQUAL_INT(return_val, 0); - return_val = cmp_max_used_bits_list_add(&i_35); - TEST_ASSERT_EQUAL_INT(return_val, 0); - return_val = cmp_max_used_bits_list_add(&i_36); - TEST_ASSERT_EQUAL_INT(return_val, 0); - return_val = cmp_max_used_bits_list_add(&i_255); - TEST_ASSERT_EQUAL_INT(return_val, 0); - - /* error cases */ - return_val = cmp_max_used_bits_list_add(NULL); - TEST_ASSERT_EQUAL_INT(return_val, -1); - return_val = cmp_max_used_bits_list_add(&i_0); - TEST_ASSERT_EQUAL_INT(return_val, -1); - i_0.version = CMP_MAX_USED_BITS_RESERVED_VERSIONS-1; - return_val = cmp_max_used_bits_list_add(&i_0); - TEST_ASSERT_EQUAL_INT(return_val, -1); - - p = cmp_max_used_bits_list_get(32); - TEST_ASSERT_EQUAL_INT(p->version, 32); - TEST_ASSERT(!memcmp(p, &i_32, sizeof(struct cmp_max_used_bits))); - - p = cmp_max_used_bits_list_get(36); - TEST_ASSERT_EQUAL_INT(p->version, 36); - TEST_ASSERT(!memcmp(p, &i_36, sizeof(struct cmp_max_used_bits))); - - p = cmp_max_used_bits_list_get(35); - TEST_ASSERT_EQUAL_INT(p->version, 35); - TEST_ASSERT(!memcmp(p, &i_35, sizeof(struct cmp_max_used_bits))); - - p = cmp_max_used_bits_list_get(255); - TEST_ASSERT_EQUAL_INT(p->version, 255); - TEST_ASSERT(!memcmp(p, &i_255, sizeof(struct cmp_max_used_bits))); - - p = cmp_max_used_bits_list_get(34); - TEST_ASSERT_EQUAL_INT(p->version, 34); - TEST_ASSERT(!memcmp(p, &i_34, sizeof(struct cmp_max_used_bits))); - - p = cmp_max_used_bits_list_get(0); - TEST_ASSERT_EQUAL_INT(p->version, 0); - TEST_ASSERT(!memcmp(p, &MAX_USED_BITS_SAFE, sizeof(struct cmp_max_used_bits))); - - p = cmp_max_used_bits_list_get(1); - TEST_ASSERT_EQUAL_INT(p->version, 1); - TEST_ASSERT(!memcmp(p, &MAX_USED_BITS_V1, sizeof(struct cmp_max_used_bits))); - - /* Try to get an element that is not in the list */ - p = cmp_max_used_bits_list_get(42); - TEST_ASSERT_NULL(p); - - p = cmp_max_used_bits_list_get(3); - TEST_ASSERT_NULL(p); - - - /* overwrite a list item */ - memset(&i_35, 0x42, sizeof(struct cmp_max_used_bits)); - i_35.version = 35; - return_val = cmp_max_used_bits_list_add(&i_35); - TEST_ASSERT_EQUAL_INT(return_val, 1); - p = cmp_max_used_bits_list_get(35); - TEST_ASSERT_EQUAL_INT(p->version, 35); - TEST_ASSERT(!memcmp(p, &i_35, sizeof(struct cmp_max_used_bits))); - - /* delete item */ - cmp_max_used_bits_list_delet(35); - p = cmp_max_used_bits_list_get(35); - TEST_ASSERT_NULL(p); - - cmp_max_used_bits_list_delet(34); - p = cmp_max_used_bits_list_get(34); - TEST_ASSERT_NULL(p); - - /* empty item */ - cmp_max_used_bits_list_empty(); - p = cmp_max_used_bits_list_get(36); - TEST_ASSERT_NULL(p); - - cmp_max_used_bits_list_empty(); - p = cmp_max_used_bits_list_get(34); - TEST_ASSERT_NULL(p); - - p = cmp_max_used_bits_list_get(0); - TEST_ASSERT_EQUAL_INT(p->version, 0); - TEST_ASSERT(!memcmp(p, &MAX_USED_BITS_SAFE, sizeof(struct cmp_max_used_bits))); - - p = cmp_max_used_bits_list_get(1); - TEST_ASSERT_EQUAL_INT(p->version, 1); - TEST_ASSERT(!memcmp(p, &MAX_USED_BITS_V1, sizeof(struct cmp_max_used_bits))); - - return_val = cmp_max_used_bits_list_add(&i_36); - TEST_ASSERT_EQUAL_INT(return_val, 0); - - p = cmp_max_used_bits_list_get(36); - TEST_ASSERT_EQUAL_INT(p->version, 36); - TEST_ASSERT(!memcmp(p, &i_36, sizeof(struct cmp_max_used_bits))); - - cmp_max_used_bits_list_empty(); - - /* error case */ -#ifdef MAKE_MALLOC_FAIL_TEST - malloc_fail = 1; - return_val = cmp_max_used_bits_list_add(&i_36); - TEST_ASSERT_EQUAL_INT(return_val, -1); - malloc_fail = 0; -#endif -} diff --git a/test/decmp/test_decmp.c b/test/decmp/test_decmp.c index 438c3313938f9e5a0e393b57605ccdf3eb47c9d5..bb7bf1673ceedd65148e310b9b2abb4482c392fb 100644 --- a/test/decmp/test_decmp.c +++ b/test/decmp/test_decmp.c @@ -1029,7 +1029,6 @@ void test_decompress_imagette_model(void) cfg.model_value = 16; cfg.cmp_par_imagette = 4; cfg.spill_imagette = 48; - cfg.max_used_bits = &MAX_USED_BITS_SAFE; bit_init_decoder(&dec, cfg.icu_output_buf, cfg.buffer_length); diff --git a/test/fuzz/fuzz_compression.c b/test/fuzz/fuzz_compression.c index daff7433aa2ab1eb62408c5b3f89959d49637259..e3a121853dbe4267b659acc98c0872bb5a047710 100644 --- a/test/fuzz/fuzz_compression.c +++ b/test/fuzz/fuzz_compression.c @@ -100,7 +100,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size) case CMP_ERROR_PAR_GENERIC: case CMP_ERROR_PAR_SPECIFIC: case CMP_ERROR_PAR_BUFFERS: - case CMP_ERROR_PAR_MAX_USED_BITS: case CMP_ERROR_PAR_NULL: /* chunk errors */ case CMP_ERROR_CHUNK_NULL: diff --git a/test/fuzz/fuzz_round_trip.c b/test/fuzz/fuzz_round_trip.c index cef659128aa90940a410df9db6b79fb3c9b131ea..5fae042172b0556e7451d4827ffec6d397dea12b 100644 --- a/test/fuzz/fuzz_round_trip.c +++ b/test/fuzz/fuzz_round_trip.c @@ -88,7 +88,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size) case CMP_ERROR_PAR_GENERIC: case CMP_ERROR_PAR_SPECIFIC: case CMP_ERROR_PAR_BUFFERS: - case CMP_ERROR_PAR_MAX_USED_BITS: case CMP_ERROR_PAR_NULL: /* chunk errors */ case CMP_ERROR_CHUNK_NULL: diff --git a/test/meson.build b/test/meson.build index 7878b91bcb99f91f1025fb6599e5c45987446b34..b3aac802980d2981721b321e191c1b6b6c06f268 100644 --- a/test/meson.build +++ b/test/meson.build @@ -82,7 +82,6 @@ subdir('cmp_decmp') subdir('cmp_data_types') subdir('cmp_entity') subdir('cmp_rdcu_cfg') -subdir('cmp_max_used_bits') test_args = '-Wno-missing-declarations' # The test runner generator does not generate header files