Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/openjpeg/src/lib/openjp2/opj_includes.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 * The copyright in this software is being made available under the 2-clauses | |
| 3 * BSD License, included below. This software may be subject to other third | |
| 4 * party and contributor rights, including patent rights, and no such rights | |
| 5 * are granted under this license. | |
| 6 * | |
| 7 * Copyright (c) 2005, Herve Drolon, FreeImage Team | |
| 8 * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR | |
| 9 * Copyright (c) 2012, CS Systemes d'Information, France | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * Redistribution and use in source and binary forms, with or without | |
| 13 * modification, are permitted provided that the following conditions | |
| 14 * are met: | |
| 15 * 1. Redistributions of source code must retain the above copyright | |
| 16 * notice, this list of conditions and the following disclaimer. | |
| 17 * 2. Redistributions in binary form must reproduce the above copyright | |
| 18 * notice, this list of conditions and the following disclaimer in the | |
| 19 * documentation and/or other materials provided with the distribution. | |
| 20 * | |
| 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' | |
| 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
| 25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 31 * POSSIBILITY OF SUCH DAMAGE. | |
| 32 */ | |
| 33 #ifndef OPJ_INCLUDES_H | |
| 34 #define OPJ_INCLUDES_H | |
| 35 | |
| 36 /* | |
| 37 * This must be included before any system headers, | |
| 38 * since they can react to macro defined there | |
| 39 */ | |
| 40 #include "opj_config_private.h" | |
| 41 | |
| 42 /* | |
| 43 ========================================================== | |
| 44 Standard includes used by the library | |
| 45 ========================================================== | |
| 46 */ | |
| 47 #include <memory.h> | |
| 48 #include <stdlib.h> | |
| 49 #include <string.h> | |
| 50 #include <math.h> | |
| 51 #include <float.h> | |
| 52 #include <time.h> | |
| 53 #include <stdio.h> | |
| 54 #include <stdarg.h> | |
| 55 #include <ctype.h> | |
| 56 #include <assert.h> | |
| 57 #include <limits.h> | |
| 58 #include <stdint.h> | |
| 59 #include <inttypes.h> | |
| 60 | |
| 61 /* | |
| 62 Use fseeko() and ftello() if they are available since they use | |
| 63 'off_t' rather than 'long'. It is wrong to use fseeko() and | |
| 64 ftello() only on systems with special LFS support since some systems | |
| 65 (e.g. FreeBSD) support a 64-bit off_t by default. | |
| 66 */ | |
| 67 #if defined(OPJ_HAVE_FSEEKO) && !defined(fseek) | |
| 68 # define fseek fseeko | |
| 69 # define ftell ftello | |
| 70 #endif | |
| 71 | |
| 72 | |
| 73 #if defined(WIN32) && !defined(Windows95) && !defined(__BORLANDC__) && \ | |
| 74 !(defined(_MSC_VER) && _MSC_VER < 1400) && \ | |
| 75 !(defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x800) | |
| 76 /* | |
| 77 Windows '95 and Borland C do not support _lseeki64 | |
| 78 Visual Studio does not support _fseeki64 and _ftelli64 until the 2005 release. | |
| 79 Without these interfaces, files over 2GB in size are not supported for Windows. | |
| 80 */ | |
| 81 # define OPJ_FSEEK(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence) | |
| 82 # define OPJ_FSTAT(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff) | |
| 83 # define OPJ_FTELL(stream) /* __int64 */ _ftelli64(stream) | |
| 84 # define OPJ_STAT_STRUCT_T struct _stati64 | |
| 85 # define OPJ_STAT(path,stat_buff) _stati64(path,/* struct _stati64 */ stat_buff) | |
| 86 #else | |
| 87 # define OPJ_FSEEK(stream,offset,whence) fseek(stream,offset,whence) | |
| 88 # define OPJ_FSTAT(fildes,stat_buff) fstat(fildes,stat_buff) | |
| 89 # define OPJ_FTELL(stream) ftell(stream) | |
| 90 # define OPJ_STAT_STRUCT_T struct stat | |
| 91 # define OPJ_STAT(path,stat_buff) stat(path,stat_buff) | |
| 92 #endif | |
| 93 | |
| 94 | |
| 95 /* | |
| 96 ========================================================== | |
| 97 OpenJPEG interface | |
| 98 ========================================================== | |
| 99 */ | |
| 100 #include "openjpeg.h" | |
| 101 | |
| 102 /* | |
| 103 ========================================================== | |
| 104 OpenJPEG modules | |
| 105 ========================================================== | |
| 106 */ | |
| 107 | |
| 108 /* Are restricted pointers available? (C99) */ | |
| 109 #if (__STDC_VERSION__ >= 199901L) | |
| 110 #define OPJ_RESTRICT restrict | |
| 111 #else | |
| 112 /* Not a C99 compiler */ | |
| 113 #if defined(__GNUC__) | |
| 114 #define OPJ_RESTRICT __restrict__ | |
| 115 | |
| 116 /* | |
| 117 vc14 (2015) outputs wrong results. | |
| 118 Need to check OPJ_RESTRICT usage (or a bug in vc14) | |
| 119 #elif defined(_MSC_VER) && (_MSC_VER >= 1400) | |
| 120 #define OPJ_RESTRICT __restrict | |
| 121 */ | |
| 122 #else | |
| 123 #define OPJ_RESTRICT /* restrict */ | |
| 124 #endif | |
| 125 #endif | |
| 126 | |
| 127 #ifdef __has_attribute | |
| 128 #if __has_attribute(no_sanitize) | |
| 129 #define OPJ_NOSANITIZE(kind) __attribute__((no_sanitize(kind))) | |
| 130 #endif | |
| 131 #endif | |
| 132 #ifndef OPJ_NOSANITIZE | |
| 133 #define OPJ_NOSANITIZE(kind) | |
| 134 #endif | |
| 135 | |
| 136 | |
| 137 /* MSVC before 2013 and Borland C do not have lrintf */ | |
| 138 #if defined(_MSC_VER) | |
| 139 #include <intrin.h> | |
| 140 static INLINE long opj_lrintf(float f) | |
| 141 { | |
| 142 #ifdef _M_X64 | |
| 143 return _mm_cvt_ss2si(_mm_load_ss(&f)); | |
| 144 | |
| 145 /* commented out line breaks many tests */ | |
| 146 /* return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); */ | |
| 147 #elif defined(_M_IX86) | |
| 148 int i; | |
| 149 _asm{ | |
| 150 fld f | |
| 151 fistp i | |
| 152 }; | |
| 153 | |
| 154 return i; | |
| 155 #else | |
| 156 return (long)((f>0.0f) ? (f + 0.5f) : (f - 0.5f)); | |
| 157 #endif | |
| 158 } | |
| 159 #elif defined(__BORLANDC__) | |
| 160 static INLINE long opj_lrintf(float f) | |
| 161 { | |
| 162 #ifdef _M_X64 | |
| 163 return (long)((f > 0.0f) ? (f + 0.5f) : (f - 0.5f)); | |
| 164 #else | |
| 165 int i; | |
| 166 | |
| 167 _asm { | |
| 168 fld f | |
| 169 fistp i | |
| 170 }; | |
| 171 | |
| 172 return i; | |
| 173 #endif | |
| 174 } | |
| 175 #else | |
| 176 static INLINE long opj_lrintf(float f) | |
| 177 { | |
| 178 return lrintf(f); | |
| 179 } | |
| 180 #endif | |
| 181 | |
| 182 #if defined(_MSC_VER) && (_MSC_VER < 1400) | |
| 183 #define vsnprintf _vsnprintf | |
| 184 #endif | |
| 185 | |
| 186 /* MSVC x86 is really bad at doing int64 = int32 * int32 on its own. Use intrinsic. */ | |
| 187 #if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86) | |
| 188 # include <intrin.h> | |
| 189 # pragma intrinsic(__emul) | |
| 190 #endif | |
| 191 | |
| 192 /* Apparently Visual Studio doesn't define __SSE__ / __SSE2__ macros */ | |
| 193 #if defined(_M_X64) | |
| 194 /* Intel 64bit support SSE and SSE2 */ | |
| 195 # ifndef __SSE__ | |
| 196 # define __SSE__ 1 | |
| 197 # endif | |
| 198 # ifndef __SSE2__ | |
| 199 # define __SSE2__ 1 | |
| 200 # endif | |
| 201 #endif | |
| 202 | |
| 203 /* For x86, test the value of the _M_IX86_FP macro. */ | |
| 204 /* See https://msdn.microsoft.com/en-us/library/b0084kay.aspx */ | |
| 205 #if defined(_M_IX86_FP) | |
| 206 # if _M_IX86_FP >= 1 | |
| 207 # ifndef __SSE__ | |
| 208 # define __SSE__ 1 | |
| 209 # endif | |
| 210 # endif | |
| 211 # if _M_IX86_FP >= 2 | |
| 212 # ifndef __SSE2__ | |
| 213 # define __SSE2__ 1 | |
| 214 # endif | |
| 215 # endif | |
| 216 #endif | |
| 217 | |
| 218 /* Type to use for bit-fields in internal headers */ | |
| 219 typedef unsigned int OPJ_BITFIELD; | |
| 220 | |
| 221 #define OPJ_UNUSED(x) (void)x | |
| 222 | |
| 223 #include "opj_clock.h" | |
| 224 #include "opj_malloc.h" | |
| 225 #include "event.h" | |
| 226 #include "function_list.h" | |
| 227 #include "bio.h" | |
| 228 #include "cio.h" | |
| 229 | |
| 230 #include "thread.h" | |
| 231 #include "tls_keys.h" | |
| 232 | |
| 233 #include "image.h" | |
| 234 #include "invert.h" | |
| 235 #include "j2k.h" | |
| 236 #include "jp2.h" | |
| 237 | |
| 238 #include "mqc.h" | |
| 239 #include "bio.h" | |
| 240 | |
| 241 #include "pi.h" | |
| 242 #include "tgt.h" | |
| 243 #include "tcd.h" | |
| 244 #include "t1.h" | |
| 245 #include "dwt.h" | |
| 246 #include "t2.h" | |
| 247 #include "mct.h" | |
| 248 #include "opj_intmath.h" | |
| 249 #include "sparse_array.h" | |
| 250 | |
| 251 #ifdef USE_JPIP | |
| 252 #include "cidx_manager.h" | |
| 253 #include "indexbox_manager.h" | |
| 254 #endif | |
| 255 | |
| 256 /* JPWL>> */ | |
| 257 #ifdef USE_JPWL | |
| 258 #include "openjpwl/jpwl.h" | |
| 259 #endif /* USE_JPWL */ | |
| 260 /* <<JPWL */ | |
| 261 | |
| 262 /* V2 */ | |
| 263 #include "opj_codec.h" | |
| 264 | |
| 265 | |
| 266 #endif /* OPJ_INCLUDES_H */ |
