Optimising ILBM decode
Hey fellas :)
For some work on a new prod I'm doing I need to decode lores EHB ILBM files. I only need to decode this type of ILBM, not ILBMs in general so I've written a decoder for just that purpose and it works perfectly fine. The two main loops required are one to pull out the colour data and another to decode the RLE graphics data. Here's my colour extraction loop: Code:
moveq.l #32-1,d7 Code:
movea.l screenone_ptr(a5),a2 So, my question is - is there any way the above routines could be optimised further than I already have or, alternatively, a completely different approach altogether which I've missed? By the way, I should mention that I'm coding specifically for the 68000 processor and not 68020+ EDIT: in the RLE decoder, possibly the copy and replicate loops could be speeded up by determining the number of bytes in the current copy or replicate operation and moving words or longwords instead of bytes when possible...? The speedup of this would need to be traded off against how long it would take the code doing the decision logic for that to run of course... |
For the color extraction part you could perhaps do this:
Code:
; assumed format: 0rgb |
Thanks for taking a look and suggesting an alternative Thoram. All your assumptions about RGB were spot on :great
I did a quick test - the code you posted doesn't always work unfortunately. For example, if d0=$f4, d1=$12 and d2=$23 (which is perfectly possible with the way colour bytes are written into the CMAP structure in an ILBM file) the resulting colour moved into the copperlist should be: $0f12 - your code outputs $0f52 :( |
Sorry :o It should be this:
Code:
; assumed format: 0rgb |
Nice one mate - looks better with that move in place of the or :)
Will do some speed testing and see if your version gains me some time. :great EDIT: Out of interest, does anyone know of any utility available that could parse a text source code and add up all the cycles the various opcodes take? Something like that would be very very handy and it seems like it should be possible to do, although I'm not sure how easy or hard it would be to code such a utility in practice... |
I would just do this to keep it short. I guess speed doesn't matter much since it's only 32 colors. Are you making an image converter or is it for a demo?
Code:
move.b (a0)+, d0 |
Yeah, basically the 1 in $12 and the 4 in $f4 got or-ed and that's 5 of course :laughing
Here's one with the move removed: Code:
; |
@ Thoram - thanks man. I can't see how your version will be anything but quicker but I'll test it out against the others. :)
@ Leffmann - it's not for an image converter, like I say - I'm only interested in being able to convert EHB pics and nothing else. I've been asked to help with making a slideshow and I want to be able to decode the images as quick as possible. Plus, I just enjoy trying to optimise my code and seeing how others would solve the same problems - helps me to learn to think more laterally. :) Oh and thanks for posting a version yourself. Like you say - the main speed savings would come from speeding up the RLE decode. Either of you got any ideas for that routine? |
My RLE depacker looks like that, dunno if it's faster or not.
Code:
; d0=size |
I guess raw palette and image data is the fastest then. The palette would only be 64 bytes ready to be written to the color registers so encoding them like this only eats time and space, and the gain from RL-encoding the images is typically not very big.
If image size does matter then plain sliding window compression might be better. It's very fast to decompress and compression ratio is always better than RLE. Ask Photon for his compressor, it does just this. |
hitchhikr: your version looks basically the same as mine, except it's missing all the other manipulations for putting the data in the correct places in the bitplanes.
I need to do those as I'm not using interleaved raw bitplanes. I take it your version converts the interleaved ILBM bitplane data straight to interleaved raw bitplanes? Leffmann - Agreed. RLE isn't very efficient. Mainly I'm trying to get a balance between ease of use of the images (cos I can just directly load and use the .iff images I'm provided) versus the time it takes to decode them. |
Maybe using the blitter to "de-interleave" the bitmap afterwards would be faster ?
|
Here's a small one for the RLE part.
Instead of copying memory to memory, like this: Code:
.replicate Code:
.replicate Perhaps you can unroll both copy loops and try to copy words instead of bytes as well, but it might be a bit of a pain ;) |
Nice one Thoram - yeah, I'd already stolen that idea from the code hitchhikr posted (:D) and implemented it into my routine. :)
|
Quote:
|
If speed is of the essence, you will always do better with converting to a custom format. You might even save a few bytes in doing so! The fastest solution is to decode ilbm and save as raw files, then switch bitplane ptrs to that frame. By Grabthar's hammer... what a savings.
If this is for replaying animation frames, you will save even more space and time by making a player compatible with IFFanim. But I think you just want to make the ultimate most fantastic superfast *drumroll* ILBM converter... which I find utterly unnecessary but there you go :) Just REPT 256 the copy or fill instruction and jump into the chunk of moves at an offset of (256-count)*2. For the fill, move (a0) into Dn first. |
Quote:
So my thinking was along these lines: if that's what I've gotta do, might as well do it as quick as possible cos, after all, doing things smaller and faster is where the fun comes into assembly coding. :) Anyway, updated quicker versions are - cols: Code:
move.b #$f0,d6 Code:
movea.l screenone_ptr(a5),a2 |
Quote:
Quote:
|
Sorry for getting your name wrong Thorham - no offence intended. Sometimes I seem to read names wrong - I keep spelling Leffmann's name with only one n too :(
I've been reminding myself to check how I've spelt his name in posts so I'll remind myself to check the spelling of your name too now as well :) |
Quote:
Did you try Photon's REPT idea? Gets rid of the dbf instructions, and without caches and pipelines (68020+) this will most certainly be faster. |
All times are GMT +2. The time now is 07:27. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.