Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 09:56, 17 September 2007.

TSS000747 - Increasing speed and reducing memory consumption of JPEG decoding

From Forum Nokia Wiki


ID TSS000747 Creation date September 17, 2007
Platform S60 3rd Edition Devices  
Category Symbian C++ Subcategory Graphics


Overview

Using CImageDecoder to decode and scale JPEG images can be a slow and memory-consuming process, depending on image size. Here are a few tips which will increase speed and decrease memory consumption.

Solution

A generic way to decode e.g. a 5 megapixel image:

  1. Create a 5 megapixel CFbsBitmap image.
  2. Create the decoder.
  3. Convert the image.
  4. Scale the 5 megapixel output to a smaller resolution size (e.g. QVGA, VGA...)

This is, however, not efficient, since it requires memory to store the 5MP intermediate bitmap image.

Instead, you can do the following:

  1. Create a CFbsBitmap image of the required size (e.g. QVGA, VGA...).
  2. Create the decoder.
  3. Convert the image.

Using this method, bitmap scaling will be handled during decoding, which will increase speed and decrease memory usage.

Note that some JPEG decoders may not support arbitrary scaling. The information for arbitrary scaling support can be obtained from the EFullyScaleable property of TFrameInfo.

If the decoder does not support arbitrary scaling, first perform the best suitable DCT (Discrete Cosine Transform) scaling (e.g. 1, 1/2, 1/4 or 1/8) and then perform a normal bitmap scaling on the resulting CFbsBitmap.

The steps are as follows:

  1. Create the decoder.
  2. Check TFrameInfo flags.
    • If arbitrary scaling supported
      1. Create a CFbsBitmap image of required size (e.g.QVGA, VGA...)
      2. Convert
    • If arbitrary scaling is not supported
      1. Create a CFbsBitmap image of best suitable DCT scaling ratio (e.g. 1, 1/2, 1/4, 1/8).
      2. Convert the image.
      3. Perform CFbsBitmap scaling on the output bitmap in order to get the final image size.


Example on DCT scaling

Original size: 2048x1536

Desired size: QVGA (320x240) - same aspect ratio

Assume that arbitrary scaling is not supported.

If DCT scaling of 1/8 ratio is used, the size of the scaled bitmap is:

2048/8 = 256 and 1536/8 = 192 (256x192)

This would result in a lower than desired resolution; upscaling 256x192 to QVGA will result in poor image quality.

If DCT scaling of 1/4 ratio is used:

2048/4 = 512 and 1536/4 = 384 (512x384)

In this case, the best choice is to use 1/4 scaling and further scale the 512x384 bitmap to 320x240 with CBitmapScaler.

Related Discussions
Thread Thread Starter Forum Replies Last Post
Datarate over Bluetooth chairmanzf Bluetooth Technology 5 2005-05-18 16:40
3650 MMAPI - bad quality jpeg encoding? denisamselem Mobile Java General 1 2003-11-04 06:37
mem-leak in fbserv ebinder General Symbian C++ 2 2002-10-25 14:32
can i have reduced pc suits? comicosmos News, Announcements and Job Listings 4 2007-11-12 19:14
How to convert the jpeg image data to CFbsBitmap whitewinds Symbian Media (Graphics & Sounds) 3 2007-04-17 08:00
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZKnowledgeBaseContentQ
     qfnZtypeQUqfnTypeZTechnicalSolutionQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX