| 1 | /* |
| 2 | Copyright 2015 - 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 | #ifndef BITSTUFFER_H |
| 25 | #define BITSTUFFER_H |
| 26 | |
| 27 | #include <vector> |
| 28 | #include "../Defines.h" |
| 29 | |
| 30 | NAMESPACE_LERC_START |
| 31 | |
| 32 | /** Bit stuffer, for reading unsigned int arrays compressed lossless in the oldest Lerc1 version |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | class BitStuffer |
| 37 | { |
| 38 | public: |
| 39 | BitStuffer() {} |
| 40 | virtual ~BitStuffer() {} |
| 41 | |
| 42 | bool read(const Byte** ppByte, std::vector<unsigned int>& dataVec) const; |
| 43 | |
| 44 | protected: |
| 45 | mutable std::vector<unsigned int> m_tmpBitStuffVec; |
| 46 | |
| 47 | static bool readUInt(const Byte** ppByte, unsigned int& k, int numBytes); // numBytes = 1, 2, or 4 |
| 48 | static unsigned int numTailBytesNotNeeded(unsigned int numElem, int numBits); |
| 49 | }; |
| 50 | |
| 51 | NAMESPACE_LERC_END |
| 52 | #endif |