PDA

View Full Version : Jpeg 2000


Moose2000
05-06-2007, 01:57 AM
I know jpeg2000 compression has been discussed here before, but it's been a while and maybe there are some new brains to pick.

I'm really keen to use jpeg2000 compressed textures in my game - I have lots of really big images, many of them with transparency - but the performance of the decompressor I'm using (openjpeg) is really bad. Or maybe it's really good and it's just that decompressing jpeg2000 is really hard. Either way, several seconds per texture is too much for me.

j2k-codec claims to be really fast, but as far as I can make out it's windows binary only, and I need something that works on windows and osx.

So, is anyone else using jpeg2000, and if so, any tips on the quickest codec? (Free/cheap for preference!) Or is there some groovy new format out there that compresses really well, decompresses quickly, and supports alpha?

Emmanuel
05-06-2007, 02:08 AM
We're using jpeg2000 and j2k-codec for our upcoming game, due to the massive amount of art. The codec is very satisfactory and very fast (faster than loading a png with alpha it seems like!), as long as you're buying the $200 version (the $49 or so version is unusable with anything produced by photoshop, it seems like). There may be an OS X version of it soon, too, but I don't want to speak out of turn. In the meantime, our mac build process transforms the j2k's source images into a color jpeg + an alpha png and it looks just as good (at the expense of a bigger filesize than j2k).

Best regards,
Emmanuel

Pallav Nawani
05-06-2007, 06:46 AM
I've also wanted to used Jpeg2000 in my game, but I've not done that so far because of the potential patent issues: http://en.wikipedia.org/wiki/JPEG_2000#Legal_issues. Any idea where the j2k-codec stands in this regard?

oNyx
05-06-2007, 03:45 PM
The best compromise right now is DXTn. For a good comparison compress the files with lzma for obtaining the final installer size. Unlike jpg or jp2 DXTn can be further compressed quite a bit.

Loading is 4 or 6 times quicker then raw and it also only uses 1/4 or 1/6 of the vram. Those are some impressive advantages.

Give it a try if you haven't done that already.

Lerc
05-06-2007, 04:15 PM
The solution I have to this is to give up on jpeg2000. It does more than I want and none of the software was satisfactory.

What I wanted was an api that could load an rgba image into memory and I could take it from there.

I created such a system, registered a sourceforge page. I used the compression in Darwin the Monkey. Now that Darwin is finished I have time to get the sourceforge thing sorted out.

here's the basic idea [I may have mentioned this before, I forget]

Totally non standard file format. The only guarantee is files made by a particular revision are read by that revision, and there will be a program that can convert png files into the current version.

The api, with regards to reading files, consists of.
void NQN_GetARGBImage(tNQN_Info* Context, void* ARGBSurface,int Width, int Height,int BytesPerRow);

tNQN_Info* NQN_Load(char* filename);

tNQN_Info* NQN_LoadFromMemory(void* Memory, int MemorySize);

void NQN_GetInfo(tNQN_Info* Context,int* Width_Out, int* Height_Out, int* Depth_Out);


The principle behind no file format is that since the files are not intended for distribution without the code that can read them, there is no requirement that the format be fixed. With no particular format the system can be improved using whatever compression comes to hand in the future.

At the moment the compression that it uses is ultra simple. it is saved as Y Cr Cb with chroma subsampling and LZMA compression. There is no lossy stage other than the colour subsampling so the compression is not nearly as good as something like Jpeg2000 but I figure there'll always be someone up to the challenge of making the compression better. In the meantime the compression is significantly better than png and I've yet to be inundated with complaints about Darwin's crappy visuals.

Moose2000
05-06-2007, 04:26 PM
With the images I'm using, and at the quality I'm prepared to accept, jpeg2000 compresses to very much smaller files than dds.

I've thought about converting to dds during the install, but that seems really clunky.

Musenik
05-06-2007, 04:33 PM
My next game has several images that are 2400x1800x24. I would love to have a (mac/pc) cross-platform JPEG-2000 decompressor. How much would current solutions cost?

Pyabo
05-06-2007, 04:57 PM
I believe cximage supports JPG2K... and it's open source.

oNyx
05-06-2007, 05:06 PM
With the images I'm using, and at the quality I'm prepared to accept, jpeg2000 compresses to very much smaller files than dds.
[...]

Uhm... as I said, for a meaningful comparison you have to compress em with the compression scheme your installer is using. A jpg or jp2 file won't be reduced much (a few % perhaps). However, a DXTn texture (eg in a dds) can be reduced to 20% of the size in extreme cases.

Even if it ends up being a tad bigger, you get the advantage of lightning fast loading times and drastically reduced vram usage (which can improve performance quite a bit).

IMO quicker loading times are far more important than a few % shaved off the installer. The longer it takes to get into the game (again) the higher the upfront time investment is. Which is sorta bad - especially for casual-ish or short games.

Moose2000
05-06-2007, 07:06 PM
Uhm... as I said, for a meaningful comparison you have to compress em with the compression scheme your installer is using.

Yes, I was including that in my comparison.

PoV
05-06-2007, 08:05 PM
Alternatively, the HD Photo format might be of interest. Similar goals as the JPEG 2000 format, but it's designed for a low performance overhead, and the lowest compression setting actually results in a lossless image. Full ansi-c source, oddly, courtesy of Microsoft.

http://www.microsoft.com/windows/windowsmedia/forpros/wmphoto/

Moose2000
05-06-2007, 09:05 PM
Oh, that sounds promising. I was aware of the format, but I just assumed it would be no-go on the Mac.
I'll have to do some tests with it.
Cheers!