Difference between revisions of "Talk:Content.bin file structure"

From WiiBrew
Jump to navigation Jump to search
(LZ77 buffer problem)
 
Line 10: Line 10:
  
 
:01 02 01 02 01 XX XX XX when you reach the third byte, it's no longer past the end of the buffer, because you just copied 2 more bytes into it.
 
:01 02 01 02 01 XX XX XX when you reach the third byte, it's no longer past the end of the buffer, because you just copied 2 more bytes into it.
 +
 +
:: Actually, the problem is not this, but the fact that the algoritm requests things like 6 bytes of data from 2093 bytes back, as it very first request. To solve this would either need some kind of "initial buffer" of about 4 kB, or another way to interpret this kinds of requests. [[User:Magicus|Magicus]] 23:29, 29 February 2008 (PST)

Revision as of 09:29, 1 March 2008

"This code is NOT fully functional, because sometimes the algorithm request data not present in the buffer, and fills it with 'X' instead. Maybe someone can fix it, I think it's not difficult ;)"

I noticed this myself when writing a decompressor for a format similar to LZ77. Sometimes it will do things like request 8 bytes from only 2 bytes before the end of the buffer. This can be very difficult to emulate if you're decompressing file-to-file, but easy if you actually decompress to a buffer in RAM and then dump the buffer to disk. The trick is it ends up repeating those 2 bytes. To help visualize the process, imagine the contents of the buffer as you do this:

01 02 XX XX XX XX XX XX
01 02 01 XX XX XX XX XX copy first byte to end of buffer
01 02 01 02 XX XX XX XX copy second byte
01 02 01 02 01 XX XX XX when you reach the third byte, it's no longer past the end of the buffer, because you just copied 2 more bytes into it.
Actually, the problem is not this, but the fact that the algoritm requests things like 6 bytes of data from 2093 bytes back, as it very first request. To solve this would either need some kind of "initial buffer" of about 4 kB, or another way to interpret this kinds of requests. Magicus 23:29, 29 February 2008 (PST)