libsidplayfp  0.3.5
PP20.h
1 /*
2  * /home/ms/files/source/libsidtune/RCS/PP20.h,v
3  *
4  * PowerPacker (AMIGA) "PP20" format decompressor.
5  * Copyright (C) Michael Schwendt <mschwendt@yahoo.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 
22 #ifndef PP_DECOMPRESSOR_H
23 #define PP_DECOMPRESSOR_H
24 
25 #include "PP20_Defs.h"
26 
27 class PP20
28 {
29  public:
30 
31  PP20();
32 
33  bool isCompressed(const void* source, const udword_ppt size);
34 
35  // If successful, allocates a new buffer containing the
36  // uncompresse data and returns the uncompressed length.
37  // Else, returns 0.
38  udword_ppt decompress(const void* source,
39  udword_ppt size,
40  ubyte_ppt** destRef);
41 
42  const char* getStatusString() { return statusString; }
43 
44  private:
45  bool checkEfficiency(const void* source);
46 
47  void bytesTOdword();
48  udword_ppt readBits(int count);
49  void bytes();
50  void sequence();
51 
52  static const char* PP_ID;
53 
54  ubyte_ppt efficiency[4];
55 
56  const ubyte_ppt* sourceBeg;
57  const ubyte_ppt* readPtr;
58 
59  const ubyte_ppt* destBeg;
60  ubyte_ppt* writePtr;
61 
62  udword_ppt current; // compressed data longword
63  int bits; // number of bits in 'current' to evaluate
64 
65  bool globalError; // exception-free version of code
66 
67  const char* statusString;
68 };
69 
70 #endif /* PP_DECOMPRESSOR_H */