#1 2020-12-07 15:36:10

jasglas
Member
Registered: 2020-12-07
Posts: 5

Android 64bits version of unit SynCrossPlatformSynLZ;

Good day,
I was busy with the CrossPlatform version of SynLZ (SynCrossPlatformSynLZ.pas)
And I came across a bug for the Android64 platform.
The PtrUInt is of version cardinal (which is a 32bits unsigned int) is not suited to hold a 64 bits pointer
I adjusted the compress and decompress procedures to work with android 64bits platform.
Are you interested in the adjusted source code?

Last edited by jasglas (2020-12-07 18:55:08)

Offline

#2 2020-12-07 16:51:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Android 64bits version of unit SynCrossPlatformSynLZ;

You are right.

It should be fixed by https://synopse.info/fossil/info/1d01ddf409

Offline

#3 2020-12-07 18:51:51

jasglas
Member
Registered: 2020-12-07
Posts: 5

Re: Android 64bits version of unit SynCrossPlatformSynLZ;

Thank you!

Offline

#4 2020-12-08 07:07:29

jasglas
Member
Registered: 2020-12-07
Posts: 5

Re: Android 64bits version of unit SynCrossPlatformSynLZ;

Hi again,

I've updated the revised version from Git and compiled it again.
But the function SynLZdecomp in file CrossPlatform\SynCrossPlatformSynLZ.pas has a pointer bug if you compile it in Android64.
You can fix it by changing like below.

original code:

function SynLZdecomp(src: pointer; size: cardinal; dst: pointer): cardinal;
var last_hashed, // initial src and dst value
    src_end: PtrUInt;
    CW, CWbit: cardinal;
   v, t, h, o:  cardinal;
    i: integer;
    offset: array[0..4095] of PtrUInt; // 16KB hashing code
label nextCW;
begin
  src_end := PtrUInt(src)+size;
.............

revised code:

function SynLZdecomp(src: pointer; size: cardinal; dst: pointer): cardinal;
var last_hashed, // initial src and dst value
    src_end: PtrUInt;
    CW, CWbit: cardinal;
   v, t, h, o:  PtrUInt;
    i: integer;
    offset: array[0..4095] of PtrUInt; // 16KB hashing code
label nextCW;
begin
  src_end := PtrUInt(src)+size;
.............

Thank you.

Offline

#5 2020-12-08 14:54:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Android 64bits version of unit SynCrossPlatformSynLZ;

You are right!
Please check https://synopse.info/fossil/info/e7da63acf8

Out of curiosity, what is the performance of this unit on Delphi Android?

Offline

#6 2020-12-09 06:16:24

jasglas
Member
Registered: 2020-12-07
Posts: 5

Re: Android 64bits version of unit SynCrossPlatformSynLZ;

Hi,

Thanks for the update.

Regarding the performance. I come from the Indy ZLib usage in Android.
And I see no obvious slower speeds.
But to know is to measure and I have not a test in place to compare the speed yet.

Offline

#7 2020-12-09 09:31:17

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Android 64bits version of unit SynCrossPlatformSynLZ;

It will compress less good than ZLib for sure, since it is a plain LZ algorithm, without Huffman encoding.
It should be faster - it is much faster than ZLib on Intel/AMD, especially the compression. But it will depend on the Delphi Android ARM compiler itself.

Offline

#8 2020-12-09 14:30:52

jasglas
Member
Registered: 2020-12-07
Posts: 5

Re: Android 64bits version of unit SynCrossPlatformSynLZ;

I'm not a compression expert but I know the basics.
As soon as Delphi has a build in assembler for ARM processors it should be possible to have a very fast compression for android as well, like for Intel/AMD.
I do like the open source in Mormot compared to Indy. It gives me confidense to know what's going on with the data.
Keep up the good work!

Offline

Board footer

Powered by FluxBB