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

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

?? model.c

?? A
?? C
?? 第 1 頁 / 共 3 頁
字號:
#include <stdio.h>
#include <mem.h>
#include <alloc.h>
#include <stdlib.h>

#include "comp.h"
#include "arith.h"


#define MAX_CUM_FREQ   0x4000   /* maximum cumulative frequency */

struct model

{
        int initial_level;
        int match_level;

        unsigned base_count;
        unsigned sym_freq;

        unsigned order_cum_freq [MAX_ORDER + 2];
        unsigned order_sym_count [MAX_ORDER + 2];
};



/*
        Define circular dictionary large enough to hold complete
        set of active input symbols.

        Extra entries are included in the dictionary corresponding
        to a string of length equal to the maximum order to facilitate
        searching across the end of the dictionary.  This extra space
        is allocated at the front of the dictionary, so that the first
        few entries are never referenced directly.

        An additional table is allocated consisting of one word entries
        used to link equivalent dictionary entries where a hash table is
        used to locate the start of each search chain.

        The last character of the test string is used locate the
        initial hash table entry.  The hash table entries are stored
        as an extension to the link table.

        The link table is accessed through the use of macros to allow
        easy access to this table when its size excceds 64K.
*/

#ifndef FAR_TABLES

static unsigned char dict [MAX_DICT];
static unsigned char base_level [MAX_DICT];
static unsigned int next_dict [MAX_DICT + HTBL1_SIZE];

#define DICT_WORD_PTR(i) ((unsigned *) (&dict [i]));
#define NEXT_DICT(i) next_dict [i]

#else

static unsigned char far *dict;
static unsigned char far *base_level;
#define DICT_WORD_PTR(i) ((unsigned far *) (&dict [i]));

#ifdef SPLIT_TABLES

static unsigned int far *next_dict [2];
#define NEXT_DICT(i) next_dict [i & 1] [i >> 1]

#else

static unsigned int far *next_dict;
#define NEXT_DICT(i) next_dict [i]

#endif
#endif


static unsigned int node;
static int new_symbol_count;
static unsigned int last_search_node;

static int max_order;
static int max_pos_size;

/*
        Define table of entries for each order giving number of symbols
        and total cumulative frequency for each order
*/

static struct model active_state;
static struct model last_state;


/*
        Define set of save areas for the state at the potential start any string
        The areas are used in rotation until a substring is matched equal to
        the minimum string length.  Normal symbol compression is performed
        during the time that the substring matches the input data.
                
        When the first non matching character is encountered, the lengths of
        the string and the compressed symbols are compared.  If the string
        length is less, the output is repositioned as specified by the
        state at the start of the string, and the string selection sequence
        overwrites the output.
*/

static struct

{
        int i;
        struct coder_state cs;
        struct model mod;
} save_state [MAX_STR_SAVE];


static int save_state_index;
static unsigned int string_pos;
static int string_len;
static int string_start;
static int skip_count;

/*
        States used while testing for text string replacements
*/

static enum
{
        STRING_WAIT,  STRING_SEARCH,  STRING_START,  STRING_ACTIVE,
        STRING_COMP,
} string_state;


/*
        Define combined set of tables giving the order and
        frequency count for each symbol encountered during dictionary scan
        Also accumulate base frequency values for each order
*/

static unsigned char level [MAX_SYM];
static unsigned int freq [MAX_SYM];
static unsigned int base_freq [MAX_ORDER + 2];

static unsigned int dup_count = 0;
static int dup_char = -1;

/*
        Build frequency table for zero and default orders
        Used to initialize state tables at start of each dictionary scan

        Always contains nonzero count for every symbol
        Includes order for each symbol selecting zero or default orders
        Initially set to all defaults with symbol frequency one
*/

static unsigned int sym_count_zero;
static unsigned int cum_freq_zero;
static unsigned int freq_zero [MAX_SYM];
static unsigned char order_zero [MAX_SYM];


/*
        Prototypes
*/

static void clear_context (void);
static void scan_dict (int);
static void scale_freq_tbl (int, int);
static void calc_symbol_freq (int);
static void select_output_symbol (void);
static int decode_symbol (void);
static void update_model (int);

static void encode_symbol (struct model *);
static void generate_switch_code (struct model *);
static void generate_symbol_code (struct model *);
static void generate_value (unsigned, unsigned);

