#define H5Z_scaleoffset_precompress_3(type, pow_fun, abs_fun, round_fun, lround_fun, llround_fun, data, d_nelmts, filavail, cd_values,         \
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 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/HDF5/releases.  *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "H5Zmodule.h"          /* This source code file is part of the H5Z module */
#include "H5private.h"        /* Generic Functions            */
#include "H5ACprivate.h"    /* Metadata cache            */
#include "H5Eprivate.h"        /* Error handling              */
#include "H5Iprivate.h"        /* IDs                      */
#include "H5MMprivate.h"    /* Memory management            */
#include "H5Pprivate.h"         /* Property lists                       */
#include "H5Oprivate.h"         /* Object headers                       */
#include "H5Sprivate.h"        /* Dataspaces                     */
#include "H5Tprivate.h"        /* Datatypes                     */
#include "H5Zpkg.h"        /* Data filters                */
/* Struct of parameters needed for compressing/decompressing one atomic datatype */
typedef struct {
   unsigned size;      /* datatype size */
   uint32_t minbits;   /* minimum bits to compress one value of such datatype */
   unsigned mem_order; /* current memory endianness order */
} parms_atomic;
enum H5Z_scaleoffset_t {t_bad=0, t_uchar=1, t_ushort, t_uint, t_ulong, t_ulong_long,
                           t_schar, t_short, t_int, t_long, t_long_long,
                           t_float, t_double};
/* Local function prototypes */
static htri_t H5Z_can_apply_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id);
static enum H5Z_scaleoffset_t H5Z_scaleoffset_get_type(unsigned dtype_class,
    unsigned dtype_size, unsigned dtype_sign);
static herr_t H5Z_scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist,
    H5T_t *type, enum H5Z_scaleoffset_t scale_type, unsigned cd_values[],
    int need_convert);
static herr_t H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id);
static size_t H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts,
    const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf);
static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size);
static H5_ATTR_CONST unsigned H5Z_scaleoffset_log2(unsigned long long num);
static void H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts,
    enum H5Z_scaleoffset_t type, unsigned filavail, const unsigned cd_values[],