JPEG decoder fixed point implementation

Started by
7 comments, last by pradip913 14 years, 10 months ago
Hi, I am currently developing a 3d mobile game which uses many textures. Now currently I am using png format for textures. I converted the textures to jpeg format and found that it is much smaller than png. I want to use jpeg files (because of its smaller size) but the problem is that I dont have a jpeg decoder. I want to know that if I want to implement a jpeg decoder myself then how should I proceed. I hope I was able explain my problem. Please give me some pointers. regards, Pradip.B
Advertisement
Quote:Original post by pradip913
I converted the textures to jpeg format and found that it is much smaller than png.


Note that the main difference between jpeg and png is that the latter compresses lossless, while jpeg images often show severe artifacts. But I guess it might be negligible on mobile platforms.


Quote:I want to use jpeg files (because of its smaller size) but the problem is that I dont have a jpeg decoder. I want to know that if I want to implement a jpeg decoder myself then how should I proceed. I hope I was able explain my problem. Please give me some pointers.


Have you already checked google(code), sourceforge, and the like? Writing decoders for standardized imagery is typically error prone and about reinventing wheels. Do yourself a favor, and try to find a free library, but look at the license terms.
DevIL supports a huge amount of image formats, including png and jpg. I've used it myself and found it quite easy to understand. It's also cross plattform so it should work on mobile devices.
What are you currently using to decode PNG?
I checked DevIL but it requires libjpeg. I dont want to use libjpeg. To be honest I would like to write a simple jpeg decoder using fixed point :).

Zahlman: For png loading I am using opensource lodepng

Quote:Original post by pradip913
I checked DevIL but it requires libjpeg.

What is the problem with libjpeg?

Quote:To be honest I would like to write a simple jpeg decoder using fixed point :).

I wonder that, if you want to write it yourself, why are you asking questions here and don't start writing, because we have already given you the right pointers: JPEG Standards.

Or is your question about how fixed point math works? Actually, it's quite simple. Wikipedia gives some starting points.
There is stb_image.c file that has public domain jpeg and png decoder implementations. You can take a look at it: http://www.google.com/search?q=stb_image.c
It's not most optimized implementation, but I think it doesn't use any float computations for jpeg decompression.
libjpeg has compile time switches that lets you choose floating point or integer. Now I am not sure if it is for encoding only or also for decoding, but since it is an old library and floating point operations were much slower in the past I would guess, it also affects decoding.

I know it has a lot of extra unnecessary stuff, but maybe it will be a good starting point...
thnkx bubu.... this is what I was looking for.... will play around it now

This topic is closed to new replies.

Advertisement