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)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)64 b(8)0 1371 y(9)104 b(Appendix:)13 b(Sample)f(code)23b(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)64 b(8)0 1548 y Fi(1)c(Intr)o(oduction)01683 y Fe(1.1)50 b(Purpose)0 1801 y Fk(The)11 b(purpose)f(of)i(this)e(speci\256cation)g(is)g(to)h(de\256ne)h(a)f(lossless)e(compressed)i(data)g(format)h(that:)68 1900 y Fh(\017)23 b Fk(Is)12b(independent)f(of)i(CPU)g(type,)g(operating)e(system,)i(\256le)g(system,)f(and)h(character)g(set,)g(and)f(hence)h(can)g(be)g(used)1141957 y(for)e(interchange;)68 2044 y Fh(\017)23 b Fk(Can)13b(be)f(produced)g(or)g(consumed,)h(even)g(for)f(an)h(arbitrarily)e(long)h(sequentially)e(presented)i(input)f(data)h(stream,)1142100 y(using)f(only)h(an)g Ff(a)h(priori)e Fk(bounded)g(amount)i(of)f(intermediate)h(storage,)f(and)h(hence)g(can)g(be)g(used)f(in)g(data)h(com-)114 2156 y(munications)c(or)i(similar)g(structures)f(such)h(as)g(Unix)f(\256lters;)68 2243 y Fh(\017)23 b Fk(Can)11 b(use)g(a)h(number)f(of)g(dif)o(ferent)g(compression)f(methods;)68 2330y Fh(\017)23 b Fk(Can)11 b(be)g(implemented)g(readily)g(in)g(a)g(manner)h(not)e(covered)h(by)g(patents,)g(and)g(hence)g(can)h(be)f(practiced)g(freely)m(.)0 2430 y(The)g(data)g(format)h(de\256ned)f(by)g(this)f(speci\256cation)g(does)h(not)f(attempt)h(to)f(allow)h(random)g(access)g(to)g(compressed)g(data.)0 2719 y(Deutsch)f(&)i(Gailly)612b(Informational)g([Page)12 b(2])p eop%%Page: 3 33 2 bop 0 46 a Fk(RFC)12 b(1950)374 b(ZLIB)12 b(Compressed)f(Data)g(Format)h(Speci\256cation)374 b(May)12 b(1996)0 195 yFe(1.2)50 b(Intended)12 b(audience)0 311 y Fk(This)f(speci\256cation)f(is)i(intended)e(for)i(use)f(by)h(implementors)f(of)g(software)h(to)f(compress)h(data)f(into)g(zlib)g(format)h(and/or)0 367y(decompress)f(data)g(from)h(zlib)e(format.)0 453 y(The)g(text)f(of)i(the)e(speci\256cation)g(assumes)h(a)h(basic)e(background)g(in)h(programming)g(at)g(the)g(level)f(of)h(bits)f(and)h(other)g(prim-)0509 y(itive)g(data)h(representations.)0 661 y Fe(1.3)50b(Scope)0 776 y Fk(The)13 b(speci\256cation)e(speci\256es)i(a)g(compressed)g(data)f(format)i(that)e(can)h(be)g(used)f(for)h(in-memory)g(compression)f(of)h(a)g(se-)0 833 y(quence)e(of)g(arbitrary)g(bytes.)0984 y Fe(1.4)50 b(Compliance)0 1100 y Fk(Unless)7 b(otherwise)h(indicated)f(below)m(,)h(a)h(compliant)e(decompressor)h(must)g(be)h(able)f(to)g(accept)h(and)f(decompress)g(any)g(data)01157 y(set)h(that)g(conforms)g(to)g(all)g(the)g(speci\256cations)f(presented)g(here;)i(a)g(compliant)e(compressor)h(must)g(produce)g(data)g(sets)g(that)0 1213 y(conform)i(to)g(all)g(the)g(speci\256cations)f(presented)g(here.)0 1365 y Fe(1.5)63b(De\256nitions)11 b(of)h(terms)h(and)f(conventions)f(used)01480 y Fk(byte:)j(8)d(bits)e(stored)h(or)h(transmitted)f(as)h(a)g(unit)f(\(same)h(as)g(an)g(octet\).)k(\(For)c(this)f(speci\256cation,)g(a)h(byte)g(is)f(exactly)g(8)h(bits,)0 1537 y(even)d(on)g(machines)h(which)e(store)h(a)h(character)g(on)f(a)h(number)f(of)h(bits)e(dif)o(ferent)h(from)h(8.\))15 b(See)9 b(below)m(,)f(for)h(the)f(numbering)01593 y(of)j(bits)f(within)g(a)h(byte.)0 1745 y Fe(1.6)50b(Changes)12 b(fr)o(om)h(pr)o(evious)f(versions)0 1861y Fk(V)-5 b(ersion)11 b(3.1)g(was)h(the)f(\256rst)g(public)g(release)h(of)f(this)g(speci\256cation.)k(In)d(version)e(3.2,)i(some)g(terminology)e(was)i(changed)0 1917 y(and)d(the)f(Adler)o(-32)h(sample)g(code)g(was)f(rewritten)h(for)g(clarity)m(.)14 b(In)9b(version)f(3.3,)i(the)e(support)g(for)h(a)g(preset)g(dictionary)e(was)0 1974 y(introduced,)j(and)h(the)g(speci\256cation)f(was)h(converted)g(to)g(RFC)h(style.)0 2147 y Fi(2)60 b(Detailed)13 b(speci\256cation)02281 y Fe(2.1)50 b(Overall)12 b(conventions)0 2396 yFk(In)f(the)g(diagrams)g(below)m(,)g(a)h(box)e(like)h(this:)1142482 y Fd(+---+)114 2538 y(|)82 b(|)27 b(<--)h(the)g(vertical)i(bars)e(might)h(be)f(missing)114 2594 y(+---+)0 2719 y Fk(Deutsch)10b(&)i(Gailly)612 b(Informational)g([Page)12 b(3])p eop%%Page: 4 44 3 bop 0 46 a Fk(RFC)12 b(1950)374 b(ZLIB)12 b(Compressed)f(Data)g(Format)h(Speci\256cation)374 b(May)12 b(1996)0 195 y(represents)f(one)g(byte;)f(a)h(box)g(like)g(this:)114 282 y Fd(+==============)q(+)114339 y(|)382 b(|)114 395 y(+==============)q(+)0 482 yFk(represents)11 b(a)g(variable)g(number)g(of)g(bytes.)0569 y(Bytes)g(stored)g(within)f(a)i(computer)f(do)g(not)g(have)h(a)g(\252bit)f(order)r(\272,)g(since)h(they)f(are)h(always)f(treated)g(as)h(a)g(unit.)j(However)n(,)0 625 y(a)d(byte)f(considered)f(as)i(an)g(integer)e(between)i(0)f(and)g(255)g(does)g(have)h(a)f(most-)h(and)f(least-signi\256cant)e(bit,)j(and)f(since)g(we)0 682y(write)f(numbers)g(with)f(the)h(most-signi\256cant)e(digit)h(on)g(the)h(left,)h(we)f(also)g(write)g(bytes)f(with)g(the)h(most-signi\256cant)e(bit)i(on)0 738 y(the)h(left.)16 b(In)11 b(the)g(diagrams)h(below)m(,)f(we)g(number)h(the)f(bits)f(of)h(a)h(byte)f(so)g(that)g(bit)f(0)i(is)e(the)i(least-signi\256cant)d(bit,)i(i.e.,)h(the)0 795y(bits)e(are)i(numbered:)114 882 y Fd(+--------+)114938 y(|76543210|)114 995 y(+--------+)0 1082 y Fk(W)n(ithin)g(a)h(computer)n(,)h(a)f(number)h(may)f(occupy)g(multiple)e(bytes.)20b(All)13 b(multi-byte)e(numbers)i(in)g(the)f(format)i(described)01138 y(here)9 b(are)g(stored)f(with)f(the)h(MOST)l(-signi\256cant)f(byte)h(\256rst)h(\(at)f(the)g(lower)h(memory)g(address\).)14b(For)8 b(example,)i(the)e(decimal)0 1195 y(number)j(520)g(is)f(stored)h(as:)223 1282 y Fd(0)136 b(1)114 1338 y(+--------+-----)q(---)q(+)1141395 y(|00000010|00001)q(000)q(|)114 1451 y(+--------+-----)q(---)q(+)141 1507 y(\303)218 b(\303)141 1564 y(|)g(|)141 1620y(|)g(+)28 b(less)g(significant)j(byte)d(=)f(8)141 1677y(+)g(more)i(significant)h(byte)e(=)g(2)g(x)f(256)0 1832y Fe(2.2)50 b(Data)12 b(format)0 1949 y Fk(A)f(zlib)g(stream)g(has)g(the)g(following)e(structure:)168 2036 y Fd(0)82 b(1)1142093 y(+---+---+)114 2149 y(|CMF|FLG|)i(\(more-->\))1142206 y(+---+---+)0 2293 y Fk(\(if)11 b(FLG.FDICT)h(set\))1682380 y Fd(0)82 b(1)g(2)g(3)114 2436 y(+---+---+---+--)q(-+)1142493 y(|)136 b(DICTID)111 b(|)82 b(\(more-->\))114 2549y(+---+---+---+--)q(-+)0 2719 y Fk(Deutsch)10 b(&)i(Gailly)612b(Informational)g([Page)12 b(4])p eop%%Page: 5 55 4 bop 0 46 a Fk(RFC)12 b(1950)374 b(ZLIB)12 b(Compressed)f(Data)g(Format)h(Speci\256cation)374 b(May)12 b(1996)114 195y Fd(+==============)q(===)q(====)q(+---)q(+--)q(-+--)q(-+--)q(-+)114252 y(|...compressed)31 b(data...|)111 b(ADLER32)g(|)114308 y(+==============)q(===)q(====)q(+---)q(+--)q(-+--)q(-+--)q(-+)0407 y Fk(Any)11 b(data)g(which)f(may)i(appear)f(after)h(ADLER32)e(are)i(not)f(part)g(of)g(the)g(zlib)f(stream.)11 506 y Fc(CMF)h(\(Compr)o(ession)g(Method)h(and)f(\257ags\))114 582 y Fk(This)h(byte)g(is)g(divided)g(into)g(a)h(4-bit)f(compression)g(method)h(and)f(a)i(4-bit)e(information)f(\256eld)i(depending)f(on)g(the)114 639y(compression)e(method.)214 733 y Fd(bits)28 b(0)g(to)f(3)55b(CM)137 b(Compression)30 b(method)214 790 y(bits)e(4)g(to)f(7)55b(CINFO)h(Compression)30 b(info)11 885 y Fc(CM)11 b(\(Compr)o(ession)g(method\))114 961 y Fk(This)h(identi\256es)h(the)h(compression)e(method)i(used)f(in)g(the)h(\256le.)23 b(CM)15 b(=)f(8)f(denotes)g(the)h(\252de\257ate\272)g(compression)114 1018 y(method)d(with)g(a)i(window)d(size)i(up)g(to)f(32K.)h(This)f(is)h(the)g(method)f(used)h(by)f(gzip)h(and)g(PNG)g(\(see)g(references)h([1])114 1074y(and)f([2])g(in)g(Chapter)h(3,)g(below)m(,)f(for)g(the)h(reference)g(documents\).)18 b(CM)13 b(=)g(15)f(is)f(reserved.)19b(It)13 b(might)e(be)i(used)f(in)114 1131 y(a)h(future)f(version)g(of)h(this)f(speci\256cation)f(to)i(indicate)f(the)g(presence)h(of)g(an)g(extra)g(\256eld)g(before)g(the)f(compressed)114 1187y(data.)11 1274 y Fc(CINFO)f(\(Compr)o(ession)g(info\))1141350 y Fk(For)d(CM)h(=)e(8,)i(CINFO)g(is)e(the)h(base-2)f(logarithm)g(of)h(the)g(LZ77)f(window)f(size,)j(minus)e(eight)g(\(CINFO=7)h(indicates)114 1407 y(a)13 b(32K)g(window)g(size\).)22b(V)-5 b(alues)13 b(of)g(CINFO)h(above)f(7)h(are)g(not)f(allowed)f(in)h(this)g(version)f(of)i(the)f(speci\256cation.)114 1463y(CINFO)e(is)g(not)f(de\256ned)i(in)e(this)g(speci\256cation)h(for)g(CM)h(not)e(equal)h(to)g(8.)11 1550 y Fc(FLG)h(\(FLaGs\))1141627 y Fk(This)e(\257ag)h(byte)g(is)g(divided)e(as)j(follows:)2141721 y Fd(bits)28 b(0)g(to)f(4)55 b(FCHECK)h(\(check)29b(bits)g(for)f(CMF)g(and)g(FLG\))214 1778 y(bit)55 b(5)191b(FDICT)83 b(\(preset)30 b(dictionary\))214 1834 y(bits)e(6)g(to)f(7)55b(FLEVEL)h(\(compression)31 b(level\))114 1929 y Fk(The)8b(FCHECK)h(value)f(must)g(be)h(such)f(that)g(CMF)i(and)e(FLG,)h(when)f(viewed)g(as)h(a)g(16-bit)e(unsigned)g(integer)h(stored)1141986 y(in)i(MSB)j(order)e(\(CMF*256)g(+)g(FLG\),)h(is)f(a)g(multiple)f(of)h(31.)11 2072 y Fc(FDICT)g(\(Pr)o(eset)h(dictionary\))1142149 y Fk(If)d(FDICT)g(is)g(set,)g(a)g(DICT)g(dictionary)e(identi\256er)i(is)f(present)g(immediately)g(after)i(the)e(FLG)h(byte.)14 b(The)9 b(dictionary)114 2205 y(is)k(a)i(sequence)f(of)g(bytes)f(which)h(are)h(initially)d(fed)i(to)g(the)g(compressor)f(without)g(producing)f(any)i(compressed)114 2262 y(output.)23 b(DICT)15b(is)f(the)g(Adler)o(-32)g(checksum)g(of)h(this)e(sequence)h(of)h(bytes)f(\(see)g(the)h(de\256nition)e(of)h(ADLER32)1142318 y(below\).)h(The)d(decompressor)f(can)g(use)h(this)e(identi\256er)h(to)g(determine)g(which)g(dictionary)f(has)h(been)g(used)g(by)g(the)114 2375 y(compressor)n(.)11 2461 y Fc(FLEVEL)i(\(Compr)o(ession)d(level\))114 2538 y Fk(These)j(\257ags)g(are)h(available)f(for)g(use)h(by)f(speci\256c)g(compression)f(methods.)21 b(The)14b(\252de\257ate\272)g(method)f(\(CM)h(=)f(8\))114 2594y(sets)d(these)h(\257ags)g(as)g(follows:)0 2719 y(Deutsch)f(&)i(Gailly)612 b(Informational)g([Page)12 b(5])p eop%%Page: 6 66 5 bop 0 46 a Fk(RFC)12 b(1950)374 b(ZLIB)12 b(Compressed)f(Data)g(Format)h(Speci\256cation)374 b(May)12 b(1996)214 195y Fd(0)27 b(-)h(compressor)i(used)e(fastest)h(algorithm)214252 y(1)e(-)h(compressor)i(used)e(fast)g(algorithm)214308 y(2)f(-)h(compressor)i(used)e(default)h(algorithm)214364 y(3)e(-)h(compressor)i(used)e(maximum)h(compression,)i(slowest)e(algorithm)114 460 y Fk(The)11 b(information)f(in)h(FLEVEL)f(is)h(not)g(needed)g(for)h(decompression;)d(it)i(is)g(there)g(to)g(indicate)g(if)g(recompression)114 516 y(might)f(be)h(worthwhile.)11603 y Fc(compr)o(essed)h(data)114 680 y Fk(For)j(compression)e(method)i(8,)g(the)g(compressed)f(data)h(is)f(stored)g(in)g(the)h(de\257ate)g(compressed)f(data)h(format)g(as)114 737 y(described)10b(in)h(the)g(document)g(\252DEFLA)-5 b(TE)10 b(Compressed)h(Data)h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -