| lzw压缩算法的c语言实现 |
|
|
|
|
| 来源: 作者: 添加日期:2006-7-17 6:53:04 点击次数: |
|
{ if( !in_table(lzw) ) { // current code not in code table // then add it to table and output prefix
insert_table(lzw); prefix = lzw->suffix; output_code( lzw->prefix ,out ,lzw ); lzw->code++;
if( lzw->code == (WORD)1<< lzw->cur_code_len ) { // code reached current code top(1<<cur_code_len) // then current code length add one lzw->cur_code_len++; if( lzw->cur_code_len == CODE_LEN + 1 ) { re_init_lzw( lzw ); }
} } else { // current code already in code table // then output nothing prefix = get_code(lzw);
} lzw->prefix = prefix; lzw->suffix = in->lp_buffer[ in->index++ ]; } }
//------------------------------------------------------------------------------ VOID encode(HANDLE h_sour,HANDLE h_dest) { LZW_DATA lzw; BUFFER_DATA in ; BUFFER_DATA out; BOOL first_run = TRUE;
lzw_create( &lzw ,h_sour,h_dest ); |
|
| |