Compiling libjpeg-turbo for android

Source: Internet
Author: User
Tags unsupported

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 a photo may lead to video screen latency. Therefore, you can only use another method to query libjpeg on the Internet. Therefore, we plan to use libjpg-turbo to convert yuv to jpg images. 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,

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:


[Cpp]
./Configure -- with-jpeg8

./Configure -- with-jpeg8
Will generate


[Cpp]
Config. status: creating config. h
Config. status: creating jconfig. h

Config. status: creating config. h
Config. status: creating jconfig. h4. Next, create the Android. mk file.


[Cpp]
# Makefile for libjpeg-turbo
 
######################################## ##########
### Simd ###
######################################## ##########
LOCAL_PATH: = $ (my-dir)
Include $ (CLEAR_VARS)
LOCAL_CFLAGS + =-d1_arm_have_neon
 
# From autoconf-generated Makefile
EXTRA_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 = neon
AM_CCASFLAGS :=- march = armv7-a-mfpu = neon
LOCAL_ARM_MODE = arm
LOCAL_MODULE_TAGS: = debug

LOCAL_MODULE: = libsimd

Include $ (BUILD_STATIC_LIBRARY)

######################################## ##############
### Libjpeg. so ##
######################################## ##############

Include $ (CLEAR_VARS)
 
# From autoconf-generated Makefile
Libjpeg_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-mapfile
 
LOCAL_SRC_FILES: = $ (libjpeg_SOURCES_DIST)

LOCAL_SHARED_LIBRARIES: = libcutils
LOCAL_STATIC_LIBRARIES: = libsimd
LOCAL_ARM_MODE = arm
LOCAL_C_INCLUDES: = $ (LOCAL_PATH)

LOCAL_CFLAGS: =-O3-fstrict-aliasing-fprefetch-loop-arrays-DANDROID \
-DANDROID_TILE_BASED_DECODE-DENABLE_ANDROID_NULL_CONVERT-d1_arm_have_neon
AM_CFLAGS: =-march = armv7-a-mfpu = neon
AM_CCASFLAGS :=- march = armv7-a-mfpu = neon
LOCAL_MODULE_PATH: = $ (TARGET_OUT_OPTIONAL_STATIC_LIBRARY)
LOCAL_MODULE_TAGS: = debug
LOCAL_MODULE: = libjpeg
Include $ (BUILD_SHARED_LIBRARY)

# Makefile for libjpeg-turbo

######################################## ##########
### Simd ###
######################################## ##########
LOCAL_PATH: = $ (my-dir)
Include $ (CLEAR_VARS)
LOCAL_CFLAGS + =-d1_arm_have_neon

# From autoconf-generated Makefile
EXTRA_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 = neon
AM_CCASFLAGS :=- march = armv7-a-mfpu = neon
LOCAL_ARM_MODE = arm
LOCAL_MODULE_TAGS: = debug
 
LOCAL_MODULE: = libsimd
 
Include $ (BUILD_STATIC_LIBRARY)
 
######################################## ##############
### Libjpeg. so ##
######################################## ##############
 
Include $ (CLEAR_VARS)

# From autoconf-generated Makefile
Libjpeg_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-mapfile

LOCAL_SRC_FILES: = $ (libjpeg_SOURCES_DIST)
 
LOCAL_SHARED_LIBRARIES: = libcutils
LOCAL_STATIC_LIBRARIES: = libsimd
LOCAL_ARM_MODE = arm
LOCAL_C_INCLUDES: = $ (LOCAL_PATH)
 
LOCAL_CFLAGS: =-O3-fstrict-aliasing-fprefetch-loop-arrays-DANDROID \
-DANDROID_TILE_BASED_DECODE-DENABLE_ANDROID_NULL_CONVERT-d1_arm_have_neon
AM_CFLAGS: =-march = armv7-a-mfpu = neon
AM_CCASFLAGS :=- march = armv7-a-mfpu = neon
LOCAL_MODULE_PATH: = $ (TARGET_OUT_OPTIONAL_STATIC_LIBRARY)
LOCAL_MODULE_TAGS: = debug
LOCAL_MODULE: = libjpeg
Include $ (BUILD_SHARED_LIBRARY)
5. Enter ndk-build on the terminal. The result is as follows:


