/*
 * This file defines the atc_options C struct and the supporting C enums
 * while also declaring the global constant ATC_OPTIONS_DEFAULT,
 * which serves as a default prototype instance of atc_options.
 */

#pragma once

#include <stddef.h>
#include <stdbool.h>

#include "atc/slice.h"

/// C equivalent of `atc::StorageOrder`.
typedef enum {ATC_MSI = 0, ATC_LSI = 1} atc_storage_order;
/// C equivalent of `atc::FloatType`.
typedef enum {ATC_FLOAT_TYPE_FLOAT32 = 0, ATC_FLOAT_TYPE_FLOAT64 = 1} atc_float_type;
/// C equivalent of `atc::ErrorMetric`.
typedef enum {ATC_RELATIVE_ERROR = 0, ATC_RMSE = 1, ATC_PSNR = 2} atc_error_metric;
/// C equivalent of `atc::IntType`.
typedef enum {ATC_INT_TYPE_UINT32 = 0, ATC_INT_TYPE_UINT64 = 1} atc_int_type;
/// C equivalent of `atc::CoreFlattening`.
typedef enum {ATC_UNFOLD = 0, ATC_ZIGZAG = 1, ATC_ZORDER = 2} atc_core_flattening;
/// C equivalent of `atc::EntropyCodingMethod`.
typedef enum {ATC_ARITHMETIC = 0, ATC_ANS = 1} atc_entropy_coding_method;

/**
 * \verbatim embed:rst
   C equivalent of :any:`atc::Options`.
   In order to create an :any:`atc_options` struct with default values, do not use the default constructor.
   Instead, use the global constant :any:`ATC_OPTIONS_DEFAULT`.
   \endverbatim
 */
typedef struct atc_options {
	
	// General options
	
	bool verbose;
	bool suppress_warnings;
	bool timings;
	int threads;
	atc_storage_order storage_order;
	atc_float_type float_type;
	
	// Compression options
	
	// General
	size_t skip_bytes;
	atc_error_metric error_metric;
	
	// T-HODCT
	bool apply_dct;
	double dct_truncation_max_sse_share;
	
	// ST-HOSVD
	double rank_truncation_max_sse_share;
	uint8_t* mode_processing_order; ///< If not null, assumed to be an array of length ``modes``.
	bool precise_svd;
	bool print_squared_singular_values;
	bool householder;
	
	// Quantization
	atc_int_type int_type;
	atc_core_flattening core_flattening;
	uint8_t* mode_storage_order; ///< If not null, assumed to be an array of length ``modes``.
	size_t quantization_blocks;
	size_t last_pass_max_threads;
	double quantization_rel_error_margin;
	bool split_bitplane_truncation;
	
	// Encoding
	atc_entropy_coding_method entropy_coding_method;
	
	// Decompression options
	size_t cutout_length;
	atc_slice* cutout; ///< An array of length ``cutout_length``.
	bool autocrop;
	double autocrop_threshold;
	
	// compress_decompress options
	
	bool calculate_error;
	
} atc_options;

/// Constant which serves as a prototype for new `atc_options` structs, with all fields initialized to the default values corresponding to those of `atc::Options`.
extern const atc_options ATC_OPTIONS_DEFAULT;
