user6106260
user6106260

Reputation:

JPEG encoder performance

I'm currently working on a JPEG encoder in C and I've just finished my first implementation. The encoder works fine on ppm/pgm images. Now I'm concerned with the performance of my encoder.

My encoder is actually slow when compared to libjpeg-turbo's JPEG cjpeg encoder. While cjpeg processes a 30 million pixels image in 200ms, mine takes ~7s to do the encoding. I don't understand how this is possible given that I'm using a fast DCT implementation.

Can anyone tell me where does this huge difference come from ? How is cjpeg so fast ?

Upvotes: 0

Views: 1617

Answers (1)

user3344003
user3344003

Reputation: 21710

You are going to need to do to some profiling to figure out what is going on. That said, I would wager the cause of the performance difference is in buffering. Logically speaking JPEG views the data as having different formats at different stages of the compression.

The input is usually an array of 24 bit color values. Those are converted to YCbCR giving another array of color value. Those are often sub-sampled so giving a logical Cb and Cr arrays that are smaller than the Y array.

For the DCT the previous arrays take on a different form; an array of 8x8 arrays.

For the DCT output you have a 16-bit per pixel array.

The management of those various arrays is likely to be the source of the difference in performance. By eliminating physical transformations you can get the most performance improvement.

Upvotes: 2

Related Questions