/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF.  The full HDF copyright notice, including       *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/.  *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*-----------------------------------------------------------------------------
 * File:    hcomp.h
 * Purpose: header file for compression information & structures
 * Dependencies: should be included after hdf.h
 * Invokes:
 * Contents:
 * Structure definitions: comp_info
 * Constant definitions: lots...
 *---------------------------------------------------------------------------*/

#ifndef H4_HCOMP_H
#define H4_HCOMP_H

#include "hdf.h"

/* For determining which type of modeling is being done */
typedef enum {
    COMP_MODEL_STDIO = 0 /* for Standard C I/O model */
} comp_model_t;

/* For determining which type of encoding is being done */
typedef enum {
    COMP_CODE_NONE = 0,   /* don't encode at all, just store */
    COMP_CODE_RLE,        /* for simple RLE encoding */
    COMP_CODE_NBIT,       /* for N-bit encoding */
    COMP_CODE_SKPHUFF,    /* for Skipping huffman encoding */
    COMP_CODE_DEFLATE,    /* for gzip 'deflate' encoding */
    COMP_CODE_SZIP,       /* for szip encoding */
    COMP_CODE_INVALID,    /* invalid last code, for range checking */
    COMP_CODE_JPEG,       /* _Ugly_ hack to allow JPEG images to be created with GRsetcompress */
    COMP_CODE_IMCOMP = 12 /* another _Ugly_ hack to allow IMCOMP images to
                   be inquired, 12 to be the same as COMP_IMCOMP writing
                   will not be allowed, however.  -BMR, Jul 2012 */
} comp_coder_t;

/* Compression types available */
#define COMP_NONE   0
#define COMP_JPEG   2
#define COMP_RLE    11
#define COMP_IMCOMP 12

/* Compression encoder/decoder configuration */
#define COMP_DECODER_ENABLED 1
#define COMP_ENCODER_ENABLED 2

typedef union tag_model_info { /* Union to contain modeling information */
    struct {
        int32  nt;   /* number type */
        int    ndim; /* number of dimensions */
        int32 *dims; /* array of dimensions */
    } dim;
} model_info;

typedef union tag_comp_info { /* Union to contain compression information */
    struct {                  /* Struct to contain information about how to compress */
        /* or decompress a JPEG encoded 24-bit image */
        int quality; /* Quality factor for JPEG compression, should be from */
        /* 0 (terrible) to 100 (very good) */
        int force_baseline; /* If force_baseline is set to TRUE then */
        /* quantization tables are limited to */
        /* 0..255 for JPEG baseline compatibility */
        /* This is only an issue for quality */
        /* settings below 24 */
    } jpeg;
    struct { /* struct to contain information about how to compress */
        /* or decompress a N-bit encoded dataset */
        int32 nt;        /* number type of the data to encode */
        int   sign_ext;  /* whether to sign extend or not */
        int   fill_one;  /* whether to fill with 1's or 0's */
        int   start_bit; /* offset of the start bit in the data */
        int   bit_len;   /* number of bits to store */
    } nbit;
    struct { /* struct to contain info about how to compress */
        /* or decompress a "skipping" huffman encoded dataset */
        int skp_size; /* size of the individual elements when skipping */
    } skphuff;
    struct { /* struct to contain info about how to compress */
        /* or decompress a gzip encoded dataset */
        int level; /* how hard to work when compressing the data */
    } deflate;
    struct {
        int32 options_mask;        /* IN */
        int32 pixels_per_block;    /* IN */
        int32 pixels_per_scanline; /* OUT: computed */
        int32 bits_per_pixel;      /* OUT: size of NT */
        int32 pixels;              /* OUT: size of dataset or chunk */
    } szip;                        /* for szip encoding */

} comp_info;

#ifdef __cplusplus
extern "C" {
#endif

HDFLIBAPI uint16 compress_map[];

#ifdef __cplusplus
}
#endif

#endif /* H4_HCOMP_H */
