Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!unhd.unh.edu!msel.unh.edu!rg From: rg@msel.unh.edu (Roger Gonzalez) Newsgroups: comp.graphics Subject: I'm writing a GIF encoder and have a couple questions Message-ID: <1991Apr8.183350.19982@unhd.unh.edu> Date: 8 Apr 91 18:33:50 GMT Sender: usenet@unhd.unh.edu (USENET News System) Organization: UNH Marine Systems Engineering Laboratory Lines: 37 Nntp-Posting-Host: msel.unh.edu First, I have RTFMed several places, and haven't gotten satisfactory explainations to a couple things: 1) The compressed codes are supposed to be prefixed by a length byte. Looking at a hex dump of a file implies to me that a value of 255 for the length means 1 byte of length, plus 254 bytes of compressed codestream. This wasn't clear in any places that I read. Now, does this mean that for the zero-length code block to be written right before the end, the value written should be 0x01? Everything else seemed to imply writing 0x00. 2) What is a good way to optimize the search process? My string table is struct {int prefix; uchar pixel}, so I always start searches at index current_prefix + 1. I quickly grew tired of waiting for this, so I temporarily (#ifdef-ed) have an array of 1048576 ints (4096 * 256) stored as lookup[pixel + (prefix<<8)]. In other words, if lookup[] is not -1, then it is the index number corresponding to the prefix/pixel combo used to address it. I'd like to come up with some sort of hash table to act as middle ground (actually, the program is still slow even with the lookup table, probably since I'm using VM instead of physical 3) Contrary to the -opinion- voiced in the FAQ, there are MANY times when one WOULD want to write an encoder for format X. Primary among them is when you have a strange piece of hardware that you want to use for your imaging. In my case, its a Datacube boardset. Thus, please no flames about why I'm bothering to write a GIF program at all. Thanks for any advice! -Roger -- "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim" - Edsgar W. Dijkstra rg@[msel|unhd].unh.edu | UNH Marine Systems Engineering Laboratory r_gonzalez@unhh.bitnet | Durham, NH 03824-3525