diff --git a/lib/icu_compress/cmp_chunk_type.c b/lib/icu_compress/cmp_chunk_type.c new file mode 100644 index 0000000000000000000000000000000000000000..c6b9c45a6b32b6d9997bc7ecb5a6212a4659b2be --- /dev/null +++ b/lib/icu_compress/cmp_chunk_type.c @@ -0,0 +1,82 @@ +/** + * @file cmp_chunk_type.h + * @author Dominik Loidolt (dominik.loidolt@univie.ac.at) + * @date 2024 + * + * @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 functions and definitions for determining the chunk type of PLATO data + */ + +#include "cmp_chunk_type.h" +#include "../common/cmp_debug.h" +#include "../common/cmp_data_types.h" + + +/** + * @brief get the chunk_type of a collection + * @details map a sub-service to a chunk service according to + * DetailedBudgetWorking_2023-10-11 + * + * @param col pointer to a collection header + * + * @returns chunk type of the collection, CHUNK_TYPE_UNKNOWN on + * failure + */ + +enum chunk_type cmp_col_get_chunk_type(const struct collection_hdr *col) +{ + enum chunk_type chunk_type; + + switch (cmp_col_get_subservice(col)) { + case SST_NCxx_S_SCIENCE_IMAGETTE: + chunk_type = CHUNK_TYPE_NCAM_IMAGETTE; + break; + case SST_NCxx_S_SCIENCE_SAT_IMAGETTE: + chunk_type = CHUNK_TYPE_SAT_IMAGETTE; + break; + case SST_NCxx_S_SCIENCE_OFFSET: + case SST_NCxx_S_SCIENCE_BACKGROUND: + chunk_type = CHUNK_TYPE_OFFSET_BACKGROUND; + break; + case SST_NCxx_S_SCIENCE_SMEARING: + chunk_type = CHUNK_TYPE_SMEARING; + break; + case SST_NCxx_S_SCIENCE_S_FX: + case SST_NCxx_S_SCIENCE_S_FX_EFX: + case SST_NCxx_S_SCIENCE_S_FX_NCOB: + case SST_NCxx_S_SCIENCE_S_FX_EFX_NCOB_ECOB: + chunk_type = CHUNK_TYPE_SHORT_CADENCE; + break; + case SST_NCxx_S_SCIENCE_L_FX: + case SST_NCxx_S_SCIENCE_L_FX_EFX: + case SST_NCxx_S_SCIENCE_L_FX_NCOB: + case SST_NCxx_S_SCIENCE_L_FX_EFX_NCOB_ECOB: + chunk_type = CHUNK_TYPE_LONG_CADENCE; + break; + case SST_FCx_S_SCIENCE_IMAGETTE: + case SST_FCx_S_SCIENCE_OFFSET_VALUES: + case SST_FCx_S_BACKGROUND_VALUES: + chunk_type = CHUNK_TYPE_F_CHAIN; + break; + case SST_NCxx_S_SCIENCE_F_FX: + case SST_NCxx_S_SCIENCE_F_FX_EFX: + case SST_NCxx_S_SCIENCE_F_FX_NCOB: + case SST_NCxx_S_SCIENCE_F_FX_EFX_NCOB_ECOB: + debug_print("Error: No chunk is defined for fast cadence subservices"); + /* fall through */ + default: + chunk_type = CHUNK_TYPE_UNKNOWN; + break; + } + + return chunk_type; +} diff --git a/lib/icu_compress/cmp_chunk_type.h b/lib/icu_compress/cmp_chunk_type.h new file mode 100644 index 0000000000000000000000000000000000000000..b72669216e2578da8d7038edd65cf100e19e596f --- /dev/null +++ b/lib/icu_compress/cmp_chunk_type.h @@ -0,0 +1,44 @@ +/** + * @file cmp_chunk_type.h + * @author Dominik Loidolt (dominik.loidolt@univie.ac.at) + * @date 2024 + * + * @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 functions and definitions for determining the chunk type of PLATO data + */ + +#ifndef CMP_CHUNK_TYPE_H +#define CMP_CHUNK_TYPE_H + +#include "../common/cmp_data_types.h" + + +/** + * @brief types of chunks containing different types of collections + * according to DetailedBudgetWorking_2023-10-11 + */ + +enum chunk_type { + CHUNK_TYPE_UNKNOWN, + CHUNK_TYPE_NCAM_IMAGETTE, + CHUNK_TYPE_SHORT_CADENCE, + CHUNK_TYPE_LONG_CADENCE, + CHUNK_TYPE_SAT_IMAGETTE, + CHUNK_TYPE_OFFSET_BACKGROUND, /* N-CAM */ + CHUNK_TYPE_SMEARING, + CHUNK_TYPE_F_CHAIN +}; + + +enum chunk_type cmp_col_get_chunk_type(const struct collection_hdr *col); + +#endif /* CMP_CHUNK_TYPE_H */ diff --git a/lib/icu_compress/cmp_icu.c b/lib/icu_compress/cmp_icu.c index b57d2acd039acb6371eba7adc8916c7ee6e1cc70..5d8fbdbf93b31e0316c9325454f128f09beb7539 100644 --- a/lib/icu_compress/cmp_icu.c +++ b/lib/icu_compress/cmp_icu.c @@ -30,6 +30,7 @@ #include "../common/cmp_entity.h" #include "../common/cmp_error.h" #include "../common/leon_inttypes.h" +#include "cmp_chunk_type.h" #include "../cmp_icu.h" #include "../cmp_chunk.h" @@ -1901,84 +1902,6 @@ static uint32_t cmp_ent_build_chunk_header(uint32_t *entity, uint32_t chunk_size } -/** - * @brief types of chunks containing different types of collections - * according to DetailedBudgetWorking_2023-10-11 - */ - -enum chunk_type { - CHUNK_TYPE_UNKNOWN, - CHUNK_TYPE_NCAM_IMAGETTE, - CHUNK_TYPE_SHORT_CADENCE, - CHUNK_TYPE_LONG_CADENCE, - CHUNK_TYPE_SAT_IMAGETTE, - CHUNK_TYPE_OFFSET_BACKGROUND, /* N-CAM */ - CHUNK_TYPE_SMEARING, - CHUNK_TYPE_F_CHAIN -}; - - -/** - * @brief get the chunk_type of a collection - * @details map a sub-service to a chunk service according to - * DetailedBudgetWorking_2023-10-11 - * - * @param col pointer to a collection header - * - * @returns chunk type of the collection, CHUNK_TYPE_UNKNOWN on - * failure - */ - -static enum chunk_type cmp_col_get_chunk_type(const struct collection_hdr *col) -{ - enum chunk_type chunk_type; - - switch (cmp_col_get_subservice(col)) { - case SST_NCxx_S_SCIENCE_IMAGETTE: - chunk_type = CHUNK_TYPE_NCAM_IMAGETTE; - break; - case SST_NCxx_S_SCIENCE_SAT_IMAGETTE: - chunk_type = CHUNK_TYPE_SAT_IMAGETTE; - break; - case SST_NCxx_S_SCIENCE_OFFSET: - case SST_NCxx_S_SCIENCE_BACKGROUND: - chunk_type = CHUNK_TYPE_OFFSET_BACKGROUND; - break; - case SST_NCxx_S_SCIENCE_SMEARING: - chunk_type = CHUNK_TYPE_SMEARING; - break; - case SST_NCxx_S_SCIENCE_S_FX: - case SST_NCxx_S_SCIENCE_S_FX_EFX: - case SST_NCxx_S_SCIENCE_S_FX_NCOB: - case SST_NCxx_S_SCIENCE_S_FX_EFX_NCOB_ECOB: - chunk_type = CHUNK_TYPE_SHORT_CADENCE; - break; - case SST_NCxx_S_SCIENCE_L_FX: - case SST_NCxx_S_SCIENCE_L_FX_EFX: - case SST_NCxx_S_SCIENCE_L_FX_NCOB: - case SST_NCxx_S_SCIENCE_L_FX_EFX_NCOB_ECOB: - chunk_type = CHUNK_TYPE_LONG_CADENCE; - break; - case SST_FCx_S_SCIENCE_IMAGETTE: - case SST_FCx_S_SCIENCE_OFFSET_VALUES: - case SST_FCx_S_BACKGROUND_VALUES: - chunk_type = CHUNK_TYPE_F_CHAIN; - break; - case SST_NCxx_S_SCIENCE_F_FX: - case SST_NCxx_S_SCIENCE_F_FX_EFX: - case SST_NCxx_S_SCIENCE_F_FX_NCOB: - case SST_NCxx_S_SCIENCE_F_FX_EFX_NCOB_ECOB: - debug_print("Error: No chunk is defined for fast cadence subservices"); - /* fall through */ - default: - chunk_type = CHUNK_TYPE_UNKNOWN; - break; - } - - return chunk_type; -} - - /** * @brief Set the compression configuration from the compression parameters * based on the chunk type of the collection diff --git a/lib/icu_compress/meson.build b/lib/icu_compress/meson.build index 01f4d370992dd60de5a047e2a0ce7bd850b6825f..bbddb279b62b8ca099d46e7fc624fb93efd62184 100644 --- a/lib/icu_compress/meson.build +++ b/lib/icu_compress/meson.build @@ -1,3 +1,4 @@ icu_compress_sources = files([ + 'cmp_chunk_type.c', 'cmp_icu.c' ])