static int start_decode_string (void);
static int decode_active_state (void);
static int decode_string_char (void);
static unsigned decode_value (unsigned);

static unsigned switch_char_freq (unsigned, unsigned);

static void delete_dict_entry (int);
static void test_string_state (void);
static void clear_text_string (void);

static void check_string_cont (void);
static void test_string_start (unsigned pos, int n);
static void test_string_resume (unsigned pos, int n);
static void replace_text_string (void);

static int log2 (unsigned);
static void scale_binary_value (long, int *, unsigned *);
static void update_bit_len (unsigned, unsigned, int *, unsigned *);
static int find_string_len (void);


/*
        Initialize model at start of compression or expansion
        Alocate and initialize tables
*/

void InitModel (int n)

{
        unsigned i;

        InitCoder ();

        active_state.initial_level = 1;
        node = MAX_ORDER;
        max_pos_size = log2 (NDICT - 1) + 1;
        max_order = n;
        if (max_order == 0) max_order = 1;

        sym_count_zero = 0;
        cum_freq_zero = 0;

#ifdef FAR_TABLES

        dict = farmalloc (MAX_DICT * sizeof (unsigned char));
        base_level = farmalloc (MAX_DICT * sizeof (unsigned char));

#ifndef SPLIT_TABLES

        next_dict = farmalloc ((MAX_DICT + HTBL1_SIZE) * sizeof (unsigned int));

        if (dict == NULL || base_level == NULL || next_dict == NULL)
        {
                printf ("Memory allocation failure\n");
                exit (EXIT_FAILURE);
        }

#else

        next_dict [0] = farmalloc ((MAX_DICT + HTBL1_SIZE + 1) / 2 * sizeof (unsigned int));
        next_dict [1] = farmalloc ((MAX_DICT + HTBL1_SIZE + 1) / 2 * sizeof (unsigned int));

        if (dict == NULL || base_level == NULL || next_dict [1] == NULL)
        {
                printf ("Memory allocation failure\n");
                exit (EXIT_FAILURE);
        }

        #endif  /* SPLIT_TABLES */

#endif  /* FAR_TABLES */

        for (i = 0; i < MAX_SYM; i ++)
        {
                freq_zero [i] = 1;
                order_zero [i] = 0;
        }

        for (i = 0; i < MAX_DICT + HTBL1_SIZE; i ++)
                NEXT_DICT (i) = NIL_DICT_PTR;

        for (i = 0; i < MAX_DICT; i ++)
        {
                dict [i] = 0;
                base_level [i] = 0;
        }

        save_state_index = 0;
        string_pos = 0;
        string_len = 0;
        string_start = 0;
        skip_count = MIN_STR;
        string_state = STRING_WAIT;
}




/*
        Compress next symbol
*/

void CompressSymbol (int ch)

{
        int i;
        unsigned cfreq;

        if (string_state == STRING_ACTIVE) check_string_cont ();

        if (dup_count > max_order + 2)
        {
                ++ active_state.order_cum_freq [max_order + 1];
                ++ freq [dup_char];

                if (ch != dup_char)
                {
                        for (i = 0, cfreq = 0; i < ch; i ++)
                        {
                                if (level [i] == level [ch]) cfreq += freq [i];
                        }
                        
                        base_freq [level [ch]] = cfreq;
                }
        }
        else
        {
                clear_context ();
                for (i = 0; i < max_order + 2; i ++) base_freq [i] = 0;
                scan_dict (ch);
        }

        for (i = 1; i <= active_state.initial_level; i ++)
        {
                while (active_state.order_cum_freq [i] > MAX_CUM_FREQ)
                        scale_freq_tbl (i, ch);
        }

        test_string_state ();

        calc_symbol_freq (ch);
        select_output_symbol ();
        update_model (ch);
}



/*
        Expand next symbol from input stream
*/

int ExpandSymbol (void)

{
        int ch;

        if (dup_count > max_order + 2)
        {
                ++ active_state.order_cum_freq [max_order + 1];
                ++ freq [dup_char];
        }
        else
        {
                clear_context ();
                scan_dict (0);
        }

        ch = string_len == 0 ? decode_symbol () : decode_string_char ();
        update_model (ch);
        
        return ch;
}



/*
        Update tables used by model for new symbol
        Link new symbol into dictionary
        Delete oldest symbol in dictionary, if required
        Update zero order frequencies if no higher level context found
*/

