亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? paq8o8.cpp

?? 匯編語言寫的壓縮算法
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
    assert(B>=2 && i>0 && (i&(i-1))==0); // size a power of 2?
  }
  U8* operator[](U32 i);
};

template <int B>
inline  U8* BH<B>::operator[](U32 i) {
  int chk=(i>>16^i)&0xffff;
  i=i*M&n;
  U8 *p;
  U16 *cp;
  int j;
  for (j=0; j<M; ++j) {
    p=&t[(i+j)*B];
    cp=(U16*)p;
    if (p[2]==0) {*cp=chk;break;}
    if (*cp==chk) break;  // found
  }
  if (j==0) return p+1;  // front
  static U8 tmp[B];  // element to move to front
  if (j==M) {
    --j;
    memset(tmp, 0, B);
    *(U16*)tmp=chk;
    if (M>2 && t[(i+j)*B+2]>t[(i+j-1)*B+2]) --j;
  }
  else memcpy(tmp, cp, B);
  memmove(&t[(i+1)*B], &t[i*B], j*B);
  memcpy(&t[i*B], tmp, B);
  return &t[i*B+1];
}

/////////////////////////// ContextMap /////////////////////////
//
// A ContextMap maps contexts to a bit histories and makes predictions
// to a Mixer.  Methods common to all classes:
//
// ContextMap cm(M, C); creates using about M bytes of memory (a power
//   of 2) for C contexts.
// cm.set(cx);  sets the next context to cx, called up to C times
//   cx is an arbitrary 32 bit value that identifies the context.
//   It should be called before predicting the first bit of each byte.
// cm.mix(m) updates Mixer m with the next prediction.  Returns 1
//   if context cx is found, else 0.  Then it extends all the contexts with
//   global bit y.  It should be called for every bit:
//
//     if (bpos==0) 
//       for (int i=0; i<C; ++i) cm.set(cxt[i]);
//     cm.mix(m);
//
// The different types are as follows:
//
// - RunContextMap.  The bit history is a count of 0-255 consecutive
//     zeros or ones.  Uses 4 bytes per whole byte context.  C=1.
//     The context should be a hash.
// - SmallStationaryContextMap.  0 <= cx < M/512.
//     The state is a 16-bit probability that is adjusted after each
//     prediction.  C=1.
// - ContextMap.  For large contexts, C >= 1.  Context need not be hashed.

// Predict to mixer m from bit history state s, using sm to map s to
// a probability.
inline int mix2(Mixer& m, int s, StateMap& sm) {
  int p1=sm.p(s);
  int n0=-!nex(s,2);
  int n1=-!nex(s,3);
  int st=stretch(p1)>>2;
  m.add(st);
  p1>>=4;
  int p0=255-p1;
  m.add(p1-p0);
  m.add(st*(n1-n0));
  m.add((p1&n0)-(p0&n1));
  m.add((p1&n1)-(p0&n0));
  return s>0;
}

// A RunContextMap maps a context into the next byte and a repeat
// count up to M.  Size should be a power of 2.  Memory usage is 3M/4.
class RunContextMap {
  BH<4> t;
  U8* cp;
public:
  RunContextMap(int m): t(m/4) {cp=t[0]+1;}
  void set(U32 cx) {  // update count
    if (cp[0]==0 || cp[1]!=buf(1)) cp[0]=1, cp[1]=buf(1);
    else if (cp[0]<255) ++cp[0];
    cp=t[cx]+1;
  }
  int p() {  // predict next bit
    if (cp[1]+256>>8-bpos==c0)
      return ((cp[1]>>7-bpos&1)*2-1)*ilog(cp[0]+1)*8;
    else
      return 0;
  }
  int mix(Mixer& m) {  // return run length
    m.add(p());
    return cp[0]!=0;
  }
};

// Context is looked up directly.  m=size is power of 2 in bytes.
// Context should be < m/512.  High bits are discarded.
class SmallStationaryContextMap {
  Array<U16> t;
  int cxt;
  U16 *cp;
public:
  SmallStationaryContextMap(int m): t(m/2), cxt(0) {
    assert((m/2&m/2-1)==0); // power of 2?
    for (int i=0; i<t.size(); ++i)
      t[i]=32768;
    cp=&t[0];
  }
  void set(U32 cx) {
    cxt=cx*256&t.size()-256;
  }
  void mix(Mixer& m, int rate=7) {
    *cp += (y<<16)-*cp+(1<<rate-1) >> rate;
    cp=&t[cxt+c0];
    m.add(stretch(*cp>>4));
  }
};

