Skip to content
Snippets Groups Projects
Select Git revision
  • 91c1d810fe0924150086b2a4833e67cb13f3e952
  • main default protected
2 results

reference.apkg

Blame
  • cmp_tool.c 26.48 KiB
    /**
     * @file   cmp_tool.c
     * @author Dominik Loidolt (dominik.loidolt@univie.ac.at)
     * @author Johannes Seelig (johannes.seelig@univie.ac.at)
     * @date   2020
     *
     * @copyright GPLv2
     * This program is free software; you can redistribute it and/or modify it
     * under the terms and conditions of the GNU General Public License,
     * version 2, as published by the Free Software Foundation.
     *
     * This program is distributed in the hope it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
     * more details.
     *
     * @brief command line tool for PLATO ICU/RDCU compression/decompression
     * @see README.md
     * @see Data Compression User Manual PLATO-UVIE-PL-UM-0001
     */
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <limits.h>
    #include <getopt.h>
    
    #include "cmp_tool-config.h"
    #include "cmp_io.h"
    #include "cmp_icu.h"
    #include "cmp_rdcu.h"
    #include "decmp.h"
    #include "cmp_guess.h"
    #include "cmp_entity.h"
    #include "rdcu_pkt_to_file.h"
    #include "cmp_data_types.h"
    
    
    #define BUFFER_LENGTH_DEF_FAKTOR 2
    
    #define DEFAULT_MODEL_ID 53264  /* random default id */
    #define DEFAULT_MODEL_COUNTER 0
    
    
    /* parse a data_type option argument */
    static enum cmp_data_type parse_data_type(const char *data_type_str);
    
    /* find a good set of compression parameters for a given dataset */
    static int guess_cmp_pars(struct cmp_cfg *cfg, const char *guess_cmp_mode,
    			  int guess_level);
    
    /* compress the data and write the results to files */
    static int compression(struct cmp_cfg *cfg, struct cmp_info *info);
    
    /* decompress the data and write the results in file(s)*/
    static int decompression(struct cmp_entity *ent, uint16_t *input_model_buf);
    
    /* create a default configuration for a compression data type */
    enum cfg_default_opt {DIFF_CFG, MODEL_CFG};
    static int cmp_cfg_create_default(struct cmp_cfg *cfg, enum cmp_data_type data_type,
    				  enum cfg_default_opt mode);
    
    
    /*
     * For long options that have no equivalent short option, use a
     * non-character as a pseudo short option, starting with CHAR_MAX + 1.
     */
    enum {
    	DIFF_CFG_OPTION = CHAR_MAX + 1,
    	GUESS_OPTION,
    	GUESS_LEVEL,