Compiling libjpeg for Android

Source: Internet
Author: User

Previously, YUV needs to be converted to JPG images. Check that libjpeg-Turbo is 2-3 times faster than libjpeg on the Internet, but it takes 40-60 ms to practice it on Android phones, although this is much better than the previous ms, but still can not meet my requirements, further view of the online information, libjpeg-Turbo is for x86 and x86-64 optimization using the SIMD command, this is not supported on mobile phones, so you need to test libjpeg's needs. Below are my compilation steps:

1, first go to the official website to download the source code http://www.ijg.org/files/jpegsr9.zip is the latest sr9

2, Then pressurize, generate the jpeg-9, enter and create the JNI directory, copy the content inside to the JNI inside

3. Generate the configuration file, create the config. Sh file under the JNI directory, and add the following in it:

 

 
Ndk =/opt/android-ndk-r8dPLATFORM = $ ndk/platforms/Android-8/arch-arm/prebuilt = $ ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86CC = $ prebuilt/bin/ARM- linux-androideabi-GCC. /configure -- prefix =/home/jpeg-9/JNI/dist -- Host = arm cc = "$ CC -- sysroot = $ platform"

4. Change the config. Sh permission and run the command to obtain the configuration file:

 

 

 
Chmod 775 config. SHSH config. Sh

5. Generate the Android. mk file with the following content:

 

 

Local_path: = $ (my-DIR) include $ (clear_vars) # From Autoconf-generated makefilelocal_module: = lib1_local_arm_mode = armlocal_src_files: = \ jaricom. c \ jcapimin. c \ jcapistd. c \ jcarith. c \ jccoefct. c \ jccolor. c \ jcdctmgr. c \ jchuff. c \ jcinit. c \ jcmainct. c \ jcmarker. c \ jcmaster. c \ jcomapi. c \ jcparam. c \ jcprepct. c \ jcsample. c \ jctrans. c \ jdapimin. c \ jdapistd. c \ jdarith. c \ jdatadst. c \ jdatasrc. c \ jdcoefct. c \ jdcolor. c \ jddctmgr. c \ jdhuff. c \ jdinput. c \ jdmainct. c \ jdmarker. c \ jdmaster. c \ jdmerge. c \ jdpostct. c \ jdsample. c \ jdtrans. c \ jerror. c \ jfdctflt. c \ jfdctfst. c \ jfdctint. c \ jidctflt. c \ jidctfst. c \ jidctint. c \ jquant1.c \ jquant2.c \ jutils. c \ jmemmgr. c \ jmemnobs. clocal_c_includes :=$ (local_path) local_cflags: =-O3-fstrict-aliasing-fprefetch-loop-Arrays-dandroid \-dandroid_tile_based_decode-example $ (build_shared_library)

6. Run ndk-build. The result is as follows:

 

 

Root @ Zhangjie:/home/jpeg-9/JNI # ndk-buildcompile arm: JPEG <= jaricom. ccompile arm: JPEG <= jcapimin. ccompile arm: JPEG <= jcapistd. ccompile arm: JPEG <= jcarith. 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 <= jcprepct. ccompile arm: JPEG <= jcsample. ccompile arm: JPEG <= jctrans. ccompile arm: JPEG <= jdapimin. ccompile arm: JPEG <= jdapistd. ccompile arm: JPEG <= jdarith. 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 <= 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 <= jquant1.ccompile arm: JPEG <= jquant2.ccompile arm: JPEG <= jutils. ccompile arm: JPEG <= jmemmgr. ccompile arm: JPEG <= jmemnobs. csharedlibrary: libjpeg. soinstall: libjpeg. so => libs/armeabi/libjpeg. so

7. Because I only want to encode it, It is simplified.CodeThe compiled library contains only the encoding, not the decoding library. The following code replaces the same part of the android. mk file:

 

Local_src_files: = jniffmpeg/appdecodeh264.c \ jniffmpeg/yuv420rgb565. s \ jniffmpeg/yuv2jpg. c \ jpeg-9/jaricom. c \ jpeg-9/jcapimin. c \ jpeg-9/jcapistd. c \ jpeg-9/jcarith. c \ jpeg-9/jccoefct. c \ jpeg-9/jccolor. c \ jpeg-9/jcdctmgr. c \ jpeg-9/jchuff. c \ jpeg-9/jcinit. c \ jpeg-9/jcmainct. jpeg-9/jcmarker. c \ jpeg-9/jcmaster. c \ jpeg-9/jcomapi. c \ jpeg-9/jcparam. c \ jpeg-9/jcprepct. c \ jpeg-9/jcsample. c \ jpeg-9/jctrans. c \ jpeg-9/jdatadst. c \ jpeg-9/jerror. c \ jpeg-9/jfdctflt. c \ jpeg-9/jfdctfst. c \ jpeg-9/jfdctint. c \ jpeg-9/jidctflt. c \ jpeg-9/jidctfst. c \ jpeg-9/jidctint. c \ jpeg-9/jquant1.c \ jpeg-9/jquant2.c \ jpeg-9/jutils. jpeg-9/jmemmgr. c \ jpeg-9/jmemnobs. c

 

 

 

Related Article

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.