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

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

?? lzw經典.cpp

?? 壓縮解壓縮代碼
?? CPP
字號:
/********************************************************************
**
** Copyright (c) 1989 Mark R. Nelson
**
** LZW data compression/expansion demonstration program.
**
** April 13, 1989
**
*****************************************************************************/
#include <stdio.h>
#include<stdlib.h>
#define BITS 12                   /* Setting the number of bits to 12, 13*/
#define HASHING_SHIFT BITS-8      /* or 14 affects several constants.    */
#define MAX_VALUE (1 << BITS) - 1 /* Note that MS-DOS machines need to   */
#define MAX_CODE MAX_VALUE - 1    /* compile their code in large model if*/
                                  /* 14 bits are selected.               */
#if BITS == 14
  #define TABLE_SIZE 18041        /* The string table size needs to be a */
#endif                            /* prime number that is somewhat larger*/
#if BITS == 13                    /* than 2**BITS.                       */
  #define TABLE_SIZE 9029
#endif
#if BITS <= 12
  #define TABLE_SIZE 5021
#endif

//void *malloc();

int *code_value;                  /* This is the code value array        */
unsigned int *prefix_code;        /* This array holds the prefix codes   */
unsigned char *append_character;  /* This array holds the appended chars */
unsigned char decode_stack[4000]; /* This array holds the decoded string */

/********************************************************************
**
** This program gets a file name from the command line.  It compresses the
** file, placing its output in a file named test.lzw.  It then expands
** test.lzw into test.out.  Test.out should then be an exact duplicate of
** the input file.
**
*************************************************************************/
void strcpy(char *s,char *t)
{
	while(*s++=*t++);
}
void compress(FILE *input,FILE *output);
int find_match(int hash_prefix,unsigned int hash_character);
void expand(FILE *input,FILE *output);
unsigned char *decode_string(unsigned char *buffer,unsigned int code);
void output_code(FILE *output,unsigned int code);
unsigned int input_code(FILE *input);

int main(int argc, char *argv[])
{
    FILE *input_file;
    FILE *output_file;
    FILE *lzw_file;
    char input_file_name[81];

/*
**  The three buffers are needed for the compression phase.
*/
   code_value=(int*)malloc(TABLE_SIZE*sizeof(unsigned int));
   prefix_code=(unsigned int*)malloc(TABLE_SIZE*sizeof(unsigned int));
   append_character=(unsigned char*)malloc(TABLE_SIZE*sizeof(unsigned char));
   if (code_value==NULL || prefix_code==NULL || append_character==NULL)
   {
      printf("Fatal error allocating table space!\n");
	  return 0;
      //exit();
  }
/*
** Get the file name, open it up, and open up the lzw output file.
*/
  if (argc>1)
     strcpy(input_file_name,argv[1]);
  else
  {
     printf("Input file name? ");
     scanf("%s",input_file_name);
  }
  input_file=fopen(input_file_name,"rb");
  lzw_file=fopen("test.lzw","wb");
  if (input_file==NULL || lzw_file==NULL)
  {
    printf("Fatal error opening files.\n");
    //exit();
	return 0;
  };
/*
** Compress the file.
*/
  compress(input_file,lzw_file);
  fclose(input_file);
  fclose(lzw_file);
  free(code_value);
/*
** Now open the files for the expansion.
*/
  lzw_file=fopen("test.lzw","rb");
  output_file=fopen("test.out","wb");
  if (lzw_file==NULL || output_file==NULL)
  {
    printf("Fatal error opening files.\n");
    //exit();
	return 0;
  };
/*
** Expand the file.
*/
  expand(lzw_file,output_file);
  fclose(lzw_file);
  fclose(output_file);

  free(prefix_code);
  free(append_character);
  return 0;
}

/*
** This is the compression routine.  The code should be a fairly close
** match to the algorithm accompanying the article.
**
*/

