Logo Search packages:      
Sourcecode: librasterlite version File versions  Download package

common.h

Go to the documentation of this file.
/*
 * $Id: common.h,v 1.27 2008/03/25 19:31:45 simakov Exp $
 *
 * EPSILON - wavelet image compression library.
 * Copyright (C) 2006-2007 Alexander Simakov, <xander@entropyware.info>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * http://epsilon-project.sourceforge.net
 */

/** \file
 *
 *  \brief Useful macro and defines
 *
 *  This file contains useful macro and defines which are
 *  common to all library parts. */

#ifndef __COMMON_H__
#define __COMMON_H__

#ifdef __cplusplus
extern "C" {
#endif

/** \addtogroup misc Miscellanea */
/*@{*/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <sys/types.h>

/** Maximum value */
00051 #define MAX(_x, _y)             ((_x) > (_y) ? (_x) : (_y))
/** Minimum value */
00053 #define MIN(_x, _y)             ((_x) < (_y) ? (_x) : (_y))
/** Absolute value */
00055 #define ABS(_x)                 ((_x) >= 0 ? (_x) : -(_x))
/** Square root */
00057 #define SQRT2                   1.414213562373095
/** Very helpful definition */
00059 #define local                   static

/** Table to speed-up number_of_bits() calculation */
00062 local int number_of_bits_table[256] = {
    0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
};

/** Number of bits in a byte value */
00082 #define NUMBER_OF_BITS(_x) (number_of_bits_table[(_x)])
/** Extract one byte from integer */
00084 #define GET_BYTE(_x, _i) (((unsigned char *) &(_x))[(_i)])

/** Type definition for filter coefficients */
00087 typedef double coeff_t;

/** Number of bits in the value
 *
 *  This function computes the number of bits in the \a value
 *  (e.g. number_of_bits(13) = 4).
 *
 *  \param value Target value
 *
 *  \return Number of bits */
int number_of_bits(int value);

/** Check whether the \a value is a power of two or not
 *
 *  This function checks whether the \a value is a
 *  power of two or not.
 *
 *  \param value Target value
 *
 *  \return \c 1 if \a value is a power of two and \c 0 otherwise */
int is_power_of_two(int value);

/*@}*/

#ifdef __cplusplus
}
#endif

#endif /* __COMMON_H__ */

Generated by  Doxygen 1.6.0   Back to index