// Context map for large contexts.  Most modeling uses this type of context
// map.  It includes a built in RunContextMap to predict the last byte seen
// in the same context, and also bit-level contexts that map to a bit
// history state.
//
// Bit histories are stored in a hash table.  The table is organized into
// 64-byte buckets alinged on cache page boundaries.  Each bucket contains
// a hash chain of 7 elements, plus a 2 element queue (packed into 1 byte) 
// of the last 2 elements accessed for LRU replacement.  Each element has
// a 2 byte checksum for detecting collisions, and an array of 7 bit history
// states indexed by the last 0 to 2 bits of context.  The buckets are indexed
// by a context ending after 0, 2, or 5 bits of the current byte.  Thus, each
// byte modeled results in 3 main memory accesses per context, with all other
// accesses to cache.
//
// On bits 0, 2 and 5, the context is updated and a new bucket is selected.
// The most recently accessed element is tried first, by comparing the
// 16 bit checksum, then the 7 elements are searched linearly.  If no match
// is found, then the element with the lowest priority among the 5 elements 
// not in the LRU queue is replaced.  After a replacement, the queue is
// emptied (so that consecutive misses favor a LFU replacement policy).
// In all cases, the found/replaced element is put in the front of the queue.
//
// The priority is the state number of the first element (the one with 0
// additional bits of context).  The states are sorted by increasing n0+n1
// (number of bits seen), implementing a LFU replacement policy.
//
// When the context ends on a byte boundary (bit 0), only 3 of the 7 bit
// history states are used.  The remaining 4 bytes implement a run model
// as follows: <count:7,d:1> <b1> <unused> <unused> where <b1> is the last byte
// seen, possibly repeated.  <count:7,d:1> is a 7 bit count and a 1 bit
// flag (represented by count * 2 + d).  If d=0 then <count> = 1..127 is the 
// number of repeats of <b1> and no other bytes have been seen.  If d is 1 then 
// other byte values have been seen in this context prior to the last <count> 
// copies of <b1>.
//
// As an optimization, the last two hash elements of each byte (representing
// contexts with 2-7 bits) are not updated until a context is seen for
// a second time.  This is indicated by <count,d> = <1,0> (2).  After update,
// <count,d> is updated to <2,0> or <1,1> (4 or 3).

class ContextMap {
  const int C;  // max number of contexts
  class E {  // hash element, 64 bytes
    U16 chk[7];  // byte context checksums
    U8 last;     // last 2 accesses (0-6) in low, high nibble
  public:
    U8 bh[7][7]; // byte context, 3-bit context -> bit history state
      // bh[][0] = 1st bit, bh[][1,2] = 2nd bit, bh[][3..6] = 3rd bit
      // bh[][0] is also a replacement priority, 0 = empty
    U8* get(U16 chk);  // Find element (0-6) matching checksum.
      // If not found, insert or replace lowest priority (not last).
  };
  Array<E, 64> t;  // bit histories for bits 0-1, 2-4, 5-7
    // For 0-1, also contains a run count in bh[][4] and value in bh[][5]
    // and pending update count in bh[7]
  Array<U8*> cp;   // C pointers to current bit history
  Array<U8*> cp0;  // First element of 7 element array containing cp[i]
  Array<U32> cxt;  // C whole byte contexts (hashes)
  Array<U8*> runp; // C [0..3] = count, value, unused, unused
  StateMap *sm;    // C maps of state -> p
  int cn;          // Next context to set by set()
  void update(U32 cx, int c);  // train model that context cx predicts c
  int mix1(Mixer& m, int cc, int bp, int c1, int y1);
    // mix() with global context passed as arguments to improve speed.
public:
  ContextMap(int m, int c=1);  // m = memory in bytes, a power of 2, C = c
  ~ContextMap();
  void set(U32 cx, int next=-1);   // set next whole byte context to cx
    // if next is 0 then set order does not matter
  int mix(Mixer& m) {return mix1(m, c0, bpos, buf(1), y);}
};

