I took a look through the source and found LzmaLib.c/LzmaLib.h, which appear to contain the compress/decompress functions I'd need.
I'm working on a Zynq FPGA's Processing Subsystem (So an ARM Cortex A9). I also took the LzmaUtils in lzma1604\C\Util\Lzma, and compiled it as an x86 project with both MSYS2 using make -f makefile.gcc and, separately, as an Eclipse project so I could easily debug what was going on easier.
It looks like header bytes 5,6, and 7 encode the final size, and I can easily have the command program determine the input size before the file is sent.
Is there anything else I need to do to successfully use LzmaCompress that I am missing? Is this a good plan?
Thanks!
-Travis
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well now I feel stupid, it's offset 5 to 8 and it's a 64 byte unsigned integer. Nevertheless, the question stands - do I need to do anything else to call Lzmauncompress? Do I even need to strip the headers?
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
5 bytes - properties (you send it propData)
8 bytes - uncompressed size (if is not FFFFFFFFFFFFFFFF), you send it in destLen.
another data - compressed data.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok! So now I can receive, uncompress, and retransmit my data!
It's incredible! However, I had to hardcode the source and destination lengths - for some reason I was having trouble picking them out of the header.
I know this is currently very ugly (and hard-coded), but unpackSize was giving me a huge (incorrect) size, and when I hardcode the lengths it is working.
inti;/* header: 5 bytes of LZMA properties and 8 bytes of uncompressed size */unsignedcharheader[LZMA_PROPS_SIZE + 8];UInt64unpackSize;//ReadLZMA_PROPS_SIZE+8bytesintoheader!for(i=0;i<sizeof(header);i++){header[i]=XUartPs_RecvByte(UART_BASEADDR);}/*for (i = 0; i < 8; i++){ unpackSize += (UInt64)header[LZMA_PROPS_SIZE + i] << (i * 8); } */unpackSize=655360;//<-Theabovedidn'tworksoIhardcodedtheunpackedsizeunsignedchar*src;src=malloc(1254-sizeof(header));//<-Hardcodedsrcsizeaswellfor(i=0;i<1254-sizeof(header);i++){src[i]=XUartPs_RecvByte(UART_BASEADDR);}unsignedchar*dest;SizeTsrcLen=1254-sizeof(header);//<-Hardcodedsrcsizeaswell//CopiedPropsfromheaderunsignedcharprops[5];for(i=0;i<5;i++){props[i]=header[i];}dest=malloc(sizeof(unsignedchar)*unpackSize);LzmaUncompress(dest,&unpackSize,src,&srcLen,props,sizeof(props));for(i=0;i<unpackSize;i++){XUartPs_SendByte(UART_BASEADDR,dest[i]);}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone,
I took a look through the source and found LzmaLib.c/LzmaLib.h, which appear to contain the compress/decompress functions I'd need.
I'm working on a Zynq FPGA's Processing Subsystem (So an ARM Cortex A9). I also took the LzmaUtils in lzma1604\C\Util\Lzma, and compiled it as an x86 project with both MSYS2 using make -f makefile.gcc and, separately, as an Eclipse project so I could easily debug what was going on easier.
It looks like header bytes 5,6, and 7 encode the final size, and I can easily have the command program determine the input size before the file is sent.
Is there anything else I need to do to successfully use LzmaCompress that I am missing? Is this a good plan?
Thanks!
-Travis
Well now I feel stupid, it's offset 5 to 8 and it's a 64 byte unsigned integer. Nevertheless, the question stands - do I need to do anything else to call Lzmauncompress? Do I even need to strip the headers?
Thanks!
5 bytes - properties (you send it propData)
8 bytes - uncompressed size (if is not FFFFFFFFFFFFFFFF), you send it in destLen.
another data - compressed data.
Ok! So now I can receive, uncompress, and retransmit my data!
It's incredible! However, I had to hardcode the source and destination lengths - for some reason I was having trouble picking them out of the header.
I know this is currently very ugly (and hard-coded), but unpackSize was giving me a huge (incorrect) size, and when I hardcode the lengths it is working.
1)
2) you don't need copy data to props, just send header. Smaller code.
3) if you need compressed size, you can store it in file just before 13 bytes of lzma header. So no need that "hardcode".