English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 11 March 2013, 00:31   #1
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 39
Posts: 1,919
Best Compression Methods For...

Hi,

I know there are a few different compression methods (e.g. LZ77, LZW, RLE and Huffman encoding), but is there a general guide to which compression method is best (and not bound by copyright/licensing laws)?

I'm in the middle of making a game and the raw graphics data (so far) is 32KB in size, but storing it in .IFF format reduces it to around 15KB and using .PNG format it is 9KB! I'm thinking that .PNG is best.

Does anyone know which methods were used in the past to compress game data? Does anyone even bother compressing game data these days when making new Amiga games??
Lonewolf10 is offline  
Old 11 March 2013, 08:38   #2
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
I presume, if you're storing your graphics in .png format, that you then have to have a routine to convert those graphics into raw bitplane data ready for display?

Why not just use raw data to start with and crunch it with a data cruncher prior to storing? Then just uncrunch the data as necessary as and when you load it.
pmc is offline  
Old 11 March 2013, 10:21   #3
Thorham
Computer Nerd

Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 42
Posts: 3,075
Quote:
Originally Posted by Lonewolf10 View Post
Does anyone even bother compressing game data these days when making new Amiga games??
Depends on your target storage method. If you have a lot of data and want the game to run of floppies, then you'll probably need compression. If floppies aren't supported, then I probably wouldn't bother because of todays large HD's.
Thorham is offline  
Old 11 March 2013, 11:30   #4
Yakumo9275
Registered User
Yakumo9275's Avatar
 
Join Date: Jan 2013
Location: Lexington VA
Posts: 94
well, if its .IFF its probably ILBM or if its from the PC side, its PBM, they are just run length compression. PNG uses zlib/pkzip DEFLATE internally.. which is LZ77 + Huffman combined. it is not covered by active patents.
Yakumo9275 is offline  
Old 11 March 2013, 15:00   #5
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 39
Posts: 1,919
Quote:
Originally Posted by pmc View Post
I presume, if you're storing your graphics in .png format, that you then have to have a routine to convert those graphics into raw bitplane data ready for display?
Yeah. I'm currently working on that in AMOS Basic and once working will convert the code into ASM I'm on the IDAT bit now (the image data compressed using LZ77 + Huffman, as Yakumo9275 mentioned above), but Huffman code (especially variable length) always gave me a headache, which is why I avoided it in the past. However, it seems to be the best compression method available so I'm attempting to tackle it head on


Quote:
Originally Posted by pmc View Post
Why not just use raw data to start with and crunch it with a data cruncher prior to storing? Then just uncrunch the data as necessary as and when you load it.
I had thought of that, but it is much more convenient if I just have one image file for each image. In the past I'd have the image in multiple formats .PNG (created in MS Paint), .IFF (viewable on Amiga's) and .RAW
(for use inside my ASM programs).
NB: I didn't know until recently that Personal Paint code decode .PNG files


Quote:
Originally Posted by Yakumo9275 View Post
well, if its .IFF its probably ILBM or if its from the PC side, its PBM, they are just run length compression. PNG uses zlib/pkzip DEFLATE internally.. which is LZ77 + Huffman combined. it is not covered by active patents.
Thanks for the info
Lonewolf10 is offline  
Old 11 March 2013, 19:11   #6
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
I use a lot of compression in my code. My main port of call is a variant of LZSS with variable length offset fields.

For my graphics I started using AMOS's graphics compression command "spack", which does quite well when saved using powerpacker library ("ppsave"/"ppload" instructions from the AMOS Compiler extension). However I replaced powerpacker with my own routine later on. I'm still using the AMOS bank format for some of the graphics (the asm source code is available), but for tiles and bobs I do RLE, and everything followed by LZSS.

When compressing audio sample data, it is beneficial to "differentiate" the sample first. That is, store the bytewise difference between each sample and the next. This typically results in a narrower range of values.

I haven't touched Huffman yet although I'd like to. Also look up Range coding - might be a bit much for an Amiga but it's quite interesting.
Mrs Beanbag is offline  
Old 16 March 2013, 23:05   #7
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 39
Posts: 1,919
Thanks for the tips, Mrs Beanbag
Lonewolf10 is offline  
Old 18 April 2013, 11:13   #8
Cyprian
Registered User

 
Join Date: Jul 2014
Location: Warsaw/Poland
Posts: 32
Quote:
Originally Posted by Lonewolf10 View Post
Yeah. I'm currently working on that in AMOS Basic and once working will convert the code into ASM I'm on the IDAT bit now (the image data compressed using LZ77 + Huffman, as Yakumo9275 mentioned above), but Huffman code (especially variable length) always gave me a headache, which is why I avoided it in the past. However, it seems to be the best compression method available so I'm attempting to tackle it head on




