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

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

?? lzw.cpp

?? 非常好用的五子棋游戲源碼
?? CPP
字號(hào):
// Created:09-21-98
// By Jeff Connelly

// LZW compression

// Based on ORIGSRC\COdLZW.C written by David Bourgin

#include "stdafx.h"
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>

#define EXPORTING
#include "comprlib.h"
#include "lzw.h"

static unsigned long val_to_read = 0, val_to_write = 0;
static unsigned char bit_counter_to_read = 0, bit_counter_to_write = 0;

#define CHAR_DIC_VAL(ptr_dic) ((*(ptr_dic)).character)
#define CODE_DIC_VAL(ptr_dic) ((*(ptr_dic)).code)
#define PLEFT_DIC_VAL(ptr_dic) ((*(ptr_dic)).left_ptr)
#define PRIGHT_DIC_VAL(ptr_dic) ((*(ptr_dic)).right_ptr)

// Enforces including marker codes and initalization_code and
// end_information_code. Comment out to not do that.
#define TYPE_GIF_ENCODING

// Word counter already known in dictionary
static unsigned int index_dic;
// Bit counter in encoding
static unsigned char bit_counter_encoding;

// 2 ^ EXP2_DIC_MAX gives the maximum word counter in the dictionary
// during all the compressions.   Possible values: 3 to 25
// Note: Higher than 12 can make some memory allocation errors depending
// on compiler and computer.
#define EXP2_DIC_MAX    12

// Maxium word counter in dictionary during one compression.  Ranges from
// end_information_code to 2 ^ EXP2_DIC_MAX
static unsigned int index_dic_max;

// Bit counter for each data input.  If input_bit_counter = 1, we can
// compress/decompress monochrome pictures if with input_bit_counter = 8
// 256-color (8-bit) pictures or any kind of files can be handled.
static unsigned char input_bit_counter;

// Bit counter to encode "initalization_code"
static unsigned char bit_counter_min_encoding;
 
// Both are consecutive coming up just after the last known word in the
// inital dictionary.
static unsigned int initialization_code, end_information_code;

static p_dic_val dictionary[1 << EXP2_DIC_MAX];

// First initalization of the dictionary
static void init_dictionary1()
{
    register unsigned int i;

    index_dic_max = 1 << 12;  // Possible values: 2 ^ 3 to 2 ^ EXP2_DIC_MAX
    input_bit_counter = 8;    // Can be 1 to EXP2_DIC_MAX - 1

    if (input_bit_counter == 1)
        bit_counter_min_encoding = 3;
    else
        bit_counter_min_encoding = input_bit_counter + 1;
    initialization_code = 1 << (bit_counter_min_encoding - 1);

#ifdef TYPE_GIF_ENCODING
    end_information_code = initialization_code + 1;
#else
    end_information_code = initialization_code - 1;
#endif

    for (i = 0; i <= end_information_code; i++)
    {
        if ((dictionary[i] = (p_dic_val)malloc(sizeof(t_dic_val))) == NULL)
        {
            while (i)
            {
                --i;
                free (dictionary[i]);
            }
            EXCEPTION (ERR_MEMORY, "Memory allocation for dictionary failed",
                                   "init_dictionary1()");
        }
        CHAR_DIC_VAL (dictionary[i]) = i;
        CODE_DIC_VAL (dictionary[i]) = i;
        PLEFT_DIC_VAL(dictionary[i]) = NULL;
        PRIGHT_DIC_VAL(dictionary[i]) = NULL;
    }
    for (; i < index_dic_max; i++)
        dictionary[i] = NULL;
    index_dic = end_information_code + 1;
    bit_counter_encoding = bit_counter_min_encoding;
}

// Initalization of the dictionary during encoding
static void init_dictionary2 ()
{
    register unsigned int i;
    for (i = 0; i < index_dic_max; i++)
        PLEFT_DIC_VAL(dictionary[i]) = PRIGHT_DIC_VAL(dictionary[i]) = NULL;
    index_dic = end_information_code + 1;
    bit_counter_encoding = bit_counter_min_encoding;
}

// Frees memory allocated for the dictionary
static void remove_dictionary ()
{
    register unsigned int i;
    for (i = 0; (i < index_dic_max) && (dictionary[i] != NULL); i++)
        free (dictionary[i]);
}

// Looks for symbol from current_node.  Made from the left pointer of
// current_node and move right until we reach the node containing symbol or
// the left ne width right pointer is NULL
static p_dic_val find_node (p_dic_val current_node, unsigned int symbol)
{
    p_dic_val new_node;

    if (!(PLEFT_DIC_VAL(current_node)))
        return current_node;
    else
    {
        new_node = PLEFT_DIC_VAL(current_node);
        while ((CHAR_DIC_VAL(new_node) != symbol) && (PRIGHT_DIC_VAL(new_node)))
            new_node = PRIGHT_DIC_VAL(new_node);
        return new_node;
    }
}

static void add_node (p_dic_val current_node, p_dic_val new_node,
               unsigned int symbol)
{
    if (!dictionary[index_dic])
    {
        if ((dictionary[index_dic] = (p_dic_val)malloc(sizeof(t_dic_val))) == NULL)
        {
            remove_dictionary ();
            EXCEPTION (ERR_MEMORY, "Memory allocation for adding new node failed",
                                   "add_node()");
        }
        CODE_DIC_VAL(dictionary[index_dic]) = index_dic;
        PLEFT_DIC_VAL(dictionary[index_dic]) = NULL;
        PRIGHT_DIC_VAL(dictionary[index_dic]) = NULL;
    }
    CHAR_DIC_VAL (dictionary[index_dic]) = symbol;
    if (current_node == new_node)
        PLEFT_DIC_VAL(new_node) = dictionary[index_dic];
    else
        PRIGHT_DIC_VAL(new_node) = dictionary[index_dic];
    ++index_dic;
    if ((signed)index_dic == (1 << bit_counter_encoding))
        ++bit_counter_encoding;
}

#define dictionary_sature() (index_dic == index_dic_max)

// Sends the value coded on bit_counter_encoding in the stream.  Bits are
// stored left to right.  For example, aaabbbbcccc is written:
// Bits     7 6 5 4 3 2 1 0
// Byte 1   a a a b b b b c
// Byte 2   c c c ? ? ? ? ?
static void write_code_lr (unsigned int value)
{
    val_to_write = (val_to_write << bit_counter_encoding) | value;
    bit_counter_to_write += bit_counter_encoding;
    while (bit_counter_to_write >= 8)
    {
        bit_counter_to_write -= 8;
        write_byte ((unsigned char)(val_to_write >> bit_counter_to_write));
        val_to_write &= ((1 << bit_counter_to_write) - 1);
    }
}

// Adds 0-bits to the last byte to write, if any.  To be considered with the
// function write_code_lr
static void complete_encoding_lr ()
{
    if (bit_counter_to_write > 0)
        write_byte ((unsigned char)
                    (val_to_write << (8 - bit_counter_to_write)));
    val_to_write = bit_counter_to_write = 0;
}

// Sends the value coded on bit_counter_encoding bits in the stream.  The Bits
// are stored from right to left.  Example: aaabbbbcccc becomes:
// Bits     7 6 5 4 3 2 1 0
// Byte 1   c b b b b a a a
// Byte 2   ? ? ? ? ? c c c
static void write_code_rl (unsigned int value)
{
    val_to_write |= ((unsigned long)value) << bit_counter_to_write;
    bit_counter_to_write += bit_counter_encoding;
    while (bit_counter_to_write >= 8)
    {
        bit_counter_to_write -= 8;
        write_byte ((unsigned char)(val_to_write & 0xFF));
        val_to_write = (val_to_write >> 8) & ((1 << bit_counter_to_write)
                        - 1);
    }
}

// Adds 0-bits to the lat byte to write, if any.  To be considered with
// write_code_rl
static void complete_encoding_rl ()
{
    if (bit_counter_to_write > 0)
        write_byte ((unsigned char)val_to_write);
    val_to_write = bit_counter_to_write = 0;
}

// Reads input_bit_counter via read_byte
static unsigned int read_input ()
{
    unsigned int read_code;
    while (bit_counter_to_read < input_bit_counter)
    {
        val_to_read = (val_to_read << 8) | read_byte ();
        bit_counter_to_read += 8;
    }
    bit_counter_to_read -= input_bit_counter;
    read_code = val_to_read >> bit_counter_to_read;
    val_to_read &= ((1 << bit_counter_to_read) - 1);
    return read_code;
}

#define end_input() ((bit_counter_to_read < input_bit_counter) && end_of_data())

// Call this to compress with LZW method
void EXPORT lzw_encode ()
{
    p_dic_val current_node, new_node;
    unsigned int symbol;

    if (!end_input())
    {
        init_dictionary1 ();
#ifdef TYPE_GIF_ENCODING
        write_code_lr (initialization_code);
#endif
        current_node = dictionary[read_input()];
        while (!end_input())
        {
            symbol = read_input ();
            new_node = find_node (current_node, symbol);
            if ((new_node != current_node) && (CHAR_DIC_VAL(new_node) == symbol))
                current_node = new_node;
            else
            {
                write_code_lr (CODE_DIC_VAL(current_node));
                add_node(current_node, new_node, symbol);
                if (dictionary_sature ())
                {
#ifdef TYPE_GIF_ENCODING
                    write_code_lr (initialization_code);
#endif
                    init_dictionary2();
                }
                current_node = dictionary[symbol];
            }
        }
        write_code_lr (CODE_DIC_VAL(current_node));
#ifdef TYPE_GIF_ENCODING
        write_code_lr (end_information_code);
#endif
        complete_encoding_lr ();
        remove_dictionary ();
    }
}





    




?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品亚洲麻豆av一区二区| 久久综合狠狠综合久久综合88 | 亚洲精品视频免费看| 欧洲生活片亚洲生活在线观看| 免费av成人在线| 国产精品美女久久久久久久网站| 91精品婷婷国产综合久久| 波多野结衣一区二区三区| 免播放器亚洲一区| 亚洲精品视频观看| 中文字幕不卡在线观看| 精品卡一卡二卡三卡四在线| 一本一本大道香蕉久在线精品| 狠狠久久亚洲欧美| 午夜精品成人在线| 亚洲视频一二三区| 国产清纯白嫩初高生在线观看91| 欧美精品乱码久久久久久| 99久久精品免费看| 国产在线观看一区二区| 日本伊人午夜精品| 亚洲成人tv网| 亚洲在线视频网站| 亚洲精品自拍动漫在线| 中文字幕欧美三区| 久久亚洲私人国产精品va媚药| 制服丝袜亚洲播放| 欧美在线你懂得| 色综合久久中文综合久久97| 国产·精品毛片| 国产一区视频网站| 国产一区二区三区在线观看免费视频| 日韩不卡手机在线v区| 亚洲国产成人av网| 亚洲成av人综合在线观看| 亚洲综合免费观看高清在线观看| 中文字幕亚洲成人| 国产精品超碰97尤物18| 国产精品久久久一本精品| 美女mm1313爽爽久久久蜜臀| 亚洲高清免费一级二级三级| 亚洲伊人色欲综合网| 一区二区三区日韩| 亚洲国产精品一区二区久久 | 五月天激情综合网| 无码av免费一区二区三区试看 | 亚洲欧洲中文日韩久久av乱码| 日本一区二区不卡视频| 国产精品久久二区二区| 国产精品久久久久久久久果冻传媒 | 色婷婷国产精品综合在线观看| 99久久综合国产精品| 91丝袜美女网| 色妹子一区二区| 欧美偷拍一区二区| 日韩一区二区在线观看视频| 日韩欧美高清dvd碟片| 26uuu亚洲| 国产精品女主播在线观看| 中文字幕一区二区三| 亚洲制服丝袜av| 日韩影视精彩在线| 久99久精品视频免费观看| 国产精品一卡二卡在线观看| 丰满岳乱妇一区二区三区| 99久久综合99久久综合网站| 在线观看免费亚洲| 欧美一区二区三级| 久久久久高清精品| 高清成人免费视频| 一本久久a久久精品亚洲| 欧美性猛交xxxxxx富婆| 欧美一区二区福利在线| 国产午夜精品一区二区三区视频| 国产精品麻豆久久久| 亚洲福利电影网| 韩国v欧美v日本v亚洲v| 色老汉av一区二区三区| 日韩精品资源二区在线| 中文字幕一区二区视频| 青青草国产精品亚洲专区无| 成人一区二区视频| 欧美久久久久久久久中文字幕| 亚洲精品在线一区二区| 亚洲免费高清视频在线| 九九九久久久精品| 色999日韩国产欧美一区二区| 欧美一区二区三区免费观看视频| 国产精品久久久久久久午夜片| 日日欢夜夜爽一区| av亚洲产国偷v产偷v自拍| 91精品国产麻豆| 综合av第一页| 狠狠色狠狠色综合系列| 91久久国产最好的精华液| 欧美大胆一级视频| 中文字幕的久久| 日产欧产美韩系列久久99| 国产成人在线看| 欧美在线观看一二区| 精品盗摄一区二区三区| 亚洲视频一区在线观看| 国产精品国产三级国产有无不卡| 麻豆国产欧美一区二区三区| 成人免费看片app下载| 欧美日韩aaaaa| 精品盗摄一区二区三区| 一区二区三区欧美久久| 国产盗摄视频一区二区三区| 色综合久久中文字幕| 中文字幕 久热精品 视频在线| 亚洲国产视频在线| 国产成人精品亚洲日本在线桃色 | 欧美一区二区免费| 亚洲男人的天堂一区二区| 精品一区二区三区蜜桃| 色综合天天综合色综合av | 韩国在线一区二区| 欧美视频一区二区| 国产蜜臀97一区二区三区 | 国产精品国产三级国产普通话99 | 午夜激情久久久| 成人国产精品免费网站| 日韩女优视频免费观看| 日日夜夜免费精品| 色婷婷亚洲一区二区三区| 久久精品视频网| 日本不卡的三区四区五区| 91视频xxxx| 国产欧美日韩激情| 日韩电影一区二区三区四区| 欧美日韩精品一区二区三区四区| 中文字幕人成不卡一区| 国产一区二区三区免费在线观看| 欧美放荡的少妇| 亚洲欧美日韩一区| 高清beeg欧美| 国产精品久久久99| 高清视频一区二区| 久久精品免视看| 久久99精品国产麻豆婷婷洗澡| 欧美日韩久久久| 天堂成人国产精品一区| 91福利在线播放| 亚洲视频一区二区免费在线观看| 高清不卡一区二区在线| 久久久久国产成人精品亚洲午夜| 亚洲成av人片一区二区三区| 3atv一区二区三区| 日韩精品成人一区二区三区 | 色狠狠桃花综合| 亚洲欧美国产高清| 国产99一区视频免费| 亚洲精品一区二区三区福利| 老司机免费视频一区二区| 8x8x8国产精品| 亚洲一区二区精品久久av| 欧美日本一道本在线视频| 午夜精品久久久久久不卡8050| 在线观看国产一区二区| 亚洲午夜精品网| 在线播放中文字幕一区| 美女视频黄a大片欧美| 精品免费国产一区二区三区四区| 精品亚洲porn| 久久久久久久网| 成人精品视频一区二区三区 | 国产一区在线精品| 欧美成人女星排名| 成人免费精品视频| 亚洲日本免费电影| 欧美午夜电影一区| 丝袜美腿亚洲一区| 精品久久人人做人人爱| 国产在线不卡一区| 国产精品久久久久精k8| 色香蕉成人二区免费| 亚洲成人综合在线| 91精品国产日韩91久久久久久| 日韩国产高清在线| 国产精品网站一区| 欧美无人高清视频在线观看| 日韩影院在线观看| 久久久亚洲综合| 不卡的av电影| 午夜欧美大尺度福利影院在线看| 91精品国产色综合久久不卡蜜臀 | 国产成人丝袜美腿| 亚洲青青青在线视频| 欧美写真视频网站| 麻豆专区一区二区三区四区五区| 久久久99久久| 欧美人牲a欧美精品| 激情综合亚洲精品| 日韩美女啊v在线免费观看| 欧美日韩中文一区| 国产在线精品一区二区夜色 | 亚洲h在线观看| 精品国产乱子伦一区| 成人网在线播放|