hier.7: Document some recently added directories.
[dragonfly.git] / contrib / libarchive / libarchive / archive_ppmd7_private.h
blob3a6b9eb4190f79f0e35668d6a9fd08403514eec9
1 /* Ppmd7.h -- PPMdH compression codec
2 2010-03-12 : Igor Pavlov : Public domain
3 This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
5 /* This code supports virtual RangeDecoder and includes the implementation
6 of RangeCoder from 7z, instead of RangeCoder from original PPMd var.H.
7 If you need the compatibility with original PPMd var.H, you can use external RangeDecoder */
9 #ifndef __LIBARCHIVE_BUILD
10 #error This header is only to be used internally to libarchive.
11 #endif
13 #ifndef ARCHIVE_PPMD7_PRIVATE_H_INCLUDED
14 #define ARCHIVE_PPMD7_PRIVATE_H_INCLUDED
16 #include "archive_ppmd_private.h"
18 #define PPMD7_MIN_ORDER 2
19 #define PPMD7_MAX_ORDER 64
21 #define PPMD7_MIN_MEM_SIZE (1 << 11)
22 #define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3)
24 struct CPpmd7_Context_;
26 typedef
27 #ifdef PPMD_32BIT
28 struct CPpmd7_Context_ *
29 #else
30 UInt32
31 #endif
32 CPpmd7_Context_Ref;
34 typedef struct CPpmd7_Context_
36 UInt16 NumStats;
37 UInt16 SummFreq;
38 CPpmd_State_Ref Stats;
39 CPpmd7_Context_Ref Suffix;
40 } CPpmd7_Context;
42 #define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq)
44 typedef struct
46 CPpmd7_Context *MinContext, *MaxContext;
47 CPpmd_State *FoundState;
48 unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag;
49 Int32 RunLength, InitRL; /* must be 32-bit at least */
51 UInt32 Size;
52 UInt32 GlueCount;
53 Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart;
54 UInt32 AlignOffset;
56 Byte Indx2Units[PPMD_NUM_INDEXES];
57 Byte Units2Indx[128];
58 CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES];
59 Byte NS2Indx[256], NS2BSIndx[256], HB2Flag[256];
60 CPpmd_See DummySee, See[25][16];
61 UInt16 BinSumm[128][64];
62 } CPpmd7;
64 /* ---------- Decode ---------- */
66 typedef struct
68 UInt32 (*GetThreshold)(void *p, UInt32 total);
69 void (*Decode)(void *p, UInt32 start, UInt32 size);
70 UInt32 (*DecodeBit)(void *p, UInt32 size0);
71 } IPpmd7_RangeDec;
73 typedef struct
75 IPpmd7_RangeDec p;
76 UInt32 Range;
77 UInt32 Code;
78 UInt32 Low;
79 UInt32 Bottom;
80 IByteIn *Stream;
81 } CPpmd7z_RangeDec;
83 /* ---------- Encode ---------- */
85 typedef struct
87 UInt64 Low;
88 UInt32 Range;
89 Byte Cache;
90 UInt64 CacheSize;
91 IByteOut *Stream;
92 } CPpmd7z_RangeEnc;
94 typedef struct
96 /* Base Functions */
97 void (*Ppmd7_Construct)(CPpmd7 *p);
98 Bool (*Ppmd7_Alloc)(CPpmd7 *p, UInt32 size, ISzAlloc *alloc);
99 void (*Ppmd7_Free)(CPpmd7 *p, ISzAlloc *alloc);
100 void (*Ppmd7_Init)(CPpmd7 *p, unsigned maxOrder);
101 #define Ppmd7_WasAllocated(p) ((p)->Base != NULL)
103 /* Decode Functions */
104 void (*Ppmd7z_RangeDec_CreateVTable)(CPpmd7z_RangeDec *p);
105 void (*PpmdRAR_RangeDec_CreateVTable)(CPpmd7z_RangeDec *p);
106 Bool (*Ppmd7z_RangeDec_Init)(CPpmd7z_RangeDec *p);
107 Bool (*PpmdRAR_RangeDec_Init)(CPpmd7z_RangeDec *p);
108 #define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0)
109 int (*Ppmd7_DecodeSymbol)(CPpmd7 *p, IPpmd7_RangeDec *rc);
111 /* Encode Functions */
112 void (*Ppmd7z_RangeEnc_Init)(CPpmd7z_RangeEnc *p);
113 void (*Ppmd7z_RangeEnc_FlushData)(CPpmd7z_RangeEnc *p);
115 void (*Ppmd7_EncodeSymbol)(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol);
116 } IPpmd7;
118 extern const IPpmd7 __archive_ppmd7_functions;
119 #endif