JPEG support for Android: resolving libjpeg.so conflicts

When porting GPAC to Android (2.3 as of today), we’ve been facing a very strange and annoying problem: JPEG images didn’t load, and libjpeg was outputing the following message:

JPEG parameter struct mismatch: library thinks size is 480,
 caller expects 520

We couldn’t find any relevant help on the Web. Discussions always ended up with no response or even some “you don’t understand what you’re doing”. The thing is we have understood and solved the problem.

First, the GPAC Android package (generated as mentionned in the README.txt file) does contain its own libjpeg.so file. The libjpeg.so file is generated from the extra_libs package. When running the Android Osmo4 player within the Eclipse debugger, the Dalvik console prints the following message:

INFO/LibrariesLoader(294): Loading library jpeg...
DEBUG/dalvikvm(294): No JNI_OnLoad found in
  /data/data/com.gpac.Osmo4/lib/libjpeg.so 0x44ede8f0, skipping init
DEBUG/dalvikvm(294): Added shared lib
  /data/data/com.gpac.Osmo4/lib/libjpeg.so 0x44ede8f0

Don’t trust it.

There is a conflict between your local libraries and the ones provided by Android. Google’s dynamic libraries are always loaded first as of Android 2.3. This is annoying because this affects numerous programs and also other dynamic libraries (such as zlib, libpng, …). We could confirm our hypothesis by changing the error messages printed by our own libjpeg.so: it didn’t match the error message showing in the Dalvik console.

The best solution we found is to rename the dynamic library to a non-usual name. libjpeg.so is now named libjpegdroid.so for the GPAC package.

You can find more info on GPAC running on Android from here or watch the following video:

[youtube]http://www.youtube.com/watch?v=himalbWpga4[/youtube]

Romain Bouqueau, Stephane Thomas

 

2 thoughts on “JPEG support for Android: resolving libjpeg.so conflicts

Comments are closed.