Home | History | Annotate | Download | only in libopenjpeg20
      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 
     58 /*
     59   Use fseeko() and ftello() if they are available since they use
     60   'off_t' rather than 'long'.  It is wrong to use fseeko() and
     61   ftello() only on systems with special LFS support since some systems
     62   (e.g. FreeBSD) support a 64-bit off_t by default.
     63 */
     64 #if defined(OPJ_HAVE_FSEEKO) && !defined(fseek)
     65 #  define fseek  fseeko
     66 #  define ftell  ftello
     67 #endif
     68 
     69 
     70 #if defined(WIN32) && !defined(Windows95) && !defined(__BORLANDC__) && \
     71   !(defined(_MSC_VER) && _MSC_VER < 1400) && \
     72   !(defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x800)
     73   /*
     74     Windows '95 and Borland C do not support _lseeki64
     75     Visual Studio does not support _fseeki64 and _ftelli64 until the 2005 release.
     76     Without these interfaces, files over 2GB in size are not supported for Windows.
     77   */
     78 #  define OPJ_FSEEK(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence)
     79 #  define OPJ_FSTAT(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff)
     80 #  define OPJ_FTELL(stream) /* __int64 */ _ftelli64(stream)
     81 #  define OPJ_STAT_STRUCT_T struct _stati64
     82 #  define OPJ_STAT(path,stat_buff) _stati64(path,/* struct _stati64 */ stat_buff)
     83 #else
     84 #  define OPJ_FSEEK(stream,offset,whence) fseek(stream,offset,whence)
     85 #  define OPJ_FSTAT(fildes,stat_buff) fstat(fildes,stat_buff)
     86 #  define OPJ_FTELL(stream) ftell(stream)
     87 #  define OPJ_STAT_STRUCT_T struct stat
     88 #  define OPJ_STAT(path,stat_buff) stat(path,stat_buff)
     89 #endif
     90 
     91 
     92 /*
     93  ==========================================================
     94    OpenJPEG interface
     95  ==========================================================
     96  */
     97 #include "openjpeg.h"
     98 
     99 /*
    100  ==========================================================
    101    OpenJPEG modules
    102  ==========================================================
    103 */
    104 
    105 /* Ignore GCC attributes if this is not GCC */
    106 #ifndef __GNUC__
    107 	#define __attribute__(x) /* __attribute__(x) */
    108 #endif
    109 
    110 
    111 /* Are restricted pointers available? (C99) */
    112 #if (__STDC_VERSION__ != 199901L)
    113 	/* Not a C99 compiler */
    114 	#ifdef __GNUC__
    115 		#define restrict __restrict__
    116 	#else
    117 		#define restrict /* restrict */
    118 	#endif
    119 #endif
    120 
    121 
    122 
    123 /* MSVC before 2013 and Borland C do not have lrintf */
    124 #if defined(_MSC_VER)
    125 #include <intrin.h>
    126 static INLINE long opj_lrintf(float f){
    127 #ifdef _M_X64
    128 	return _mm_cvt_ss2si(_mm_load_ss(&f));
    129 
    130 	/* commented out line breaks many tests */
    131   /* return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); */
    132 #elif defined(_M_IX86)
    133     int i;
    134      _asm{
    135         fld f
    136         fistp i
    137     };
    138 
    139     return i;
    140 #else
    141 	return (long)((f>0.0f) ? (f + 0.5f) : (f - 0.5f));
    142 #endif
    143 }
    144 #elif defined(__BORLANDC__)
    145 static INLINE long opj_lrintf(float f) {
    146 #ifdef _M_X64
    147      return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f));
    148 #else
    149 	int i;
    150 
    151 	_asm {
    152 		fld f
    153 			fistp i
    154 	};
    155 
    156 	return i;
    157 #endif
    158 }
    159 #else
    160 static INLINE long opj_lrintf(float f) {
    161 	return lrintf(f);
    162 }
    163 #endif
    164 
    165 #if defined(_MSC_VER) && (_MSC_VER < 1400)
    166 	#define vsnprintf _vsnprintf
    167 #endif
    168 
    169 /* MSVC x86 is really bad at doing int64 = int32 * int32 on its own. Use intrinsic. */
    170 #if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
    171 #	include <intrin.h>
    172 #	pragma intrinsic(__emul)
    173 #endif
    174 
    175 #include "opj_inttypes.h"
    176 #include "opj_clock.h"
    177 #include "opj_malloc.h"
    178 #include "event.h"
    179 #include "function_list.h"
    180 #include "bio.h"
    181 #include "cio.h"
    182 
    183 #include "image.h"
    184 #include "invert.h"
    185 #include "j2k.h"
    186 #include "jp2.h"
    187 
    188 #include "mqc.h"
    189 #include "raw.h"
    190 #include "bio.h"
    191 
    192 #include "pi.h"
    193 #include "tgt.h"
    194 #include "tcd.h"
    195 #include "t1.h"
    196 #include "dwt.h"
    197 #include "t2.h"
    198 #include "mct.h"
    199 #include "opj_intmath.h"
    200 
    201 #ifdef USE_JPIP
    202 #include "cidx_manager.h"
    203 #include "indexbox_manager.h"
    204 #endif
    205 
    206 /* JPWL>> */
    207 #ifdef USE_JPWL
    208 #include "openjpwl/jpwl.h"
    209 #endif /* USE_JPWL */
    210 /* <<JPWL */
    211 
    212 /* V2 */
    213 #include "opj_codec.h"
    214 
    215 
    216 #endif /* OPJ_INCLUDES_H */
    217