Ағылшыншамен салыстырыңыз: абзацты басыңыз — түпнұсқа терезеде ашылады. Абзац астындағы EN түймесі оны мәтін ішінде көрсетеді.
Мазмұны
Кіріспе
Lempel–Ziv–Welch (LZW) – Абрахам Лемпель, Джейкоб Зив және Терри Уэлч жасаған әмбебап жоғалмайтын деректерді сығу алгоритмі. Ол 1984 жылы Уэлч тарапынан Лемпель мен Зив 1978 жылы жариялаған LZ78 алгоритмінің жетілдірілген нұсқасы ретінде жарияланды. Алгоритмді іске асыру оңай және аппараттық іске асыруларда өте жоғары өнімділікке қол жеткізуге мүмкіндік береді. Бұл Unix жүйесіндегі файлдарды сығу құралының алгоритмі және GIF кескін форматында қолданылады.
Universal lossless data compression algorithm
Lempel–Ziv–Welch (LZW) is a universal lossless data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch. It was published by Welch in 1984 as an improved implementation of the LZ78 algorithm published by Lempel and Ziv in 1978. The algorithm is simple to implement and has the potential for very high throughput in hardware implementations. It is the algorithm of the Unix file compression utility compress and is used in the GIF image format.
Өзгермелі ендік кодтар
Егер өзгермелі ендік кодтар қолданылса, кодтаушы мен декодер кодталған деректерде енді бірдей нүктелерде өзгертуге сақ болуы керек, әйтпесе олар ағындағы жеке кодтар арасындағы шекараларда келіспеуі мүмкін. Стандартты нұсқада кодтаушы кестеде жоқ ω + s тізбесі кездескенде (оған код қосу қажет), бірақ кестедегі келесі қолжетімді код 2p (p + 1 бит қажет ететін бірінші код) болса, енін p-ден p + 1-ге дейін арттырады. Кодтаушы ω кодын ені p-де шығарады (өйткені бұл код p + 1 бит қажет етпейді), содан кейін кодтың енін ұлғайтады, нәтижесінде келесі шығарылатын кодтың ені p + 1 бит болады. Декодер кесте құруда әрқашан кодтаушыдан бір код қалып қояды, сондықтан ω кодын көрген кезде ол 2p − 1 коды үшін жазба жасайды. Бұл кодтаушының код енін арттыратын нүкте болғандықтан, декодер де осы жерде енді арттыруы керек – p битке сәйкес келетін ең үлкен кодты шығаратын сәтте. Алайда, кодтау алгоритмінің кейбір алғашқы нұсқалары код енін арттырып, содан кейін ω кодын ескі еннің орнына жаңа енде шығарды, бұл декодерге ен бір кодты ертерек өзгерткендей көрінеді. Бұл «ерте өзгерту» деп аталады; ол Adobe компаниясын PDF файлдарында екі нұсқаға да рұқсат беруге мәжбүр етті, бірақ әр LZW сығылған ағынының басында ерте өзгерту қолданылып жатса, оны көрсету үшін арнайы белгіні қосты. LZW сығылуын қолдайтын графикалық файл форматтарының ішінде TIFF ерте өзгертуді қолданады, ал GIF және көптеген басқалары қолданбайды. Кесте таза кодқа жауап ретінде тазартылғанда, кодтаушы мен декодер екі жақ та кодтың енін бастапқы енге қайтарады, таза кодтан кейін келетін кодтан бастап.
If variable width codes are being used, the encoder and decoder must be careful to change the width at the same points in the encoded data so they don't disagree on boundaries between individual codes in the stream. In the standard version, the encoder increases the width from p to p + 1 when a sequence ω + s is encountered that is not in the table (so that a code must be added for it) but the next available code in the table is 2p (the first code requiring p + 1 bits). The encoder emits the code for ω at width p (since that code does not require p + 1 bits), and then increases the code width so that the next code emitted is p + 1 bits wide. The decoder is always one code behind the encoder in building the table, so when it sees the code for ω, it generates an entry for code 2p − 1. Since this is the point where the encoder increases the code width, the decoder must increase the width here as well—at the point where it generates the largest code that fits in p bits. Unfortunately, some early implementations of the encoding algorithm increase the code width and then emit ω at the new width instead of the old width, so that to the decoder it looks like the width changes one code too early. This is called "early change"; it caused so much confusion that Adobe now allows both versions in PDF files, but includes an explicit flag in the header of each LZW compressed stream to indicate whether early change is being used. Of the graphics file formats that support LZW compression, TIFF uses early change, while GIF and most others don't. When the table is cleared in response to a clear code, both encoder and decoder change the code width after the clear code back to the initial code width, starting with the code immediately following the clear code.
Қаптау тәртібі
Шығарылатын кодтар әдетте байт шекараларына сәйкес келмейтіндіктен, кодтаушы мен декодер кодтардың байттарға қалай жинақталатыны туралы келісуі керек. Екі кең таралған әдіс бар: LSB бірінші («ең кіші маңызды бит бірінші») және MSB бірінші («ең үлкен маңызды бит бірінші»). LSB бірінші жинақтауда, бірінші кодтың ең кіші маңызды биті бірінші ағын байтының ең кіші маңызды битімен сәйкестендіріледі, ал егер код 8 биттен асатын болса, жоғары реттік биттер келесі байттың ең кіші маңызды биттерімен сәйкестендіріледі; ал келесі кодтар LSB арқылы ағымдағы ағын байтында әлі пайдаланылмаған ең кіші маңызды биттерге енгізіліп, қажет болған жағдайда келесі байттарға таратылады. MSB бірінші жинақтауда, бірінші кодтың ең үлкен маңызды биті бірінші ағын байтының MSB-сымен сәйкестендіріледі, ал артық биттер келесі байттың MSB-сымен сәйкестендіріледі; келесі кодтар MSB арқылы ағымдағы ағын байтында әлі пайдаланылмаған ең үлкен маңызды биттерге жазылады. GIF файлдары LSB бірінші жинақтау тәртібін қолданады. TIFF файлдары мен PDF файлдары MSB бірінші жинақтау тәртібін қолданады.
Since the codes emitted typically do not fall on byte boundaries, the encoder and decoder must agree on how codes are packed into bytes. The two common methods are LSB first ("least significant bit first") and MSB first ("most significant bit first"). In LSB first packing, the first code is aligned so that the least significant bit of the code falls in the least significant bit of the first stream byte, and if the code has more than 8 bits, the high order bits left over are aligned with the least significant bits of the next byte; further codes are packed with LSB going into the least significant bit not yet used in the current stream byte, proceeding into further bytes as necessary. MSB first packing aligns the first code so that its most significant bit falls in the MSB of the first stream byte, with overflow aligned with the MSB of the next byte; further codes are written with MSB going into the most significant bit not yet used in the current stream byte. GIF files use LSB first packing order. TIFF files and PDF files use MSB first packing order.
Қосымша кодтау
Жоғарыда сипатталған қарапайым схема LZW алгоритмінің өзіне назар аударады. Көптеген қолданбалар шығыс символдарының тізбегіне қосымша кодтау қолданады. Кейбір қолданбалар кодталған ағынды мәтіндік форматқа түрлендірудің әртүрлі әдістерін пайдаланып, басып шығаруға болатын символдар түрінде ұсынады; бұл кодталған мәліметтің көлемін арттырады және сығылу деңгейін төмендетеді. Керісінше, адаптивті энтропиялық кодтаушыны қолдану арқылы сығылуды арттыруға болады. Мұндай кодтаушы келесі символдың мәнінің ықтималдық таралуын, бұған дейін байқалған мәндердің жиілігіне сүйене отырып, бағалайды. Хаффман кодтау немесе арифметикалық кодтау сияқты стандартты энтропиялық кодтау, жоғары ықтималдығы бар мәндер үшін қысқа кодтарды пайдаланады.
The simple scheme described above focuses on the LZW algorithm itself. Many applications apply further encoding to the sequence of output symbols. Some package the coded stream as printable characters using some form of binary to text encoding; this increases the encoded length and decreases the compression rate. Conversely, increased compression can often be achieved with an adaptive entropy encoder. Such a coder estimates the probability distribution for the value of the next symbol, based on the observed frequencies of values so far. A standard entropy encoding such as Huffman coding or arithmetic coding then uses shorter codes for values with higher probabilities.
Қолданылуы
LZW компрессиясы компьютерлерде ең көп тараған алғашқы әмбебап деректерді қысу әдісі болды. Көлемді ағылшын мәтін файлы LZW арқылы әдетте бастапқы көлемінің жартысына дейін қысылуы мүмкін. LZW 1986 жылы Unix жүйелерінде дерлік стандартты құралға айналған, қоғамдық домендегі compress бағдарламасында қолданылды. Кейіннен ол LZW патентын бұзғаны және LZ77 негізіндегі DEFLATE алгоритмін пайдаланатын gzip қысудың жақсы нәтижелерін көрсеткені үшін көптеген таралымдардан жойылды, бірақ 2008 жылға дейін кем дегенде FreeBSD таралымына compress және uncompress кірген. Тағы да бірнеше танымал қысу құралдары LZW немесе оған ұқсас әдістерді қолданды. LZW 1987 жылы GIF кескін форматының құрамына енген кезде кеңінен таралды. Ол сондай-ақ TIFF және PDF файлдарында (қосымша опция ретінде) қолданылуы мүмкін. (LZW Adobe Acrobat бағдарламалық құралында болғанымен, Acrobat PDF файлдарындағы мәтіндік және түсті кестелерге негіделген кескін деректерінің көп бөлігі үшін әдепкі бойынша DEFLATE-ты қолданады.)
LZW compression became the first widely used universal data compression method on computers. A large English text file can typically be compressed via LZW to about half its original size. LZW was used in the public domain program compress, which became a more or less standard utility in Unix systems around 1986. It has since disappeared from many distributions, both because it infringed the LZW patent and because gzip produced better compression ratios using the LZ77 based DEFLATE algorithm, but as of 2008 at least FreeBSD includes both compress and uncompress as a part of the distribution. Several other popular compression utilities also used LZW or closely related methods. LZW became very widely used when it became part of the GIF image format in 1987. It may also (optionally) be used in TIFF and PDF files. (Although LZW is available in Adobe Acrobat software, Acrobat by default uses DEFLATE for most text and color table based image data in PDF files.)
Патенттер
LZW және ұқсас алгоритмдерге қатысты АҚШ-та және басқа да елдерде түрлі патенттер берілді. LZ78-ті Лемпель, Зив, Кохн және Истман жасады, ол Sperry Corporation, кейіннен Unisys Corporation компаниясына тиесілі болды және 1981 жылдың 10 тамызында тіркелді. LZW алгоритміне екі АҚШ патенті берілді: Виктор С. Миллер мен Марк Н. Вегманға, IBM компаниясына тиесілі, бастапқыда 1983 жылдың 1 маусымында және Уэлчқа, Sperry Corporation компаниясына, кейіннен Unisys Corporation компаниясына тиесілі, 1983 жылдың 20 маусымында. Жоғарыда аталған патенттерден басқа, Уэлчтің 1983 жылғы патентіне оған әсер еткен бірнеше басқа патенттерге де сілтемелер енгізілген, соның ішінде 1980 жылы NEC-тің Джун Канатсудан екі жапондық патент (JP9343880A және JP17790880A), (1974) Джон С. Хоернингтен, (1977) Клаус Э. Холцтен және 1981 жылы неміс патенті (DE19813118676) Карл Экхарт Хайнцтен. 1993–1994 жылдары және 1999 жылы Unisys Corporation GIF суреттерінде LZW үшін лицензиялық төлемдерді енгізуге тырысқанда кеңінен сынға ұшырады. 1993–1994 жылдардағы Unisys CompuServe дауы (CompuServe GIF форматын жасаған компания) Usenet-тегі comp.graphics талқысына «GIF форматын алмастыру туралы ойлар» деген тақырыпта әкелді, бұл өз кезегінде электрондық поштамен алмасуға және ақырында 1995 жылы патенттік шектеулерден бос Портативті желілік графикалық (PNG) файл форматын құруға әкелді. Unisys компаниясының LZW алгоритміне арналған АҚШ патенті 2003 жылдың 20 маусымында, тіркелгеннен 20 жыл өткен соң тоқтап қалды. Ұлыбритания, Франция, Германия, Италия, Жапония және Канадада тіркелген патенттердің мерзімі 2004 жылы аяқталды. – Сөздіктегі ең ұзын тізбекті іздеу («ағымдағы» сәйкестік); алдыңғы сәйкестік пен ағымдағы сәйкестіктің біріктірілуін сөздікке қосу. (Осылайша сөздік жазбалары жылдам өседі, бірақ бұл схеманы іске асыру әлдеқайда күрделі.) Миллер мен Вегман сөздік толған кезде жиі қолданылмайтын жазбаларды жоюды ұсынады. LZAP (1988, Джеймс Сторр) – LZMW модификациясы: сөздікке ағымдағы сәйкестікпен алдыңғы сәйкестіктің біріктірілуін ғана қосудың орнына, ағымдағы сәйкестіктің әрбір бастапқы қосымшасымен алдыңғы сәйкестіктің біріктірілуін қосыңыз («AP» – «барлық префикстер» дегенді білдіреді). Мысалы, егер алдыңғы сәйкестік «wiki» және ағымдағы сәйкестік «pedia» болса, онда LZAP кодері сөздікке 5 жаңа тізбек қосады: «wikip», «wikipe», «wikiped», «wikipedi» және «wikipedia», ал LZMW кодері тек «wikipedia» тізбегін ғана қосады. Бұл LZMW-нің күрделілігін азайтады, бірақ сөздікке көбірек жазбалар қосуға мүмкіндік береді. LZWL – LZW-дің буынға негізделген түрі.
Various patents have been issued in the United States and other countries for LZW and similar algorithms. LZ78 was covered by by Lempel, Ziv, Cohn, and Eastman, assigned to Sperry Corporation, later Unisys Corporation, filed on August 10, 1981. Two US patents were issued for the LZW algorithm: by Victor S. Miller and Mark N. Wegman and assigned to IBM, originally filed on June 1, 1983, and by Welch, assigned to Sperry Corporation, later Unisys Corporation, filed on June 20, 1983. In addition to the above patents, Welch's 1983 patent also includes citations to several other patents that influenced it, including two 1980 Japanese patents (JP9343880A and JP17790880A) from NEC's Jun Kanatsu, (1974) from John S. Hoerning, (1977) from Klaus E. Holtz, and a 1981 German patent (DE19813118676) from Karl Eckhart Heinz. In 1993–94, and again in 1999, Unisys Corporation received widespread condemnation when it attempted to enforce licensing fees for LZW in GIF images. The 1993–1994 Unisys CompuServe controversy (CompuServe being the creator of the GIF format) prompted a Usenet comp. graphics discussion Thoughts on a GIF replacement file format, which in turn fostered an email exchange that eventually culminated in the creation of the patent unencumbered Portable Network Graphics (PNG) file format in 1995. Unisys's US patent on the LZW algorithm expired on June 20, 2003, 20 years after it had been filed. Patents that had been filed in the United Kingdom, France, Germany, Italy, Japan and Canada all expired in 2004, – Searches input for the longest string already in the dictionary (the "current" match); adds the concatenation of the previous match with the current match to the dictionary. (Dictionary entries thus grow more rapidly; but this scheme is much more complicated to implement.) Miller and Wegman also suggest deleting low frequency entries from the dictionary when the dictionary fills up. LZAP (1988, by James Storer) – modification of LZMW: instead of adding just the concatenation of the previous match with the current match to the dictionary, add the concatenations of the previous match with each initial substring of the current match ("AP" stands for "all prefixes"). For example, if the previous match is "wiki" and current match is "pedia", then the LZAP encoder adds 5 new sequences to the dictionary: "wikip", "wikipe", "wikiped", "wikipedi", and "wikipedia", where the LZMW encoder adds only the one sequence "wikipedia". This eliminates some of the complexity of LZMW, at the price of adding more dictionary entries. LZWL is a syllable based variant of LZW.