static void update_model (int ch)

{
        int n;

        NEXT_DICT (node) = NIL_DICT_PTR;
        NEXT_DICT (last_search_node) = node;
        last_search_node = node;

        if (active_state.match_level < 2)
        {
                cum_freq_zero ++;
                if (order_zero [ch])
                        freq_zero [ch] ++;
                else
                {
                        order_zero [ch] = 1;
                        sym_count_zero ++;
                }
        }

        dict [node] = ch;
        if (ch == dup_char)
                dup_count ++;
        else
        {
                dup_char = ch;
                dup_count = 0;
        }

        n = active_state.match_level;
        if (n == 0) n = 1;
        base_level [node] = n;

        delete_dict_entry (node + max_order);

        active_state.initial_level = active_state.match_level;
        if (active_state.initial_level <= max_order)
                active_state.initial_level ++;

        if (++ node == MAX_DICT)
        {
                node = MAX_ORDER;
                for (n = 1; n <= max_order; n ++)
                        dict [MAX_ORDER - n] = dict [MAX_DICT - n];
        }
}



/*
        Delete oldest symbol from dictionary
        Update frequency counts if added for lower order
*/

static void delete_dict_entry (int i)

{
        unsigned int n;
        int j;

        n = i;
        if (n >= MAX_DICT) n -= NDICT;

        switch (base_level [n])
        {
                case 0:
                        break;

                case 1:
                        j = dict [n];
                        cum_freq_zero --;
                        if (-- freq_zero [j] == 0)
                        {
                                order_zero [j] = 0;
                                freq_zero [j] = 1;
                                sym_count_zero --;
                        }

                default:
                        j = dict [n - 1];
                        NEXT_DICT (j + MAX_DICT) = NEXT_DICT (n);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久国内精品视频| 亚洲综合一二三区| 在线不卡的av| 美日韩一区二区三区| 久久国产精品99久久人人澡| 在线不卡a资源高清| 麻豆成人久久精品二区三区小说| 亚洲人成在线观看一区二区| 在线精品视频免费播放| 欧美变态tickle挠乳网站| 亚洲免费视频中文字幕| 亚洲欧美日韩综合aⅴ视频| 91精品福利在线一区二区三区 | 日韩一区二区免费视频| 亚洲欧洲日本在线| 中文一区在线播放| 美女视频一区在线观看| 国产麻豆精品久久一二三| 亚洲午夜精品一区二区三区他趣| 精品国产一区二区在线观看| 日韩免费成人网| 欧美成人女星排名| 亚洲成av人片在线| 欧美国产亚洲另类动漫| 中文字幕亚洲一区二区av在线| 欧美性生活久久| 欧美三区免费完整视频在线观看| 国产一区二三区| 成人一级片在线观看| 国产精品久久久久久久岛一牛影视| 亚洲欧美一区二区在线观看| 久久久天堂av| 国产呦萝稀缺另类资源| 久久99国产精品麻豆| 九色综合国产一区二区三区| 国产欧美日韩卡一| 成人深夜福利app| 欧美在线|欧美| 国产美女av一区二区三区| 一区二区三区.www| 久久久久久久久蜜桃| 精品一区二区三区影院在线午夜| 26uuu国产日韩综合| 在线免费视频一区二区| 亚洲欧美自拍偷拍| 欧美日韩一区二区三区高清| 99久久精品免费看| 亚洲国产三级在线| 国产亚洲欧美一区在线观看| 国产精品一卡二卡在线观看| 67194成人在线观看| 日本sm残虐另类| 精品国产一区二区三区av性色| 国产精品77777| 欧美在线免费播放| 不卡av电影在线播放| 国产亚洲精品资源在线26u| 狠狠色伊人亚洲综合成人| 欧洲精品一区二区三区在线观看| 日韩视频在线你懂得| 91精品国产欧美一区二区成人| 欧美一二区视频| 日韩一区二区三区三四区视频在线观看| 日韩综合小视频| 国产一区二区毛片| 亚洲精品大片www| 国产精品欧美一区喷水| 蜜桃在线一区二区三区| 日韩av一区二区在线影视| 国产激情91久久精品导航| 白白色 亚洲乱淫| 欧美一区二区久久久| 国产精品素人一区二区| 丝袜亚洲另类丝袜在线| 成人免费视频视频在线观看免费 | 在线不卡中文字幕播放| 久久亚洲免费视频| 亚洲一区二区三区中文字幕| 精油按摩中文字幕久久| 在线欧美一区二区| 中文字幕第一区综合| 日韩高清一区二区| k8久久久一区二区三区| 欧美一区二区日韩| 亚洲影院在线观看| 国产成人亚洲综合a∨婷婷| 欧美男男青年gay1069videost| 欧美一区二区三区四区在线观看| 亚洲免费成人av| 爽好久久久欧美精品| 91麻豆自制传媒国产之光| 久久亚洲二区三区| 青青青伊人色综合久久| 在线亚洲免费视频| 久久久国产精品午夜一区ai换脸| 天涯成人国产亚洲精品一区av| 菠萝蜜视频在线观看一区| 精品国产乱码久久久久久蜜臀 | 国产伦精品一区二区三区在线观看| 欧美三级韩国三级日本一级| 国产精品久久久久四虎| 国产成人精品免费视频网站| 日韩一级视频免费观看在线| 一区二区三区在线不卡| 国产69精品久久777的优势| 欧美xxxxx裸体时装秀| 午夜影院久久久| 不卡欧美aaaaa| 精品国产髙清在线看国产毛片| 亚洲成人午夜影院| 91精品福利视频| 亚洲婷婷国产精品电影人久久| 懂色av一区二区在线播放| 久久人人爽人人爽| 极品美女销魂一区二区三区 | 成人综合在线视频| 国产清纯美女被跳蛋高潮一区二区久久w| 日韩精品亚洲一区| 欧美一区二区三区的| 一区二区三区蜜桃网| 在线视频国内自拍亚洲视频| 一区二区免费视频| 在线观看视频一区| 亚洲一区二区视频在线| 欧美三级电影在线看| 亚洲国产精品一区二区www在线| 日本丶国产丶欧美色综合| 亚洲欧美日韩国产手机在线| 99re这里都是精品| 亚洲精品免费视频| 日本精品裸体写真集在线观看| 亚洲欧美日韩在线| 精品视频在线免费| 日韩综合一区二区| 欧美日韩亚洲另类| 日韩二区三区四区| 欧美一区二区三区日韩视频| 麻豆精品国产91久久久久久| 久久综合九色综合97婷婷女人 | 色婷婷精品大在线视频| 亚洲精品视频在线看| 日本高清不卡视频| 亚洲h在线观看| 日韩一区二区在线看片| 国产一区二区三区美女| 欧美国产日韩精品免费观看| 99久久婷婷国产| 亚洲国产视频一区二区| 91精品在线免费观看| 国产一区二区三区不卡在线观看| 欧美tickling网站挠脚心| 久久99九九99精品| 日本一区二区三区高清不卡| 欧美综合在线视频| 日韩av网站在线观看| 久久亚洲一区二区三区明星换脸| 成人av午夜电影| 亚洲五月六月丁香激情| 欧美一区三区四区| 懂色av噜噜一区二区三区av| 一区二区三区四区在线| 日韩精品资源二区在线| 成人一区二区视频| 亚洲国产精品久久人人爱蜜臀| 日韩女优视频免费观看| av一二三不卡影片| 天堂成人国产精品一区| 国产欧美一区二区精品性色| 欧美怡红院视频| 日韩av中文在线观看| 亚洲欧美偷拍卡通变态| 精品剧情在线观看| 日本韩国一区二区三区| 精品亚洲国内自在自线福利| 国产精品家庭影院| 欧美一级日韩一级| 播五月开心婷婷综合| 亚洲成人自拍网| 欧美经典一区二区| 欧美一级一区二区| 91官网在线观看| 日韩精品久久理论片| 1024成人网色www| 精品乱人伦一区二区三区| 色噜噜狠狠一区二区三区果冻| 黄色日韩三级电影| 视频一区二区三区入口| 中文字幕日韩一区| 欧美mv和日韩mv国产网站| 欧美视频一区二区在线观看| 国产精品123区| 欧美aaa在线| 亚洲主播在线观看| 亚洲欧洲精品天堂一级| 91麻豆精品国产91久久久久| 成人高清视频在线| 国产福利一区二区三区视频在线| 五月综合激情婷婷六月色窝| 国产精品国产三级国产aⅴ原创| 日韩欧美国产一区在线观看|