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

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

?? cm.cpp

?? cm 壓縮算法的源代碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
#if 0

    CM is the static context modeling archiver.
    (C) Bulat Ziganshin 1993, 97, 98
    My email addresses:
        FIDO 2:5049/36.26
        bulatz@fort.tatarstan.ru

    The algorithm:
    1. A context tree of the depth set by the -o option is built, and
       the frequency of each character in each context is noted.
    2. All the context-character pairs with the frequency that is less than
       the one given by the -n option are removed from the tree. The frequencies
       of such pairs are given to the ESCAPE-code of their respective contexts
       and to the combination "parent context-character".
    3. The remaining tree is coded and written to the output file.
    4. The source is coded using the tree.

    Deficiencies:
    1. All the memory - for the text and for the tree is allocated once at the
       start of the program (its amount is confugurable by the -t and -m options).
       A more flexible memory allocation strategy is needed.
    2. The command-line interface is dumb.

    Future directions:
    1. The tree depth to be made adjustable depending on the actual frequencies
       of particular contexts.
    2. The deletion of an element from the tree to be done if and only if
       the element is not beneficial (number of bits saved in coding text is
       greater than number of bits used in coding the tree).
    3. Tree coding to be made smarter.

    When compiled with Visual C++ 5.0 the program works faster than HAP 4;
    compression ratio is approximately the same.

    The first group of #define's (in the source code) denotes compilation
    modes. To switch modes, add or remove the letter N, e.g. ARITH <-> NARITH.

#endif

#define DEBUG
#define TEST_TREE
#define NPRINT_TREE_STATS
#define PRINT_STATS
#define ARITH
#define NARITH_PRINT
#define NPRINT_TREE
#define NPRINT_TEXT

#define STATIC static
#define INLINE /*inline*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>
#include <fcntl.h>
#include <ctype.h>
#include <limits.h>
#include <assert.h>
#include <sys\stat.h>

#define MAXIMAL_MAXORDER  256
#define MAX_SUM (1<<14)
#define max(a,b) ((a)>(b)?(a):(b))
#define endof(array) (array+sizeof(array)/sizeof(*array))
#define set0(array)  memset( array, 0, sizeof(array) )
typedef unsigned int uint;
typedef unsigned char uchar;

#define SWITCH_CHARS "-/"
#define command_set "ax"
#define command_a   uint('a')
#define command_x   uint('x')
#define no_command  0
#define test_command(if_a,if_x)   ( command==command_a? (if_a):(if_x) )
#define mincount_for(n)  mincount
#define mincount_for0    (2*mincount)

static char M_ARGUMENT[] = "Superfluous argument";
static char M_BADNUM[]   = "Bad numeric argument";
static char M_COMMAND[]  = "Bad command";
static char M_FILES[]    = "Can't open files.";
static char M_NOMEMORY[] = "No memory";
static char M_NOTEXT[]   = "No memory for text buffer";
static char M_NOTREE[]   = "No memory for context tree";
static char M_OPTION[]   = "Bad flag";
static char M_READ[]     = "Can't read file.";
static char M_WRITE[]    = "Can't write file. Disk full?";

#if 1 || __I86__ >= 3
#define FILEBUFFER_SIZE        32768
#define DEFAULT_FREEMEMSIZE    (5<<20)
#define DEFAULT_MAXSIZE        (1<<20)
#elif defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
#define FILEBUFFER_SIZE        2048
#define DEFAULT_FREEMEMSIZE    30720
#define DEFAULT_MAXSIZE        4096
#elif defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
#define FILEBUFFER_SIZE        32768
#define DEFAULT_FREEMEMSIZE    65000
#define DEFAULT_MAXSIZE        57344
#else
#error What's your memory model???
#endif

#define DEFAULT_MAXORDER       3
#define DEFAULT_MINCOUNT       10
#define DEFAULT_CHAR           ' '

uchar *text;
char  *arcname, *textname;
uint  command, size, maxsize, maxorder, &maxlevel=maxorder, mincount;
uchar contextstr[MAXIMAL_MAXORDER];
struct  {
    uint n;    // No EncodeTreeChar
} flags[1];

STATIC INLINE void error(char *message) {
    printf( "\n" );
    printf( message );
    exit(1);
}

#ifndef NDEBUG
#define do_assert(cmd) cmd
#define debug_printf(args)   printf args
#else
#define do_assert(cmd)
#define debug_printf(args)
#endif

#ifdef PRINT_STATS
#define printf_stats(args)   printf args
#define do_stats(expr)       expr
#else
#define printf_stats(args)
#define do_stats(expr)
#endif

