当前位置:操作系统 > 安卓/Android >>

android 编译libjpeg-turbo

最近解码视频生成的是yuv数据,然后需要生成jpg图片,之前的方案是yuv-rgb-bmp-jpg这样的话是很慢的,计算了时间大概要300ms左右,导致多次点击照相,会造成视频画面的延迟,所以只能使用别的方案替代,在网上查询libjpeg,所以打算使用libjpg-turbo来实现yuv转换为jpg图像。下面是使用ndk来交叉编译libjpeg-turbo生成libjpeg-turbo.so。

1、从官网下载最新的libjpeg-turbo源码,

2、解压缩下载的文件,然后进入,并创建jni文件夹,最后将里面的文件都拷贝到jni文件中

3、进入jni目录,然后创建配置文件(例如jconfig.h,config.h),在终端输入:


[cpp]
./configure --with-jpeg8 

 ./configure --with-jpeg8
就会生成


[cpp]
config.status: creating config.h 
config.status: creating jconfig.h 

config.status: creating config.h
config.status: creating jconfig.h4、接下来是创建Android.mk文件


[cpp] 
# Makefile for libjpeg-turbo  
 
##################################################  
###                simd                        ###  
##################################################  
LOCAL_PATH := $(my-dir) 
include $(CLEAR_VARS) 
LOCAL_CFLAGS += -D__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 -D__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 += -D__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 tra

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,