Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  Print  
  many sprites  (Read 3415 times)
0 Members and 1 Guest are viewing this topic.
Offline DzzD

JGO Kernel
*****

Posts: 2134
Medals: 16



« Reply #30 on: 2010-02-11 19:19:36 »

I assume Sun's decoder is what is used by ImageIO, so performance will probably be the same (slower than SWT's decoder). I don't know if there is a license issue or if it is even possible to have it to make a ByteBuffer instead of BufferedImage.
dont know but I found the performance very nice : I got 80 more jpg / sec in comparaison of toolkit and ibm the lastest JPEGDecoder you post here, also you can build a bufferedimage or a raster, you can get an byte array from a raster in no time.

1  
2  
3  
4  
5  
jpegInput.reset();
byte[] b;
Raster buf=decoder.decodeAsRaster();
b=((DataBufferByte)buf.getDataBuffer()).getData();
ByteBuffer buffer = ByteBuffer.wrap(b);


same result 265 jpg /s

Offline Nate

JGO Neuromancer
****

Posts: 1063
Medals: 30


mooooo


« Reply #31 on: 2010-02-11 20:06:52 »

OpenGL needs a direct ByteBuffer though, so you'll have to copy the byte[]. I do like accessing the byte[] your way better than row by row. I've updated my test, but it didn't make ImageIO faster:
http://n4te.com/temp/Test.java

With the new decoder, it fails to decode your Ken fireball pic and also my test image (bent over next to a plant stake!). I tried it on a third pic (only click if you want to see me drinking frozen lemonade with my nipple Wink ) and it worked. This image is 1280x960. I found it took 211ms to parse. With SWT's decoder it is parsed in 81ms, with ImageIO 85ms to 140ms. Here is my test for the new decoder:
http://n4te.com/temp/Test2.java
HPROF:
1  
2  
3  
   1 64.90% 64.90%    1407 300051 JPEGDecoder2.ScaleIDCT
   2 17.76% 82.66%     385 300053 JPEGDecoder2.output
   3  8.63% 91.28%     187 300052 JPEGDecoder2.output

I think the IDCT is not as advanced as SWT's, which seems to do some checks and shortcut if possible. I probably won't pursue the new decoder further since it seem to be slower and has an unfriendly license. I am impressed with its conciseness though!

I tried Sun's decoder. I can get it to decode once, but the second time around it fails. This makes little sense to me! Here is the test:
http://n4te.com/temp/Test3.java

Offline Nate

JGO Neuromancer
****

Posts: 1063
Medals: 30


mooooo


« Reply #32 on: 2010-02-12 00:47:12 »

I ported the IFAST DCT but I can't get it to work right. Sad Not sure what is wrong with it. I left the jpeg_idct_ifast method in the latest, which is now here:

http://code.google.com/p/skorpios/source/browse/trunk/skorpios-common/src/com/esotericsoftware/skorpios/opengl/JPEGDecoder.java

I can see a few of the optimizations IFAST is doing, so I duplicated jpeg_idct_islow, called it jpeg_idct_islow2 and managed to removed some shifts and adds. The difference is pretty negligible, but whatever, less is less.  Kiss

I added the alpha stuff needed to use this to decode my IMG (alpha+JPEG, see IMGDecoder in Skorpios) format. In actual usage in my game, the new decoder loads an IMG file twice as fast as the old ImageIO way. Cool Now its time to test it on Android and then I can get back to my animation system!  Grin

Games published by our own members! Go get 'em!
Offline Nate

JGO Neuromancer
****

Posts: 1063
Medals: 30


mooooo


« Reply #33 on: 2010-06-05 06:54:04 »

I came across this in my Googley adventures...
http://nothings.org/stb_image.c
Has limited support for JPEG, PNG, BMP, TGA, PSD, and ZLIB. Maybe something there can be lifted.

Pages: 1 [2]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.108 seconds with 20 queries.