#ifdef PRINT_TREE
#define printf_tree(args) printf args
#else
#define printf_tree(args)
#endif

#ifdef PRINT_TEXT
#define printf_text(args) printf args
#else
#define printf_text(args)
#endif


// Buffered I/O section ****************************************************

struct TFile {
    static uchar buffer[FILEBUFFER_SIZE], *pbf;
    int  handle;
    uint ModeW, ModeB;  // Flags for write-mode & buffering

    void  init(char *name,uint writing,uint buffering);
    void  done();
    uint  read(uchar *buf, uint bytes);
    void  write(uchar *buf, uint bytes);

    void  InitReadBuffer()      { assert(ModeB); pbf = endof(buffer); }
    void  InitWriteBuffer()     { assert(ModeB); pbf = buffer; }
    void  ReadBuffer()          { assert(ModeB); read(pbf=buffer,FILEBUFFER_SIZE); }
    void  WriteBuffer()         { assert(ModeB); write(pbf=buffer,FILEBUFFER_SIZE); }
    void  CheckReadBuffer()     { if(pbf==endof(buffer)) ReadBuffer(); }
    void  CheckWriteBuffer()    { if(pbf==endof(buffer)) WriteBuffer(); }
    uchar ReadByte()            { CheckReadBuffer(); assert(ModeB && pbf>=buffer && pbf<endof(buffer)); return *pbf++; }
    void  WriteByte(uchar c)    { CheckWriteBuffer(); assert(ModeB && pbf>=buffer && pbf<endof(buffer)); *pbf++=c; }
    void  WriteInt(uint n);
    uint  ReadInt();
    void  DoneReadBuffer()      { }
    void  DoneWriteBuffer()     { assert(ModeB); write(buffer,pbf-buffer); }
};
uchar TFile::buffer[]="", *TFile::pbf=0;

void TFile::init( char *name, uint writing, uint buffering ) {
    if( writing ) {
        handle = open( name, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IWRITE );
    } else {
        handle = open( name, O_RDONLY|O_BINARY );
    }
    if( handle < 0 ) {
        error( M_FILES );
    }
    ModeW = writing;
    ModeB = buffering;
    if( buffering ) {
        if( writing ) {
            InitWriteBuffer();
        } else {
            InitReadBuffer();
        }
    }
}

void TFile::done() {
    if( ModeB ) {
        if( ModeW ) {
            DoneWriteBuffer();
        } else {
            DoneReadBuffer();
        }
    }
    close(handle);
}

uint TFile::read(uchar *buf, uint bytes) {
    assert(!ModeW);
    int n=::read(handle,buf,bytes);
    if( n<0 ) {
        error( M_READ );
    }
    return (uint)n;
}

void TFile::write(uchar *buf, uint bytes) {
    assert(ModeW);
    if( ::write(handle,buf,bytes) != bytes ) {
        error( M_WRITE );
    }
}

INLINE void TFile::WriteInt( uint n ) {
    if( n<254 ) {
        WriteByte(n);
    } else if( n<=65535u ) {
        WriteByte(254);
        WriteByte(n&255);
        WriteByte(n>>8);
    } else {
        uchar *p=(uchar*)&n;
        uint  i=sizeof(n);

        WriteByte(255);
        do {
            WriteByte(*p++);
        } while( --i );
    }
}

INLINE uint TFile::ReadInt() {
    uint n;

    n = ReadByte();
    if( n==254 ) {
        n = ReadByte();
        n += ReadByte()<<8;
    } else if( n==255 ) {
        uchar *p=(uchar*)&n;
        uint  i=sizeof(n);

        do {
            *p++ = ReadByte();
        } while( --i );
    }
    return n;
}

TFile infile, outfile;

//ZBR
//STATIC INLINE uint eof_infile() {
//    return tell(infile) == filelength(infile);
//    return 0;
//}


// Actual arithmetic compression section ***********************************

uint CodedBytes;
#define MIN_RANGE 0x4001
#define MAX_RANGE 0xFFFF

#ifdef ARITH

#define WriteOutputFile(code_value)  (CodedBytes++, outfile.WriteByte(code_value))
#define ReadInputFile()              (CodedBytes++, infile.ReadByte())

#if 0
  arith.c      a byte oriented arithmetic coding

  Michael Schindler
  Feb. 1997
  http://eiunix.tuwien.ac.at/~michael

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

  arithmetic coder without bit-stuff (FAST!)
  For a general idea on arithmetic coders check
  A. Moffats paper at the DCC95.

  Define NOWARN to suppress warnings about bytes_to_follow overflows.
  It is faster; the compressed file must be >1GB that this can happen,
  the probability for this to happen is about 256**-(2**31), so I do
  not expect it to happen within this universe.
  If this is still too likely increase the size of bytes_to_follow.

  If tot_f is a power of two consider replacing the division by a shift
  and doing an CACAM style rescaling (2 divisions) to save the if-statement.
#endif

#define NOWARN

/*  PROTOTYPES  ***************************************************/

/* Start encoding */
void start_encoding( char c );

/* Encode a symbol */
inline void encode_freq(
    unsigned int sy_f,    /* frequency of symbol */
    unsigned int lt_f,    /* frequency of symbols < the decoded symbol */
    unsigned int tot_f);  /* frequency of all symbols */

/* Finish encoding */
void done_encoding( void );

/* Start decoding */
int start_decoding( void );

/* Calculate culmulative frequency for next symbol. Does NO update!        */
inline unsigned int decode_culfreq( unsigned int tot_f );

/* Update decoding variables */
inline void decode_update(
    unsigned int sy_f,    /* frequency of symbol */
    unsigned int lt_f,    /* frequency of symbols < the decoded symbol */
    unsigned int tot_f);  /* frequency of all symbols */

/* Finish decoding */
void done_decoding( void );

/*  PROTOTYPES: END ***********************************************/


/* SIZE OF ARITHMETIC CODE VALUES. */

#define CODE_BITS 31                   /* Number of bits in a code value   */

/* Type of an arithmetic code value must accomodate CODE_BITS+1 bits */
#if MAXINT > 1L<<16
  typedef unsigned int code_value;
#else
  typedef unsigned long code_value;
#endif

/* it is highly recommended that the total frequency count is less than    */
/* 1 << (CODE_BITS-13) to minimize the error introduced by approximation.  */
/* for a discussion see "Arithmetic coding revisited" by A. Moffat.        */

#define SHIFT_BITS (CODE_BITS - 8)
#define EXTRA_BITS ((CODE_BITS-1) % 8 + 1)
#define Top_value ((code_value)1 << CODE_BITS)
#define Bottom_value (Top_value >> 8)

static char copyright[]="arith.c 1.0 (c) 1997 michael@eiunix.tuwien.ac.at";

static unsigned char enbuffer, debuffer;  /* char buffer                   */
static code_value enlow, enrange;         /* Encoder state                 */
static unsigned int bytes_to_follow;      /* number of bytes to follow     */
static code_value deoffs, der, derange;   /* Decoder state                 */


static inline void outbyte()

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲午夜羞羞片| 日本高清无吗v一区| 色系网站成人免费| 日韩视频中午一区| 亚洲精品国产无天堂网2021| 加勒比av一区二区| 91精品国产综合久久久久久漫画 | 成人精品亚洲人成在线| 欧美性欧美巨大黑白大战| 欧美国产精品专区| 久久99久久精品| 欧美一卡二卡三卡| 午夜精品福利在线| 在线免费一区三区| 亚洲情趣在线观看| 92国产精品观看| 欧美激情一区二区三区| 国产乱子轮精品视频| 欧美一区二区日韩一区二区| 亚洲gay无套男同| 欧美日韩精品久久久| 亚洲午夜精品在线| 欧美日韩精品一区视频| 亚洲国产一区二区a毛片| 色乱码一区二区三区88| 亚洲欧美日韩综合aⅴ视频| 成人激情小说网站| 亚洲欧洲av在线| 99视频精品在线| 亚洲毛片av在线| 在线亚洲免费视频| 亚洲国产你懂的| 欧美久久一区二区| 毛片一区二区三区| 2024国产精品| 高清免费成人av| 最近中文字幕一区二区三区| 色噜噜久久综合| 日韩中文字幕亚洲一区二区va在线| 717成人午夜免费福利电影| 日本在线观看不卡视频| 欧美mv日韩mv| 成人avav影音| 亚洲va天堂va国产va久| 3d动漫精品啪啪| 国产剧情一区二区| **性色生活片久久毛片| 欧美日韩一区三区四区| 蜜臀99久久精品久久久久久软件| 久久美女艺术照精彩视频福利播放| 国产不卡高清在线观看视频| 一区二区三区欧美激情| 日韩欧美综合在线| 成人激情免费电影网址| 亚洲一卡二卡三卡四卡无卡久久| 91麻豆精品国产91| 国产v日产∨综合v精品视频| 亚洲精品中文在线观看| 日韩视频国产视频| caoporm超碰国产精品| 午夜精品成人在线视频| 中文字幕高清一区| 欧美精品日韩一本| 不卡av在线免费观看| 日韩精品乱码免费| 亚洲天堂网中文字| 日韩欧美视频一区| 91免费视频大全| 国内外成人在线| 亚洲成人黄色小说| 国产日产欧美一区二区视频| 欧美网站一区二区| 成人一区二区视频| 蜜臀av一区二区| 亚洲精品ww久久久久久p站| 久久日韩精品一区二区五区| 欧美在线综合视频| 成人免费福利片| 日韩成人精品在线观看| 一区二区在线观看不卡| 91精品国产入口| 色婷婷综合久色| 国产精品 日产精品 欧美精品| 亚洲福利一区二区三区| 最新欧美精品一区二区三区| 欧美tk—视频vk| 欧美精品v日韩精品v韩国精品v| 不卡欧美aaaaa| 国产乱码字幕精品高清av| 免费在线欧美视频| 亚洲欧美日韩系列| 中文字幕制服丝袜成人av| 日韩久久免费av| 欧美群妇大交群中文字幕| 日本韩国一区二区三区| eeuss鲁片一区二区三区| 国产成人免费视| 国内精品第一页| 美女国产一区二区三区| 日本va欧美va精品| 日韩高清在线观看| 手机精品视频在线观看| 亚洲成人一区在线| 亚洲国产va精品久久久不卡综合| 亚洲乱码国产乱码精品精的特点| 国产免费成人在线视频| 久久久久久久综合狠狠综合| 久久综合网色—综合色88| 亚洲精品一区在线观看| 久久午夜老司机| 91精品国产日韩91久久久久久| 欧美日本不卡视频| 欧美一区二区视频网站| 日韩一区二区精品葵司在线 | 欧美性做爰猛烈叫床潮| 色婷婷国产精品| 欧亚洲嫩模精品一区三区| 欧美日韩综合在线| 欧美久久久一区| 日韩欧美三级在线| 久久久国产午夜精品| 国产精品乱码一区二区三区软件| 国产精品久久久久久久岛一牛影视 | 亚洲免费观看视频| 亚洲永久精品大片| 免费人成网站在线观看欧美高清| 麻豆成人av在线| 成人综合激情网| 欧洲av一区二区嗯嗯嗯啊| 日韩一区二区在线免费观看| 26uuu久久天堂性欧美| 国产精品视频一二| 亚洲午夜av在线| 久久99精品一区二区三区三区| 国产精品18久久久久| 91在线云播放| 欧美精品日韩综合在线| 国产欧美一区二区精品久导航| 中文字幕一区二区三| 五月天一区二区三区| 国产福利一区在线观看| 91黄视频在线| 久久久青草青青国产亚洲免观| 亚洲欧洲精品天堂一级 | 亚洲国产精品欧美一二99| 蜜桃久久久久久| 91麻豆国产在线观看| 日韩三级在线免费观看| 亚洲日本丝袜连裤袜办公室| 免费欧美在线视频| 一本色道久久综合亚洲aⅴ蜜桃 | 蜜桃久久久久久久| jlzzjlzz亚洲女人18| 欧美精品1区2区3区| 中文字幕久久午夜不卡| 日本亚洲免费观看| 94色蜜桃网一区二区三区| 免费高清不卡av| 国产精品无遮挡| 午夜欧美电影在线观看| 国产一区999| 9191成人精品久久| 中国av一区二区三区| 日本美女一区二区三区| 91老师片黄在线观看| 久久久精品国产99久久精品芒果| 亚洲综合一区二区三区| 不卡高清视频专区| 久久综合色之久久综合| 丝瓜av网站精品一区二区| 日本道精品一区二区三区| 欧美激情一区二区三区| 美女视频免费一区| 91精品国产品国语在线不卡| 亚洲黄色片在线观看| 波多野结衣中文字幕一区二区三区| 日韩精品一区二区三区蜜臀| 日韩激情一区二区| 精品视频在线免费看| 亚洲欧美视频在线观看视频| 夫妻av一区二区| 中文字幕免费在线观看视频一区| 国内精品写真在线观看| 日韩视频免费观看高清完整版| 亚洲成av人片| 欧美日韩国产综合一区二区| 亚洲国产精品久久久男人的天堂| 91丨九色丨蝌蚪富婆spa| 亚洲欧洲精品天堂一级 | 中文字幕第一区| 国产裸体歌舞团一区二区| 精品国产乱码久久久久久蜜臀| 日本va欧美va欧美va精品| 欧美一级在线免费| 日韩成人伦理电影在线观看| 日韩视频一区在线观看| 国内一区二区视频| 国产香蕉久久精品综合网| 国产99精品在线观看| 中文字幕在线观看一区|