Don't udpate LastOverSpeedTick when using aqua_speed
[ryzomcore.git] / nel / 3rdparty / seven_zip / Ppmd.h
bloba5c1e3ef2545fe94eda049fe5cea5f603ef2affd
1 /* Ppmd.h -- PPMD codec common code
2 2017-04-03 : Igor Pavlov : Public domain
3 This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
5 #ifndef __PPMD_H
6 #define __PPMD_H
8 #include "CpuArch.h"
10 EXTERN_C_BEGIN
12 #ifdef MY_CPU_32BIT
13 #define PPMD_32BIT
14 #endif
16 #define PPMD_INT_BITS 7
17 #define PPMD_PERIOD_BITS 7
18 #define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS))
20 #define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift))
21 #define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2)
22 #define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob))
23 #define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob))
25 #define PPMD_N1 4
26 #define PPMD_N2 4
27 #define PPMD_N3 4
28 #define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4)
29 #define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4)
31 #pragma pack(push, 1)
32 /* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */
34 /* SEE-contexts for PPM-contexts with masked symbols */
35 typedef struct
37 UInt16 Summ; /* Freq */
38 Byte Shift; /* Speed of Freq change; low Shift is for fast change */
39 Byte Count; /* Count to next change of Shift */
40 } CPpmd_See;
42 #define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \
43 { (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); }
45 typedef struct
47 Byte Symbol;
48 Byte Freq;
49 UInt16 SuccessorLow;
50 UInt16 SuccessorHigh;
51 } CPpmd_State;
53 #pragma pack(pop)
55 typedef
56 #ifdef PPMD_32BIT
57 CPpmd_State *
58 #else
59 UInt32
60 #endif
61 CPpmd_State_Ref;
63 typedef
64 #ifdef PPMD_32BIT
65 void *
66 #else
67 UInt32
68 #endif
69 CPpmd_Void_Ref;
71 typedef
72 #ifdef PPMD_32BIT
73 Byte *
74 #else
75 UInt32
76 #endif
77 CPpmd_Byte_Ref;
79 #define PPMD_SetAllBitsIn256Bytes(p) \
80 { size_t z; for (z = 0; z < 256 / sizeof(p[0]); z += 8) { \
81 p[z+7] = p[z+6] = p[z+5] = p[z+4] = p[z+3] = p[z+2] = p[z+1] = p[z+0] = ~(size_t)0; }}
83 EXTERN_C_END
85 #endif