Recently, the video is decoded to generate YUV data and then JPG images. The previous scheme is YUV-RGB-BMP-JPG, which is very slow. The calculation time is about Ms, multiple clicks on the camera may lead to video screen latency. Therefore, you can only use other methods to query libjpeg on the Internet. However, I read another article titled. The following is the use of ndk to cross-compile libjpeg-Turbo to generate a libjpeg-turbo.so.
1. download the latest libjpeg-Turbo source code from the official website, http://sourceforge.net/projects/libjpeg-turbo/, now the latest version is libjpeg-turbo-1.2.1
2. decompress the downloaded file, enter, create a JNI folder, and finally copy all the files to the JNI file.
3. Enter the JNI directory, create a configuration file (for example, jconfig. H, config. H), and enter:
./configure --with-jpeg8
Will generate
config.status: creating config.hconfig.status: creating jconfig.h
4. Create the Android. mk file.
# Makefile for libjpeg-turbo##################################################### simd #####################################################LOCAL_PATH := $(my-dir)include $(CLEAR_VARS)LOCAL_CFLAGS += -D__ARM_HAVE_NEON# From autoconf-generated MakefileEXTRA_DIST = simd/nasm_lt.sh simd/jcclrmmx.asm simd/jcclrss2.asm simd/jdclrmmx.asm simd/jdclrss2.asm \simd/jdmrgmmx.asm simd/jdmrgss2.asm simd/jcclrss2-64.asm simd/jdclrss2-64.asm \simd/jdmrgss2-64.asm simd/CMakeLists.txt libsimd_SOURCES_DIST = simd/jsimd_arm_neon.S \ simd/jsimd_arm.c LOCAL_SRC_FILES := $(libsimd_SOURCES_DIST)LOCAL_C_INCLUDES := $(LOCAL_PATH)/simd \ $(LOCAL_PATH)/android AM_CFLAGS := -march=armv7-a -mfpu=neonAM_CCASFLAGS := -march=armv7-a -mfpu=neonLOCAL_ARM_MODE=arm LOCAL_MODULE_TAGS := debug LOCAL_MODULE := libsimd include $(BUILD_STATIC_LIBRARY) ######################################################### libjpeg.so ######################################################## include $(CLEAR_VARS)# From autoconf-generated Makefilelibjpeg_SOURCES_DIST = jcapimin.c jcapistd.c jccoefct.c jccolor.c \ jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ jcomapi.c jcparam.c jcphuff.c jcprepct.c jcsample.c jctrans.c \ jdapimin.c jdapistd.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c \ jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c \ jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c \jaricom.c jcarith.c jdarith.c \turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c \turbojpeg-mapfileLOCAL_SRC_FILES:= $(libjpeg_SOURCES_DIST) LOCAL_SHARED_LIBRARIES := libcutilsLOCAL_STATIC_LIBRARIES := libsimdLOCAL_ARM_MODE=armLOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_CFLAGS :=-O3 -fstrict-aliasing -fprefetch-loop-arrays -DANDROID \ -DANDROID_TILE_BASED_DECODE -DENABLE_ANDROID_NULL_CONVERT -D__ARM_HAVE_NEONAM_CFLAGS := -march=armv7-a -mfpu=neonAM_CCASFLAGS := -march=armv7-a -mfpu=neonLOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_STATIC_LIBRARY)LOCAL_MODULE_TAGS := debugLOCAL_MODULE := libjpeginclude $(BUILD_SHARED_LIBRARY)
5. Enter ndk-build on the terminal. The result is as follows:
root@zhangjie:/home/libjpeg-turbo-1.2.1/jni# ndk-buildAndroid NDK: WARNING: Unsupported source file extensions in /home/libjpeg-turbo-1.2.1/jni/Android.mk for module jpeg Android NDK: turbojpeg-mapfile Compile arm : jpeg <= jcapimin.cCompile arm : jpeg <= jcapistd.cCompile arm : jpeg <= jccoefct.cCompile arm : jpeg <= jccolor.cCompile arm : jpeg <= jcdctmgr.cCompile arm : jpeg <= jchuff.cCompile arm : jpeg <= jcinit.cCompile arm : jpeg <= jcmainct.cCompile arm : jpeg <= jcmarker.cCompile arm : jpeg <= jcmaster.cCompile arm : jpeg <= jcomapi.cCompile arm : jpeg <= jcparam.cCompile arm : jpeg <= jcphuff.cCompile arm : jpeg <= jcprepct.cCompile arm : jpeg <= jcsample.cCompile arm : jpeg <= jctrans.cCompile arm : jpeg <= jdapimin.cCompile arm : jpeg <= jdapistd.cCompile arm : jpeg <= jdatadst.cCompile arm : jpeg <= jdatasrc.cCompile arm : jpeg <= jdcoefct.cCompile arm : jpeg <= jdcolor.cCompile arm : jpeg <= jddctmgr.cCompile arm : jpeg <= jdhuff.cCompile arm : jpeg <= jdinput.cCompile arm : jpeg <= jdmainct.cCompile arm : jpeg <= jdmarker.cCompile arm : jpeg <= jdmaster.cCompile arm : jpeg <= jdmerge.cCompile arm : jpeg <= jdphuff.cCompile arm : jpeg <= jdpostct.cCompile arm : jpeg <= jdsample.cCompile arm : jpeg <= jdtrans.cCompile arm : jpeg <= jerror.cCompile arm : jpeg <= jfdctflt.cCompile arm : jpeg <= jfdctfst.cCompile arm : jpeg <= jfdctint.cCompile arm : jpeg <= jidctflt.cCompile arm : jpeg <= jidctfst.cCompile arm : jpeg <= jidctint.cCompile arm : jpeg <= jidctred.cCompile arm : jpeg <= jquant1.cCompile arm : jpeg <= jquant2.cCompile arm : jpeg <= jutils.cCompile arm : jpeg <= jmemmgr.cCompile arm : jpeg <= jmemnobs.cCompile arm : jpeg <= jaricom.cCompile arm : jpeg <= jcarith.cCompile arm : jpeg <= jdarith.cCompile arm : jpeg <= turbojpeg.cCompile arm : jpeg <= transupp.cCompile arm : jpeg <= jdatadst-tj.cCompile arm : jpeg <= jdatasrc-tj.cCompile arm : simd <= jsimd_arm_neon.SCompile arm : simd <= jsimd_arm.cStaticLibrary : libsimd.aSharedLibrary : libjpeg.soInstall : libjpeg.so => libs/armeabi/libjpeg.so