-typedef unsigned int OPJ_SIZE_T;
-typedef double OPJ_FLOAT64;
-typedef float OPJ_FLOAT32;
-
-#if (defined(WIN32) || defined(WIN64)) && !defined(__MINGW32__)
-
-typedef signed __int64 OPJ_INT64;
-#define OPJ_INT64_F "I64"
-typedef unsigned __int64 OPJ_UINT64;
+typedef size_t OPJ_SIZE_T;
+
+#include "opj_config.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+typedef int8_t OPJ_INT8;
+typedef uint8_t OPJ_UINT8;
+typedef int16_t OPJ_INT16;
+typedef uint16_t OPJ_UINT16;
+typedef int32_t OPJ_INT32;
+typedef uint32_t OPJ_UINT32;
+typedef int64_t OPJ_INT64;
+typedef uint64_t OPJ_UINT64;
+#define OPJ_INT64_F "ll"
+#define OPJ_UINT64_F "ll"
+#else
+#if defined(_WIN32)
+typedef signed __int8 OPJ_INT8;
+typedef unsigned __int8 OPJ_UINT8;
+typedef signed __int16 OPJ_INT16;
+typedef unsigned __int16 OPJ_UINT16;
+typedef signed __int32 OPJ_INT32;
+typedef unsigned __int32 OPJ_UINT32;
+typedef signed __int64 OPJ_INT64;
+typedef unsigned __int64 OPJ_UINT64;
+#define OPJ_INT64_F "I64"