#include "Precomp.h"
#include <string.h>
#include "Ppmd7.h"
Go to the source code of this file.
|
void | Ppmd7_Construct (CPpmd7 *p) |
|
void | Ppmd7_Free (CPpmd7 *p, ISzAllocPtr alloc) |
|
Bool | Ppmd7_Alloc (CPpmd7 *p, UInt32 size, ISzAllocPtr alloc) |
|
static void | InsertNode (CPpmd7 *p, void *node, unsigned indx) |
|
static void * | RemoveNode (CPpmd7 *p, unsigned indx) |
|
static void | SplitBlock (CPpmd7 *p, void *ptr, unsigned oldIndx, unsigned newIndx) |
|
static void | GlueFreeBlocks (CPpmd7 *p) |
|
static void * | AllocUnitsRare (CPpmd7 *p, unsigned indx) |
|
static void * | AllocUnits (CPpmd7 *p, unsigned indx) |
|
static void * | ShrinkUnits (CPpmd7 *p, void *oldPtr, unsigned oldNU, unsigned newNU) |
|
static void | SetSuccessor (CPpmd_State *p, CPpmd_Void_Ref v) |
|
static void | RestartModel (CPpmd7 *p) |
|
void | Ppmd7_Init (CPpmd7 *p, unsigned maxOrder) |
|
static CTX_PTR | CreateSuccessors (CPpmd7 *p, Bool skip) |
|
static void | SwapStates (CPpmd_State *t1, CPpmd_State *t2) |
|
static void | UpdateModel (CPpmd7 *p) |
|
static void | Rescale (CPpmd7 *p) |
|
CPpmd_See * | Ppmd7_MakeEscFreq (CPpmd7 *p, unsigned numMasked, UInt32 *escFreq) |
|
static void | NextContext (CPpmd7 *p) |
|
void | Ppmd7_Update1 (CPpmd7 *p) |
|
void | Ppmd7_Update1_0 (CPpmd7 *p) |
|
void | Ppmd7_UpdateBin (CPpmd7 *p) |
|
void | Ppmd7_Update2 (CPpmd7 *p) |
|
|
const Byte | PPMD7_kExpEscape [16] = { 25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 } |
|
static const UInt16 | kInitBinEsc [] = { 0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x5ABC, 0x6632, 0x6051} |
|
#define I2U |
( |
|
indx) | |
(p->Indx2Units[indx]) |
#define MyMem12Cpy |
( |
|
dest, |
|
|
|
src, |
|
|
|
num |
|
) |
| |
Value:
do { d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; s += 3; d += 3; } while (--n); }
Definition at line 260 of file Ppmd7.c.
#define NODE |
( |
|
offs) | |
((CPpmd7_Node *)(p->Base + (offs))) |
#define REF |
( |
|
ptr) | |
((UInt32)((Byte *)(ptr) - (p)->Base)) |
#define SUFFIX |
( |
|
ctx) | |
CTX((ctx)->Suffix) |
#define U2I |
( |
|
nu) | |
(p->Units2Indx[(size_t)(nu) - 1]) |
static void* AllocUnits |
( |
CPpmd7 * |
p, |
|
|
unsigned |
indx |
|
) |
| |
|
static |
static void* AllocUnitsRare |
( |
CPpmd7 * |
p, |
|
|
unsigned |
indx |
|
) |
| |
|
static |
Definition at line 345 of file Ppmd7.c.
368 if (successor != upBranch)
390 upState.
Freq = (
Byte)(1 + ((2 * cf <= s0) ? (5 * cf > s0) : ((2 * cf + 3 * s0 - 1) / (2 * s0))));
static void GlueFreeBlocks |
( |
CPpmd7 * |
p) | |
|
|
static |
Definition at line 147 of file Ppmd7.c.
171 n =
NODE(n)->Prev = next;
177 NODE(head)->Stamp = 1;
178 NODE(head)->Next = n;
179 NODE(n)->Prev = head;
192 if (node2->
Stamp != 0 || nu >= 0x10000)
202 for (n =
NODE(head)->Next; n != head;)
207 for (nu = node->
NU; nu > 128; nu -= 128, node += 128)
209 if (
I2U(i =
U2I(nu)) != nu)
211 unsigned k =
I2U(--i);
static void InsertNode |
( |
CPpmd7 * |
p, |
|
|
void * |
node, |
|
|
unsigned |
indx |
|
) |
| |
|
static |
static void NextContext |
( |
CPpmd7 * |
p) | |
|
|
static |
void Ppmd7_Construct |
( |
CPpmd7 * |
p) | |
|
Definition at line 60 of file Ppmd7.c.
68 unsigned step = (i >= 12 ? 4 : (i >> 2) + 1);
76 memset(p->
NS2BSIndx + 11, (3 << 1), 256 - 11);
78 for (i = 0; i < 3; i++)
80 for (m = i, k = 1; i < 256; i++)
88 memset(p->
HB2Flag + 0x40, 8, 0x100 - 0x40);
void Ppmd7_Init |
( |
CPpmd7 * |
p, |
|
|
unsigned |
maxOrder |
|
) |
| |
Definition at line 638 of file Ppmd7.c.
644 see = p->
See[(unsigned)p->
NS2Indx[(
size_t)nonMasked - 1]] +
647 4 * (
unsigned)(numMasked > nonMasked) +
652 *escFreq = r + (r == 0);
void Ppmd7_Update1 |
( |
CPpmd7 * |
p) | |
|
Definition at line 672 of file Ppmd7.c.
677 if (s[0].Freq > s[-1].Freq)
void Ppmd7_Update1_0 |
( |
CPpmd7 * |
p) | |
|
void Ppmd7_Update2 |
( |
CPpmd7 * |
p) | |
|
void Ppmd7_UpdateBin |
( |
CPpmd7 * |
p) | |
|
static void* RemoveNode |
( |
CPpmd7 * |
p, |
|
|
unsigned |
indx |
|
) |
| |
|
static |
static void Rescale |
( |
CPpmd7 * |
p) | |
|
|
static |
Definition at line 574 of file Ppmd7.c.
576 unsigned i, adder, sumFreq, escFreq;
581 for (; s != stats; s--)
594 escFreq -= (++s)->Freq;
597 if (s[0].Freq > s[-1].Freq)
603 while (--s1 != stats && tmp.
Freq > s1[-1].
Freq);
613 do { i++; }
while ((--s)->Freq == 0);
629 n0 = (numStats + 1) >> 1;
static void RestartModel |
( |
CPpmd7 * |
p) | |
|
|
static |
Definition at line 289 of file Ppmd7.c.
310 for (i = 0; i < 256; i++)
318 for (i = 0; i < 128; i++)
319 for (k = 0; k < 8; k++)
323 for (m = 0; m < 64; m += 8)
327 for (i = 0; i < 25; i++)
328 for (k = 0; k < 16; k++)
static void* ShrinkUnits |
( |
CPpmd7 * |
p, |
|
|
void * |
oldPtr, |
|
|
unsigned |
oldNU, |
|
|
unsigned |
newNU |
|
) |
| |
|
static |
Definition at line 264 of file Ppmd7.c.
266 unsigned i0 =
U2I(oldNU);
267 unsigned i1 =
U2I(newNU);
static void SplitBlock |
( |
CPpmd7 * |
p, |
|
|
void * |
ptr, |
|
|
unsigned |
oldIndx, |
|
|
unsigned |
newIndx |
|
) |
| |
|
static |
Definition at line 135 of file Ppmd7.c.
137 unsigned i, nu =
I2U(oldIndx) -
I2U(newIndx);
139 if (
I2U(i =
U2I(nu)) != nu)
141 unsigned k =
I2U(--i);
static void UpdateModel |
( |
CPpmd7 * |
p) | |
|
|
static |
Definition at line 425 of file Ppmd7.c.
447 if (s[0].Freq >= s[-1].Freq)
483 if (fSuccessor <= successor)
491 fSuccessor =
REF(cs);
495 successor = fSuccessor;
516 unsigned oldNU = ns1 >> 1;
517 unsigned i =
U2I(oldNU);
518 if (i !=
U2I((
size_t)oldNU + 1))
555 cf = 1 + (cf > sf) + (cf >= 4 * sf);
560 cf = 4 + (cf >= 9 * sf) + (cf >= 12 * sf) + (cf >= 15 * sf);
const UInt16 kInitBinEsc[] = { 0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x5ABC, 0x6632, 0x6051} |
|
static |
const Byte PPMD7_kExpEscape[16] = { 25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 } |