
Thread
2003.03.26 12:02 "LZW and 4bit tiffs", by Carter John-jcarte01
Hi
I'm having great fun here trying to write a LZW decompression function.
I've pretty much stuck to the description given in section 13 of the tiff spec (v6) it goes more or less like so
- read in a compressed strip
- extract codes until EOI (257 dec) (keeping track of bit boundaries etc) the codes I'm getting out seem ok
I have 2 questions
- should the code you extract be in the table or at least if not in the table the index to where the next new string will be added,
- if statement 1 is false should the new string be written to location table[code] or should it be written to the first available free space in the table.
the reason i ask is that with the following sequence of code extractions and table additions i end up adding two strings of length 0 together ( malloc complains about this ).
thanks jc
code result
256 init table
153
258
259
260
261
262
87
173
203
247
251
268
269
270
383?
253 both strings = 0 length
265
272
275
240
274
276
113
265
274
280
276
250
283
277
399?
286 both strings = 0 length
271
277
289
269
111
257 EOI code
____________________________
John Carter
BSS O&M Development group,
Motorola,
Mahon Industrial Estate,
Cork.
Tel: +353 21 4807 637 (direct)
Fax: +353 21 4357635 ( reception )
Mobile: +353 86 3947920
Email <mailto:john.a.carter@motorola.com> www <http://www.cork.cig.mot.com/~jcarte01/> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Homer: There's 3 ways to do things, the right way, the wrong way, and the max power way.
Bart: isn't that the wrong way.
Homer: yea but faster.