Genesi Home Home Projects Forums
Login
Username:

Password:

Remember Me
 
[Register an Account]

Developer Programs
i.MX515
Power2People MPC8610

Efika 5200B

Search Projects

Google

Sponsored By



Efika 5200B Project
Reggae on Efika

in category Multimedia
proposed by Grzegorz Kraszewski on 21st February 2006 (accepted on 20th March 2006)

Blog Entry

  Another release - this time PGM images get decoded
posted by Grzegorz Kraszewski on 27th January 2007

Portable GrayMap is one of NetPBM family formats, commonly used on Unix-like systems for processing. Images are not compressed and file format is well documented, so why not support it? Then netpbm.demuxer has been extended to support binary and plaintext flavors of PGM. There is still no support of 16-bit images, but they are very rare. ITU.R 709 gamma correction is also implemented, but as an option. I've found that most apps write PGM-s without recommended gamma correction, so Reggae does not apply the inverse transform by default. A new class, videopcm.decoder converts 8-bit grayscale stream to the common ARGB32 format.

When implementing inverse gamma, I've done some benchmarking of different implementations. There is a common opinion that current CPU-s are so fast that it is better calculate in-place than use a lookup table. It need not to be a case for small, 256 byte table. I've run a benchmark over 1 000 000 pixels. Calculating with pow() takes 380 ms. Approximating the function with 3-rd order polynomial (minimum order to have accuracy needed) makes it a bit faster - 169 ms. Then I've turned it to integer arithmetic (with some bit shifts here and there) to get 12 ms, not bad, AltiVec version of this routine would be a killer :-). And what about look-up table? Well, 11 ms. The conclusion is for small lookup tables (it easily fits L1 cache), they are still damn fast, but integer calculations can catch up if not very complicated. This time polynomial approximation needed 6 multiplications, 3 additions and 3 bit shifts. I guess 2-nd order polynomial would be faster than lookup table, but it is not accurate enough in this case.

PowerDeveloper.org: Copyright © 2004-2010, Genesi USA, Inc. The Power Architecture and Power.org wordmarks and the Power and Power.org logos and related marks are trademarks and service marks licensed by Power.org. All other names and trademarks used are property of their respective owners. Privacy Policy