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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 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()

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91美女视频网站| 卡一卡二国产精品 | 亚洲一区免费观看| 色综合色综合色综合色综合色综合| 国产欧美日韩在线看| 国产成人av影院| 亚洲欧洲av在线| 色综合咪咪久久| 亚洲国产综合视频在线观看| 在线播放一区二区三区| 久久国产视频网| 中文字幕av一区 二区| 成人黄色电影在线| 亚洲女人的天堂| 欧美日韩三级一区| 另类的小说在线视频另类成人小视频在线| 日韩美女主播在线视频一区二区三区| 久久精品国产亚洲5555| 国产精品你懂的在线欣赏| 色综合久久中文综合久久牛| 天堂蜜桃一区二区三区| 久久久久青草大香线综合精品| 粉嫩aⅴ一区二区三区四区五区| 亚洲三级免费观看| 欧美一级夜夜爽| 大陆成人av片| 99久久777色| 夜夜嗨av一区二区三区四季av | 精品国产凹凸成av人导航| 免费人成精品欧美精品| 日韩精品成人一区二区在线| 欧美一区二区成人| 91视频免费看| 欧美a级一区二区| caoporn国产一区二区| 国内精品在线播放| 麻豆精品久久久| 国产一区二区三区国产| 一本久道久久综合中文字幕| 国产麻豆精品视频| 国产乱色国产精品免费视频| 久久精品国产一区二区三| 日本伊人精品一区二区三区观看方式| 亚洲人123区| 中国色在线观看另类| 国产欧美日韩综合| 精品精品国产高清一毛片一天堂| 欧美精品少妇一区二区三区 | 日本亚洲三级在线| 亚洲综合偷拍欧美一区色| 一区二区国产视频| 国产精品久久久久影院色老大| 国产精品久久久久精k8| 欧美激情中文字幕一区二区| 久久女同精品一区二区| 国产日韩欧美电影| 国产精品久久久久久妇女6080| 亚洲欧美激情在线| 亚洲高清免费一级二级三级| 日本在线不卡视频一二三区| 蜜桃久久久久久| 国产精品亚洲专一区二区三区| 成人一级视频在线观看| 97精品久久久久中文字幕| 99久久精品免费精品国产| 一本色道a无线码一区v| 欧美精品777| 久久久99久久精品欧美| 中文字幕一区二区三区精华液 | 亚洲综合精品自拍| 亚洲丝袜制服诱惑| 亚洲香蕉伊在人在线观| 日韩精品三区四区| 国产在线视视频有精品| 国产在线精品免费| 麻豆一区二区三区| 国产大陆a不卡| 欧美性感一类影片在线播放| 日韩一区二区电影网| 中文字幕国产一区| 亚洲午夜一区二区三区| 玖玖九九国产精品| av资源站一区| 在线播放一区二区三区| 精品国产电影一区二区| 中文字幕制服丝袜成人av| 亚洲天堂免费在线观看视频| 亚洲同性同志一二三专区| 亚洲精品免费电影| 亚洲第一精品在线| 91色婷婷久久久久合中文| 国产精品1区2区3区在线观看| 久久99国产精品免费| 国产乱一区二区| 不卡的看片网站| 色综合久久久久久久久久久| 欧美精品一级二级| 337p粉嫩大胆噜噜噜噜噜91av| 精品国一区二区三区| 国产婷婷精品av在线| 亚洲欧美日韩国产中文在线| 日韩主播视频在线| 成人av在线播放网站| 欧美理论在线播放| 亚洲欧洲精品成人久久奇米网| 日本视频中文字幕一区二区三区| 美女在线观看视频一区二区| 欧美精品一区二区三区高清aⅴ| 日韩伦理电影网| 国内偷窥港台综合视频在线播放| 91在线精品一区二区三区| 日韩免费电影一区| 亚洲美女屁股眼交| 国产一区二区三区视频在线播放| 欧美日韩亚洲综合在线| 国产精品理论片| 日韩av网站在线观看| 日本韩国视频一区二区| 欧美成人aa大片| 五月激情综合网| 波多野结衣一区二区三区| 欧美不卡视频一区| 亚洲小少妇裸体bbw| av在线综合网| 日韩欧美久久久| 亚洲一区二区av电影| 波多野结衣中文一区| 精品裸体舞一区二区三区| 亚洲成av人片观看| 色综合色狠狠天天综合色| 久久亚洲一区二区三区明星换脸| 日本不卡视频在线| 欧美疯狂做受xxxx富婆| 亚洲在线观看免费| youjizz久久| 国产亚洲一区二区三区四区| 狠狠色伊人亚洲综合成人| 91久久精品一区二区三| 亚洲狼人国产精品| 91美女福利视频| 欧美国产综合一区二区| 激情综合网最新| 欧美一区二区三区婷婷月色| 亚洲精品久久嫩草网站秘色| 国产精品888| 日韩一级视频免费观看在线| 一区二区三区 在线观看视频| 国产精品一二三四| 精品剧情v国产在线观看在线| 日韩精品一二三区| 丁香桃色午夜亚洲一区二区三区| 精品久久国产97色综合| 美女在线视频一区| 日韩欧美在线网站| 日韩国产欧美在线播放| 欧美伦理视频网站| 日日夜夜精品视频免费| 88在线观看91蜜桃国自产| 视频一区视频二区中文| 欧美mv和日韩mv国产网站| 国产真实精品久久二三区| 国产视频一区在线观看| 国产91色综合久久免费分享| 久久夜色精品国产欧美乱极品| 欧美一区二区三区电影| 国产一区二区视频在线播放| 国产午夜精品久久| 日本道免费精品一区二区三区| 亚洲成av人影院| 久久久九九九九| 在线一区二区三区| 久久99国产精品久久99 | 日韩欧美亚洲一区二区| 国产麻豆精品久久一二三| 国产精品久久久久国产精品日日| 99精品热视频| 亚洲成a人v欧美综合天堂下载| 9久草视频在线视频精品| 亚洲伦理在线免费看| 91国偷自产一区二区开放时间| 亚洲va在线va天堂| 精品三级在线观看| 国产传媒久久文化传媒| 精品福利一二区| 99久久99精品久久久久久 | 一区二区三区在线视频播放| 欧美日本一道本在线视频| 国产麻豆精品theporn| 亚洲天堂网中文字| 日韩区在线观看| 男女激情视频一区| 亚洲人精品一区| 日韩一区二区在线观看视频| 精东粉嫩av免费一区二区三区| 亚洲私人影院在线观看| 555www色欧美视频| 成人高清视频在线| 美女在线视频一区| 中文字幕亚洲综合久久菠萝蜜| 欧美日韩一级视频|