Grok
7.6.3
src
lib
jp2
grk_includes.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2016-2021 Grok Image Compression Inc.
3
*
4
* This source code is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Affero General Public License, version 3,
6
* as published by the Free Software Foundation.
7
*
8
* This source code is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Affero General Public License for more details.
12
*
13
* You should have received a copy of the GNU Affero General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15
*
16
*
17
* This source code incorporates work covered by the BSD 2-clause license.
18
* Please see the LICENSE file in the root directory for details.
19
*
20
*/
21
22
#pragma once
23
24
25
/*
26
* This must be included before any system headers,
27
* since they can react to macro defined there
28
*/
29
#include "grk_config_private.h"
30
31
/*
32
==========================================================
33
Standard includes used by the library
34
==========================================================
35
*/
36
#include <memory.h>
37
#include <stdlib.h>
38
#include <string>
39
#ifdef _MSC_VER
40
#define _USE_MATH_DEFINES // for C++
41
#endif
42
#include <cmath>
43
#include <float.h>
44
#include <time.h>
45
#include <stdio.h>
46
#include <stdarg.h>
47
#include <ctype.h>
48
#include <assert.h>
49
#include <inttypes.h>
50
#include <climits>
51
#include <algorithm>
52
#include <sstream>
53
#include <iostream>
54
#include <vector>
55
#include <algorithm>
56
#include <numeric>
57
58
/*
59
Use fseeko() and ftello() if they are available since they use
60
'int64_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 int64_t by default.
63
*/
64
#if defined(GROK_HAVE_FSEEKO) && !defined(fseek)
65
# define fseek fseeko
66
# define ftell ftello
67
#endif
68
69
#if defined(_WIN32)
70
# define GROK_FSEEK(stream,offset,whence) _fseeki64(stream,
/* __int64 */
offset,whence)
71
# define GROK_FSTAT(fildes,stat_buff) _fstati64(fildes,
/* struct _stati64 */
stat_buff)
72
# define GROK_FTELL(stream)
/* __int64 */
_ftelli64(stream)
73
# define GROK_STAT_STRUCT_T struct _stati64
74
# define GROK_STAT(path,stat_buff) _stati64(path,
/* struct _stati64 */
stat_buff)
75
#else
76
# define GROK_FSEEK(stream,offset,whence) fseek(stream,offset,whence)
77
# define GROK_FSTAT(fildes,stat_buff) fstat(fildes,stat_buff)
78
# define GROK_FTELL(stream) ftell(stream)
79
# define GROK_STAT_STRUCT_T struct stat
80
# define GROK_STAT(path,stat_buff) stat(path,stat_buff)
81
#endif
82
83
/*
84
==========================================================
85
Grok interface
86
==========================================================
87
*/
88
89
#include "
minpf_plugin_manager.h
"
90
#include "
plugin_interface.h
"
91
92
/*
93
==========================================================
94
Grok modules
95
==========================================================
96
*/
97
98
#if defined(__GNUC__)
99
#define GRK_RESTRICT __restrict__
100
#else
101
#define GRK_RESTRICT
/* GRK_RESTRICT */
102
#endif
103
104
105
#ifdef __has_attribute
106
#if __has_attribute(no_sanitize)
107
#define GROK_NOSANITIZE(kind) __attribute__((no_sanitize(kind)))
108
#endif
109
#endif
110
#ifndef GROK_NOSANITIZE
111
#define GROK_NOSANITIZE(kind)
112
#endif
113
114
#include "
simd.h
"
115
116
#if defined(_MSC_VER)
117
#include <intrin.h>
118
static
inline
long
grk_lrintf
(
float
f)
119
{
120
#ifdef _M_X64
121
return
_mm_cvt_ss2si(_mm_load_ss(&f));
122
#elif defined(_M_IX86)
123
int
i;
124
_asm{
125
fld f
126
fistp i
127
};
128
129
return
i;
130
#else
131
return
(
long
)((f>0.0f) ? (f + 0.5f) : (f - 0.5f));
132
#endif
133
}
134
#else
135
static
inline
long
grk_lrintf
(
float
f) {
136
return
lrintf(f);
137
}
138
#endif
139
140
#if defined(_MSC_VER) && (_MSC_VER < 1400)
141
#define vsnprintf _vsnprintf
142
#endif
143
144
/* MSVC x86 is really bad at doing int64 = int32 * int32 on its own. Use intrinsic. */
145
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
146
# include <intrin.h>
147
# pragma intrinsic(__emul)
148
#endif
149
150
#define GRK_UNUSED(x) (void)x
151
152
#include "
ThreadPool.hpp
"
153
#include "
IOpenable.h
"
154
#include <
MemStream.h
>
155
#include "
GrkMappedFile.h
"
156
#include "
MemManager.h
"
157
#include "
logger.h
"
158
#include "
util.h
"
159
#include "
grk_exceptions.h
"
160
#include "
ChunkBuffer.h
"
161
#include "
BitIO.h
"
162
#include "
BufferedStream.h
"
163
#include "
Quantizer.h
"
164
#include <
Profile.h
>
165
#include "
LengthMarkers.h
"
166
#include "
SIZMarker.h
"
167
#include "
PPMMarker.h
"
168
#include "
SOTMarker.h
"
169
#include "
CodeStream.h
"
170
#include "
markers.h
"
171
#include <
Dump.h
>
172
#include "
FileFormat.h
"
173
#include "
BitIO.h
"
174
#include "
TagTree.h
"
175
#include "
T1Structs.h
"
176
#include <
WaveletReverse.h
>
177
#include <
TileComponentWindowBuffer.h
>
178
#include "
PacketIter.h
"
179
#include <
SparseBuffer.h
>
180
#include "
TileComponent.h
"
181
#include "
TileProcessor.h
"
182
#include <
WaveletFwdImpl.h
>
183
#include "
t1_common.h
"
184
#include <
SparseBuffer.h
>
185
#include <
T2Compress.h
>
186
#include <
T2Decompress.h
>
187
#include "
mct.h
"
188
#include "
grk_intmath.h
"
189
#include "
plugin_bridge.h
"
190
#include "
RateControl.h
"
191
#include "
RateInfo.h
"
192
#include "
T1Interface.h
"
193
#include "
T1Factory.h
"
194
#include <
T1DecompressScheduler.h
>
195
#include <
T1CompressScheduler.h
>
RateControl.h
SIZMarker.h
BitIO.h
RateInfo.h
T1Factory.h
T2Compress.h
t1_common.h
logger.h
grk_lrintf
static long grk_lrintf(float f)
Definition:
grk_includes.h:135
FileFormat.h
The JPEG 2000 file format Reader/Writer (JP2)
TagTree.h
markers.h
CodeStream.h
simd.h
grk_intmath.h
Dump.h
LengthMarkers.h
T1CompressScheduler.h
plugin_bridge.h
mct.h
minpf_plugin_manager.h
TileComponentWindowBuffer.h
BufferedStream.h
ChunkBuffer.h
Profile.h
TileComponent.h
SparseBuffer.h
Sparse array management.
MemStream.h
WaveletReverse.h
SOTMarker.h
GrkMappedFile.h
PacketIter.h
Implementation of a packet iterator (PI)
T1DecompressScheduler.h
MemManager.h
T1Structs.h
WaveletFwdImpl.h
PPMMarker.h
T2Decompress.h
T1Interface.h
ThreadPool.hpp
TileProcessor.h
Quantizer.h
util.h
grk_exceptions.h
IOpenable.h
plugin_interface.h
Generated by
1.8.20