Re: [libredwg] LZ77 Compression

2012-11-19 Thread Till Heuschmann
Hi Dave,

unfortunately I have no experience in using Eclipse. Try not to load the 
executable but to load the source and compile it with Eclipse. I use MS Visual 
Studio Express to compile LibreDWG on Windows. In order to compile with VS some 
minor changes are necessary. If you are interested I can send it to you. In the 
case that you are using Linux maybe someone else could tell how it works.

Regards
Till  

Am 17.11.2012 um 22:31 schrieb Dave Coventry:

> Hi Till,
> 
> On 14 September 2012 21:51, Till Heuschmann  
> wrote:
>> have you run the function step by step in a debugger?
> 
> I'm trying to run the function in a debugger.
> 
> I've installed Eclipse and Netbeans but am unable to load an
> executable to run in the debugger.
> 
> Do you know of anywhere I can get instructions on how to do this?
> 
> Kind regards,
> 
> Dave
> 




Re: [libredwg] LZ77 Compression

2012-11-17 Thread Dave Coventry
Hi Till,

On 14 September 2012 21:51, Till Heuschmann  wrote:
> have you run the function step by step in a debugger?

I'm trying to run the function in a debugger.

I've installed Eclipse and Netbeans but am unable to load an
executable to run in the debugger.

Do you know of anywhere I can get instructions on how to do this?

Kind regards,

Dave



Re: [libredwg] LZ77 Compression

2012-10-11 Thread Dave Coventry
Hi Till,

Just to clarify what's confusing me:

Here is case 15: (line 244, decode_r2007.c)

case 15:
  copy_2(13);
  copy_4(9);
  copy_8(1);
  copy_1(0);
  break;

If I start out with the following src array:
src=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
and an empty dst array, the dst array gets populated thus:


copy_2(13);
dst=[14,13]

copy_4(9);
dst=[14,13,9,10,11,12]

copy_8(1);
dst=[14,13,9,10,11,12,1,2,3,4,5,6,7,8]

copy_1(0);
dst=[14,13,9,10,11,12,1,2,3,4,5,6,7,8,0]

Are you sure that's how it works?

Or have I misread the C++ code?

Many thanks,

Dave Coventry



Re: [libredwg] LZ77 Compression

2012-10-09 Thread Dave Coventry
Hi Till,

Thanks for the assistance.

I'm battling to understand it.

On 14 September 2012 21:51, Till Heuschmann  wrote:
> have you run the function step by step in a debugger?

Well, I've been following the code as best I can.

If I go to the copy_compressed_bytes function, I see copy_16(16);
Which is a #defined macro
 #define copy_16(offset) \
dst = copy_bytes_16(dst, src + offset);

Which points to the function:
char*
copy_bytes_16(char *dst, char *src)
{
  *(uint64_t*)dst = *(uint64_t*)(src + 8);
  *(uint64_t*)(dst + 8) = *(uint64_t*)src;
  return dst + 16;
}

I'm trying to emulate this in Pascal and am battling to understand the pointers.

If I look at the function copy_compressed_bytes(char *dst, char *src,
int length) (in decode_r2007.c, line appox 173), I see case 6 (line
202) which copies the next 6 bytes from the src to the dst arrays, the
6th first, then bytes 2 to 5 in their correct order, followed by the
first byte. Is this correct?

Case 7 copies the 8th byte, followed by the 7th, then 2, 3, 4, 5
followed by the first byte.

Case 8 just copies the 8 bytes without changing the order.

I'm a little confused. :+?



Re: [libredwg] LZ77 Compression

2012-09-14 Thread Till Heuschmann
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
>