Talk:LZW compression: Difference between revisions

Some help with this →‎C example problem
(→‎C example problem: new section)
(Some help with this →‎C example problem)
Line 60:
 
Again, terrible code. Depends on 4 other badly written files, so it's incovenient to test at least; doesn't actually compile after pulling all files together; after some quick fix (probably incorrectly, but I don't have the patience to wade through all the mess), program outputs garbage. By the look of it, the dictionary data structure is quite suboptimal, to put it lightly. --[[User:Ledrug|Ledrug]] 23:13, 5 August 2011 (UTC)
:I've added the following message to the C section. I was able to adapt this code to produce a GIF encoder seeing that it was nearly there. This is a specific variant of LZW that probably should have its own page on this wiki with a redirect at the top of this page. Unfortunately the code could use a complete rewrite, which I intend to do for myself, but I've no need for a decoder, and have already used C++ in my changes, so I must leave this as an exercise (for others to do for themself.) Furthermore I've noticed that one or two other languages on this page have adapted this C code (they would require repair as well.) As for a GIF-LZW encoder, it only implements 8bit color. GIF can also do 1~7 bit color. Just something to keep in mind. By "efficient" the comments probably mean how GIF uses a variable length code size that increases as the codes require more bits to be represented. I do not believe it's a commentary on its algorithm; although it looks fine to me (aside from being poorly worded.) ''I THINK it is an interesting example, because it's unlikely anyone would want an LZW encoder for anything other than GIF files, since other formats that use LZW are unlikely to be in use today. And no one would use LZW otherwise except to work with old files/systems!''
 
:'''WARNING: This code appears to have come from a GIF codec that has been modified to meet the requirements of this page, provided that the decoder works with the encoder to produce correct output. For writing GIF files the write_bits subroutine is wrong for Little Endian systems (it may be wrong for Big Endian as well.) The encoder also increases the number of bits in the variable length GIF-LZW after the N-2 code, whereas this must be done after N-1 to produce a working GIF file (just looking at the encoder, it's easy to see how this mistake could be made.)''' --[[User:Mick P.|Mick P.]] ([[User talk:Mick P.|talk]]) 03:17, 21 October 2015 (UTC)
Anonymous user