7

I need to decode (unpack into bitmap) pretty small (about 1200 * 1200) JPEG. The problem is I need to do it quickly. I have tried libjpeg, and it's quite slow. I have also tried BitmapFactory.decodeByteArray - it's a bit faster, but still not fast enough. What are another options? A native (C++) library is much preferred.

P.S. My JPEGs are created directly in memory.

P.P.S. I wonder how come libjpeg is slower than BitmapFactory.decodeByteArray.

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
  • 4
    Since when is 1200x1200 "pretty small"? Most screens are only 320x240 or so. Heck, my desktop is only 1280x1024. (1) Make a smaller JPEG (2) Only decode it once and cache it. – Mooing Duck Oct 12 '11 at 18:11
  • Good point, actually :) I consider it small since I started working with DSLRs. And I'm targeting tablets. Now, as for your suggestions: 1) Tried that (scale factor 2) - the performance is still not sufficient, further reduction of resolution is unacceptable. 2) No way, I need to display different JPEGs in realtime (more or less). – Violet Giraffe Oct 12 '11 at 19:18
  • With regards the speed difference; The android code will probably use some instruction set on the ARM CPU to decode the JPG faster than the C code can using CPU. – stealthcopter May 02 '12 at 12:50
  • 1
    @stealthcopter: But as far as I know, there's only one such instruction set - NEON, which my device doesn't support. The only possibility I see is Android uses hand - optimized code, but ARM instruction set is not exactly the type you want to manually optimize, and being RISC, it's supposed to be optimized by compiler pretty well... – Violet Giraffe May 02 '12 at 13:44
  • **Re:** the speed difference: the framework *may* use hardware JPEG decoder if the SoC does have this capability (e.g. some Samsung's Exynos have it). Unfortunately, there is no way to guarantee this hardware acceleration will be used by the framework, even if it is available, and there is no way to run this decoder directly on an unrooted device. – Alex Cohn Oct 01 '17 at 07:16
  • @AlexCohn: by the framework, do you mean `BitmapFactory.decodeByteArray` and similar APIs? – Violet Giraffe Oct 01 '17 at 16:43
  • Yes, but more specifically I mean the implementation of this method on a specific platform. – Alex Cohn Oct 01 '17 at 18:37
  • http://www.briancbecker.com/blog/2010/analysis-of-jpeg-decoding-speeds/ – Gabriel Feb 05 '19 at 09:26

1 Answers1

2

Try Libjpeg Turbo: http://libjpeg-turbo.virtualgl.org/

rossb83
  • 1,694
  • 4
  • 21
  • 40