void compress(FILE *input,FILE *output)
{
  unsigned int next_code;
 unsigned int character;
 unsigned int string_code;
 unsigned int index;
 int i;

  next_code=256;              /* Next code is the next available string code*/
  for (i=0;i<TABLE_SIZE;i++)  /* Clear out the string table before starting */
    code_value[i]=-1;

  i=0;
  printf("Compressing...\n");
  string_code=getc(input);    /* Get the first code                         */
/*
** This is the main loop where it all happens.  This loop runs util all of
** the input has been exhausted.  Note that it stops adding codes to the
** table after all of the possible codes have been defined.
*/
  while ((character=getc(input)) != (unsigned)EOF)
  {
    if (++i==1000)                         /* Print a * every 1000    */
    {                                      /* input characters.  This */
      i=0;                                 /* is just a pacifier.     */
      printf("*");
    }
    index=find_match(string_code,character);/* See if the string is in */
    if (code_value[index] != -1)            /* the table.  If it is,   */
      string_code=code_value[index];        /* get the code value.  If */
    else                                    /* the string is not in the*/
    {                                       /* table, try to add it.   */
      if (next_code <= MAX_CODE)
      {
        code_value[index]=next_code++;
        prefix_code[index]=string_code;
        append_character[index]=character;
      }
      output_code(output,string_code);  /* When a string is found  */
      string_code=character;            /* that is not in the table*/
    }                                   /* I output the last string*/
  }                                     /* after adding the new one*/
/*
** End of the main loop.
*/
  output_code(output,string_code); /* Output the last code               */
  output_code(output,MAX_VALUE);   /* Output the end of buffer code      */
  output_code(output,0);           /* This code flushes the output buffer*/
  printf("\n");
}

/*
** This is the hashing routine.  It tries to find a match for the prefix+char
** string in the string table.  If it finds it, the index is returned.  If
** the string is not found, the first available index in the string table is
** returned instead.
*/

int find_match(int hash_prefix,unsigned int hash_character)
{
int index;
int offset;

  index = (hash_character << HASHING_SHIFT) ^ hash_prefix;
  if (index == 0)
    offset = 1;
  else
    offset = TABLE_SIZE - index;
  while (1)
  {
    if (code_value[index] == -1)
      return(index);
    if (prefix_code[index] == hash_prefix && append_character[index] == hash_character)
      return(index);
    index -= offset;
    if (index < 0)
      index += TABLE_SIZE;
  }
}

/*
**  This is the expansion routine.  It takes an LZW format file, and expands
**  it to an output file.  The code here should be a fairly close match to
**  the algorithm in the accompanying article.
*/

void expand(FILE *input,FILE *output)
{
unsigned int next_code;
unsigned int new_code;
unsigned int old_code;
int character;
int counter;
unsigned char *string;
//char *decode_string(unsigned char *buffer,unsigned int code);

  next_code=256;           /* This is the next available code to define */
  counter=0;               /* Counter is used as a pacifier.            */
  printf("Expanding...\n");

  old_code=input_code(input);  /* Read in the first code, initialize the */
  character=old_code;          /* character variable, and send the first */
  putc(old_code,output);       /* code to the output file                */
/*
**  This is the main expansion loop.  It reads in characters from the LZW file
**  until it sees the special code used to inidicate the end of the data.
*/
  while ((new_code=input_code(input)) != (MAX_VALUE))
  {
    if (++counter==1000)   /* This section of code prints out     */
    {                      /* an asterisk every 1000 characters   */
      counter=0;           /* It is just a pacifier.              */
      printf("*");
    }
/*
** This code checks for the special STRING+CHARACTER+STRING+CHARACTER+STRING
** case which generates an undefined code.  It handles it by decoding
** the last code, and adding a single character to the end of the decode string.
*/
    if (new_code>=next_code)
    {
      *decode_stack=character;
      string=decode_string(decode_stack+1,old_code);
    }
/*
** Otherwise we do a straight decode of the new code.
*/
    else
      string=decode_string(decode_stack,new_code);
/*
** Now we output the decoded string in reverse order.
*/
    character=*string;
    while (string >= decode_stack)
      putc(*string--,output);
/*
** Finally, if possible, add a new code to the string table.
*/
    if (next_code <= MAX_CODE)
    {
      prefix_code[next_code]=old_code;
      append_character[next_code]=character;
      next_code++;
    }
    old_code=new_code;
  }
  printf("\n");
}

