Sign in to follow this  
pradip913

JPEG decoder fixed point implementation

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this