|
OpenJPEG 2.1.2
|
00001 /* 00002 * The copyright in this software is being made available under the 2-clauses 00003 * BSD License, included below. This software may be subject to other third 00004 * party and contributor rights, including patent rights, and no such rights 00005 * are granted under this license. 00006 * 00007 * Copyright (c) 2005, Herve Drolon, FreeImage Team 00008 * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 00009 * Copyright (c) 2012, CS Systemes d'Information, France 00010 * All rights reserved. 00011 * 00012 * Redistribution and use in source and binary forms, with or without 00013 * modification, are permitted provided that the following conditions 00014 * are met: 00015 * 1. Redistributions of source code must retain the above copyright 00016 * notice, this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright 00018 * notice, this list of conditions and the following disclaimer in the 00019 * documentation and/or other materials provided with the distribution. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' 00022 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00024 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00025 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00026 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00027 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00030 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00031 * POSSIBILITY OF SUCH DAMAGE. 00032 */ 00033 #ifndef OPJ_INCLUDES_H 00034 #define OPJ_INCLUDES_H 00035 00036 /* 00037 * This must be included before any system headers, 00038 * since they can react to macro defined there 00039 */ 00040 #include "opj_config_private.h" 00041 00042 /* 00043 ========================================================== 00044 Standard includes used by the library 00045 ========================================================== 00046 */ 00047 #include <memory.h> 00048 #include <stdlib.h> 00049 #include <string.h> 00050 #include <math.h> 00051 #include <float.h> 00052 #include <time.h> 00053 #include <stdio.h> 00054 #include <stdarg.h> 00055 #include <ctype.h> 00056 #include <assert.h> 00057 00058 /* 00059 Use fseeko() and ftello() if they are available since they use 00060 'off_t' rather than 'long'. It is wrong to use fseeko() and 00061 ftello() only on systems with special LFS support since some systems 00062 (e.g. FreeBSD) support a 64-bit off_t by default. 00063 */ 00064 #if defined(OPJ_HAVE_FSEEKO) && !defined(fseek) 00065 # define fseek fseeko 00066 # define ftell ftello 00067 #endif 00068 00069 00070 #if defined(WIN32) && !defined(Windows95) && !defined(__BORLANDC__) && \ 00071 !(defined(_MSC_VER) && _MSC_VER < 1400) && \ 00072 !(defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x800) 00073 /* 00074 Windows '95 and Borland C do not support _lseeki64 00075 Visual Studio does not support _fseeki64 and _ftelli64 until the 2005 release. 00076 Without these interfaces, files over 2GB in size are not supported for Windows. 00077 */ 00078 # define OPJ_FSEEK(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence) 00079 # define OPJ_FSTAT(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff) 00080 # define OPJ_FTELL(stream) /* __int64 */ _ftelli64(stream) 00081 # define OPJ_STAT_STRUCT_T struct _stati64 00082 # define OPJ_STAT(path,stat_buff) _stati64(path,/* struct _stati64 */ stat_buff) 00083 #else 00084 # define OPJ_FSEEK(stream,offset,whence) fseek(stream,offset,whence) 00085 # define OPJ_FSTAT(fildes,stat_buff) fstat(fildes,stat_buff) 00086 # define OPJ_FTELL(stream) ftell(stream) 00087 # define OPJ_STAT_STRUCT_T struct stat 00088 # define OPJ_STAT(path,stat_buff) stat(path,stat_buff) 00089 #endif 00090 00091 00092 /* 00093 ========================================================== 00094 OpenJPEG interface 00095 ========================================================== 00096 */ 00097 #include "openjpeg.h" 00098 00099 /* 00100 ========================================================== 00101 OpenJPEG modules 00102 ========================================================== 00103 */ 00104 00105 /* Are restricted pointers available? (C99) */ 00106 #if (__STDC_VERSION__ >= 199901L) 00107 #define OPJ_RESTRICT restrict 00108 #else 00109 /* Not a C99 compiler */ 00110 #if defined(__GNUC__) 00111 #define OPJ_RESTRICT __restrict__ 00112 00113 /* 00114 vc14 (2015) outputs wrong results. 00115 Need to check OPJ_RESTRICT usage (or a bug in vc14) 00116 #elif defined(_MSC_VER) && (_MSC_VER >= 1400) 00117 #define OPJ_RESTRICT __restrict 00118 */ 00119 #else 00120 #define OPJ_RESTRICT /* restrict */ 00121 #endif 00122 #endif 00123 00124 #ifdef __has_attribute 00125 #if __has_attribute(no_sanitize) 00126 #define OPJ_NOSANITIZE(kind) __attribute__((no_sanitize(kind))) 00127 #endif 00128 #endif 00129 #ifndef OPJ_NOSANITIZE 00130 #define OPJ_NOSANITIZE(kind) 00131 #endif 00132 00133 00134 /* MSVC before 2013 and Borland C do not have lrintf */ 00135 #if defined(_MSC_VER) 00136 #include <intrin.h> 00137 static INLINE long opj_lrintf(float f){ 00138 #ifdef _M_X64 00139 return _mm_cvt_ss2si(_mm_load_ss(&f)); 00140 00141 /* commented out line breaks many tests */ 00142 /* return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); */ 00143 #elif defined(_M_IX86) 00144 int i; 00145 _asm{ 00146 fld f 00147 fistp i 00148 }; 00149 00150 return i; 00151 #else 00152 return (long)((f>0.0f) ? (f + 0.5f) : (f - 0.5f)); 00153 #endif 00154 } 00155 #elif defined(__BORLANDC__) 00156 static INLINE long opj_lrintf(float f) { 00157 #ifdef _M_X64 00158 return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); 00159 #else 00160 int i; 00161 00162 _asm { 00163 fld f 00164 fistp i 00165 }; 00166 00167 return i; 00168 #endif 00169 } 00170 #else 00171 static INLINE long opj_lrintf(float f) { 00172 return lrintf(f); 00173 } 00174 #endif 00175 00176 #if defined(_MSC_VER) && (_MSC_VER < 1400) 00177 #define vsnprintf _vsnprintf 00178 #endif 00179 00180 /* MSVC x86 is really bad at doing int64 = int32 * int32 on its own. Use intrinsic. */ 00181 #if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86) 00182 # include <intrin.h> 00183 # pragma intrinsic(__emul) 00184 #endif 00185 00186 #include "opj_inttypes.h" 00187 #include "opj_clock.h" 00188 #include "opj_malloc.h" 00189 #include "event.h" 00190 #include "function_list.h" 00191 #include "bio.h" 00192 #include "cio.h" 00193 00194 #include "image.h" 00195 #include "invert.h" 00196 #include "j2k.h" 00197 #include "jp2.h" 00198 00199 #include "mqc.h" 00200 #include "raw.h" 00201 #include "bio.h" 00202 00203 #include "pi.h" 00204 #include "tgt.h" 00205 #include "tcd.h" 00206 #include "t1.h" 00207 #include "dwt.h" 00208 #include "t2.h" 00209 #include "mct.h" 00210 #include "opj_intmath.h" 00211 00212 #ifdef USE_JPIP 00213 #include "cidx_manager.h" 00214 #include "indexbox_manager.h" 00215 #endif 00216 00217 /* JPWL>> */ 00218 #ifdef USE_JPWL 00219 #include "openjpwl/jpwl.h" 00220 #endif /* USE_JPWL */ 00221 /* <<JPWL */ 00222 00223 /* V2 */ 00224 #include "opj_codec.h" 00225 00226 00227 #endif /* OPJ_INCLUDES_H */
1.7.3