// Find or create hash element matching checksum ch
inline U8* ContextMap::E::get(U16 ch) {
  if (chk[last&15]==ch) return &bh[last&15][0];
  int b=0xffff, bi=0;
  for (int i=0; i<7; ++i) {
    if (chk[i]==ch) return last=last<<4|i, (U8*)&bh[i][0];
    int pri=bh[i][0];
    if (pri<b && (last&15)!=i && last>>4!=i) b=pri, bi=i;
  }
  return last=0xf0|bi, chk[bi]=ch, (U8*)memset(&bh[bi][0], 0, 7);
}

// Construct using m bytes of memory for c contexts
ContextMap::ContextMap(int m, int c): C(c), t(m>>6), cp(c), cp0(c),
    cxt(c), runp(c), cn(0) {
  assert(m>=64 && (m&m-1)==0);  // power of 2?
  assert(sizeof(E)==64);
  sm=new StateMap[C];
  for (int i=0; i<C; ++i) {
    cp0[i]=cp[i]=&t[0].bh[0][0];
    runp[i]=cp[i]+3;
  }
}

ContextMap::~ContextMap() {
  delete[] sm;
}

// Set the i'th context to cx
inline void ContextMap::set(U32 cx, int next) {
  int i=cn++;
  i&=next;
  assert(i>=0 && i<C);
  cx=cx*987654323+i;  // permute (don't hash) cx to spread the distribution
  cx=cx<<16|cx>>16;
  cxt[i]=cx*123456791+i;
}

// Update the model with bit y1, and predict next bit to mixer m.
// Context: cc=c0, bp=bpos, c1=buf(1), y1=y.
int ContextMap::mix1(Mixer& m, int cc, int bp, int c1, int y1) {

  // Update model with y
  int result=0;
  for (int i=0; i<cn; ++i) {
    if (cp[i]) {
      assert(cp[i]>=&t[0].bh[0][0] && cp[i]<=&t[t.size()-1].bh[6][6]);
      assert((long(cp[i])&63)>=15);
      int ns=nex(*cp[i], y1);
      if (ns>=204 && rnd() << (452-ns>>3)) ns-=4;  // probabilistic increment
      *cp[i]=ns;
    }

    // Update context pointers
    if (bpos>1 && runp[i][0]==0)
    {
     cp[i]=0;
    }
    else
    {
     switch(bpos)
     {
      case 1: case 3: case 6: cp[i]=cp0[i]+1+(cc&1); break;
      case 4: case 7: cp[i]=cp0[i]+3+(cc&3); break;
      case 2: case 5: cp0[i]=cp[i]=t[cxt[i]+cc&t.size()-1].get(cxt[i]>>16); break;
      default:
      {
       cp0[i]=cp[i]=t[cxt[i]+cc&t.size()-1].get(cxt[i]>>16);
       // Update pending bit histories for bits 2-7
       if (cp0[i][3]==2) {
         const int c=cp0[i][4]+256;
         U8 *p=t[cxt[i]+(c>>6)&t.size()-1].get(cxt[i]>>16);
         p[0]=1+((c>>5)&1);
         p[1+((c>>5)&1)]=1+((c>>4)&1);
         p[3+((c>>4)&3)]=1+((c>>3)&1);
         p=t[cxt[i]+(c>>3)&t.size()-1].get(cxt[i]>>16);
         p[0]=1+((c>>2)&1);
         p[1+((c>>2)&1)]=1+((c>>1)&1);
         p[3+((c>>1)&3)]=1+(c&1);
         cp0[i][6]=0;
       }
       // Update run count of previous context
       if (runp[i][0]==0)  // new context
         runp[i][0]=2, runp[i][1]=c1;
       else if (runp[i][1]!=c1)  // different byte in context
         runp[i][0]=1, runp[i][1]=c1;
       else if (runp[i][0]<254)  // same byte in context
         runp[i][0]+=2;
       else if (runp[i][0]==255)
         runp[i][0]=128;
       runp[i]=cp0[i]+3;
      } break;
     }
    }

    // predict from last byte in context
    if (runp[i][1]+256>>8-bp==cc) {
      int rc=runp[i][0];  // count*2, +1 if 2 different bytes seen
      int b=(runp[i][1]>>7-bp&1)*2-1;  // predicted bit + for 1, - for 0
      int c=ilog(rc+1)<<2+(~rc&1);
      m.add(b*c);
    }
    else
      m.add(0);

    // predict from bit context
   if(cp[i])
   {
    result+=mix2(m, *cp[i], sm[i]);
   }
   else
   {
    mix2(m, 0, sm[i]);
   }


  }
  if (bp==7) cn=0;
  return result;
}

