"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "C/Ppmd8.c" between
p7zip_15.14.1_src_all.tar.gz and p7zip_16.02_src_all.tar.gz

About: p7zip is a command-line file archiver with a high compression ratio (a port of the Windows program 7za.exe).

Ppmd8.c  (p7zip_15.14.1_src_all):Ppmd8.c  (p7zip_16.02_src_all)
/* Ppmd8.c -- PPMdI codec /* Ppmd8.c -- PPMdI codec
2015-09-28 : Igor Pavlov : Public domain 2016-05-21 : Igor Pavlov : Public domain
This code is based on PPMd var.I (2002): Dmitry Shkarin : Public domain */ This code is based on PPMd var.I (2002): Dmitry Shkarin : Public domain */
#include "Precomp.h" #include "Precomp.h"
#include <string.h> #include <string.h>
#include "Ppmd8.h" #include "Ppmd8.h"
const Byte PPMD8_kExpEscape[16] = { 25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 }; const Byte PPMD8_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, 0x 5ABC, 0x6632, 0x6051}; static const UInt16 kInitBinEsc[] = { 0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x 5ABC, 0x6632, 0x6051};
skipping to change at line 243 skipping to change at line 243
if (numBytes <= (UInt32)(p->HiUnit - p->LoUnit)) if (numBytes <= (UInt32)(p->HiUnit - p->LoUnit))
{ {
void *retVal = p->LoUnit; void *retVal = p->LoUnit;
p->LoUnit += numBytes; p->LoUnit += numBytes;
return retVal; return retVal;
} }
return AllocUnitsRare(p, indx); return AllocUnitsRare(p, indx);
} }
#define MyMem12Cpy(dest, src, num) \ #define MyMem12Cpy(dest, src, num) \
{ UInt32 *d = (UInt32 *)dest; const UInt32 *s = (const UInt32 *)src; UInt32 n { UInt32 *d = (UInt32 *)dest; const UInt32 *z = (const UInt32 *)src; UInt32 n
= num; \ = num; \
do { d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; s += 3; d += 3; } while (--n); } do { d[0] = z[0]; d[1] = z[1]; d[2] = z[2]; z += 3; d += 3; } while (--n); }
static void *ShrinkUnits(CPpmd8 *p, void *oldPtr, unsigned oldNU, unsigned newNU ) static void *ShrinkUnits(CPpmd8 *p, void *oldPtr, unsigned oldNU, unsigned newNU )
{ {
unsigned i0 = U2I(oldNU); unsigned i0 = U2I(oldNU);
unsigned i1 = U2I(newNU); unsigned i1 = U2I(newNU);
if (i0 == i1) if (i0 == i1)
return oldPtr; return oldPtr;
if (p->FreeList[i1] != 0) if (p->FreeList[i1] != 0)
{ {
void *ptr = RemoveNode(p, i1); void *ptr = RemoveNode(p, i1);
skipping to change at line 775 skipping to change at line 775
do { SetSuccessor(ps[--numPs], REF(c)); } while (numPs); do { SetSuccessor(ps[--numPs], REF(c)); } while (numPs);
RESET_TEXT(1); RESET_TEXT(1);
p->OrderFall = 1; p->OrderFall = 1;
return c; return c;
} }
else else
#endif #endif
if (SUCCESSOR(s) <= upBranch) if (SUCCESSOR(s) <= upBranch)
{ {
CTX_PTR successor; CTX_PTR successor;
CPpmd_State *s1 = p->FoundState; CPpmd_State *s2 = p->FoundState;
p->FoundState = s; p->FoundState = s;
successor = CreateSuccessors(p, False, NULL, c); successor = CreateSuccessors(p, False, NULL, c);
if (successor == NULL) if (successor == NULL)
SetSuccessor(s, 0); SetSuccessor(s, 0);
else else
SetSuccessor(s, REF(successor)); SetSuccessor(s, REF(successor));
p->FoundState = s1; p->FoundState = s2;
} }
if (p->OrderFall == 1 && c1 == p->MaxContext) if (p->OrderFall == 1 && c1 == p->MaxContext)
{ {
SetSuccessor(p->FoundState, SUCCESSOR(s)); SetSuccessor(p->FoundState, SUCCESSOR(s));
p->Text--; p->Text--;
} }
if (SUCCESSOR(s) == 0) if (SUCCESSOR(s) == 0)
return NULL; return NULL;
return CTX(SUCCESSOR(s)); return CTX(SUCCESSOR(s));
skipping to change at line 927 skipping to change at line 927
oldPtr = STATS(c); oldPtr = STATS(c);
MyMem12Cpy(ptr, oldPtr, oldNU); MyMem12Cpy(ptr, oldPtr, oldNU);
InsertNode(p, oldPtr, i); InsertNode(p, oldPtr, i);
c->Stats = STATS_REF(ptr); c->Stats = STATS_REF(ptr);
} }
} }
c->SummFreq = (UInt16)(c->SummFreq + (3 * ns1 + 1 < ns)); c->SummFreq = (UInt16)(c->SummFreq + (3 * ns1 + 1 < ns));
} }
else else
{ {
CPpmd_State *s = (CPpmd_State*)AllocUnits(p, 0); CPpmd_State *s2 = (CPpmd_State*)AllocUnits(p, 0);
if (!s) if (!s2)
{ {
RESTORE_MODEL(c, CTX(fSuccessor)); RESTORE_MODEL(c, CTX(fSuccessor));
return; return;
} }
*s = *ONE_STATE(c); *s2 = *ONE_STATE(c);
c->Stats = REF(s); c->Stats = REF(s2);
if (s->Freq < MAX_FREQ / 4 - 1) if (s2->Freq < MAX_FREQ / 4 - 1)
s->Freq <<= 1; s2->Freq <<= 1;
else else
s->Freq = MAX_FREQ - 4; s2->Freq = MAX_FREQ - 4;
c->SummFreq = (UInt16)(s->Freq + p->InitEsc + (ns > 2)); c->SummFreq = (UInt16)(s2->Freq + p->InitEsc + (ns > 2));
} }
cf = 2 * fFreq * (c->SummFreq + 6); cf = 2 * fFreq * (c->SummFreq + 6);
sf = (UInt32)s0 + c->SummFreq; sf = (UInt32)s0 + c->SummFreq;
if (cf < 6 * sf) if (cf < 6 * sf)
{ {
cf = 1 + (cf > sf) + (cf >= 4 * sf); cf = 1 + (cf > sf) + (cf >= 4 * sf);
c->SummFreq += 4; c->SummFreq += 4;
} }
else else
{ {
cf = 4 + (cf > 9 * sf) + (cf > 12 * sf) + (cf > 15 * sf); cf = 4 + (cf > 9 * sf) + (cf > 12 * sf) + (cf > 15 * sf);
c->SummFreq = (UInt16)(c->SummFreq + cf); c->SummFreq = (UInt16)(c->SummFreq + cf);
} }
{ {
CPpmd_State *s = STATS(c) + ns1 + 1; CPpmd_State *s2 = STATS(c) + ns1 + 1;
SetSuccessor(s, successor); SetSuccessor(s2, successor);
s->Symbol = fSymbol; s2->Symbol = fSymbol;
s->Freq = (Byte)cf; s2->Freq = (Byte)cf;
c->Flags |= flag; c->Flags |= flag;
c->NumStats = (Byte)(ns1 + 1); c->NumStats = (Byte)(ns1 + 1);
} }
} }
p->MaxContext = p->MinContext = CTX(fSuccessor); p->MaxContext = p->MinContext = CTX(fSuccessor);
} }
static void Rescale(CPpmd8 *p) static void Rescale(CPpmd8 *p)
{ {
unsigned i, adder, sumFreq, escFreq; unsigned i, adder, sumFreq, escFreq;
skipping to change at line 1041 skipping to change at line 1041
p->MinContext->SummFreq = (UInt16)(sumFreq + escFreq - (escFreq >> 1)); p->MinContext->SummFreq = (UInt16)(sumFreq + escFreq - (escFreq >> 1));
p->MinContext->Flags |= 0x4; p->MinContext->Flags |= 0x4;
p->FoundState = STATS(p->MinContext); p->FoundState = STATS(p->MinContext);
} }
CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked1, UInt32 *escFreq) CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked1, UInt32 *escFreq)
{ {
CPpmd_See *see; CPpmd_See *see;
if (p->MinContext->NumStats != 0xFF) if (p->MinContext->NumStats != 0xFF)
{ {
see = p->See[p->NS2Indx[p->MinContext->NumStats + 2] - 3] + see = p->See[(unsigned)p->NS2Indx[(unsigned)p->MinContext->NumStats + 2] - 3 ] +
(p->MinContext->SummFreq > 11 * ((unsigned)p->MinContext->NumStats + 1)) + (p->MinContext->SummFreq > 11 * ((unsigned)p->MinContext->NumStats + 1)) +
2 * (2 * (unsigned)p->MinContext->NumStats < 2 * (unsigned)(2 * (unsigned)p->MinContext->NumStats <
((unsigned)SUFFIX(p->MinContext)->NumStats + numMasked1)) + ((unsigned)SUFFIX(p->MinContext)->NumStats + numMasked1)) +
p->MinContext->Flags; p->MinContext->Flags;
{ {
unsigned r = (see->Summ >> see->Shift); unsigned r = (see->Summ >> see->Shift);
see->Summ = (UInt16)(see->Summ - r); see->Summ = (UInt16)(see->Summ - r);
*escFreq = r + (r == 0); *escFreq = r + (r == 0);
} }
} }
else else
{ {
 End of changes. 10 change blocks. 
20 lines changed or deleted 20 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS