| 1 | /* |
| 2 | Copyright 2021 - 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 | Analytical Raster Compression. |
| 22 | Original coding 2021 Yuriy Yakimenko |
| 23 | */ |
| 24 | |
| 25 | #ifndef FPL_UNIT_TYPES_H |
| 26 | #define FPL_UNIT_TYPES_H |
| 27 | |
| 28 | #include <cstddef> |
| 29 | #include <stdint.h> |
| 30 | #include "Defines.h" |
| 31 | |
| 32 | NAMESPACE_LERC_START |
| 33 | |
| 34 | enum UnitType { UNIT_TYPE_UNKNOWN = 0, UNIT_TYPE_BYTE = 1, UNIT_TYPE_SHORT = 2, UNIT_TYPE_LONG = 3, UNIT_TYPE_64_BIT = 4, UNIT_TYPE_FLOAT = 5, UNIT_TYPE_DOUBLE = 6 }; |
| 35 | |
| 36 | struct UnitTypes |
| 37 | { |
| 38 | static size_t size (const UnitType type); |
| 39 | static UnitType type (int iBytes, bool bFloatType); |
| 40 | |
| 41 | static unsigned char unitCode (const UnitType type) ; |
| 42 | |
| 43 | static void setDerivative (const UnitType type, void *pData, const size_t nCount, const int nLevel, const int start_level = 1); |
| 44 | static void setRowsDerivative (const UnitType type, void *pData, const size_t nCols, const size_t nRows, const int nLevel, int phase = 0); |
| 45 | static void setCrossDerivative (const UnitType type, void *pData, const size_t nCols, const size_t nRows, const int nLevel, int phase = 0); |
| 46 | |
| 47 | static void setBlockDerivative (const UnitType type, void *pData, const size_t nCols, const size_t nRows, const int nLevel, const int start_level = 1); |
| 48 | |
| 49 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 50 | |
| 51 | // RESTORE: |
| 52 | |
| 53 | static void restoreBlockSequence (const int delta, void *pData, const size_t nCols, const size_t nRows, const UnitType unit_type); |
| 54 | static void restoreCrossBytes (const int delta, void *pData, const size_t nCols, const size_t nRows, const UnitType unit_type); |
| 55 | |
| 56 | static void doFloatTransform(uint32_t* pData, const size_t iCnt); |
| 57 | static void undoFloatTransform(uint32_t* pData, const size_t iCnt); |
| 58 | } ; |
| 59 | |
| 60 | NAMESPACE_LERC_END |
| 61 | #endif |