1 /* 2 =============================================================================== 3 4 FILE: arithmeticdecoder.hpp 5 6 CONTENTS: 7 8 A modular C++ wrapper for an adapted version of Amir Said's FastAC Code. 9 see: http://www.cipr.rpi.edu/~said/FastAC.html 10 11 PROGRAMMERS: 12 13 martin.isenburg@rapidlasso.com - http://rapidlasso.com 14 15 COPYRIGHT: 16 17 (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality 18 19 This is free software; you can redistribute and/or modify it under the 20 terms of the GNU Lesser General Licence as published by the Free Software 21 Foundation. See the COPYING file for more information. 22 23 This software is distributed WITHOUT ANY WARRANTY and without even the 24 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 25 26 CHANGE HISTORY: 27 28 22 August 2016 -- can be used as init dummy by "native LAS 1.4 compressor" 29 13 November 2014 -- integrity check in readBits(), readByte(), readShort() 30 6 September 2014 -- removed the (unused) inheritance from EntropyDecoder 31 10 January 2011 -- licensing change for LGPL release and liblas integration 32 8 December 2010 -- unified framework for all entropy coders 33 30 October 2009 -- refactoring Amir Said's FastAC code 34 35 =============================================================================== 36 */ 37 #ifndef ARITHMETIC_DECODER_HPP 38 #define ARITHMETIC_DECODER_HPP 39 40 #include "mydefs.hpp" 41 #include "bytestreamin.hpp" 42 43 class ArithmeticModel; 44 class ArithmeticBitModel; 45 46 class ArithmeticDecoder 47 { 48 public: 49 50 /* Constructor & Destructor */ 51 ArithmeticDecoder(); 52 ~ArithmeticDecoder(); 53 54 /* Manage decoding */ 55 BOOL init(ByteStreamIn* instream, BOOL really_init = TRUE); 56 void done(); 57 58 /* Manage an entropy model for a single bit */ 59 ArithmeticBitModel* createBitModel(); 60 void initBitModel(ArithmeticBitModel* model); 61 void destroyBitModel(ArithmeticBitModel* model); 62 63 /* Manage an entropy model for n symbols (table optional) */ 64 ArithmeticModel* createSymbolModel(U32 n); 65 void initSymbolModel(ArithmeticModel* model, U32* table=0); 66 void destroySymbolModel(ArithmeticModel* model); 67 68 /* Decode a bit with modelling */ 69 U32 decodeBit(ArithmeticBitModel* model); 70 71 /* Decode a symbol with modelling */ 72 U32 decodeSymbol(ArithmeticModel* model); 73 74 /* Decode a bit without modelling */ 75 U32 readBit(); 76 77 /* Decode bits without modelling */ 78 U32 readBits(U32 bits); 79 80 /* Decode an unsigned char without modelling */ 81 U8 readByte(); 82 83 /* Decode an unsigned short without modelling */ 84 U16 readShort(); 85 86 /* Decode an unsigned int without modelling */ 87 U32 readInt(); 88 89 /* Decode a float without modelling */ 90 F32 readFloat(); 91 92 /* Decode an unsigned 64 bit int without modelling */ 93 U64 readInt64(); 94 95 /* Decode a double without modelling */ 96 F64 readDouble(); 97 98 /* Only read from instream if ArithmeticDecoder is dummy */ getByteStreamIn() const99 ByteStreamIn* getByteStreamIn() const { return instream; }; 100 101 private: 102 103 ByteStreamIn* instream; 104 105 void renorm_dec_interval(); 106 U32 value, length; 107 }; 108 109 #endif 110