aboutsummaryrefslogtreecommitdiff
path: root/C/Ppmd7aDec.c
diff options
context:
space:
mode:
Diffstat (limited to 'C/Ppmd7aDec.c')
-rw-r--r--C/Ppmd7aDec.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/C/Ppmd7aDec.c b/C/Ppmd7aDec.c
index 55e164e..ef86dde 100644
--- a/C/Ppmd7aDec.c
+++ b/C/Ppmd7aDec.c
@@ -1,5 +1,5 @@
1/* Ppmd7aDec.c -- PPMd7a (PPMdH) Decoder 1/* Ppmd7aDec.c -- PPMd7a (PPMdH) Decoder
22023-04-02 : Igor Pavlov : Public domain 22023-09-07 : Igor Pavlov : Public domain
3This code is based on: 3This code is based on:
4 PPMd var.H (2001): Dmitry Shkarin : Public domain 4 PPMd var.H (2001): Dmitry Shkarin : Public domain
5 Carryless rangecoder (1999): Dmitry Subbotin : Public domain */ 5 Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
@@ -58,7 +58,7 @@ typedef CPpmd7_Context * CTX_PTR;
58#define SUCCESSOR(p) Ppmd_GET_SUCCESSOR(p) 58#define SUCCESSOR(p) Ppmd_GET_SUCCESSOR(p)
59void Ppmd7_UpdateModel(CPpmd7 *p); 59void Ppmd7_UpdateModel(CPpmd7 *p);
60 60
61#define MASK(sym) ((unsigned char *)charMask)[sym] 61#define MASK(sym) ((Byte *)charMask)[sym]
62 62
63 63
64int Ppmd7a_DecodeSymbol(CPpmd7 *p) 64int Ppmd7a_DecodeSymbol(CPpmd7 *p)
@@ -120,8 +120,8 @@ int Ppmd7a_DecodeSymbol(CPpmd7 *p)
120 MASK(s->Symbol) = 0; 120 MASK(s->Symbol) = 0;
121 do 121 do
122 { 122 {
123 unsigned sym0 = s2[0].Symbol; 123 const unsigned sym0 = s2[0].Symbol;
124 unsigned sym1 = s2[1].Symbol; 124 const unsigned sym1 = s2[1].Symbol;
125 s2 += 2; 125 s2 += 2;
126 MASK(sym0) = 0; 126 MASK(sym0) = 0;
127 MASK(sym1) = 0; 127 MASK(sym1) = 0;
@@ -209,17 +209,17 @@ int Ppmd7a_DecodeSymbol(CPpmd7 *p)
209 unsigned num2 = num / 2; 209 unsigned num2 = num / 2;
210 210
211 num &= 1; 211 num &= 1;
212 hiCnt = (s->Freq & (unsigned)(MASK(s->Symbol))) & (0 - (UInt32)num); 212 hiCnt = (s->Freq & (UInt32)(MASK(s->Symbol))) & (0 - (UInt32)num);
213 s += num; 213 s += num;
214 p->MinContext = mc; 214 p->MinContext = mc;
215 215
216 do 216 do
217 { 217 {
218 unsigned sym0 = s[0].Symbol; 218 const unsigned sym0 = s[0].Symbol;
219 unsigned sym1 = s[1].Symbol; 219 const unsigned sym1 = s[1].Symbol;
220 s += 2; 220 s += 2;
221 hiCnt += (s[-2].Freq & (unsigned)(MASK(sym0))); 221 hiCnt += (s[-2].Freq & (UInt32)(MASK(sym0)));
222 hiCnt += (s[-1].Freq & (unsigned)(MASK(sym1))); 222 hiCnt += (s[-1].Freq & (UInt32)(MASK(sym1)));
223 } 223 }
224 while (--num2); 224 while (--num2);
225 } 225 }
@@ -238,13 +238,13 @@ int Ppmd7a_DecodeSymbol(CPpmd7 *p)
238 238
239 s = Ppmd7_GetStats(p, p->MinContext); 239 s = Ppmd7_GetStats(p, p->MinContext);
240 hiCnt = count; 240 hiCnt = count;
241 // count -= s->Freq & (unsigned)(MASK(s->Symbol)); 241 // count -= s->Freq & (UInt32)(MASK(s->Symbol));
242 // if ((Int32)count >= 0) 242 // if ((Int32)count >= 0)
243 { 243 {
244 for (;;) 244 for (;;)
245 { 245 {
246 count -= s->Freq & (unsigned)(MASK((s)->Symbol)); s++; if ((Int32)count < 0) break; 246 count -= s->Freq & (UInt32)(MASK((s)->Symbol)); s++; if ((Int32)count < 0) break;
247 // count -= s->Freq & (unsigned)(MASK((s)->Symbol)); s++; if ((Int32)count < 0) break; 247 // count -= s->Freq & (UInt32)(MASK((s)->Symbol)); s++; if ((Int32)count < 0) break;
248 } 248 }
249 } 249 }
250 s--; 250 s--;