Custom paletted image format without palette storage

All the inane chatter goes in here. If you're curious about whether we will support a game, post HERE not in General Discussion :)

Moderator: ScummVM Team

kaveirious
Got a warning
Posts: 27
Joined: Fri Jul 27, 2007 12:49 am

Custom paletted image format without palette storage

Post by kaveirious »

Hi guys

this might not be the first time someone derives it, might it is an independent discovery 8)

I have some ideas (and have implemented them) on paletted color images that don't need a palette to accompany them!!! There are limitations but i can put down a few more explanations if you are interested (you only need another magic number of 32-bits size). No palette whatsoever.

My custom image format works but haven't publicized the idea before today.

I will come back with a more complete post on this thread in a few hours. For know suffices to say that there exist 21 basic palettes of this form, plus an unlimited number of "interpolated" (i call them balanced but might be improper) ones. Thus, there is a bouquet of n x 21 different palettes without need of storing the actual palette.

I haven't yet did the maths for the number of distinct colors that can be reproduced this way.

My palette specs offer a way to standardize what colors to use; will not try to change the world but want to stick to my palette system in my future works.

Any comments? Should i add more info (will do in a few hours, i have a deadline on something else)

-kaveirious
kaveirious
Got a warning
Posts: 27
Joined: Fri Jul 27, 2007 12:49 am

Post by kaveirious »

And a tip:

you can consider my format as a kind of "flexible shortened (low precision) RGB format".

It is an attempt to standardize palette generation. There are fields of work like small embedded systems where this would make sense. In the same sense that the venerable NES used 4 64-color palettes (i think).

Cheers
User avatar
eriktorbjorn
ScummVM Developer
Posts: 3561
Joined: Mon Oct 31, 2005 7:39 am

Re: Custom paletted image format without palette storage

Post by eriktorbjorn »

kaveirious wrote:There are limitations but i can put down a few more explanations if you are interested (you only need another magic number of 32-bits size). No palette whatsoever.
I assume this magic number, in combination with the colour index, is used to generate the desired colour. The trick, then, would be to find the number that approximates the original palette.

But to be honest, I don't really see what this has to do with ScummVM...
kaveirious
Got a warning
Posts: 27
Joined: Fri Jul 27, 2007 12:49 am

Post by kaveirious »

I assume this magic number, in combination with the colour index, is used to generate the desired colour. The trick, then, would be to find the number that approximates the original palette.

But to be honest, I don't really see what this has to do with ScummVM...
What i use is a kind of flexible RGB encoding. You can have interpretations of the form:
RRRRGGBB or RRGGGBBB etc

Generally you can have from 2 to 64 (powers-of-2 only) distinct levels for each chromatic component, given that the product of the number of levels is 256.

Thus, you need a "magic" number to specify the encoding of the RGB format. For example: 04-04-16 for 4 levels of R and G, and 16 levels of B.

I intend to use this in my homebrew embedded hardware systems. I still think of buliding a VM for gaming in hardware. Probably not SCUMMvm due to known issues but would like to get some inspiration of the good things in SCUMMvm :)

Kind regards
-kaveirious


[/quote]
kaveirious
Got a warning
Posts: 27
Joined: Fri Jul 27, 2007 12:49 am

Post by kaveirious »

Plus: yes, i have tested approximations to third-party content. But the palette system is meant to be used for creating new content (and is better suited to).

Kind regards
-kaveirious
seubz
Posts: 41
Joined: Sat Aug 11, 2007 1:24 am

Post by seubz »

I still don't understand your point here... You're throwing all the benefits of indexed images to trash, and what you're doing has nothing to do with palettes. You're just creating your own RGB encoding format.

Also, I'd like to know what kind of embedded systems you use in order to think that this would prove to be useful.
User avatar
Noelemahc
Posts: 178
Joined: Sat Jul 07, 2007 2:24 pm

Post by Noelemahc »

seubz, from what I've managed to understand, the concept is based off 21 pre-determined palettes of an unknown amount of colours, and as such each pixel will be determined by either an index number from one of those, or a mix between two or more.

So, if handled properly, this concept WILL retain the main advantage of palletized images (namely: tiny size), but only if we're talking one-palette-colour-per-pixel here. I can't seem to grasp how an image featuring trans-palette colours could be defined in a size smaller than that of an average 8-bit DDS or any other palettized image.

P.S. This will still have the issue of storing the pre-made palettes on each end user's machine (or as part of a redistributable package attached to the software using this format). So unless we're talking future custom content distribution, microscopic palette sizes or HUMONGOUS amount of images (to compensate the long-run effect of the format change from, say, PNG) this may not be the best of choices for a (relatively) uncomplex game, for example.

Of course, this is based purely on two years' worth of sporadic experience with chomping open screwy console game file formats* and may not represent the actual state of things. Perhaps I simply misinterpreted the author's concept, but as a pragmatic bastard, I won't believe the proposition effective until I see some live examples or a more systematized description to base conclusions about.
_________________________
* - I'm dumb and stupid, I still swizzle and unswizzle images by hand.
seubz
Posts: 41
Joined: Sat Aug 11, 2007 1:24 am

Post by seubz »

seubz, from what I've managed to understand, the concept is based off 21 pre-determined palettes of an unknown amount of colours, and as such each pixel will be determined by either an index number from one of those, or a mix between two or more.
Noelemahc: I see what you mean, I must have misunderstood what the author of the post tried to say. So in other words, it just adds some sort of new index pointing to the palette, at least when you're talking about an "index number from one of those". Didn't CoMI used that already ? I'm into disassembling SCUMM v8's format these days, and sometimes one room can have two palettes or more (at least the implementation makes it possible).
Of course, this is based purely on two years' worth of sporadic experience with chomping open screwy console game file formats* and may not represent the actual state of things. Perhaps I simply misinterpreted the author's concept, but as a pragmatic bastard, I won't believe the proposition effective until I see some live examples or a more systematized description to base conclusions about.
Completely agreed ;)
kaveirious
Got a warning
Posts: 27
Joined: Fri Jul 27, 2007 12:49 am

Post by kaveirious »

Hi all

first of all, thank you on your comments.

Since this came up, i believe that this discussion is appropriate for the "General Discussion" forum.
Also, I'd like to know what kind of embedded systems you use in order to think that this would prove to be useful.
It is an embedded system that may or may not interface to RAM resources. That this for storage everything that there is ia ROM storage (for booting) and on-chip RAM storage. Typically this on-chip RAM storage is 16KB (8KB for user programs and very simple RTOS layer) and 8KB for data).

Even with external RAM capability (let's say 1MB), it is not efficient to have available any possible palette (way to represent colors). I came up with these specs for flexible RGB so that what the colors are can be inferred by the "indices" (which are now colors actually). If you had a palette, it would like a sorted one (R lower and higher first, then G, then B).

Plus: you don't even need to store the 21 predefined palettes (that Noelemahc referred to).
if handled properly, this concept WILL retain the main advantage of palletized images
Yes!
how an image featuring trans-palette colours could be defined in a size smaller than that of an average 8-bit DDS or any other palettized image.
I lost you here, but there is no explicit palettes in my image files. It is inferred. Maybe i should write an encode/decode tool to/from my format for BMP. I have written something for my work that might get GPL'ed later on.

The system is a highly-constrained one. There is no RTOS more than: "Select application to run" or "Select mode". Recall cartridge-based systems of the past.

Overall i came up with this independently but certainly it probable (and most likely) that this concept came up in other occasions in the past.

My main aim is to remove the palettes while having the capability of expressing way more than 256 colors (not on the same palette:). The inferred predefined palettes provide this capability.

Kind regards
-kaveirious
User avatar
Noelemahc
Posts: 178
Joined: Sat Jul 07, 2007 2:24 pm

Post by Noelemahc »

I lost you here, but there is no explicit palettes in my image files. It is inferred. Maybe i should write an encode/decode tool to/from my format for BMP. I have written something for my work that might get GPL'ed later on.
Alright, what I meant was...

A common garden variety palettized image stores its data in the following manner: there is a header which defines the file type, the amount of colours and the image size in pixels or what-have-you, right? Then comes the palette section, which stores the RGB values of all the colours defined earlier. Which would, in a DDS file*, clock in at precisely two bytes per channel or eight bytes per colour**, leading to the palette block being precisely 1 kilobyte in size.

The image block consists of 2X bytes, where X is the amount of pixels we have in our image (for an 8-bit image, naturally). Each pixel is therefore defined by a pair of bytes, denoting the number of the colour to be used for this particular pixel (f.e. [AF] will call colour number 176 off the palette table). This is why, say, a 256x256 8-bit DDS file only weighs 66688 bytes.

This is twice more than that of a DXT1 DDS file of the same dimensions (which would be 32896 bytes large) because DXT is a lossy format, much like JPEG, and from what I understand relies on interpolation of the pixels by defining the colour only of every fourth or something to that effect.

The upside of DXT is small size and full access to 32-bit colour (as opposed to the predefined 8 bits of indexed images), the upside of indexation is crisper textures. But compare this to an uncompressed 32-bit BMP of the same dimensions. 262198 bytes, a little under four times as large as the indexed image and, consequentially, eight times as large as the lossy image.

What BMP does, is it stores huge chunks of data, meticulously defining every single colour there is for every single pixel there is. I'm a tad lazy to find out whether or not a TIFF file will be larger and if so, why, because I've never used TIFF and probably never will. In any case, the BMP file is so large because where the indexed image uses two bytes to define a pixel***, the BMP uses eight, for the full RGBA info.

And now explain to me, pretty please with sugar on top, how can you create a format which will be smaller than BMP if you'll have to define not only the palette from which a particular colour will come****, but also whether a particular colour is achieved by mixing together two colours off two separate palettes? This would double the necessary space up to six bytes, and even so only if we assume that the colours will be mixed in equal proportions, as any other way will requre at least an additional byte. And that's already based off the assumption that we use 8-bit palettes so we only need two bytes to define a colour within one - you still haven't clarified how large yours are going to be.

Bottom line? I can't quite grasp how will this be better than PNG in terms of processing power impact AND video memory usage (for 3d applications) AAAAAAANNNNDDDD, most important, consumption of hard drive space.

_____________
* - Which isn't that far removed from a GIF in its manner of storing indexed images. It's just that I've spent a goodly amount of time staring my eyes out at swizzled and indexed DDS images trying to wrap my head around swizzling itself, so I prefer to stick to what I know.
** - If we're talking RGBA, which we most probably are if we're to discuss any game-related application that doesn't rely on such a fickle trick as transparency colours.
*** - At this point, the header+palette size is small enough to be considered negligible.
**** - That's easy, we tuck on one extra byte to the indexed format, right? Three bytes instead of four, but we can only run with 16 palettes this way.
kaveirious
Got a warning
Posts: 27
Joined: Fri Jul 27, 2007 12:49 am

Post by kaveirious »

Hi Noe...

wait a sec. I think you don't understand what "embedded hardware development" really is. Your comments (some) are only valid for the PC world. I design apps that do not run on a PC. Run run on a 4-5 Watt chip that can be reprogrammed regarding both hardware (what processor it emulates) and firmware.

And now to specifics:
What BMP does, is it stores huge chunks of data, meticulously defining every single colour there is for every single pixel there is. I'm a tad lazy to find out whether or not a TIFF file will be larger and if so, why, because I've never used TIFF and probably never will. In any case, the BMP file is so large because where the indexed image uses two bytes to define a pixel***, the BMP uses eight, for the full RGBA info.
But i don't care (yet) if BMPs are large. They are (since the are uncompressed in non-RLE mode).

I don't deal yet with the Flash storage issue. It is possible to have 32Mbit Flash. This could store any given backgrounds for a game per se. It suffices for 320x200 resolution i intend to work with.

It is possible to compress and decompress (to/from Flash storage) but this would require some work. For the record, i use a type of arithmetic coding. It will compress (typically) 3-20 times !losslessly!. BMP + arithmetic encoding do the work for me. Take note of this, this is important ^_^
The compression/expansion firmware is up and running as of today.

I also don't want to work with real color since it will be all synthetic content.

I thought this place would be the right one to discuss paletted image issues.

What my problem is that the embedded system can not store (and more importantly manage) zillions of different palettes. I also don't want the 4x bloat of real color since i don't want to have real color after all (synthetic content, remember). Personally, i hate real color images. I don't watch new movies (often), I prefer Cinemascope + Technicolor :) I like their reddish shades.

And further, the embedded system will generate synthetic content, so 21 palettes (there can be interpolated versions of these 21s as well) require 21*256*8 bits plus any head marking required. Not much. Having RGBA bloat is much.

And remember. The system will run more/less like a game console. None of the PC goodies included. 98% of sales (in quantity) on microprocessors/microcontrollers are not AMD or Intel. They are 8051, PIC, 68k, ARM, MIPS, 4-bits that we never hear about, DSPs, custom processors etc.

-kaveirious

PS: On another topic, i was discussing ScummVM (or any game VM) implementation on hardware. But (not all) most people didn't understand the notion of a processor running ScummVM bytecodes natively.
Last edited by kaveirious on Sat Nov 17, 2007 6:46 pm, edited 1 time in total.
kaveirious
Got a warning
Posts: 27
Joined: Fri Jul 27, 2007 12:49 am

Post by kaveirious »

Bottom line? I can't quite grasp how will this be better than PNG in terms of processing power impact AND video memory usage (for 3d applications) AAAAAAANNNNDDDD, most important, consumption of hard drive space.
There is NO hard disc. Only on-chip RAM (some KBs) and Flash storage (4MBits or 32MBits, haven't decided yet).

Please, please, please remember that there is no HD whatsoever.
I keep telling you, but you come from a PC/software discipline and you don't quite grasp on.
User avatar
sev
ScummVM Lead
Posts: 2306
Joined: Wed Sep 21, 2005 1:06 pm
Contact:

Post by sev »

Besides being complete offtopic even in the Junkyard forum, all of this looks quite weird.

Okay, I just invented a way to store palette images without any palettes! Only thing you need is this magic byte at the beginning of the image.

Psst! I'll reveal you my secret. I have this nice set of 256 palettes predefined, and this magic byte is just my palette index. By predefined I mean either arithmetic generation or verbose copy of some palette number N.

Is that really so innovative? :)

And with 32 bits of magic I can even store set of constants which I will use in some polynome to generate my palettes.


Eugene
kaveirious
Got a warning
Posts: 27
Joined: Fri Jul 27, 2007 12:49 am

Post by kaveirious »

You just dont get it man.

The magic number defines the interpretation, not where the actual palette lies. BECAUSE THERE IS NO PALETTE, PERIOD!

It is like RAW (almost raw) on STEROIDS.

no room for BMP header decoding etc, i dont want to do this in firm ware! It is only custom hardware and firmware.

No PC, no HD, nothing. Get off your PC man! Can you make it operate on 4 or 5 Watt constraint? Can you, man?

Can you leave it unattended for a couple of weeks? Or couple of years? Who are you that will define if this discussion is suitable for ScummVM forums or not? You guys keep mumbling about SCUMM for years and have not decided yet if there is room for legal development (could be a loose interpretation) of new SCUMM content. Is anybody here interested in creating new content and not just playing with old games?

Until the time that you can, give me a break.

AND MOVE THE THREAD BACK.
User avatar
Raziel
ScummVM Porter
Posts: 1541
Joined: Tue Oct 25, 2005 8:27 am
Location: a dying planet
Contact:

Post by Raziel »

kaveirious wrote: You just dont get it man.

SNIPPED

Is anybody here interested in creating new content and not just playing with old games?
That is the whole point of ScummVM, you're on the wrong forum, MAN ;-)
Post Reply