//////////////////////////// Models //////////////////////////////

// All of the models below take a Mixer as a parameter and write
// predictions to it.

//////////////////////////// matchModel ///////////////////////////

// matchModel() finds the longest matching context and returns its length

int matchModel(Mixer& m) {
  const int MAXLEN=65534;  // longest allowed match + 1
  static Array<int> t(MEM);  // hash table of pointers to contexts
  static int h=0;  // hash of last 7 bytes
  static int ptr=0;  // points to next byte of match if any
  static int len=0;  // length of match, or 0 if no match
  static int result=0;
  
  static SmallStationaryContextMap scm1(0x20000);

  if (!bpos) {
    h=h*997*8+buf(1)+1&t.size()-1;  // update context hash
    if (len) ++len, ++ptr;
    else {  // find match
      ptr=t[h];
      if (ptr && pos-ptr<buf.size())
        while (buf(len+1)==buf[ptr-len-1] && len<MAXLEN) ++len;
    }
    t[h]=pos;  // update hash table
    result=len;
//    if (result>0 && !(result&0xfff)) printf("pos=%d len=%d ptr=%d\n", pos, len, ptr);
    scm1.set(pos);
  }

  // predict
  if (len)
  {
   if (buf(1)==buf[ptr-1] && c0==buf[

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久久久影院老司| 国产精品一区专区| 一区二区三区免费| 亚洲人午夜精品天堂一二香蕉| 国产亚洲精久久久久久| 国产亚洲精品资源在线26u| 精品久久久久一区二区国产| 日韩一区二区三区av| 91精品国产综合久久久蜜臀粉嫩| 欧美午夜精品理论片a级按摩| 色老综合老女人久久久| 日本精品裸体写真集在线观看| 99精品久久久久久| 91久久香蕉国产日韩欧美9色| 99久久综合99久久综合网站| 色综合久久综合网欧美综合网| 色噜噜久久综合| 色94色欧美sute亚洲线路一ni| 91久久精品一区二区| 欧美日韩国产一区| 日韩视频一区二区三区| 久久精品水蜜桃av综合天堂| 国产午夜亚洲精品不卡| 亚洲人成人一区二区在线观看 | 国产日韩三级在线| 国产精品久久久久影院亚瑟 | 亚洲欧美日韩在线| 亚洲欧美日韩一区二区三区在线观看| 亚洲视频免费在线| 日韩高清一区二区| 国产美女av一区二区三区| 成人动漫精品一区二区| 一本大道久久精品懂色aⅴ| 欧美视频日韩视频| 久久中文娱乐网| 国产精品嫩草影院com| 亚洲免费av高清| 三级久久三级久久久| 韩国成人在线视频| 99亚偷拍自图区亚洲| 欧美精三区欧美精三区| 亚洲精品在线三区| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 亚洲一区视频在线| 国精产品一区一区三区mba桃花| 成人av在线电影| 欧美精品乱人伦久久久久久| 国产性色一区二区| 午夜视频一区在线观看| 国产成人精品亚洲午夜麻豆| 欧美伊人久久久久久久久影院| 亚洲精品一区二区三区四区高清| 亚洲视频每日更新| 老司机午夜精品99久久| 99久久综合99久久综合网站| 91精品国产综合久久久久久| 中文字幕亚洲在| 日本网站在线观看一区二区三区 | 国产a级毛片一区| 欧美日韩大陆在线| 国产精品毛片久久久久久| 亚洲国产综合色| 韩国女主播一区| 欧洲亚洲精品在线| 国产精品久久毛片a| 久久精品国产99久久6| 91福利国产成人精品照片| 国产亚洲精品久| 日本美女一区二区三区| 一本大道久久a久久精二百| 久久久久国产免费免费| 天堂影院一区二区| 色猫猫国产区一区二在线视频| 国产亚洲欧美日韩在线一区| 日本欧美韩国一区三区| 色综合久久九月婷婷色综合| 中文字幕乱码亚洲精品一区| 午夜电影一区二区三区| 色哟哟国产精品| 国产精品色哟哟| 国产一级精品在线| 日韩欧美一区二区不卡| 亚洲电影视频在线| 色哟哟日韩精品| 成人欧美一区二区三区黑人麻豆| 精品一二三四区| 8v天堂国产在线一区二区| 亚洲一区二区在线免费观看视频| www.激情成人| 国产精品国产三级国产专播品爱网| 国产中文字幕精品| 精品久久国产字幕高潮| 欧美a一区二区| 欧美一区在线视频| 日韩高清在线不卡| 在线播放日韩导航| 亚洲成人中文在线| 欧美日韩国产中文| 午夜欧美在线一二页| 日本乱码高清不卡字幕| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 亚洲综合一区二区| 色婷婷精品久久二区二区蜜臂av| 中文字幕一区二区不卡| 成人黄色软件下载| 国产精品国产三级国产三级人妇| 成人免费毛片嘿嘿连载视频| 日本一区二区综合亚洲| 国产69精品一区二区亚洲孕妇| 久久你懂得1024| 国产成人福利片| 中文字幕乱码久久午夜不卡| zzijzzij亚洲日本少妇熟睡| 中文字幕在线观看一区二区| av在线综合网| 一区二区三区影院| 欧美丝袜丝交足nylons| 日韩av中文字幕一区二区三区| 67194成人在线观看| 日本免费新一区视频| 精品成a人在线观看| 懂色av噜噜一区二区三区av| 亚洲欧美色综合| 欧美日本一道本| 美女看a上一区| 国产女人aaa级久久久级| 91在线码无精品| 亚洲一区二区三区四区五区中文 | 日韩理论片在线| 在线欧美日韩精品| 天堂久久久久va久久久久| 精品国产91乱码一区二区三区| 国产不卡一区视频| 一区二区三区四区激情 | 一区二区三区久久| 欧美精品视频www在线观看| 久久91精品久久久久久秒播| 中文字幕av一区 二区| 91福利在线观看| 精品在线一区二区三区| 久久久国产精华| 色综合久久中文综合久久97| 日本亚洲免费观看| 欧美国产日韩在线观看| 精品视频1区2区| 韩国av一区二区| 一区二区高清在线| 日韩欧美国产午夜精品| 成人av在线一区二区三区| 婷婷开心久久网| 国产三级三级三级精品8ⅰ区| 91麻豆视频网站| 蜜桃传媒麻豆第一区在线观看| 亚洲国产成人一区二区三区| 欧美在线免费观看亚洲| 激情六月婷婷综合| 亚洲成在人线免费| 国产三级欧美三级| 欧美一区二区视频在线观看2020| 粉嫩蜜臀av国产精品网站| 五月婷婷久久丁香| 国产精品剧情在线亚洲| 日韩欧美专区在线| 色吧成人激情小说| 国产精品系列在线观看| 午夜精品久久一牛影视| 国产精品嫩草久久久久| 日韩欧美第一区| 欧美视频在线播放| 成人av在线网| 国产在线不卡一区| 日韩有码一区二区三区| 中文字幕亚洲视频| 久久久99精品免费观看| 777亚洲妇女| 色噜噜久久综合| 粉嫩欧美一区二区三区高清影视 | 欧美一三区三区四区免费在线看| 99视频精品全部免费在线| 韩国精品主播一区二区在线观看 | 久久成人免费日本黄色| 亚洲一区二区视频| 国产精品乱人伦| 久久久亚洲国产美女国产盗摄| 欧美日韩不卡视频| 91色porny在线视频| 国产精品一区免费在线观看| 视频一区免费在线观看| 亚洲一区二区视频在线观看| 亚洲天堂精品视频| 欧美国产一区在线| 久久综合国产精品| 精品美女一区二区| 日韩欧美一区二区久久婷婷| 91精品国产91热久久久做人人 | 精品久久久久久久久久久久包黑料| 欧美日韩一级黄| 欧美剧在线免费观看网站| 欧美综合一区二区三区| 97精品久久久久中文字幕|