I had thought of that, but it is much more convenient if I just have one image file for each image. In the past I'd have the image in multiple formats .PNG (created in MS Paint), .IFF (viewable on Amiga's) and .RAW
(for use inside my ASM programs).
NB: I didn't know until recently that Personal Paint code decode .PNG files




Thanks for the info
there you can find source code (asm 68k ) for PNG and LZ77 decompression http://dhs.nu/files.php?t=democreation
Cyprian is offline  
Old 18 April 2013, 16:07   #9
MagerValp
Registered User
 
Join Date: Aug 2008
Location: Göteborg / Sweden
Posts: 236
Hmm, I have a compression method I developed for the C64 that should port over quite easily. I wrote test unpacker in AmigaE as a proof of concept:
Code:
PROC backunpack(indata:PTR TO CHAR, inlen:LONG, outdata:PTR TO CHAR)
    DEF inpos = 0
    DEF outpos = 0
    DEF backpos
    DEF c
    DEF l
    
    WHILE inpos < inlen
        c := indata[inpos++]
        SELECT 256 OF c
            CASE 0
                RETURN outpos
            CASE $80 TO $ff
                l := c - 127
                REPEAT
                    outdata[outpos++] := indata[inpos++]
                    DEC l
                UNTIL l = 0
            DEFAULT
                l := c + 2
                backpos := outpos - 256 + indata[inpos++]
                REPEAT
                    outdata[outpos++] := outdata[backpos++]
                    DEC l
                UNTIL l = 0
        ENDSELECT
    ENDWHILE
ENDPROC
As you can see it's quite simple but it still performs better than LZ77.
MagerValp is offline  
Old 18 April 2013, 21:38   #10
Cyprian
Registered User

 
Join Date: Jul 2014
Location: Warsaw/Poland
Posts: 32
MagerValp it looks like RLE compression
Cyprian is offline  
Old 18 April 2013, 22:01   #11
MagerValp
Registered User
 
Join Date: Aug 2008
Location: Göteborg / Sweden
Posts: 236
No, it does repeating patterns, its closest ancestor is LZSS.
MagerValp is offline  
Old 18 April 2013, 22:20   #12
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 39
Posts: 1,919
Quote:
Originally Posted by MagerValp View Post
No, it does repeating patterns, its closest ancestor is LZSS.
I know what LZ is short for (Lempel-Ziv), but what is the SS for?
Lonewolf10 is offline  
Old 18 April 2013, 23:13   #13
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,028
Storer–Szymanski
StingRay is offline  
Old 20 April 2013, 22:22   #14
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 39
Posts: 1,919
Thanks, Stingray.
Lonewolf10 is offline  
Old 15 June 2013, 18:12   #15
Photon
Moderator
Photon's Avatar
 
Join Date: Nov 2004
Location: Hult / Sweden
Posts: 4,565
Do the gfx come from an Amiga or a PC paint program? How many colors are we talking? What is the average width/height of the image files?

If you're not cramped for memory, I recommend to just save in the best format available in the paint program and load it as that format. Speeds up development by skipping the conversion and compression steps.
Photon is offline  
Old 15 June 2013, 22:59   #16
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 39
Posts: 1,919
Quote:
Originally Posted by Photon View Post
Do the gfx come from an Amiga or a PC paint program? How many colors are we talking? What is the average width/height of the image files?
Most of the graphics are currently drawn using Microsoft Paint (on my laptop), with 16 colours. The master image I have at the moment is something like 2000x1000, but once everything is drawn I will split the graphics into more manageable chunks (e.g. 320x200 or so) with each image storing graphics for one or two levels.

I'm considering using a CGI image for the title screen, and possibly making use of the super-hires mode. I already have some polygon corridors and towers created using Wings 3D (again, on my laptop), which I made last year for fun


I already have working code to inflate .PNG files in AMOS Basic, and am slowly converting it to ASM
Lonewolf10 is offline  
Old 16 June 2013, 17:31   #17
Photon
Moderator
Photon's Avatar
 
Join Date: Nov 2004
Location: Hult / Sweden
Posts: 4,565
Then you're set I'd say So unless you absolutely must do some cutting or editing on the Amiga end, it would be unnecessary to convert them to iff or add special compression or something like that.
Photon 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
Methods for removing labels from floppies diablothe2nd support.Other 22 08 July 2013 21:43
Compression Suggestions h0ffman Coders. General 2 31 December 2010 12:19
A600 case trimming - tools/methods mancalledSun Hardware mods 2 26 March 2010 04:26
Data compression History DH Nostalgia & memories 21 23 October 2008 13:18

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 06:41.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.09606 seconds with 15 queries