| 1 | /* |
| 2 | Copyright 2016 - 2026 Esri |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | |
| 16 | A local copy of the license and additional notices are located with the |
| 17 | source distribution at: |
| 18 | |
| 19 | http://github.com/Esri/lerc/ |
| 20 | |
| 21 | Contributors: Thomas Maurer |
| 22 | */ |
| 23 | |
| 24 | #include "Defines.h"cxx . . $ `<file>/src/LercLib/Defines.h`/ |
| 25 | #include "include/Lerc_c_api.h"cxx . . $ `<file>/src/LercLib/include/Lerc_c_api.h`/ |
| 26 | #include "include/Lerc_types.h"cxx . . $ `<file>/src/LercLib/include/Lerc_types.h`/ |
| 27 | #include "Lerc.h"cxx . . $ `<file>/src/LercLib/Lerc.h`/ |
| 28 | |
| 29 | USING_NAMESPACE_LERCcxx . . $ `src/LercLib/Defines.h:37:9`! |
| 30 | |
| 31 | // -------------------------------------------------------------------------- ; |
| 32 | |
| 33 | lerc_status lerc_computeCompressedSizecxx . . $ lerc_computeCompressedSize(5e1e5e0ac12849ce).(const void* pData, unsigned int dataType, int nDepth, int nCols, int nRows, int nBands, |
| 34 | int nMasks, const unsigned char* pValidBytes, double maxZErr, unsigned int* numBytes) |
| 35 | { |
| 36 | return lerc_computeCompressedSizeForVersion(pData, -1, dataType, nDepth, nCols, nRows, nBands, nMasks, |
| 37 | pValidBytes, maxZErr, numBytes); |
| 38 | } |
| 39 | |
| 40 | // -------------------------------------------------------------------------- ; |
| 41 | |
| 42 | lerc_status lerc_computeCompressedSizeForVersioncxx . . $ lerc_computeCompressedSizeForVersion(69311e560ac804ad).(const void* pData, int version, unsigned int dataType, int nDepth, int nCols, int nRows, int nBands, |
| 43 | int nMasks, const unsigned char* pValidBytes, double maxZErr, unsigned int* numBytes) |
| 44 | { |
| 45 | if (!numBytes) |
| 46 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 47 | |
| 48 | *numBytes = 0; |
| 49 | |
| 50 | if (!pData || dataType >= Lerccxx . . $ LercNS/Lerc#::DT_Undefinedcxx . . $ LercNS/Lerc#DT_Undefined. || nDepth <= 0 || nCols <= 0 || nRows <= 0 || nBands <= 0 || maxZErr < 0) |
| 51 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 52 | |
| 53 | if (!(nMasks == 0 || nMasks == 1 || nMasks == nBands) || (nMasks > 0 && !pValidBytes)) |
| 54 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 55 | |
| 56 | Lerccxx . . $ LercNS/Lerc#::DataTypecxx . . $ LercNS/Lerc#DataType# dt = (Lerccxx . . $ LercNS/Lerc#::DataTypecxx . . $ LercNS/Lerc#DataType#)dataType; |
| 57 | return (lerc_status)Lerccxx . . $ LercNS/Lerc#::ComputeCompressedSizecxx . . $ LercNS/Lerc#ComputeCompressedSize(907a79ad428f5081).(pData, version, dt, nDepth, nCols, nRows, nBands, nMasks, |
| 58 | pValidBytes, maxZErr, *numBytes, nullptr, nullptr); |
| 59 | } |
| 60 | |
| 61 | // -------------------------------------------------------------------------- ; |
| 62 | |
| 63 | lerc_status lerc_encodecxx . . $ lerc_encode(40c4359e19c84dce).(const void* pData, unsigned int dataType, int nDepth, int nCols, int nRows, int nBands, |
| 64 | int nMasks, const unsigned char* pValidBytes, double maxZErr, unsigned char* pOutBuffer, unsigned int outBufferSize, |
| 65 | unsigned int* nBytesWritten) |
| 66 | { |
| 67 | return lerc_encodeForVersion(pData, -1, dataType, nDepth, nCols, nRows, nBands, nMasks, pValidBytes, |
| 68 | maxZErr, pOutBuffer, outBufferSize, nBytesWritten); |
| 69 | } |
| 70 | |
| 71 | // -------------------------------------------------------------------------- ; |
| 72 | |
| 73 | lerc_status lerc_encodeForVersioncxx . . $ lerc_encodeForVersion(c95b36d2244f59f).(const void* pData, int version, unsigned int dataType, int nDepth, int nCols, int nRows, int nBands, |
| 74 | int nMasks, const unsigned char* pValidBytes, double maxZErr, unsigned char* pOutBuffer, unsigned int outBufferSize, |
| 75 | unsigned int* nBytesWritten) |
| 76 | { |
| 77 | if (!nBytesWritten) |
| 78 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 79 | |
| 80 | *nBytesWritten = 0; |
| 81 | |
| 82 | if (!pData || dataType >= Lerccxx . . $ LercNS/Lerc#::DT_Undefinedcxx . . $ LercNS/Lerc#DT_Undefined. || nDepth <= 0 || nCols <= 0 || nRows <= 0 || nBands <= 0 || maxZErr < 0 || !pOutBuffer || !outBufferSize) |
| 83 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 84 | |
| 85 | if (!(nMasks == 0 || nMasks == 1 || nMasks == nBands) || (nMasks > 0 && !pValidBytes)) |
| 86 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 87 | |
| 88 | Lerccxx . . $ LercNS/Lerc#::DataTypecxx . . $ LercNS/Lerc#DataType# dt = (Lerccxx . . $ LercNS/Lerc#::DataTypecxx . . $ LercNS/Lerc#DataType#)dataType; |
| 89 | return (lerc_status)Lerccxx . . $ LercNS/Lerc#::Encodecxx . . $ LercNS/Lerc#Encode(5806e23373902463).(pData, version, dt, nDepth, nCols, nRows, nBands, nMasks, pValidBytes, |
| 90 | maxZErr, pOutBuffer, outBufferSize, *nBytesWritten, nullptr, nullptr); |
| 91 | } |
| 92 | |
| 93 | // -------------------------------------------------------------------------- ; |
| 94 | |
| 95 | lerc_status lerc_getBlobInfocxx . . $ lerc_getBlobInfo(5c9a9d501e536624).(const unsigned char* pLercBlob, unsigned int blobSize, |
| 96 | unsigned int* infoArray, double* dataRangeArray, int infoArraySize, int dataRangeArraySize) |
| 97 | { |
| 98 | if (!pLercBlob || !blobSize || (!infoArray && !dataRangeArray) || ((infoArraySize <= 0) && (dataRangeArraySize <= 0))) |
| 99 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 100 | |
| 101 | Lerccxx . . $ LercNS/Lerc#::LercInfocxx . . $ LercNS/Lerc#LercInfo# lercInfo; |
| 102 | ErrCodecxx . . $ LercNS/ErrCode# errCode = Lerccxx . . $ LercNS/Lerc#::GetLercInfocxx . . $ LercNS/Lerc#GetLercInfo(db35de8f40228c29).(pLercBlob, blobSize, lercInfo); |
| 103 | if (errCode != ErrCodecxx . . $ LercNS/ErrCode#::Okcxx . . $ LercNS/ErrCode#Ok.) |
| 104 | return (lerc_status)errCode; |
| 105 | |
| 106 | if (infoArray) |
| 107 | { |
| 108 | int i = 0, ias = infoArraySize; |
| 109 | |
| 110 | if (ias > 0) |
| 111 | memset(infoArray, 0, ias * sizeof(infoArray[0])); |
| 112 | |
| 113 | if (i < ias) |
| 114 | infoArray[i++] = (unsigned int)lercInfo.versioncxx . . $ LercNS/Lerc#LercInfo#version.; |
| 115 | if (i < ias) |
| 116 | infoArray[i++] = (unsigned int)lercInfo.dtcxx . . $ LercNS/Lerc#LercInfo#dt.; |
| 117 | if (i < ias) |
| 118 | infoArray[i++] = (unsigned int)lercInfo.nDepthcxx . . $ LercNS/Lerc#LercInfo#nDepth.; |
| 119 | if (i < ias) |
| 120 | infoArray[i++] = (unsigned int)lercInfo.nColscxx . . $ LercNS/Lerc#LercInfo#nCols.; |
| 121 | if (i < ias) |
| 122 | infoArray[i++] = (unsigned int)lercInfo.nRowscxx . . $ LercNS/Lerc#LercInfo#nRows.; |
| 123 | if (i < ias) |
| 124 | infoArray[i++] = (unsigned int)lercInfo.nBandscxx . . $ LercNS/Lerc#LercInfo#nBands.; |
| 125 | if (i < ias) |
| 126 | infoArray[i++] = (unsigned int)lercInfo.numValidPixelcxx . . $ LercNS/Lerc#LercInfo#numValidPixel.; |
| 127 | if (i < ias) |
| 128 | infoArray[i++] = (unsigned int)lercInfo.blobSizecxx . . $ LercNS/Lerc#LercInfo#blobSize.; |
| 129 | if (i < ias) |
| 130 | infoArray[i++] = (unsigned int)lercInfo.nMaskscxx . . $ LercNS/Lerc#LercInfo#nMasks.; |
| 131 | if (i < ias) |
| 132 | infoArray[i++] = (unsigned int)lercInfo.nDepthcxx . . $ LercNS/Lerc#LercInfo#nDepth.; |
| 133 | if (i < ias) |
| 134 | infoArray[i++] = (unsigned int)lercInfo.nUsesNoDataValuecxx . . $ LercNS/Lerc#LercInfo#nUsesNoDataValue.; |
| 135 | } |
| 136 | |
| 137 | if (dataRangeArray) |
| 138 | { |
| 139 | int i = 0, dras = dataRangeArraySize; |
| 140 | |
| 141 | if (dras > 0) |
| 142 | memset(dataRangeArray, 0, dras * sizeof(dataRangeArray[0])); |
| 143 | |
| 144 | // for nDepth > 1, and mix of valid and invalid values at same pixel, better reset min / max to -1 |
| 145 | // than return min or max values that contain noData (to be fixed in next codec version) |
| 146 | |
| 147 | bool bUsesNoData = (lercInfo.nDepthcxx . . $ LercNS/Lerc#LercInfo#nDepth. > 1) && (lercInfo.nUsesNoDataValuecxx . . $ LercNS/Lerc#LercInfo#nUsesNoDataValue. > 0); |
| 148 | |
| 149 | if (i < dras) |
| 150 | dataRangeArray[i++] = !bUsesNoData ? lercInfo.zMincxx . . $ LercNS/Lerc#LercInfo#zMin. : -1; |
| 151 | if (i < dras) |
| 152 | dataRangeArray[i++] = !bUsesNoData ? lercInfo.zMaxcxx . . $ LercNS/Lerc#LercInfo#zMax. : -1; |
| 153 | if (i < dras) |
| 154 | dataRangeArray[i++] = lercInfo.maxZErrorcxx . . $ LercNS/Lerc#LercInfo#maxZError.; |
| 155 | } |
| 156 | |
| 157 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::Okcxx . . $ LercNS/ErrCode#Ok.; |
| 158 | } |
| 159 | |
| 160 | // -------------------------------------------------------------------------- ; |
| 161 | |
| 162 | lerc_status lerc_getDataRangescxx . . $ lerc_getDataRanges(db076112dd04d5b1).(const unsigned char* pLercBlob, unsigned int blobSize, |
| 163 | int nDepth, int nBands, double* pMins, double* pMaxs) |
| 164 | { |
| 165 | if (!pLercBlob || !blobSize || !pMins || !pMaxs || nDepth <= 0 || nBands <= 0) |
| 166 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 167 | |
| 168 | Lerccxx . . $ LercNS/Lerc#::LercInfocxx . . $ LercNS/Lerc#LercInfo# lercInfo; |
| 169 | ErrCodecxx . . $ LercNS/ErrCode# errCode = Lerccxx . . $ LercNS/Lerc#::GetLercInfocxx . . $ LercNS/Lerc#GetLercInfo(db35de8f40228c29).(pLercBlob, blobSize, lercInfo, pMins, pMaxs, (size_t)nDepth * (size_t)nBands); |
| 170 | if (errCode != ErrCodecxx . . $ LercNS/ErrCode#::Okcxx . . $ LercNS/ErrCode#Ok.) |
| 171 | return (lerc_status)errCode; |
| 172 | |
| 173 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::Okcxx . . $ LercNS/ErrCode#Ok.; |
| 174 | } |
| 175 | |
| 176 | // -------------------------------------------------------------------------- ; |
| 177 | |
| 178 | lerc_status lerc_decodecxx . . $ lerc_decode(77ae6712d737a404).(const unsigned char* pLercBlob, unsigned int blobSize, int nMasks, |
| 179 | unsigned char* pValidBytes, int nDepth, int nCols, int nRows, int nBands, unsigned int dataType, void* pData) |
| 180 | { |
| 181 | return lerc_decode_4D(pLercBlob, blobSize, nMasks, pValidBytes, |
| 182 | nDepth, nCols, nRows, nBands, dataType, pData, nullptr, nullptr); |
| 183 | } |
| 184 | // -------------------------------------------------------------------------- ; |
| 185 | |
| 186 | lerc_status lerc_decodeToDoublecxx . . $ lerc_decodeToDouble(6674b82df06527f5).(const unsigned char* pLercBlob, unsigned int blobSize, int nMasks, |
| 187 | unsigned char* pValidBytes, int nDepth, int nCols, int nRows, int nBands, double* pData) |
| 188 | { |
| 189 | return lerc_decodeToDouble_4D(pLercBlob, blobSize, nMasks, pValidBytes, |
| 190 | nDepth, nCols, nRows, nBands, pData, nullptr, nullptr); |
| 191 | } |
| 192 | |
| 193 | // -------------------------------------------------------------------------- ; |
| 194 | // -------------------------------------------------------------------------- ; |
| 195 | |
| 196 | lerc_status lerc_computeCompressedSize_4Dcxx . . $ lerc_computeCompressedSize_4D(3bba2a1d267a0ce9).(const void* pData, unsigned int dataType, int nDepth, int nCols, int nRows, int nBands, |
| 197 | int nMasks, const unsigned char* pValidBytes, double maxZErr, unsigned int* numBytes, const unsigned char* pUsesNoData, const double* noDataValues) |
| 198 | { |
| 199 | if (!numBytes) |
| 200 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 201 | |
| 202 | *numBytes = 0; |
| 203 | |
| 204 | if (!pData || dataType >= Lerccxx . . $ LercNS/Lerc#::DT_Undefinedcxx . . $ LercNS/Lerc#DT_Undefined. || nDepth <= 0 || nCols <= 0 || nRows <= 0 || nBands <= 0 || maxZErr < 0) |
| 205 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 206 | |
| 207 | if (!(nMasks == 0 || nMasks == 1 || nMasks == nBands) || (nMasks > 0 && !pValidBytes)) |
| 208 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 209 | |
| 210 | Lerccxx . . $ LercNS/Lerc#::DataTypecxx . . $ LercNS/Lerc#DataType# dt = (Lerccxx . . $ LercNS/Lerc#::DataTypecxx . . $ LercNS/Lerc#DataType#)dataType; |
| 211 | return (lerc_status)Lerccxx . . $ LercNS/Lerc#::ComputeCompressedSizecxx . . $ LercNS/Lerc#ComputeCompressedSize(907a79ad428f5081).(pData, -1, dt, nDepth, nCols, nRows, nBands, nMasks, |
| 212 | pValidBytes, maxZErr, *numBytes, pUsesNoData, noDataValues); |
| 213 | } |
| 214 | |
| 215 | // -------------------------------------------------------------------------- ; |
| 216 | |
| 217 | lerc_status lerc_encode_4Dcxx . . $ lerc_encode_4D(c347b42ad200c1b0).(const void* pData, unsigned int dataType, int nDepth, int nCols, int nRows, int nBands, |
| 218 | int nMasks, const unsigned char* pValidBytes, double maxZErr, unsigned char* pOutBuffer, unsigned int outBufferSize, |
| 219 | unsigned int* nBytesWritten, const unsigned char* pUsesNoData, const double* noDataValues) |
| 220 | { |
| 221 | if (!nBytesWritten) |
| 222 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 223 | |
| 224 | *nBytesWritten = 0; |
| 225 | |
| 226 | if (!pData || dataType >= Lerccxx . . $ LercNS/Lerc#::DT_Undefinedcxx . . $ LercNS/Lerc#DT_Undefined. || nDepth <= 0 || nCols <= 0 || nRows <= 0 || nBands <= 0 || maxZErr < 0 || !pOutBuffer || !outBufferSize) |
| 227 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 228 | |
| 229 | if (!(nMasks == 0 || nMasks == 1 || nMasks == nBands) || (nMasks > 0 && !pValidBytes)) |
| 230 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 231 | |
| 232 | Lerccxx . . $ LercNS/Lerc#::DataTypecxx . . $ LercNS/Lerc#DataType# dt = (Lerccxx . . $ LercNS/Lerc#::DataTypecxx . . $ LercNS/Lerc#DataType#)dataType; |
| 233 | return (lerc_status)Lerccxx . . $ LercNS/Lerc#::Encodecxx . . $ LercNS/Lerc#Encode(5806e23373902463).(pData, -1, dt, nDepth, nCols, nRows, nBands, nMasks, pValidBytes, |
| 234 | maxZErr, pOutBuffer, outBufferSize, *nBytesWritten, pUsesNoData, noDataValues); |
| 235 | } |
| 236 | |
| 237 | // -------------------------------------------------------------------------- ; |
| 238 | |
| 239 | lerc_status lerc_decode_4Dcxx . . $ lerc_decode_4D(da19ffaf1893197f).(const unsigned char* pLercBlob, unsigned int blobSize, int nMasks, |
| 240 | unsigned char* pValidBytes, int nDepth, int nCols, int nRows, int nBands, unsigned int dataType, void* pData, |
| 241 | unsigned char* pUsesNoData, double* noDataValues) |
| 242 | { |
| 243 | if (!pLercBlob || !blobSize || !pData || dataType >= Lerccxx . . $ LercNS/Lerc#::DT_Undefinedcxx . . $ LercNS/Lerc#DT_Undefined. || nDepth <= 0 || nCols <= 0 || nRows <= 0 || nBands <= 0) |
| 244 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 245 | |
| 246 | if (!(nMasks == 0 || nMasks == 1 || nMasks == nBands) || (nMasks > 0 && !pValidBytes)) |
| 247 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 248 | |
| 249 | Lerccxx . . $ LercNS/Lerc#::DataTypecxx . . $ LercNS/Lerc#DataType# dt = (Lerccxx . . $ LercNS/Lerc#::DataTypecxx . . $ LercNS/Lerc#DataType#)dataType; |
| 250 | |
| 251 | return (lerc_status)Lerccxx . . $ LercNS/Lerc#::Decodecxx . . $ LercNS/Lerc#Decode(107064e3f405a899).(pLercBlob, blobSize, nMasks, pValidBytes, nDepth, nCols, nRows, nBands, dt, pData, pUsesNoData, noDataValues); |
| 252 | } |
| 253 | |
| 254 | // -------------------------------------------------------------------------- ; |
| 255 | |
| 256 | lerc_status lerc_decodeToDouble_4Dcxx . . $ lerc_decodeToDouble_4D(f5ddad87905419a7).(const unsigned char* pLercBlob, unsigned int blobSize, int nMasks, |
| 257 | unsigned char* pValidBytes, int nDepth, int nCols, int nRows, int nBands, double* pData, |
| 258 | unsigned char* pUsesNoData, double* noDataValues) |
| 259 | { |
| 260 | if (!pLercBlob || !blobSize || !pData || nDepth <= 0 || nCols <= 0 || nRows <= 0 || nBands <= 0) |
| 261 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 262 | |
| 263 | if (!(nMasks == 0 || nMasks == 1 || nMasks == nBands) || (nMasks > 0 && !pValidBytes)) |
| 264 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::WrongParamcxx . . $ LercNS/ErrCode#WrongParam.; |
| 265 | |
| 266 | Lerccxx . . $ LercNS/Lerc#::LercInfocxx . . $ LercNS/Lerc#LercInfo# lercInfo; |
| 267 | ErrCodecxx . . $ LercNS/ErrCode# errCode; |
| 268 | if ((errCode = Lerccxx . . $ LercNS/Lerc#::GetLercInfocxx . . $ LercNS/Lerc#GetLercInfo(db35de8f40228c29).(pLercBlob, blobSize, lercInfo)) != ErrCodecxx . . $ LercNS/ErrCode#::Okcxx . . $ LercNS/ErrCode#Ok.) |
| 269 | return (lerc_status)errCode; |
| 270 | |
| 271 | Lerccxx . . $ LercNS/Lerc#::DataTypecxx . . $ LercNS/Lerc#DataType# dt = lercInfo.dtcxx . . $ LercNS/Lerc#LercInfo#dt.; |
| 272 | if (dt < 0 || dt > Lerccxx . . $ LercNS/Lerc#::DT_Doublecxx . . $ LercNS/Lerc#DT_Double.) |
| 273 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::Failedcxx . . $ LercNS/ErrCode#Failed.; |
| 274 | |
| 275 | if (lercInfo.nDepthcxx . . $ LercNS/Lerc#LercInfo#nDepth. != nDepth || lercInfo.nColscxx . . $ LercNS/Lerc#LercInfo#nCols. != nCols || lercInfo.nRowscxx . . $ LercNS/Lerc#LercInfo#nRows. != nRows || lercInfo.nBandscxx . . $ LercNS/Lerc#LercInfo#nBands. != nBands) |
| 276 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::Failedcxx . . $ LercNS/ErrCode#Failed.; |
| 277 | |
| 278 | if (dt == Lerccxx . . $ LercNS/Lerc#::DT_Doublecxx . . $ LercNS/Lerc#DT_Double.) |
| 279 | { |
| 280 | if ((errCode = Lerccxx . . $ LercNS/Lerc#::Decodecxx . . $ LercNS/Lerc#Decode(107064e3f405a899).(pLercBlob, blobSize, nMasks, pValidBytes, |
| 281 | nDepth, nCols, nRows, nBands, dt, pData, pUsesNoData, noDataValues)) != ErrCodecxx . . $ LercNS/ErrCode#::Okcxx . . $ LercNS/ErrCode#Ok.) |
| 282 | { |
| 283 | return (lerc_status)errCode; |
| 284 | } |
| 285 | } |
| 286 | else |
| 287 | { |
| 288 | // use the buffer passed for in place decode and convert |
| 289 | int sizeofDt[] = { 1, 1, 2, 2, 4, 4, 4, 8 }; |
| 290 | size_t nDataValues = (size_t)nDepth * nCols * nRows * nBands; // can be > 4 GB |
| 291 | void* ptrDec = (Bytecxx . . $ LercNS/Byte#*)pData + nDataValues * (sizeof(double) - sizeofDt[dt]); |
| 292 | |
| 293 | if ((errCode = Lerccxx . . $ LercNS/Lerc#::Decodecxx . . $ LercNS/Lerc#Decode(107064e3f405a899).(pLercBlob, blobSize, nMasks, pValidBytes, |
| 294 | nDepth, nCols, nRows, nBands, dt, ptrDec, pUsesNoData, noDataValues)) != ErrCodecxx . . $ LercNS/ErrCode#::Okcxx . . $ LercNS/ErrCode#Ok.) |
| 295 | { |
| 296 | return (lerc_status)errCode; |
| 297 | } |
| 298 | |
| 299 | if ((errCode = Lerccxx . . $ LercNS/Lerc#::ConvertToDoublecxx . . $ LercNS/Lerc#ConvertToDouble(82cb9f5f9c82c481).(ptrDec, dt, nDataValues, pData)) != ErrCodecxx . . $ LercNS/ErrCode#::Okcxx . . $ LercNS/ErrCode#Ok.) |
| 300 | return (lerc_status)errCode; |
| 301 | } |
| 302 | |
| 303 | return (lerc_status)ErrCodecxx . . $ LercNS/ErrCode#::Okcxx . . $ LercNS/ErrCode#Ok.; |
| 304 | } |
| 305 | |
| 306 | // -------------------------------------------------------------------------- ; |
| 307 |