[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libredwg] LZ77 Compression
From: |
Till Heuschmann |
Subject: |
Re: [libredwg] LZ77 Compression |
Date: |
Fri, 14 Sep 2012 21:51:10 +0200 |
Hi Dave,
have you run the function step by step in a debugger?
Length is 2 and src points to the 0x0 after the 0x2 (which was used as length)
The next function of interest is copy_compressed_bytes(dst, src, length) where
two bytes (in your case 0x0 and 0x70) are copied from the location where src
points to to the location where dst points to.
Afterwards the pointers dst and src are moved two bytes forward to point behind
the just copied bytes (src += length).
It's hard to explain in one sentence.
Am 12.09.2012 um 20:17 schrieb Dave Coventry:
> Can someone assist me on decoding LZ77 compression?
>
> I am trying to read a 2007 dwg file.
>
> I have extracted the header information at address 0x80 and have
> selected every third byte which I have stored in a data array.
>
> The array has the following information beginning at byte 32:
>
> 0x20,0x0,0x0,0x2,0x0,0x70,0x60,0x2,0xA6,0xA0,0x67,0x0,0x1,0xA6,0x15,0xED,0x7D,0x6D,0x62,0xE6,0x9,0x7F,0x77,0x8,0x2,0x4,
> ...
>
> Reading the sourcecode decode_r2007.c:
>
> unsigned char opcode = *src++;
>
> if ((opcode & 0xf0) == 0x20)
> {
> src += 2;
> length = *src++ & 0x07;
>
> if (length == 0)
> return 1;
> }
>
> opcode is indeed 0x20, and length is 2.
>
> But where to next? I suppose I'm a little confused by the pointer
> programming, and I can't work out the process.
>
> Thank you,
>
> Dave Coventry
>