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

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

?? codlzw.c

?? 著名壓縮算法的實現
?? C
字號:
/* File: codlzw.c   Author: David Bourgin   Creation date: 25/3/95   Last update: 12/10/95   Purpose: Example of LZW encoding with a file source to compress.*/#include <stdio.h>/* For routines printf,fgetc and fputc. */#include <malloc.h>/* For routines malloc and free. */#include <stdlib.h>/* For routine exit. *//* Error codes returned to the caller. */#define NO_ERROR       0#define BAD_FILE_NAME  1#define BAD_ARGUMENT   2#define BAD_MEM_ALLOC  3/* Useful constants. */#define FALSE 0#define TRUE  1/* Global variables. */FILE *source_file,*dest_file;                             /* Being that fgetc=EOF only after an access                                then 'byte_stored_status' is 'TRUE' if a byte has been stored by 'fgetc'                                or 'FALSE' if there's no valid byte not handled in 'val_byte_stored' */int byte_stored_status=FALSE;int byte_stored_val;/* Pseudo procedures */#define end_of_data()  (byte_stored_status?FALSE:!(byte_stored_status=((byte_stored_val=fgetc(source_file))!=EOF)))#define read_byte()  (byte_stored_status?byte_stored_status=FALSE,(unsigned char)byte_stored_val:(unsigned char)fgetc(source_file))#define write_byte(byte)  ((void)fputc((byte),dest_file))unsigned long int val_to_read=0,                  val_to_write=0;unsigned char bit_counter_to_read=0,              bit_counter_to_write=0;typedef struct s_dic_val { unsigned int character;                           unsigned int code;                           struct s_dic_val *left_ptr,                                            *right_ptr;                         } t_dic_val,*p_dic_val;#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)#define TYPE_GIF_ENCODING/* Enforces including marker codes initialization_code et end_information_code.   To invalid this option, set the line #define... in comments. */unsigned int index_dic;/* Word counter already known in the dictionary. */unsigned char bit_counter_encoding;/* Bit counter in the encoding. */#define EXP2_DIC_MAX  12/* 2^EXP2_DIC_MAX gives the maximum word counter in the dictionary during *all* the compressions.   Possible values: 3 to 25.   Attention: Beyond 12, you can have some errors of memory allocation   depending on your compiler and your computer. */unsigned int index_dic_max;/* index_dic_max gives the maximum word counter in the dictionary during *one* compression.   This constant is restricted to the range of end_information_code to 2^EXP2_DIC_MAX. */unsigned char input_bit_counter,/* Bit counter for each data in input.   With input_bit_counter=1, we can compress/decompress monochrome pictures   and with input_bit_counter=8, we can handle 256-colors pictures or any kind of files. */              bit_counter_min_encoding;/* Bit counter to encode 'initialization_code'. */unsigned int initialization_code;unsigned int end_information_code;/* initialization_code and end_information_code are both consecutive   coming up just after the last known word in the initial dictionary. */p_dic_val dictionary[1<<EXP2_DIC_MAX];void init_dictionary1()/* Returned parameters: None.   Action: First initialization of the dictionary when we start an encoding.   Errors: None if there is enough room.*/{ register unsigned int i;  index_dic_max=1<<12;       /* Attention: Possible values: 2^3 to 2^EXP2_DIC_MAX. */  input_bit_counter=8;       /* Attention: Possible values: 1 to EXP2_DIC_MAX-1                                (usually, for pictures, set up to 1, or 4, or 8, in the case                                of monochrome, or 16-colors, or 256-colors picture). */  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]);             }             exit(BAD_MEM_ALLOC);           }        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;}void init_dictionary2()/* Returned parameters: None.   Action: Initialization of the dictionary during the encoding.   Errors: None.*/{ register unsigned int i;  for (i=0;i<index_dic_max;i++)      { PLEFT_DIC_VAL(dictionary[i])=NULL;        PRIGHT_DIC_VAL(dictionary[i])=NULL;      }  index_dic=end_information_code+1;  bit_counter_encoding=bit_counter_min_encoding;}void remove_dictionary()/* Returned parameters: None.   Action: Removes the dictionary used for the decoding from the dynamical memory.   Errors: None.*/{ register unsigned int i;  for (i=0;(i<index_dic_max)&&(dictionary[i]!=NULL);i++)      free(dictionary[i]);}p_dic_val find_node(current_node,symbol)/* Returned parameters: Returns a node in the tree of the dictionary.   Action: Looks for 'symbol' from 'current_node'.   This research is made from the left pointer of 'current_node'   (if the left pointer wasn't equal to NULL) and then move to all the right   pointers until we reach the node containing 'symbol' or the last node which   right pointer is NULL.   Errors: If the symbol has not been found out, (current_node=returned node) or (CHAR_DIC_VAL(returned node)#symbol).   The 'current_node' given to this routine must never be equal to NULL.*/p_dic_val current_node;unsigned int symbol;{ p_dic_val new_node;  if (PLEFT_DIC_VAL(current_node)==NULL)     return current_node;  else { new_node=PLEFT_DIC_VAL(current_node);         while ((CHAR_DIC_VAL(new_node)!=symbol)&&(PRIGHT_DIC_VAL(new_node)!=NULL))               new_node=PRIGHT_DIC_VAL(new_node);         return new_node;       }}void add_node(current_node,new_node,symbol)/* Returned parameters: None.   Action: Creates a new_node in the tree of dictionary.   The summoning of this routine is normally done after a call to to find_node.   Errors: None.*/p_dic_val current_node,new_node;unsigned int symbol;{ if (dictionary[index_dic]==NULL)     { if ((dictionary[index_dic]=(p_dic_val)malloc(sizeof(t_dic_val)))==NULL)          { remove_dictionary();            exit(BAD_MEM_ALLOC);          }       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 (index_dic==(1 << bit_counter_encoding))     bit_counter_encoding++;}#define dictionary_sature()  (index_dic==index_dic_max)void write_code_lr(value)/* Returned parameters: None.   Action: Sends the value coded on 'bit_counter_encoding' bits in the stream of output codes.   The bits are stored from right to left. 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 ? ? ? ? ?   Errors: An input/output error could disturb the running of the program.*/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);        }}void complete_encoding_lr()/* Returned parameters: None.   Action: Adds 0-bits to the last byte to write, if any.   This procedure is to be considered with the procedure write_code_lr.   Errors: An input/output error could disturb the running of the program.*/{ 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;}void write_code_rl(value)/* Returned parameters: None.   Action: Sends the value coded on 'bit_counter_encoding' bits in the stream of output codes.   The bits are stored from right to left. Example: aaabbbbcccc is written:   Bits     7 6 5 4 3 2 1 0   Byte 1   c b b b b a a a   Byte 2   ? ? ? ? ? c c c   Errors: An input/output error could disturb the running of the program.*/unsigned int value;{ val_to_write |= ((unsigned long int)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);        }}void complete_encoding_rl()/* Returned parameters: None.   Action: Adds 0-bits to the last byte to write, if any.   This procedure is to be considered with the procedure write_code_rl.   Errors: An input/output error could disturb the running of the program.*/{ if (bit_counter_to_write>0)     write_byte((unsigned char)val_to_write);  val_to_write=bit_counter_to_write=0;}unsigned int read_input()/* Returned parameters: None.   Action: Reads input_bit_counter via the function 'read_byte'.   Errors: An input/output error could disturb the running of the program.*/{ 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())void lzwencoding()/* Returned parameters: None.   Action: Compresses with LZW method all bytes read by the function 'read_input'.   Errors: An input/output error could disturb the running of the program.*/{ 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();     }}void aide()/* Returned parameters: None.   Action: Displays the help of the program and then stops its running.   Errors: None.*/{ printf("This utility enables you to compress a file by using LZW method\n");  printf("as given 'La Video et Les Imprimantes sur PC'\n");  printf("\nUse: codlzw source target\n");  printf("source: Name of the file to compress\n");  printf("target: Name of the compressed file\n");}int main(argc,argv)/* Returned parameters: Returns an error code (0=None).   Action: Main procedure.   Errors: Detected, handled and an error code is returned, if any.*/int argc;char *argv[];{ if (argc!=3)     { aide();       exit(BAD_ARGUMENT);     }  else if ((source_file=fopen(argv[1],"rb"))==NULL)          { aide();            exit(BAD_FILE_NAME);          }       else if ((dest_file=fopen(argv[2],"wb"))==NULL)               { aide();                 exit(BAD_FILE_NAME);               }            else { lzwencoding();                   fclose(source_file);                   fclose(dest_file);                 }  printf("Execution of codlzw completed.\n");  return (NO_ERROR);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜桃av一区二区三区电影| 国产欧美日韩精品一区| 亚洲综合色视频| 欧美亚男人的天堂| 夜夜嗨av一区二区三区四季av| 99国产精品视频免费观看| 亚洲欧美日韩精品久久久久| 日本久久一区二区三区| 亚洲最快最全在线视频| 欧美人xxxx| 国产精品一区二区你懂的| 国产精品久久久久一区二区三区| 91欧美激情一区二区三区成人| 亚洲大尺度视频在线观看| 欧美tickling网站挠脚心| 国产成人啪免费观看软件| 一区二区中文视频| 欧美精选一区二区| 国产不卡视频一区二区三区| 亚洲精品美腿丝袜| 日韩三级av在线播放| 国产激情视频一区二区在线观看| 亚洲精品日韩专区silk| 6080yy午夜一二三区久久| 国产福利精品一区| 亚洲欧美aⅴ...| 亚洲精品一区二区三区香蕉| 波多野洁衣一区| 日韩av电影免费观看高清完整版 | 日韩激情在线观看| 欧美精品一区二区蜜臀亚洲| 一本一道久久a久久精品 | 色综合久久久久| 亚洲成av人片一区二区| 国产免费成人在线视频| 欧美日韩一区二区欧美激情 | 欧美极品少妇xxxxⅹ高跟鞋 | 色综合天天综合给合国产| 日韩成人伦理电影在线观看| 久久久高清一区二区三区| 在线观看日韩一区| 福利一区在线观看| 日韩不卡一区二区三区| 亚洲欧洲国产专区| 国产亚洲人成网站| 9191成人精品久久| 成人免费av资源| 国产一区欧美二区| 亚欧色一区w666天堂| 中文字幕欧美激情一区| 日韩视频一区二区三区在线播放| 色哦色哦哦色天天综合| 国产成人综合在线| 久久99国产精品免费| 一区二区三区在线看| 中文字幕乱码一区二区免费| 欧美一区二区三区视频在线| 欧美在线视频你懂得| 成人一区二区三区视频在线观看 | 久久精品国产澳门| 亚洲国产精品久久一线不卡| 国产精品福利电影一区二区三区四区| 日韩欧美一区电影| 欧美日韩成人综合在线一区二区| 91亚洲午夜精品久久久久久| 岛国精品在线观看| 精品在线一区二区三区| 青青草精品视频| 日韩精品一级中文字幕精品视频免费观看 | 国产最新精品精品你懂的| 亚洲一区日韩精品中文字幕| 亚洲日本成人在线观看| 国产精品久久久久婷婷| 亚洲国产精品精华液2区45| 亚洲精品在线观| 26uuu另类欧美亚洲曰本| 精品久久久三级丝袜| 欧美videossexotv100| 精品国产电影一区二区| 精品区一区二区| 精品国产人成亚洲区| 精品久久一二三区| 国产免费久久精品| 亚洲欧洲日韩女同| 亚洲色图清纯唯美| 亚洲欧洲综合另类在线| 亚洲美女偷拍久久| 亚洲一区影音先锋| 日韩和欧美一区二区三区| 天天操天天综合网| 美女网站在线免费欧美精品| 蜜臀av亚洲一区中文字幕| 久久se精品一区二区| 国产一区二区三区电影在线观看| 国产精品18久久久久久久网站| 国产99久久久精品| 一本色道综合亚洲| 欧美自拍偷拍午夜视频| 欧美性猛交xxxx黑人交| 精品第一国产综合精品aⅴ| 精品国产91乱码一区二区三区| 久久综合色综合88| 国产精品视频一二| 伊人开心综合网| 日韩高清中文字幕一区| 国产精品伊人色| 色网综合在线观看| 欧美一区二区精美| 国产精品沙发午睡系列990531| 亚洲精品伦理在线| 蜜桃av一区二区| 懂色中文一区二区在线播放| 91久久精品一区二区三区| 欧美日本在线观看| 国产欧美一区二区三区在线看蜜臀| 中文字幕av一区二区三区高| 亚洲风情在线资源站| 国内精品视频666| 色综合 综合色| 欧美岛国在线观看| 亚洲精品日产精品乱码不卡| 美女脱光内衣内裤视频久久网站| 成人在线一区二区三区| 91精品欧美久久久久久动漫 | 中文一区一区三区高中清不卡| 亚洲综合激情另类小说区| 久久电影网站中文字幕| 色哟哟一区二区在线观看| 精品播放一区二区| 亚洲综合久久久| 成人小视频免费在线观看| 欧美一区二区私人影院日本| 国产精品女人毛片| 精品系列免费在线观看| 91久久精品日日躁夜夜躁欧美| 久久夜色精品国产噜噜av| 亚洲国产aⅴ成人精品无吗| 国产精品亚洲综合一区在线观看| 欧美日韩国产在线观看| 亚洲日本va在线观看| 国产电影精品久久禁18| 日韩精品最新网址| 午夜久久电影网| 91丝袜高跟美女视频| 国产亚洲成av人在线观看导航| 日本成人中文字幕| 欧美久久久久久久久中文字幕| 亚洲三级在线观看| 成人av资源网站| 久久一二三国产| 精品一区二区三区欧美| 欧美嫩在线观看| 亚洲小少妇裸体bbw| 97久久人人超碰| 国产精品国产三级国产普通话99| 国内不卡的二区三区中文字幕| 制服丝袜亚洲色图| 亚洲电影中文字幕在线观看| 99riav一区二区三区| 国产日韩精品一区| 国产精品1区二区.| 久久久精品日韩欧美| 国产综合久久久久影院| 精品国产乱码久久久久久1区2区| 美女免费视频一区| 欧美一级专区免费大片| 免费成人你懂的| 日韩午夜在线影院| 蜜桃视频在线一区| 精品久久久久一区| 国产麻豆日韩欧美久久| 久久久久久久综合日本| 国产尤物一区二区在线| 国产日韩精品一区| 播五月开心婷婷综合| 亚洲欧美综合另类在线卡通| 99视频超级精品| 一区二区三区在线观看视频| 欧美体内she精高潮| 日本少妇一区二区| 亚洲精品一区二区三区四区高清 | 成人激情校园春色| 亚洲欧洲三级电影| 欧美日韩一本到| 日韩高清不卡一区| 久久亚洲影视婷婷| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 国产精品久久一卡二卡| 99久久久久久99| 亚洲国产精品久久艾草纯爱| 91.麻豆视频| 国产一区在线看| 国产精品久久久久久久久搜平片| 91亚洲精品久久久蜜桃网站 | 91在线观看视频| 亚洲国产一区二区视频| 欧美一级二级三级乱码| 国产69精品久久久久毛片 | 同产精品九九九| 久久婷婷国产综合国色天香|