jpayne@69
|
1 /*
|
jpayne@69
|
2 Copyright 2016 - 2022 Esri
|
jpayne@69
|
3
|
jpayne@69
|
4 Licensed under the Apache License, Version 2.0 (the "License");
|
jpayne@69
|
5 you may not use this file except in compliance with the License.
|
jpayne@69
|
6 You may obtain a copy of the License at
|
jpayne@69
|
7
|
jpayne@69
|
8 http://www.apache.org/licenses/LICENSE-2.0
|
jpayne@69
|
9
|
jpayne@69
|
10 Unless required by applicable law or agreed to in writing, software
|
jpayne@69
|
11 distributed under the License is distributed on an "AS IS" BASIS,
|
jpayne@69
|
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
jpayne@69
|
13 See the License for the specific language governing permissions and
|
jpayne@69
|
14 limitations under the License.
|
jpayne@69
|
15
|
jpayne@69
|
16 A local copy of the license and additional notices are located with the
|
jpayne@69
|
17 source distribution at:
|
jpayne@69
|
18
|
jpayne@69
|
19 http://github.com/Esri/lerc/
|
jpayne@69
|
20
|
jpayne@69
|
21 Contributors: Thomas Maurer
|
jpayne@69
|
22 */
|
jpayne@69
|
23
|
jpayne@69
|
24 #ifndef LERC_API_INCLUDE_GUARD
|
jpayne@69
|
25 #define LERC_API_INCLUDE_GUARD
|
jpayne@69
|
26
|
jpayne@69
|
27 //#define USE_EMSCRIPTEN // to build a wasm Lerc decoder, install emscripten first
|
jpayne@69
|
28
|
jpayne@69
|
29 #ifdef USE_EMSCRIPTEN
|
jpayne@69
|
30 #include <emscripten/emscripten.h>
|
jpayne@69
|
31 #endif
|
jpayne@69
|
32
|
jpayne@69
|
33 #ifdef __cplusplus
|
jpayne@69
|
34 extern "C" {
|
jpayne@69
|
35 #endif
|
jpayne@69
|
36
|
jpayne@69
|
37 /* LERC version numbers and related macros added in 3.0.0 */
|
jpayne@69
|
38
|
jpayne@69
|
39 #define LERC_VERSION_MAJOR 4
|
jpayne@69
|
40 #define LERC_VERSION_MINOR 0
|
jpayne@69
|
41 #define LERC_VERSION_PATCH 0
|
jpayne@69
|
42
|
jpayne@69
|
43 /* Macro to compute a LERC version number from its components */
|
jpayne@69
|
44 #define LERC_COMPUTE_VERSION(maj,min,patch) ((maj)*10000+(min)*100+(patch))
|
jpayne@69
|
45
|
jpayne@69
|
46 /* Current LERC version from the above version numbers */
|
jpayne@69
|
47 #define LERC_VERSION_NUMBER \
|
jpayne@69
|
48 LERC_COMPUTE_VERSION(LERC_VERSION_MAJOR, LERC_VERSION_MINOR, LERC_VERSION_PATCH)
|
jpayne@69
|
49
|
jpayne@69
|
50 /* Macro that returns true if the current LERC version is at least the version specified by (maj,min,patch) */
|
jpayne@69
|
51 #define LERC_AT_LEAST_VERSION(maj,min,patch) \
|
jpayne@69
|
52 (LERC_VERSION_NUMBER >= LERC_COMPUTE_VERSION(maj,min,patch))
|
jpayne@69
|
53
|
jpayne@69
|
54 #if defined _WIN32 || defined __CYGWIN__
|
jpayne@69
|
55 # if defined(LERC_STATIC)
|
jpayne@69
|
56 # define LERCDLL_API
|
jpayne@69
|
57 # elif defined(LERC_EXPORTS)
|
jpayne@69
|
58 # define LERCDLL_API __declspec(dllexport)
|
jpayne@69
|
59 # else
|
jpayne@69
|
60 # define LERCDLL_API __declspec(dllimport)
|
jpayne@69
|
61 # endif
|
jpayne@69
|
62 #elif __GNUC__ >= 4
|
jpayne@69
|
63 #define LERCDLL_API __attribute__((visibility("default")))
|
jpayne@69
|
64 #else
|
jpayne@69
|
65 #define LERCDLL_API
|
jpayne@69
|
66 #endif
|
jpayne@69
|
67
|
jpayne@69
|
68 //! C-API for LERC library
|
jpayne@69
|
69
|
jpayne@69
|
70
|
jpayne@69
|
71 //! Added in version 4.0:
|
jpayne@69
|
72 //!
|
jpayne@69
|
73 //! - 1) better support 3D and 4D data, allow for lossy encoding even if a noData value is used
|
jpayne@69
|
74 //! - 2) better lossless compression for float and double (pass maxZError = 0)
|
jpayne@69
|
75 //! - 3) allow to pass integer > 32 bit as double (Lerc detects it is all integer and uses that)
|
jpayne@69
|
76 //! - 4) renamed nDim to nDepth (without changing the function signatures)
|
jpayne@69
|
77 //!
|
jpayne@69
|
78 //! More on 1). In version 3.0, for 2D images, the 2D valid / invalid byte masks represent invalid pixels.
|
jpayne@69
|
79 //! For more than 1 band, different masks per band can be used. No change to that.
|
jpayne@69
|
80 //! For nDepth > 1, or an array of values per pixel, there is the special case of a mix of valid and invalid values
|
jpayne@69
|
81 //! at the same pixel. The 2D mask cannot cover this case.
|
jpayne@69
|
82 //! We have added 4 new functions to version 4.0 to cover this case, see below. If you don't encounter this
|
jpayne@69
|
83 //! "mixed case", you can continue using the same API functions as in version 3.0.
|
jpayne@69
|
84 //! If you should encounter a Lerc blob that has this mix, both the regular lerc_decode() and
|
jpayne@69
|
85 //! lerc_getDataRanges() functions will fail with "ErrCode::HasNoData".
|
jpayne@69
|
86 //! In that case, you need to call the new lerc_decode_4D() function.
|
jpayne@69
|
87 //!
|
jpayne@69
|
88 //! More on 2). Better lossless compression for float and double is enabled for all API functions.
|
jpayne@69
|
89 //! For 1) and 3) you have to call the new "..._4D()" functions, see further below.
|
jpayne@69
|
90
|
jpayne@69
|
91
|
jpayne@69
|
92 typedef unsigned int lerc_status;
|
jpayne@69
|
93
|
jpayne@69
|
94 //! All output buffers must have been allocated by the caller.
|
jpayne@69
|
95
|
jpayne@69
|
96 //! Compute the buffer size in bytes required to hold the compressed input tile. Optional.
|
jpayne@69
|
97 //! You can call lerc_encode(...) directly as long as the output buffer is big enough.
|
jpayne@69
|
98
|
jpayne@69
|
99 //! Order of raw input data is top left corner to lower right corner, row by row. This for each band.
|
jpayne@69
|
100 //! Data type is { char = 0, uchar = 1, short = 2, ushort = 3, int = 4, uint = 5, float = 6, double = 7 }, see Lerc_types.h .
|
jpayne@69
|
101 //! maxZErr is the max compression error per pixel allowed.
|
jpayne@69
|
102
|
jpayne@69
|
103 //! The image or mask of valid pixels is optional. Nullptr means all pixels are valid.
|
jpayne@69
|
104 //! If not all pixels are valid, set invalid pixel bytes to 0, valid pixel bytes to 1.
|
jpayne@69
|
105 //! Size of the valid / invalid pixel image is (nCols * nRows * nMasks).
|
jpayne@69
|
106
|
jpayne@69
|
107 LERCDLL_API
|
jpayne@69
|
108 lerc_status lerc_computeCompressedSize(
|
jpayne@69
|
109 const void* pData, // raw image data, row by row, band by band
|
jpayne@69
|
110 unsigned int dataType, // char = 0, uchar = 1, short = 2, ushort = 3, int = 4, uint = 5, float = 6, double = 7
|
jpayne@69
|
111 int nDepth, // number of values per pixel (e.g., 3 for RGB, data is stored as [RGB, RGB, ...])
|
jpayne@69
|
112 int nCols, // number of columns
|
jpayne@69
|
113 int nRows, // number of rows
|
jpayne@69
|
114 int nBands, // number of bands (e.g., 3 for [RRRR ..., GGGG ..., BBBB ...])
|
jpayne@69
|
115 int nMasks, // 0 - all valid, 1 - same mask for all bands, nBands - masks can differ between bands
|
jpayne@69
|
116 const unsigned char* pValidBytes, // nullptr if all pixels are valid; otherwise 1 byte per pixel (1 = valid, 0 = invalid)
|
jpayne@69
|
117 double maxZErr, // max coding error per pixel, defines the precision
|
jpayne@69
|
118 unsigned int* numBytes); // size of outgoing Lerc blob
|
jpayne@69
|
119
|
jpayne@69
|
120 //! Encode the input data into a compressed Lerc blob.
|
jpayne@69
|
121
|
jpayne@69
|
122 LERCDLL_API
|
jpayne@69
|
123 lerc_status lerc_encode(
|
jpayne@69
|
124 const void* pData, // raw image data, row by row, band by band
|
jpayne@69
|
125 unsigned int dataType, // char = 0, uchar = 1, short = 2, ushort = 3, int = 4, uint = 5, float = 6, double = 7
|
jpayne@69
|
126 int nDepth, // number of values per pixel (e.g., 3 for RGB, data is stored as [RGB, RGB, ...])
|
jpayne@69
|
127 int nCols, // number of columns
|
jpayne@69
|
128 int nRows, // number of rows
|
jpayne@69
|
129 int nBands, // number of bands (e.g., 3 for [RRRR ..., GGGG ..., BBBB ...])
|
jpayne@69
|
130 int nMasks, // 0 - all valid, 1 - same mask for all bands, nBands - masks can differ between bands
|
jpayne@69
|
131 const unsigned char* pValidBytes, // nullptr if all pixels are valid; otherwise 1 byte per pixel (1 = valid, 0 = invalid)
|
jpayne@69
|
132 double maxZErr, // max coding error per pixel, defines the precision
|
jpayne@69
|
133 unsigned char* pOutBuffer, // buffer to write to, function fails if buffer too small
|
jpayne@69
|
134 unsigned int outBufferSize, // size of output buffer
|
jpayne@69
|
135 unsigned int* nBytesWritten); // number of bytes written to output buffer
|
jpayne@69
|
136
|
jpayne@69
|
137
|
jpayne@69
|
138 //! Use the 2 functions below to encode to an older codec version
|
jpayne@69
|
139
|
jpayne@69
|
140 LERCDLL_API
|
jpayne@69
|
141 lerc_status lerc_computeCompressedSizeForVersion(
|
jpayne@69
|
142 const void* pData, // raw image data, row by row, band by band
|
jpayne@69
|
143 int codecVersion, // [2 .. 6] for [v2.2 .. v2.6], or -1 for latest codec v2.6
|
jpayne@69
|
144 unsigned int dataType, // char = 0, uchar = 1, short = 2, ushort = 3, int = 4, uint = 5, float = 6, double = 7
|
jpayne@69
|
145 int nDepth, // number of values per pixel (e.g., 3 for RGB, data is stored as [RGB, RGB, ...])
|
jpayne@69
|
146 int nCols, // number of columns
|
jpayne@69
|
147 int nRows, // number of rows
|
jpayne@69
|
148 int nBands, // number of bands (e.g., 3 for [RRRR ..., GGGG ..., BBBB ...])
|
jpayne@69
|
149 int nMasks, // 0 - all valid, 1 - same mask for all bands, nBands - masks can differ between bands
|
jpayne@69
|
150 const unsigned char* pValidBytes, // nullptr if all pixels are valid; otherwise 1 byte per pixel (1 = valid, 0 = invalid)
|
jpayne@69
|
151 double maxZErr, // max coding error per pixel, defines the precision
|
jpayne@69
|
152 unsigned int* numBytes); // size of outgoing Lerc blob
|
jpayne@69
|
153
|
jpayne@69
|
154 LERCDLL_API
|
jpayne@69
|
155 lerc_status lerc_encodeForVersion(
|
jpayne@69
|
156 const void* pData, // raw image data, row by row, band by band
|
jpayne@69
|
157 int codecVersion, // [2 .. 6] for [v2.2 .. v2.6], or -1 for latest codec v2.6
|
jpayne@69
|
158 unsigned int dataType, // char = 0, uchar = 1, short = 2, ushort = 3, int = 4, uint = 5, float = 6, double = 7
|
jpayne@69
|
159 int nDepth, // number of values per pixel (e.g., 3 for RGB, data is stored as [RGB, RGB, ...])
|
jpayne@69
|
160 int nCols, // number of columns
|
jpayne@69
|
161 int nRows, // number of rows
|
jpayne@69
|
162 int nBands, // number of bands (e.g., 3 for [RRRR ..., GGGG ..., BBBB ...])
|
jpayne@69
|
163 int nMasks, // 0 - all valid, 1 - same mask for all bands, nBands - masks can differ between bands
|
jpayne@69
|
164 const unsigned char* pValidBytes, // nullptr if all pixels are valid; otherwise 1 byte per pixel (1 = valid, 0 = invalid)
|
jpayne@69
|
165 double maxZErr, // max coding error per pixel, defines the precision
|
jpayne@69
|
166 unsigned char* pOutBuffer, // buffer to write to, function fails if buffer too small
|
jpayne@69
|
167 unsigned int outBufferSize, // size of output buffer
|
jpayne@69
|
168 unsigned int* nBytesWritten); // number of bytes written to output buffer
|
jpayne@69
|
169
|
jpayne@69
|
170
|
jpayne@69
|
171 //! Call this to get info about the compressed Lerc blob. Optional.
|
jpayne@69
|
172 //! Info returned in infoArray is
|
jpayne@69
|
173 //! { version, dataType, nDepth, nCols, nRows, nBands, nValidPixels, blobSize, nMasks, nDepth, nUsesNoDataValue }, see Lerc_types.h .
|
jpayne@69
|
174 //! Info returned in dataRangeArray is { zMin, zMax, maxZErrorUsed }, see Lerc_types.h .
|
jpayne@69
|
175 //! If nDepth > 1 or nBands > 1 the data range [zMin, zMax] is over all values.
|
jpayne@69
|
176
|
jpayne@69
|
177 // Remark on function signature. The arrays to be filled may grow in future versions. In order not to break
|
jpayne@69
|
178 // existing code, the function fills these arrays only up to their allocated size.
|
jpayne@69
|
179
|
jpayne@69
|
180 // Remark on param blobSize. Usually it is known, either the file size of the blob written to disk,
|
jpayne@69
|
181 // or the size of the blob transmitted. It should be passed accurately for 2 reasons:
|
jpayne@69
|
182 // _ function finds out how many single band Lerc blobs are concatenated, if any
|
jpayne@69
|
183 // _ function checks for truncated file or blob
|
jpayne@69
|
184 // It is OK to pass blobSize too large as long as there is no other (valid) Lerc blob following next.
|
jpayne@69
|
185 // If in doubt, check the code in Lerc::GetLercInfo(...) for the exact logic.
|
jpayne@69
|
186
|
jpayne@69
|
187 LERCDLL_API
|
jpayne@69
|
188 #ifdef USE_EMSCRIPTEN
|
jpayne@69
|
189 EMSCRIPTEN_KEEPALIVE
|
jpayne@69
|
190 #endif
|
jpayne@69
|
191 lerc_status lerc_getBlobInfo(
|
jpayne@69
|
192 const unsigned char* pLercBlob, // Lerc blob to decode
|
jpayne@69
|
193 unsigned int blobSize, // blob size in bytes
|
jpayne@69
|
194 unsigned int* infoArray, // info array with all info needed to allocate the outgoing arrays for calling decode
|
jpayne@69
|
195 double* dataRangeArray, // quick access to overall data range [zMin, zMax] without having to decode the data
|
jpayne@69
|
196 int infoArraySize, // number of elements of infoArray
|
jpayne@69
|
197 int dataRangeArraySize); // number of elements of dataRangeArray
|
jpayne@69
|
198
|
jpayne@69
|
199 //! Call this to quickly get the data ranges [min, max] per dimension and band without having to decode the pixels. Optional.
|
jpayne@69
|
200 //! The 2 output data arrays must have been allocated to the same size (nDepth * nBands).
|
jpayne@69
|
201 //! The output data array's layout is an image with nDepth columns and nBands rows.
|
jpayne@69
|
202
|
jpayne@69
|
203 LERCDLL_API
|
jpayne@69
|
204 #ifdef USE_EMSCRIPTEN
|
jpayne@69
|
205 EMSCRIPTEN_KEEPALIVE
|
jpayne@69
|
206 #endif
|
jpayne@69
|
207 lerc_status lerc_getDataRanges(
|
jpayne@69
|
208 const unsigned char* pLercBlob, // Lerc blob to decode
|
jpayne@69
|
209 unsigned int blobSize, // blob size in bytes
|
jpayne@69
|
210 int nDepth, // number of values per pixel (e.g., 3 for RGB, data is stored as [RGB, RGB, ...])
|
jpayne@69
|
211 int nBands, // number of bands (e.g., 3 for [RRRR ..., GGGG ..., BBBB ...])
|
jpayne@69
|
212 double* pMins, // outgoing minima per dimension and band
|
jpayne@69
|
213 double* pMaxs); // outgoing maxima per dimension and band
|
jpayne@69
|
214
|
jpayne@69
|
215 //! Decode the compressed Lerc blob into a raw data array.
|
jpayne@69
|
216 //! The data array must have been allocated to size (nDepth * nCols * nRows * nBands * sizeof(dataType)).
|
jpayne@69
|
217 //! The valid pixels array, if not all pixels valid, must have been allocated to size (nCols * nRows * nMasks).
|
jpayne@69
|
218
|
jpayne@69
|
219 LERCDLL_API
|
jpayne@69
|
220 #ifdef USE_EMSCRIPTEN
|
jpayne@69
|
221 EMSCRIPTEN_KEEPALIVE
|
jpayne@69
|
222 #endif
|
jpayne@69
|
223 lerc_status lerc_decode(
|
jpayne@69
|
224 const unsigned char* pLercBlob, // Lerc blob to decode
|
jpayne@69
|
225 unsigned int blobSize, // blob size in bytes
|
jpayne@69
|
226 int nMasks, // 0, 1, or nBands; return as many masks in the next array
|
jpayne@69
|
227 unsigned char* pValidBytes, // gets filled if not nullptr, even if all valid
|
jpayne@69
|
228 int nDepth, // number of values per pixel (e.g., 3 for RGB, data is stored as [RGB, RGB, ...])
|
jpayne@69
|
229 int nCols, // number of columns
|
jpayne@69
|
230 int nRows, // number of rows
|
jpayne@69
|
231 int nBands, // number of bands (e.g., 3 for [RRRR ..., GGGG ..., BBBB ...])
|
jpayne@69
|
232 unsigned int dataType, // char = 0, uchar = 1, short = 2, ushort = 3, int = 4, uint = 5, float = 6, double = 7
|
jpayne@69
|
233 void* pData); // outgoing data array
|
jpayne@69
|
234
|
jpayne@69
|
235 //! Same as above, but decode into double array independent of compressed data type.
|
jpayne@69
|
236 //! Wasteful in memory, but convenient if a caller from Python or C# does not want to deal with
|
jpayne@69
|
237 //! data type conversion, templating, or casting.
|
jpayne@69
|
238 //! Should this api be extended to new data types that don't fit into a double such as int64,
|
jpayne@69
|
239 //! then this function will fail for such compressed data types.
|
jpayne@69
|
240
|
jpayne@69
|
241 LERCDLL_API
|
jpayne@69
|
242 lerc_status lerc_decodeToDouble(
|
jpayne@69
|
243 const unsigned char* pLercBlob, // Lerc blob to decode
|
jpayne@69
|
244 unsigned int blobSize, // blob size in bytes
|
jpayne@69
|
245 int nMasks, // 0, 1, or nBands; return as many masks in the next array
|
jpayne@69
|
246 unsigned char* pValidBytes, // gets filled if not nullptr, even if all valid
|
jpayne@69
|
247 int nDepth, // number of values per pixel (e.g., 3 for RGB, data is stored as [RGB, RGB, ...])
|
jpayne@69
|
248 int nCols, // number of columns
|
jpayne@69
|
249 int nRows, // number of rows
|
jpayne@69
|
250 int nBands, // number of bands (e.g., 3 for [RRRR ..., GGGG ..., BBBB ...])
|
jpayne@69
|
251 double* pData); // outgoing data array
|
jpayne@69
|
252
|
jpayne@69
|
253
|
jpayne@69
|
254 //! Added in version 4.0:
|
jpayne@69
|
255 //!
|
jpayne@69
|
256 //! The 4 functions below are new. The main purpose (and difference to the functions above) is to support, for 3D and 4D data,
|
jpayne@69
|
257 //! the special case of a mix of valid and invalid values at the same pixel.
|
jpayne@69
|
258 //!
|
jpayne@69
|
259 //! Main idea: Lerc has the property that for each 8x8 pixel block the minimum value is always encoded lossless in the block header.
|
jpayne@69
|
260 //! To enable lossy encoding in the presence of noData values, the original noData value is mapped below the range of the valid values,
|
jpayne@69
|
261 //! if possible. If not possible, it switches to lossless. On decode, that temporary noData value gets mapped back to the original
|
jpayne@69
|
262 //! noData value.
|
jpayne@69
|
263 //!
|
jpayne@69
|
264 //! To minimize the occurence of noData values (and for better compression), Lerc tries to move noData values to the byte mask
|
jpayne@69
|
265 //! wherever possible (e.g., all values at some pixel are invalid). So for a given band the noData values may disappear and get
|
jpayne@69
|
266 //! all moved to the byte mask. Decode only returns a noData value if it is really used. In that case the caller needs to filter
|
jpayne@69
|
267 //! the decoded arrays using both the byte mask returned and the noData value returned.
|
jpayne@69
|
268 //!
|
jpayne@69
|
269 //! In addition to the noData support, the new functions can also take integer values > 32 bit (but < 53 bit) as a double array,
|
jpayne@69
|
270 //! and if all integer, use that for compression.
|
jpayne@69
|
271 //!
|
jpayne@69
|
272 //! If floating point data contains NaN, Lerc tries to move it to the byte mask or replace it by a passed noData value.
|
jpayne@69
|
273 //! Note, if not all NaN values can be moved to the mask (mixed case), and no noData value was passed, Lerc will fail.
|
jpayne@69
|
274 //! It would be wrong to invent a noData value on the tile level.
|
jpayne@69
|
275
|
jpayne@69
|
276
|
jpayne@69
|
277 //! Encode functions:
|
jpayne@69
|
278 //!
|
jpayne@69
|
279 //! If you don't use a noData value, are fine with the byte masks, just pass nullptr for the last 2 arguments.
|
jpayne@69
|
280 //!
|
jpayne@69
|
281 //! If you do have noData values at pixels that are marked as valid pixels by the byte mask,
|
jpayne@69
|
282 //! pass 2 arrays of size nBands each, one value per band.
|
jpayne@69
|
283 //! In pUsesNoData array, for each band, pass 1 for noData value is used, 0 if not.
|
jpayne@69
|
284 //! In noDataValues array, for each band, pass the noData value if there is one.
|
jpayne@69
|
285
|
jpayne@69
|
286 LERCDLL_API
|
jpayne@69
|
287 lerc_status lerc_computeCompressedSize_4D(
|
jpayne@69
|
288 const void* pData, // raw image data, row by row, band by band
|
jpayne@69
|
289 unsigned int dataType, // char = 0, uchar = 1, short = 2, ushort = 3, int = 4, uint = 5, float = 6, double = 7
|
jpayne@69
|
290 int nDepth, // number of values per pixel (e.g., 3 for RGB, data is stored as [RGB, RGB, ...])
|
jpayne@69
|
291 int nCols, // number of columns
|
jpayne@69
|
292 int nRows, // number of rows
|
jpayne@69
|
293 int nBands, // number of bands (e.g., 3 for [RRRR ..., GGGG ..., BBBB ...])
|
jpayne@69
|
294 int nMasks, // 0 - all valid, 1 - same mask for all bands, nBands - masks can differ between bands
|
jpayne@69
|
295 const unsigned char* pValidBytes, // nullptr if all pixels are valid; otherwise 1 byte per pixel (1 = valid, 0 = invalid)
|
jpayne@69
|
296 double maxZErr, // max coding error per pixel, defines the precision
|
jpayne@69
|
297 unsigned int* numBytes, // size of outgoing Lerc blob
|
jpayne@69
|
298 const unsigned char* pUsesNoData, // if there are invalid values not marked by the mask, pass an array of size nBands, 1 - uses noData, 0 - not
|
jpayne@69
|
299 const double* noDataValues); // same, pass an array of size nBands with noData value per band, or pass nullptr
|
jpayne@69
|
300
|
jpayne@69
|
301 LERCDLL_API
|
jpayne@69
|
302 lerc_status lerc_encode_4D(
|
jpayne@69
|
303 const void* pData, // raw image data, row by row, band by band
|
jpayne@69
|
304 unsigned int dataType, // char = 0, uchar = 1, short = 2, ushort = 3, int = 4, uint = 5, float = 6, double = 7
|
jpayne@69
|
305 int nDepth, // number of values per pixel (e.g., 3 for RGB, data is stored as [RGB, RGB, ...])
|
jpayne@69
|
306 int nCols, // number of columns
|
jpayne@69
|
307 int nRows, // number of rows
|
jpayne@69
|
308 int nBands, // number of bands (e.g., 3 for [RRRR ..., GGGG ..., BBBB ...])
|
jpayne@69
|
309 int nMasks, // 0 - all valid, 1 - same mask for all bands, nBands - masks can differ between bands
|
jpayne@69
|
310 const unsigned char* pValidBytes, // nullptr if all pixels are valid; otherwise 1 byte per pixel (1 = valid, 0 = invalid)
|
jpayne@69
|
311 double maxZErr, // max coding error per pixel, defines the precision
|
jpayne@69
|
312 unsigned char* pOutBuffer, // buffer to write to, function fails if buffer too small
|
jpayne@69
|
313 unsigned int outBufferSize, // size of output buffer
|
jpayne@69
|
314 unsigned int* nBytesWritten, // number of bytes written to output buffer
|
jpayne@69
|
315 const unsigned char* pUsesNoData, // if there are invalid values not marked by the mask, pass an array of size nBands, 1 - uses noData, 0 - not
|
jpayne@69
|
316 const double* noDataValues); // same, pass an array of size nBands with noData value per band, or pass nullptr
|
jpayne@69
|
317
|
jpayne@69
|
318
|
jpayne@69
|
319 //! Decode functions:
|
jpayne@69
|
320 //!
|
jpayne@69
|
321 //! Same as for regular decode, first call lerc_getBlobInfo() to get all info needed from the blob header.
|
jpayne@69
|
322 //! Check the property (InfoArray::nUsesNoDataValue) to check if there is any noData value used.
|
jpayne@69
|
323 //!
|
jpayne@69
|
324 //! If not, just pass nullptr for the last 2 arguments.
|
jpayne@69
|
325 //!
|
jpayne@69
|
326 //! If yes, pass 2 arrays of size nBands each, one value per band.
|
jpayne@69
|
327 //! In pUsesNoData array, for each band, 1 means a noData value is used, 0 means not.
|
jpayne@69
|
328 //! In noDataValues array, for each band, it has the noData value if there is one.
|
jpayne@69
|
329 //! This is the same noData value as passed for encode.
|
jpayne@69
|
330
|
jpayne@69
|
331 LERCDLL_API
|
jpayne@69
|
332 #ifdef USE_EMSCRIPTEN
|
jpayne@69
|
333 EMSCRIPTEN_KEEPALIVE
|
jpayne@69
|
334 #endif
|
jpayne@69
|
335 lerc_status lerc_decode_4D(
|
jpayne@69
|
336 const unsigned char* pLercBlob, // Lerc blob to decode
|
jpayne@69
|
337 unsigned int blobSize, // blob size in bytes
|
jpayne@69
|
338 int nMasks, // 0, 1, or nBands; return as many masks in the next array
|
jpayne@69
|
339 unsigned char* pValidBytes, // gets filled if not nullptr, even if all valid
|
jpayne@69
|
340 int nDepth, // number of values per pixel (e.g., 3 for RGB, data is stored as [RGB, RGB, ...])
|
jpayne@69
|
341 int nCols, // number of columns
|
jpayne@69
|
342 int nRows, // number of rows
|
jpayne@69
|
343 int nBands, // number of bands (e.g., 3 for [RRRR ..., GGGG ..., BBBB ...])
|
jpayne@69
|
344 unsigned int dataType, // char = 0, uchar = 1, short = 2, ushort = 3, int = 4, uint = 5, float = 6, double = 7
|
jpayne@69
|
345 void* pData, // outgoing data array
|
jpayne@69
|
346 unsigned char* pUsesNoData, // pass an array of size nBands, 1 - band uses noData, 0 - not
|
jpayne@69
|
347 double* noDataValues); // same, pass an array of size nBands to get the noData value per band, if any
|
jpayne@69
|
348
|
jpayne@69
|
349 LERCDLL_API
|
jpayne@69
|
350 lerc_status lerc_decodeToDouble_4D(
|
jpayne@69
|
351 const unsigned char* pLercBlob, // Lerc blob to decode
|
jpayne@69
|
352 unsigned int blobSize, // blob size in bytes
|
jpayne@69
|
353 int nMasks, // 0, 1, or nBands; return as many masks in the next array
|
jpayne@69
|
354 unsigned char* pValidBytes, // gets filled if not nullptr, even if all valid
|
jpayne@69
|
355 int nDepth, // number of values per pixel (e.g., 3 for RGB, data is stored as [RGB, RGB, ...])
|
jpayne@69
|
356 int nCols, // number of columns
|
jpayne@69
|
357 int nRows, // number of rows
|
jpayne@69
|
358 int nBands, // number of bands (e.g., 3 for [RRRR ..., GGGG ..., BBBB ...])
|
jpayne@69
|
359 double* pData, // outgoing data array
|
jpayne@69
|
360 unsigned char* pUsesNoData, // pass an array of size nBands, 1 - band uses noData, 0 - not
|
jpayne@69
|
361 double* noDataValues); // same, pass an array of size nBands to get the noData value per band, if any
|
jpayne@69
|
362
|
jpayne@69
|
363
|
jpayne@69
|
364 #ifdef __cplusplus
|
jpayne@69
|
365 }
|
jpayne@69
|
366 #endif
|
jpayne@69
|
367
|
jpayne@69
|
368 #endif // LERC_API_INCLUDE_GUARD
|