/*
** This routine simply decodes a string from the string table, storing
** it in a buffer.  The buffer can then be output in reverse order by
** the expansion program.
*/

unsigned char *decode_string(unsigned char *buffer,unsigned int code)
{
int i;

  i=0;
  while (code > 255)
  {
    *buffer++ = append_character[code];
    code=prefix_code[code];
    if (i++>=4094)
    {
      printf("Fatal error during code expansion.\n");
     // exit();
	  return NULL;
    }
  }
  *buffer=code;
  return(buffer);
}

/*
** The following two routines are used to output variable length
** codes.  They are written strictly for clarity, and are not
** particularyl efficient.
*/

unsigned int input_code(FILE *input)
{
unsigned int return_value;
static int input_bit_count=0;
static unsigned long input_bit_buffer=0L;

  while (input_bit_count <= 24)
  {
    input_bit_buffer |= 
        (unsigned long) getc(input) << (24-input_bit_count);
    input_bit_count += 8;
  }
  return_value=input_bit_buffer >> (32-BITS);
  input_bit_buffer <<= BITS;
  input_bit_count -= BITS;
  return(return_value);
}

void output_code(FILE *output,unsigned int code)
{
static int output_bit_count=0;
static unsigned long output_bit_buffer=0L;

  output_bit_buffer |= (unsigned long) code << (32-BITS-output_bit_count);
  output_bit_count += BITS;
  while (output_bit_count >= 8)
  {
    putc(output_bit_buffer >> 24,output);
    output_bit_buffer <<= 8;
    output_bit_count -= 8;
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕一区二区三区不卡| 午夜av一区二区| 偷拍日韩校园综合在线| 国产乱码精品一区二区三区五月婷| 99视频精品在线| 91精品国产一区二区三区蜜臀| 国产精品乱人伦中文| 日韩精彩视频在线观看| 色综合亚洲欧洲| 中文字幕乱码一区二区免费| 男女性色大片免费观看一区二区| 91麻豆福利精品推荐| 国产性做久久久久久| 蜜桃视频一区二区| 欧美色老头old∨ideo| 国产精品电影院| 国产剧情一区在线| 精品久久国产老人久久综合| 午夜日韩在线观看| 欧美亚洲国产一卡| 亚洲乱码精品一二三四区日韩在线| 国产激情一区二区三区四区 | 一二三四区精品视频| 成人免费观看av| 久久久国产午夜精品| 九九久久精品视频| 亚洲人一二三区| 懂色av中文字幕一区二区三区| 精品人在线二区三区| 日韩中文字幕亚洲一区二区va在线| 欧美色综合天天久久综合精品| 亚洲精品亚洲人成人网| 成人白浆超碰人人人人| 中文在线免费一区三区高中清不卡 | 亚洲欧美色一区| hitomi一区二区三区精品| 国产精品色在线观看| av中文字幕亚洲| 亚洲色大成网站www久久九九| 99精品欧美一区二区三区小说| 亚洲国产电影在线观看| aaa欧美日韩| 一区二区三区在线视频免费 | 国产精品性做久久久久久| 久久综合久久综合九色| 国产黑丝在线一区二区三区| 国产精品美女久久久久久| 97se亚洲国产综合自在线| 亚洲欧美偷拍三级| 欧美绝品在线观看成人午夜影视| 蜜臀久久久99精品久久久久久| 337p日本欧洲亚洲大胆精品| 国产99精品国产| 亚洲视频在线观看三级| 欧美性xxxxx极品少妇| 日韩av一区二区三区| 精品久久久久久久人人人人传媒| 国产成人av资源| 亚洲一区二区三区四区的| 在线综合亚洲欧美在线视频| 久久97超碰色| 亚洲色图丝袜美腿| 日韩一区二区三区在线观看| 国产成人夜色高潮福利影视| 亚洲欧美自拍偷拍色图| 9191久久久久久久久久久| 国产一区二区三区四区五区入口 | 精品国产sm最大网站免费看| 成人av影院在线| 日韩精品国产欧美| 国产精品女主播av| 欧美日韩成人在线| 成人亚洲一区二区一| 亚洲二区视频在线| 国产日本一区二区| 7878成人国产在线观看| 成人精品亚洲人成在线| 奇米色一区二区三区四区| 国产精品卡一卡二卡三| 欧美一级在线免费| 99re66热这里只有精品3直播| 日本欧美一区二区三区| 亚洲色图一区二区| 久久久亚洲国产美女国产盗摄 | 国产精品久久影院| 欧美日韩日本视频| 99视频一区二区| 国产一区二区三区观看| 天天射综合影视| 最好看的中文字幕久久| 久久精品视频在线看| 欧美一区二区播放| 欧美在线一区二区| av成人免费在线| 粉嫩一区二区三区性色av| 日韩成人一区二区三区在线观看| 亚洲精品成人天堂一二三| 国产日韩欧美高清| 久久精品综合网| 欧美大片国产精品| 欧美一级高清大全免费观看| 精品视频1区2区3区| 91丨国产丨九色丨pron| 国产99精品国产| 国产一区二区h| 免费成人在线观看视频| 婷婷中文字幕综合| 日韩影院精彩在线| 天堂久久一区二区三区| 亚洲午夜久久久久久久久久久| 亚洲欧美日韩久久| 亚洲视频在线观看一区| 亚洲视频一区在线| 自拍偷自拍亚洲精品播放| 国产精品美女久久久久aⅴ| 中文字幕不卡的av| 国产精品色哟哟网站| 国产精品乱码一区二区三区软件 | 国产精品538一区二区在线| 久久精品国产精品亚洲综合| 日产国产欧美视频一区精品| 偷拍与自拍一区| 免费成人美女在线观看| 久久97超碰色| 国产suv精品一区二区6| 成人av影视在线观看| 91视频www| 欧美日韩精品一区二区三区四区| 欧美二区在线观看| 久久综合五月天婷婷伊人| 久久久久国产精品厨房| 国产精品国产三级国产普通话99| 国产精品久久久久三级| 亚洲自拍偷拍综合| 日产欧产美韩系列久久99| 国产一区二区三区四区五区入口 | 欧美日韩国产综合一区二区| 538prom精品视频线放| 精品美女一区二区| 亚洲国产精品v| 亚洲精品高清在线| 日本成人在线电影网| 国产乱码精品一区二区三区忘忧草 | 午夜精品福利在线| 国内欧美视频一区二区| av高清不卡在线| 欧美日韩午夜在线视频| 樱桃国产成人精品视频| 日韩国产精品91| 风间由美一区二区av101| 日本高清免费不卡视频| 欧美一区二区免费观在线| 国产色91在线| 爽好多水快深点欧美视频| 国产精品99久久久| 欧美日韩一本到| 欧美国产日韩a欧美在线观看| 亚洲午夜在线视频| 国产精品18久久久久久久网站| 日本韩国欧美在线| 国产亚洲福利社区一区| 亚洲成年人影院| 99麻豆久久久国产精品免费 | 奇米影视7777精品一区二区| av一区二区久久| 日韩视频在线观看一区二区| 亚洲色图视频网| 国产激情偷乱视频一区二区三区| 欧美图区在线视频| 中文字幕一区二区在线观看| 久久66热re国产| 欧美亚洲综合网| 亚洲欧洲99久久| 国产精品456| 精品对白一区国产伦| 亚洲成人在线网站| 色综合天天综合在线视频| 国产欧美一区二区精品久导航| 爽好久久久欧美精品| 欧美综合视频在线观看| 国产亚洲一区字幕| 久久国产生活片100| 欧美剧情片在线观看| 亚洲精品第一国产综合野| 成人综合婷婷国产精品久久| 日韩欧美国产一区二区三区| 亚洲成人激情综合网| 在线精品亚洲一区二区不卡| 国产精品久久久一本精品| 国产精品自拍av| 久久久亚洲精华液精华液精华液| 日本不卡视频在线观看| 91.com在线观看| 香蕉影视欧美成人| 欧美体内she精视频| 亚洲综合色婷婷| 欧美日韩一区国产| 日韩精品亚洲一区二区三区免费| 欧美在线999| 亚洲高清视频在线|