/* deflate.c -- compress data using the deflation algorithm
* Copyright (C) 1995-2005 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
* ALGORITHM
*
* The "deflation" process depends on being able to identify portions
* of the input text which are identical to earlier input (within a
* sliding window trailing behind the input currently being processed).
*
* The most straightforward technique turns out to be the fastest for
* most input files: try all possible matches and select the longest.
* The key feature of this algorithm is that insertions into the string
* dictionary are very simple and thus fast, and deletions are avoided
* completely. Insertions are performed at each input character, whereas
* string matches are performed only when the previous match ends. So it
* is preferable to spend more time in matches to allow very fast string
* insertions and avoid deletions. The matching algorithm for small
* strings is inspired from that of Rabin & Karp. A brute force approach
* is used to find longer strings when a small match has been found.
* A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
* (by Leonid Broukhis).
* A previous version of this file used a more sophisticated algorithm
* (by Fiala and Greene) which is guaranteed to run in linear amortized
* time, but has a larger average cost, uses more memory and is patented.
* However the F&G algorithm may be faster for some highly redundant
* files if the parameter max_chain_length (described below) is too large.
*
* ACKNOWLEDGEMENTS
*
* The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
* I found it in 'freeze' written by Leonid Broukhis.
* Thanks to many people for bug reports and testing.
*
* REFERENCES
*
* Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
* Available in http://www.ietf.org/rfc/rfc1951.txt
*
* A description of the Rabin and Karp algorithm is given in the book
* "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
*
* Fiala,E.R., and Greene,D.H.
* Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
*
*/
/* @(#) $Id: deflate.c,v 1.4 2005/11/17 21:34:56 thetruecamper Exp $ */
#include "deflate.h"
const char deflate_copyright[] =
" deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
include such an acknowledgment, I would appreciate that you keep this
copyright string in the executable of your product.
*/
/* ===========================================================================
* Function prototypes.
*/
typedef enum {
need_more, /* block not completed, need more input or more output */
block_done, /* block flush performed */
finish_started, /* finish started, need only more output at next deflate */
finish_done /* finish done, accept no more input or output */
} block_state;
typedef block_state (*compress_func) OF((deflate_state *s, int flush));
/* Compression function. Returns the block state after the call. */
local void fill_window OF((deflate_state *s));
local block_state deflate_stored OF((deflate_state *s, int flush));
local block_state deflate_fast OF((deflate_state *s, int flush));
#ifndef FASTEST
local block_state deflate_slow OF((deflate_state *s, int flush));
#endif
local void lm_init OF((deflate_state *s));
local void putShortMSB OF((deflate_state *s, uInt b));
local void flush_pending OF((z_streamp strm));
local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
#ifndef FASTEST
#ifdef ASMV
void match_init OF((void)); /* asm code initialization */
uInt longest_match OF((deflate_state *s, IPos cur_match));
#else
local uInt longest_match OF((deflate_state *s, IPos cur_match));
#endif
#endif
local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
#ifdef DEBUG
local void check_match OF((deflate_state *s, IPos start, IPos match,
int length));
#endif
/* ===========================================================================
* Local data
*/
#define NIL 0
/* Tail of hash chains */
#ifndef TOO_FAR
# define TOO_FAR 4096
#endif
/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
/* Minimum amount of lookahead, except at the end of the input file.
* See deflate.c for comments about the MIN_MATCH+1.
*/
/* Values for max_lazy_match, good_match and max_chain_length, depending on
* the desired pack level (0..9). The values given below have been tuned to
* exclude worst case performance for pathological files. Better values may be
* found for specific files.
*/
typedef struct config_s {
ush good_length; /* reduce lazy search above this match length */
ush max_lazy; /* do not perform lazy search above this match length */
ush nice_length; /* quit search above this match length */
ush max_chain;
compress_func func;
} config;
#ifdef FASTEST
local const config configuration_table[2] = {
/* good lazy nice chain */
/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */
#else
local const config configuration_table[10] = {
/* good lazy nice chain */
/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
/* 2 */ {4, 5, 16, 8, deflate_fast},
/* 3 */ {4, 6, 32, 32, deflate_fast},
/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
/* 5 */ {8, 16, 32, 32, deflate_slow},
/* 6 */ {8, 16, 128, 128, deflate_slow},
/* 7 */ {8, 32, 128, 256, deflate_slow},
/* 8 */ {32, 128, 258, 1024, deflate_slow},
/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
#endif
/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
* For deflate_fast() (levels <= 3) good is ignored and lazy has a different
* meaning.
*/
#define EQUAL 0
/* result of memcmp for equal strings */
#ifndef NO_DUMMY_DECL
struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
#endif
/* ===========================================================================
* Update a hash value with the given input byte
* IN assertion: all calls to to UPDATE_HASH are made with consecutive
* input characters, so that a running hash key can be computed from the
* previous key instead of complete recalculation each time.
*/
#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
/* ===========================================================================
* Insert string str in the dictionary and set match_head to the previous head
* of the hash chain (the most recent string with same hash key). Return
* the previous length of the hash chain.
* If this file is compiled with -DFASTEST, the compression level is forced
* to 1, and no hash chains are maintained.
* IN assertion: all calls to to INSERT_STRING are made with consecutive
* input characters and the first MIN_MATCH bytes of str are valid
* (except for the last MIN_MATCH-1 bytes of the input file).
*/
#ifdef FASTEST
#define INSERT_STRING(s, str, match_head) \
(UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
match_head = s->head[s->ins_h], \
s->head[s->ins_h] = (Pos)(str))
#else
#define INSERT_STRING(s, str, match_head) \
(UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共838个文件
h:433个
cpp:205个
c:96个
开放式架构: 采用标准C++实现,支持Windows,Unix-like 操作系统; 实验和工程的通用平台,不仅是一个检索系统,同时也是一个全文索引和检索框架 多个组件基于插件设计,不仅可以采用C/C++对系统进行扩展,也可以通过内置的跨平台COM库设计COM组件来扩展系统 。 功能: 支持增量索引,差量索引,多字段索引,提供了3种前向索引方式; 支持纯文本,HTML,PDF等文件格式; 提供快速中文分词; 从底层到高层,提供了多种索引访问接口,灵活自由地使用索引文件; 提供丰富的检索语法,支持多字段检索,日期范围检索,检索结果自定义排序等。 性能: 在Pentium 4 2.8G 2GRAM的机器上超过200Mb每分钟的索引速度 在近7G的索引文件(100G网页,11G纯文本的索引)上检索,仅使用十几M内存在数毫秒内返回查询结果; 支持Tb数量级的文本索引和检索 灵活性: 对于简单的使用者: 直接提供了多种文件格式解析器(HTML,PDF,WORD等); 系统采用类似于XML格式的配置文件,可以根据数据集和机器配置情况,灵活配置整个系统,无需编写代码。 对于研究人员: 提供了TREC文档集解析器; 检索模型易于扩展; 提供了3种前向索引方式,可以直接用来做文本分类、聚类,摘要等 实验; 对于开发者: 系统各组成部分耦合性低,从应用层模块到系统核心层模块,均可单独修改、升级或替换;扩展既可以在源代码上直接进行,也可以使用非C/C++语言通过COM组件扩展
资源推荐
资源详情
资源评论
收起资源包目录
firtex-1.0.3_RC_src.tar(Linux版本源代码) (838个子文件)
Makefile.am 5KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 1KB
Makefile.am 814B
Makefile.am 735B
Makefile.am 731B
Makefile.am 725B
Makefile.am 493B
Makefile.am 488B
Makefile.am 422B
Makefile.am 388B
Makefile.am 382B
Makefile.am 360B
Makefile.am 333B
Makefile.am 319B
Makefile.am 223B
Makefile.am 191B
Makefile.am 170B
Makefile.am 126B
gvmat32.asm 27KB
inffas32.asm 16KB
AUTHORS 19B
logo.bmp 70KB
Toolbar.bmp 478B
deflate.c 64KB
HTHost.c 50KB
unzip.c 50KB
inflate.c 49KB
stem_UTF_8_french.c 49KB
stem_ISO_8859_1_french.c 48KB
trees.c 44KB
stem_UTF_8_hungarian.c 42KB
stem_UTF_8_spanish.c 42KB
HTReqMan.c 42KB
stem_ISO_8859_1_hungarian.c 42KB
stem_ISO_8859_1_spanish.c 41KB
stem_UTF_8_italian.c 41KB
stem_UTF_8_english.c 40KB
stem_ISO_8859_1_italian.c 40KB
stem_UTF_8_portuguese.c 39KB
stem_ISO_8859_1_english.c 39KB
stem_ISO_8859_1_portuguese.c 38KB
zip.c 38KB
HTAnchor.c 37KB
HTNet.c 35KB
gzio.c 31KB
HTMLPDTD.c 27KB
stem_UTF_8_finnish.c 27KB
HTBTree.c 26KB
stem_UTF_8_porter.c 26KB
stem_ISO_8859_1_finnish.c 26KB
stem_UTF_8_russian.c 26KB
HTFormat.c 25KB
stem_ISO_8859_1_porter.c 25KB
stem_KOI8_R_russian.c 24KB
HTWWWStr.c 24KB
infback.c 22KB
HTTCP.c 22KB
stem_UTF_8_dutch.c 22KB
stem_ISO_8859_1_dutch.c 21KB
SGML.c 21KB
HTML.c 19KB
HTInet.c 18KB
stem_UTF_8_german.c 18KB
stem_ISO_8859_1_german.c 17KB
HTTeXGen.c 17KB
HTParse.c 16KB
HTResponse.c 15KB
inftrees.c 14KB
HTChannl.c 14KB
crc32.c 13KB
HTMLGen.c 13KB
inffast.c 13KB
utilities.c 12KB
HTMethod.c 12KB
stem_UTF_8_danish.c 12KB
stem_ISO_8859_1_danish.c 11KB
stem_UTF_8_swedish.c 11KB
stem_ISO_8859_1_swedish.c 11KB
HTUTree.c 11KB
HTDNS.c 11KB
stem_UTF_8_norwegian.c 10KB
stem_ISO_8859_1_norwegian.c 10KB
HTTimer.c 9KB
HTUU.c 8KB
zutil.c 7KB
HTLink.c 7KB
iowin32.c 7KB
HTList.c 6KB
HTAlert.c 6KB
HTString.c 6KB
HText.c 6KB
HTError.c 6KB
HTChunk.c 6KB
HTLib.c 5KB
HTProt.c 5KB
共 838 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
- bluecll2012-09-22很难得的资源,不过下了几次都失败。。。
VostroStar
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功