> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>
>
To reply to my own question, the reason why you don't get pthread
support is that the configure script does a check for libpthread,
which android lacks. If you override this, and hack the code that
detects the number of processors (since android doesn't seem to have
cpu_set_t), you can get it to compile with pthread support. Sadly,
enabling pthreads didn't seem to affect performance much.
The easy fix is to create a fake empty library:
/etc/android-ndk-r8d/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin/arm-linux-androideabi-ar
q ./libpthread.a
./configure --enable-pic --enable-static
--cross-prefix=/etc/android-ndk-r8d/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin/arm-linux-androideabi-
--sysroot=/etc/android-ndk-r8d/platforms/android-14/arch-arm
--host=arm-linux --extra-ldflags="-L."
After this, configuration gives us
thread: posix
This is not enough, though. make will fail, because Android does not
define cpu_set_t and the affinity API to derive number of cores at
runtime. I am using the following patch:
git diff common/cpu.c
diff --git a/common/cpu.c b/common/cpu.c
index 42a1b0e..bbbfcf4 100644
--- a/common/cpu.c
+++ b/common/cpu.c
@@-416,6 +416,9 @@ int x264_cpu_num_processors( void )
#if !HAVE_THREAD
return 1;
+#elif ANDROID
+ return android_getCpuCount();
+
#elif SYS_WINDOWS
return x264_pthread_num_processors_np( void )
To enable this, use
./configure --enable-pic --enable-static
--cross-prefix=/etc/android-ndk-r8d/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin/arm-linux-androideabi-
--sysroot=/etc/android-ndk-r8d/platforms/android-14/arch-arm
--host=arm-linux --extra-ldflags="-L." --extra-cflags="-DANDROID"
android_getCpuCount() is supplied by Android NDK, see
http://www.kandroid.org/ndk/docs/CPU-FEATURES.html.I hope this helps. On quad-core Android devices, the gain is quite significant (nowhere near 400%, though). We are using the ultafast/zerolatency preset to compress VGA frames in multi-sliced mode.Alex Cohn