亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
91久久香蕉国产日韩欧美9色| 五月综合激情婷婷六月色窝| 欧美一级欧美三级| 欧美在线短视频| 色94色欧美sute亚洲13| 97国产一区二区| 色婷婷精品久久二区二区蜜臂av| 91尤物视频在线观看| 色香色香欲天天天影视综合网| 91麻豆精品秘密| 色视频成人在线观看免| 欧美日韩一区三区四区| 国产午夜精品理论片a级大结局| 久久免费看少妇高潮| 国产精品乱人伦| 综合久久久久久| 婷婷开心激情综合| 国内精品在线播放| 成人国产一区二区三区精品| 91在线视频观看| 91精品中文字幕一区二区三区| 精品国产电影一区二区| 国产精品无人区| 婷婷中文字幕一区三区| 久久99精品国产.久久久久| 国产在线播放一区二区三区| 91视频免费播放| 91精品综合久久久久久| 国产精品视频线看| 亚洲第一在线综合网站| 久久99精品久久久久久| 成人h动漫精品| 6080国产精品一区二区| 国产偷国产偷精品高清尤物| 亚洲精品高清视频在线观看| 精品一二三四区| 欧美在线色视频| 国产亚洲精品超碰| 亚洲国产视频在线| 成人综合在线网站| 777午夜精品免费视频| 亚洲国产精品激情在线观看| 亚州成人在线电影| 成人精品国产一区二区4080| 欧美精品tushy高清| 国产精品毛片无遮挡高清| 天堂在线亚洲视频| 99精品久久久久久| 久久久久久久综合| 日本一道高清亚洲日美韩| 一本久道中文字幕精品亚洲嫩| 欧美不卡123| 亚洲成精国产精品女| 国产.欧美.日韩| 日韩一区二区三区视频在线 | 亚洲v精品v日韩v欧美v专区| 国产成人免费视频网站高清观看视频| 精品污污网站免费看| 日韩av在线播放中文字幕| 97久久人人超碰| 日本一区二区三区dvd视频在线| 婷婷久久综合九色国产成人| 94-欧美-setu| 中文字幕精品三区| 精东粉嫩av免费一区二区三区| 欧美日韩日日摸| 一个色综合av| 91美女精品福利| 中文幕一区二区三区久久蜜桃| 精品一区二区影视| 精品少妇一区二区| 激情欧美日韩一区二区| 欧美成人vps| 蜜桃精品视频在线| 精品国产免费视频| 国产精选一区二区三区| 久久婷婷久久一区二区三区| 久久福利资源站| 久久久久久久性| 成人18视频日本| 亚洲日本一区二区| 色婷婷久久久亚洲一区二区三区 | 亚洲高清视频的网址| 欧美天天综合网| 首页国产欧美久久| 日韩一级在线观看| 国产一区在线精品| 中文一区二区完整视频在线观看| 成人一级片网址| 亚洲乱码国产乱码精品精的特点 | 久久色在线视频| 精品系列免费在线观看| 国产欧美精品一区二区三区四区 | 欧美日韩不卡一区二区| 无吗不卡中文字幕| 国产亚洲精品7777| 91国产福利在线| 偷拍一区二区三区| 国产午夜精品理论片a级大结局| a4yy欧美一区二区三区| 亚洲成人精品一区二区| 精品少妇一区二区三区日产乱码 | 亚洲一区二区3| 日韩视频中午一区| 成人国产精品免费观看视频| 亚洲电影一区二区| 久久夜色精品国产噜噜av| 91在线无精精品入口| 日本欧美一区二区三区| 中文字幕日韩欧美一区二区三区| 欧美日韩精品一区视频| 国产一区二区三区不卡在线观看 | 亚洲日本中文字幕区| 欧美丝袜丝交足nylons图片| 午夜免费欧美电影| 亚洲精品一区二区三区福利| 成人久久18免费网站麻豆 | 极品美女销魂一区二区三区| 欧美精品一区二区久久久 | ㊣最新国产の精品bt伙计久久| 97久久超碰精品国产| 亚洲图片另类小说| 久久久久久久性| 欧美在线免费观看视频| 国产在线播放一区| 亚洲最快最全在线视频| 欧美日韩国产综合久久| 99久久国产综合精品女不卡| 天堂在线亚洲视频| 欧美激情一区二区三区蜜桃视频| 欧美在线观看视频在线| 日韩黄色小视频| 亚洲影视在线观看| 精品国产一区二区国模嫣然| 91污在线观看| 精品夜夜嗨av一区二区三区| 成人免费一区二区三区在线观看| 精品国产乱码久久久久久浪潮| 色哟哟在线观看一区二区三区| 精品一区二区影视| 亚洲主播在线观看| 亚洲国产激情av| 7777女厕盗摄久久久| 91免费观看国产| 精品一区二区三区视频| 《视频一区视频二区| 亚洲精品在线观看网站| 成人国产在线观看| 国产黄色成人av| 日韩精品午夜视频| 午夜电影久久久| 亚洲欧美自拍偷拍| 欧美极品美女视频| 精品免费日韩av| 在线播放中文一区| 欧美色精品天天在线观看视频| 成人影视亚洲图片在线| 韩国女主播成人在线观看| 国产精品白丝在线| 亚洲色图在线播放| ...av二区三区久久精品| 国产精品欧美一区二区三区| 久久综合国产精品| 日韩欧美aaaaaa| 国产丝袜美腿一区二区三区| 久久影院午夜片一区| 日韩免费在线观看| 欧美tk—视频vk| 国产视频亚洲色图| 久久久久国产精品免费免费搜索| 欧美一区二区三区四区五区| 欧美日韩免费一区二区三区视频| 国产99精品在线观看| 色视频欧美一区二区三区| 99re热视频这里只精品| 暴力调教一区二区三区| 成人禁用看黄a在线| 欧美无砖专区一中文字| 欧美系列亚洲系列| 91精品国产综合久久蜜臀| 欧美一区二区在线播放| 久久久青草青青国产亚洲免观| 国产欧美日韩一区二区三区在线观看 | 国产传媒日韩欧美成人| 丰满岳乱妇一区二区三区 | 欧美高清在线精品一区| 国产精品国产馆在线真实露脸| 亚洲午夜在线视频| 日韩电影在线一区二区| 国产在线不卡视频| 色婷婷综合五月| 精品久久免费看| 1000精品久久久久久久久| 亚洲第四色夜色| 亚洲第一福利一区| 成人免费视频网站在线观看| 欧洲精品一区二区| 欧美v国产在线一区二区三区| 久久欧美一区二区| 日韩和欧美一区二区三区|