[Cpp]
Root @ MAID:/home/libjpeg-turbo-1.2.1/jni # ndk-build
Android 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. c
Compile arm: jpeg <= jcapistd. c
Compile arm: jpeg <= jccoefct. c
Compile arm: jpeg <= jccolor. c
Compile arm: jpeg <= jcdctmgr. c
Compile arm: jpeg <= jchuff. c
Compile arm: jpeg <= jcinit. c
Compile arm: jpeg <= jcmainct. c
Compile arm: jpeg <= jcmarker. c
Compile arm: jpeg <= jcmaster. c
Compile arm: jpeg <= jcomapi. c
Compile arm: jpeg <= jcparam. c
Compile arm: jpeg <= jcphuff. c
Compile arm: jpeg <= jcprepct. c
Compile arm: jpeg <= jcsample. c
Compile arm: jpeg <= jctrans. c
Compile arm: jpeg <= jdapimin. c
Compile arm: jpeg <= jdapistd. c
Compile arm: jpeg <= jdatadst. c
Compile arm: jpeg <= jdatasrc. c
Compile arm: jpeg <= jdcoefct. c
Compile arm: jpeg <= jdcolor. c
Compile arm: jpeg <= jddctmgr. c
Compile arm: jpeg <= jdhuff. c
Compile arm: jpeg <= jdinput. c
Compile arm: jpeg <= jdmainct. c
Compile arm: jpeg <= jdmarker. c
Compile arm: jpeg <= jdmaster. c
Compile arm: jpeg <= jdmerge. c
Compile arm: jpeg <= jdphuff. c
Compile arm: jpeg <= jdpostct. c
Compile arm: jpeg <= jdsample. c
Compile arm: jpeg <= jdtrans. c
Compile arm: jpeg <= jerror. c
Compile arm: jpeg <= jfdctflt. c
Compile arm: jpeg <= jfdctfst. c
Compile arm: jpeg <= jfdctint. c
Compile arm: jpeg <= jidctflt. c
Compile arm: jpeg <= jidctfst. c
Compile arm: jpeg <= jidctint. c
Compile arm: jpeg <= jidctred. c
Compile arm: jpeg <= jquant1.c
Compile arm: jpeg <= jquant2.c
Compile arm: jpeg <= jutils. c
Compile arm: jpeg <= jmemmgr. c
Compile arm: jpeg <= jmemnobs. c
Compile arm: jpeg <= jaricom. c
Compile arm: jpeg <= jcarith. c
Compile arm: jpeg <= jdarith. c
Compile arm: jpeg <= turbojpeg. c
Compile arm: jpeg <= transupp. c
Compile arm: jpeg <= jdatadst-tj.c
Compile arm: jpeg <= jdatasrc-tj.c
Compile arm: simd <= jsimd_arm_neon.S
Compile arm: simd <= jsimd_arm.c
StaticLibrary: libsimd.
SharedLibrary: libjpeg. so
Install: libjpeg. so => libs/armeabi/libjpeg. so

Root @ MAID:/home/libjpeg-turbo-1.2.1/jni # ndk-build
Android 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. c
Compile arm: jpeg <= jcapistd. c
Compile arm: jpeg <= jccoefct. c
Compile arm: jpeg <= jccolor. c
Compile arm: jpeg <= jcdctmgr. c
Compile arm: jpeg <= jchuff. c
Compile arm: jpeg <= jcinit. c
Compile arm: jpeg <= jcmainct. c
Compile arm: jpeg <= jcmarker. c
Compile arm: jpeg <= jcmaster. c
Compile arm: jpeg <= jcomapi. c
Compile arm: jpeg <= jcparam. c
Compile arm: jpeg <= jcphuff. c
Compile arm: jpeg <= jcprepct. c
Compile arm: jpeg <= jcsample. c
Compile arm: jpeg <= jctrans. c
Compile arm: jpeg <= jdapimin. c
Compile arm: jpeg <= jdapistd. c
Compile arm: jpeg <= jdatadst. c
Compile arm: jpeg <= jdatasrc. c
Compile arm: jpeg <= jdcoefct. c
Compile arm: jpeg <= jdcolor. c
Compile arm: jpeg <= jddctmgr. c
Compile arm: jpeg <= jdhuff. c
Compile arm: jpeg <= jdinput. c
Compile arm: jpeg <= jdmainct. c
Compile arm: jpeg <= jdmarker. c
Compile arm: jpeg <= jdmaster. c
Compile arm: jpeg <= jdmerge. c
Compile arm: jpeg <= jdphuff. c
Compile arm: jpeg <= jdpostct. c
Compile arm: jpeg <= jdsample. c
Compile arm: jpeg <= jdtrans. c
Compile arm: jpeg <= jerror. c
Compile arm: jpeg <= jfdctflt. c
Compile arm: jpeg <= jfdctfst. c
Compile arm: jpeg <= jfdctint. c
Compile arm: jpeg <= jidctflt. c
Compile arm: jpeg <= jidctfst. c
Compile arm: jpeg <= jidctint. c
Compile arm: jpeg <= jidctred. c
Compile arm: jpeg <= jquant1.c
Compile arm: jpeg <= jquant2.c
Compile arm: jpeg <= jutils. c
Compile arm: jpeg <= jmemmgr. c
Compile arm: jpeg <= jmemnobs. c
Compile arm: jpeg <= jaricom. c
Compile arm: jpeg <= jcarith. c
Compile arm: jpeg <= jdarith. c
Compile arm: jpeg <= turbojpeg. c
Compile arm: jpeg <= transupp. c
Compile arm: jpeg <= jdatadst-tj.c
Compile arm: jpeg <= jdatasrc-tj.c
Compile arm: simd <= jsimd_arm_neon.S
Compile arm: simd <= jsimd_arm.c
StaticLibrary: libsimd.
SharedLibrary: libjpeg. so
Install: libjpeg. so => libs/armeabi/libjpeg. so


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.