PAQ8/orig/paq8o10t.cpp
// Model a 1728 by 2376 2-color CCITT bitmap image, left to right scan,
// MSB first (216 bytes per row, 513216 bytes total).  Insert predictions
// into m.
Model a 1728 by 2376 2-color CCITT bitmap image, left to right scan,
MSB first (216 bytes per row, 513216 bytes total).  Insert predictions
into m.
Model a 1728 by 2376 2 - color CCITT bitmap image left to right scan MSB first ( 216 bytes per row 513216 bytes total ) . Insert predictions into m .
void picModel(Mixer& m) {
  static U32 r0, r1, r2, r3;  
  static Array<U8> t(0x10200);  
  const int N=3;  
  static int cxt[N];  
  static StateMap sm[N];
  int i;
  for ( i=0; i<N; ++i)
    t[cxt[i]]=nex(t[cxt[i]],y);
  r0+=r0+y;
  r1+=r1+((buf(215)>>(7-bpos))&1);
  r2+=r2+((buf(431)>>(7-bpos))&1);
  r3+=r3+((buf(647)>>(7-bpos))&1);
  cxt[0]=r0&0x7|r1>>4&0x38|r2>>3&0xc0;
  cxt[1]=0x100+(r0&1|r1>>4&0x3e|r2>>2&0x40|r3>>1&0x80);
  cxt[2]=0x200+(r0&0x3f^r1&0x3ffe^r2<<2&0x7f00^r3<<5&0xf800);
  for ( i=0; i<N; ++i)
    m.add(stretch(sm[i].p(t[cxt[i]])));
}
void picModel ( Mixer & m ) { static U32 r0 , r1 , r2 , r3 ; static Array < U8 > t ( 0x10200 ) ; const int N = 3 ; static int cxt [ N ] ; static StateMap sm [ N ] ; int i ; for ( i = 0 ; i < N ; ++ i ) t [ cxt [ i ] ] = nex ( t [ cxt [ i ] ] , y ) ; r0 += r0 + y ; r1 += r1 + ( ( buf ( 215 ) >> ( 7 - bpos ) ) & 1 ) ; r2 += r2 + ( ( buf ( 431 ) >> ( 7 - bpos ) ) & 1 ) ; r3 += r3 + ( ( buf ( 647 ) >> ( 7 - bpos ) ) & 1 ) ; cxt [ 0 ] = r0 & 0x7 | r1 >> 4 & 0x38 | r2 >> 3 & 0xc0 ; cxt [ 1 ] = 0x100 + ( r0 & 1 | r1 >> 4 & 0x3e | r2 >> 2 & 0x40 | r3 >> 1 & 0x80 ) ; cxt [ 2 ] = 0x200 + ( r0 & 0x3f ^ r1 & 0x3ffe ^ r2 << 2 & 0x7f00 ^ r3 << 5 & 0xf800 ) ; for ( i = 0 ; i < N ; ++ i ) m . add ( stretch ( sm [ i ] . p ( t [ cxt [ i ] ] ) ) ) ; }
Model a 1728 by 2376 2-color CCITT bitmap image, left to right scan,
MSB first (216 bytes per row, 513216 bytes total).
Model a 1728 by 2376 2 - color CCITT bitmap image left to right scan MSB first ( 216 bytes per row 513216 bytes total ) .
// last 4 rows, bit 8 is over current pixel // model: cxt -> state // number of contexts // contexts // update the model // update the contexts (pixels surrounding the predicted one) // predict