#ifndef LIBRAW_INT_DEFINES_H
#define LIBRAW_INT_DEFINES_H
#ifndef USE_JPEG
#define NO_JPEG
#endif
#ifndef USE_JASPER
#define NO_JASPER
#endif
#define DCRAW_VERSION "9.26"
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#define _USE_MATH_DEFINES
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#ifdef __CYGWIN__
#include <io.h>
#endif
#if defined LIBRAW_WIN32_CALLS
#include <sys/utime.h>
#ifndef LIBRAW_NO_WINSOCK2
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#endif
#define snprintf _snprintf
#define strcasecmp stricmp
#define strncasecmp strnicmp
#else
#include <unistd.h>
#include <utime.h>
#include <netinet/in.h>
typedef long long INT64;
typedef unsigned long long UINT64;
#endif
#ifdef NODEPS
#define NO_JASPER
#define NO_JPEG
#define NO_LCMS
#endif
#ifndef NO_JASPER
#include <jasper/jasper.h>
#endif
#ifndef NO_JPEG
#include <jpeglib.h>
#endif
#ifndef NO_LCMS
#ifdef USE_LCMS
#include <lcms.h>
#else
#include <lcms2.h>
#endif
#endif
#ifdef LOCALEDIR
#include <libintl.h>
#define _(String) gettext(String)
#else
#define _(String) (String)
#endif
#ifdef LJPEG_DECODE
#error Please compile dcraw.c by itself.
#error Do not link it with ljpeg_decode.
#endif
#ifndef LONG_BIT
#define LONG_BIT (8 * sizeof(long))
#endif
#define FORC(cnt) for (c = 0; c < cnt; c++)
#define FORC3 FORC(3)
#define FORC4 FORC(4)
#define FORCC for (c = 0; c < colors && c < 4; c++)
#define SQR(x) ((x) * (x))
#define ABS(x) (((int)(x) ^ ((int)(x) >> 31)) - ((int)(x) >> 31))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define LIM(x, min, max) MAX(min, MIN(x, max))
#define ULIM(x, y, z) ((y) < (z) ? LIM(x, y, z) : LIM(x, z, y))
#define CLIP(x) LIM((int)(x), 0, 65535)
#define CLIP15(x) LIM((int)(x), 0, 32767)
#define SWAP(a, b) \
{ \
a = a + b; \
b = a - b; \
a = a - b; \
}
#define my_swap(type, i, j) \
{ \
type t = i; \
i = j; \
j = t; \
}
#ifdef __GNUC__
inline
#elif defined(_MSC_VER)
__forceinline
#else
static
#endif
float fMAX(float a, float b) { return MAX(a, b); }
#define GRBG_2_RGBG(q) (q ^ (q >> 1) ^ 1)
#define RGGB_2_RGBG(q) (q ^ (q >> 1))
#define BG2RG1_2_RGBG(q) (q ^ 2)
#define GRGB_2_RGBG(q) (q ^ 1)
#define RBGG_2_RGBG(q) ((q >> 1) | ((q & 1) << 1))
#define RAWINDEX(row, col) ((row)*raw_width + (col))
#define RAW(row, col) raw_image[(row)*raw_width + (col)]
#define BAYER(row, col) \
image[((row) >> shrink) * iwidth + ((col) >> shrink)][FC(row, col)]
#define BAYER2(row, col) \
image[((row) >> shrink) * iwidth + ((col) >> shrink)][fcol(row, col)]
#define BAYERC(row, col, c) \
imgdata.image[((row) >> IO.shrink) * S.iwidth + ((col) >> IO.shrink)][c]
#endif