libjpeg-turbo for Android: how to organize runtime selection of NEON / non-NEON code?

525 views Asked by At

I'm using a libjpeg-turbo port for Android. It's not much different from the base jpeg-turbo in terms of source code: http://git.linaro.org/gitweb?p=people/tomgall/libjpeg-turbo/libjpeg-turbo.git;a=shortlog;h=refs/heads/android

There is a module (static library) consisting of 2 cpu features-dependent files: jsimd_arm_neon.S and jsimd_arm.c. I want to compile jpeg-turbo with NEON support, I must define __ARM_HAVE_NEON and compile this module with -march=armv7-a -mfpu=neon. I want the library to run on older hardware with no Neon support (like Tegra 2), I should remove neon compiler flag and undef __ARM_HAVE_NEON.

My question is: how to compile it so that neon or non-neon path can be selected at runtime without SIGILL on non-neon hardware? I know how to check for NEON at runtime, but I don't know how to modify libjpeg-turbo and organize libraries.

1

There are 1 answers

0
Bruce On BEST ANSWER

An old question but I'll add to it anyway just in case. Someone did go into detail and one of the issues was dynamically selecting NEON. It is explained here: https://stackoverflow.com/a/20697814/712413.

The relevant section is item 4 to modify some lines in the init_simd() method.