English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Releases

 
 
Thread Tools
Old 03 December 2014, 23:59   #41
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Been a while, was just wondering if your header stripper file-prepping code will make it to a shell command?
Photon is offline  
Old 05 December 2014, 12:24   #42
Keir
Registered User
 
Join Date: May 2011
Location: Cambridge
Posts: 682
Quote:
Originally Posted by Photon View Post
Been a while, was just wondering if your header stripper file-prepping code will make it to a shell command?
I use a Linux cross-dev environment, so I have no setup for making Amiga CLI utils. This is one reason why deflate was interesting to me, as I can create compressed streams easily on the Linux host.
Keir is offline  
Old 06 December 2014, 12:01   #43
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
So how would anyone without your setup prepare a compressed file for use with your decompression source?
Photon is offline  
Old 07 December 2014, 08:55   #44
Keir
Registered User
 
Join Date: May 2011
Location: Cambridge
Posts: 682
Quote:
Originally Posted by Photon View Post
So how would anyone without your setup prepare a compressed file for use with your decompression source?
Produce a gzip file and strip the gzip header (trivial job, format described in RFC 1952, also I provide POSIX C source to do the job). Produce a zlib file and strip the zlib header (trivial job, format described in RFC 1950). Extract deflate stream from a PNG file. And so on; many uses, possibilities, but not a direct replacement for an Amiga-dedicated packer/unpacker toolkit. But there are very many of those, some very good, whereas easy creation of compressed files on a foreign host is a rarer feature.

Last edited by Keir; 07 December 2014 at 09:25.
Keir is offline  
Old 07 December 2014, 15:21   #45
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by Photon View Post
Been a while, was just wondering if your header stripper file-prepping code will make it to a shell command?
Ok, I spent one or two hours today to convert degzip.c into a portable ISO-C99 source. Then used vbcc to make an AmigaOS 68000 executable from it. You find it together with the source in the attached archive.

Quote:
Originally Posted by kaffer View Post
also I provide POSIX C source to do the job).
Unfortunately POSIX only guarantees portability under Unix-like systems, which AmigaOS is not. Also the endian-conversion functions (htobe32, le32toh, etc.) are not POSIX. And you should not depend on 'int' being 32 bits, so I changed insz and outsz to uint32_t.
Attached Files
File Type: lha degzip68k.lha (17.5 KB, 293 views)
phx is offline  
Old 07 December 2014, 16:24   #46
Keir
Registered User
 
Join Date: May 2011
Location: Cambridge
Posts: 682
Quote:
Originally Posted by phx View Post
Ok, I spent one or two hours today to convert degzip.c into a portable ISO-C99 source. Then used vbcc to make an AmigaOS 68000 executable from it. You find it together with the source in the attached archive.
That's awesome thank you. I hope you don't mind me adding this into my github repo, I'll cite you at the top of the file.

Quote:
Unfortunately POSIX only guarantees portability under Unix-like systems, which AmigaOS is not. Also the endian-conversion functions (htobe32, le32toh, etc.) are not POSIX. And you should not depend on 'int' being 32 bits, so I changed insz and outsz to uint32_t.
You're right, I forget how much I deviate from POSIX and use GNU/Linux-isms, such as getopt_long() also, so your job was bigger than I'd've expected.
Keir is offline  
Old 07 December 2014, 18:31   #47
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by kaffer View Post
I hope you don't mind me adding this into my github repo
Not at all. Please do!
I have quickly tested all options and everything seemed ok, but no guarantee.
phx is offline  
Old 11 November 2016, 15:07   #48
arti
Registered User
 
Join Date: Jul 2008
Location: Poland
Posts: 662
Hi,

I would like to use this optimised inflate function in NetSurf for PNG decoding but I have no knowledge of asm.
Can sb complie an object file so I could link it?

What arguments does it take?

Code:
int __wrap_inflate(mz_streamp pStream, int flush)
{
	inflate_asm(pStream, flush);
}
arti is offline  
Old 13 November 2016, 19:22   #49
arti
Registered User
 
Join Date: Jul 2008
Location: Poland
Posts: 662
Will it work for PNG's at anyway?
arti is offline  
Old 13 November 2016, 19:51   #50
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
It seems this is the wrong thread, as you don't want to use kaffer's degzip to inflate your data.

Concerning your questions: Yes, as far as I know PNG uses zlib's inflate-algorithm. For everything else you posted too little information.
phx is offline  
Old 13 November 2016, 20:15   #51
arti
Registered User
 
Join Date: Jul 2008
Location: Poland
Posts: 662
I want to use inflate.asm mentioned in first post, so it should be on topic.

I am sorting out how link vasm a.out with c gcc compiled program.
arti is offline  
Old 14 November 2016, 12:46   #52
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by arti View Post
I want to use inflate.asm mentioned in first post, so it should be on topic.
Oh, indeed. That's a long time ago. Now I remember. Sorry.

I didn't write the code, only ported it to vasm. From looking at the source I would say that you call the "inflate" routine with register A5 pointing to the input stream and A4 pointing to the output buffer for the inflated (uncompressed) data.

Quote:
I am sorting out how link vasm a.out with c gcc compiled program.
Just use the gcc-linker GNU-ld. I assume it expects a.out object file format, which is also generated by your gcc-version for Amiga/68k? Then call vasm with the option "-Faout".

You may also want to rename the inflate function in the assembler source from "inflate" to "_inflate" and export the symbol with "xdef _inflate". So you can call it from C as inflate().
phx is offline  
Old 14 November 2016, 13:47   #53
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by arti View Post
Will it work for PNG's at anyway?
Normal zlib's inflate should work for PNG (so this one will too if it's compliant with the spec) but isn't necessarily optimal as it has to support features that PNG doesn't use (i don't remember the details).
meynaf is online now  
Old 14 November 2016, 15:08   #54
arti
Registered User
 
Join Date: Jul 2008
Location: Poland
Posts: 662
With xdef _inflate and -Fhunk I have linked this.
Now , how do I call inflate.
Simply inflate(stream)?
arti is offline  
Old 16 November 2016, 19:26   #55
arti
Registered User
 
Join Date: Jul 2008
Location: Poland
Posts: 662
This how I have implemented inflate.asm in png lib:

Code:
register z_streamp instream __asm("a5");
register int flush __asm("a6");

int inflate_asm(register z_streamp instream __asm("a5") ,register int flush __asm("a6"));

int
png_zlib_inflate(png_structrp png_ptr, int flush)
{
...
   return  inflate_asm(&png_ptr->zstream, flush);
}
or

Code:
register int outdata __asm("a4");
register z_streamp instream __asm("a5");
register int flush __asm("a6");

int inflate_asm(register z_streamp instream __asm("a5"), register int outdata __asm("a4") ,register int flush __asm("a6"));

int
png_zlib_inflate(png_structrp png_ptr, int flush)
{

...

    inflate_asm(&png_ptr->zstream, outdata, flush);
	
   return  outdata;

}
None of this works, have I missed something ?

Last edited by arti; 16 November 2016 at 19:35.
arti is offline  
Old 16 November 2016, 20:53   #56
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
I don't know which gcc version you use and how it behaves, but I doubt this will work.

What are you trying to achieve with these global register definitions?
Code:
register int outdata __asm("a4");
register z_streamp instream __asm("a5");
register int flush __asm("a6");
I'm not sure what will happen here. Probably gcc will allocate these three registers for all functions with these variables, degrading code quality.

And there is no "flush" argument in the assembler implementation of inflate(). Do you know what "flush" is doing? A6 is used for an (optional) alternative stack area, AFAIK, but only when you define the appropriate symbol (it is not used by default).
phx is offline  
Old 17 November 2016, 11:50   #57
arti
Registered User
 
Join Date: Jul 2008
Location: Poland
Posts: 662
My bad, it is first time I work with asm you know.
I do not understand it fully yet.

Code:
int inflate_asm(register z_streamp instream __asm("a5"), register int outdata __asm("a4"));

int
png_zlib_inflate(png_structrp png_ptr, int flush)
{
int outdata; ... inflate_asm(&png_ptr->zstream, outdata); return outdata;
}
Still no go.
arti is offline  
Old 17 November 2016, 12:57   #58
arti
Registered User
 
Join Date: Jul 2008
Location: Poland
Posts: 662
Here is example code:
http://netsurf.baderman.net/inflate.zip
arti is offline  
Old 09 December 2016, 14:31   #59
Keir
Registered User
 
Join Date: May 2011
Location: Cambridge
Posts: 682
Hi, Sorry I did not check this thread in a long while. Plumbing into libpng is not as straightforward as you think. It seems the library has a zlib-style streaming interface, and wishes to call an inflate handler which will decompress until the input buffer is empty or the output buffer is full. My inflate asm has a simpler interface where you pass a pointer to the (complete) input in memory, and a pointer to sufficient output space in memory. There is no facility for returning to the caller to collect more input stream or to empty an output buffer. This could be added, it's a question of doing the work and also no doubt slowing down the inflate routine as it will need to check for buffer empty/full conditions within some inner loops.

Alternatively if it can be established or arranged that libpng always fully reads the input into memory and provide sufficient output buffer space then you should be able to pull the input/output buffer pointers out of the z_streamp structure and pass those to inflate_asm() in a5/a6. The 'flush' parameter to png_zlib_inflate can be disregarded.
Keir is offline  
Old 12 December 2016, 11:36   #60
arti
Registered User
 
Join Date: Jul 2008
Location: Poland
Posts: 662
Thanks for reply kaffer.
I was hoping it to be as simple as replacing only inflate function.
To achieve what you wrote I need to educate myself a bit more first.
arti is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Amiga formatted zip disks via USB zip drive in WinUAE? planetidiot New to Emulation or Amiga scene 8 02 February 2018 08:43
System.zip / bad zip-file Ztein project.ClassicWB 24 22 April 2012 02:14
Use of 4MB PCMCIA Fast Flash Memory as Fast RAM in A1200 nkarytia support.Hardware 10 16 September 2011 13:37
Added SIMM to ZIP adapter, now 16MB Fast RAM tonyyeb support.Hardware 18 01 September 2008 10:59
LZX unpacking??? Medvind support.Apps 25 27 November 2002 12:33

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:07.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09963 seconds with 14 queries