Skip to content

Commit 1c32296

Browse files
committed
Merge pull request kivy#373 from kivy/jpeg_new
switch to faster jpeg-turbo
2 parents 1c86ad2 + 419e5d9 commit 1c32296

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+7726
-763
lines changed

src/jni/jpeg/Android.mk

100644100755
Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,79 @@
1-
LOCAL_PATH:= $(call my-dir)
1+
LOCAL_PATH := $(my-dir)
22
include $(CLEAR_VARS)
33

44
LOCAL_ARM_MODE := arm
55

6+
# Set ANDROID_JPEG_USE_VENUM to true to enable VeNum optimizations
7+
ANDROID_JPEG_USE_VENUM := true
8+
9+
# Disable VeNum optimizations if they are not supported on the build target
10+
ifneq ($(ARCH_ARM_HAVE_VFP),true)
11+
ANDROID_JPEG_USE_VENUM := false
12+
else
13+
ifneq ($(ARCH_ARM_HAVE_NEON),true)
14+
ANDROID_JPEG_USE_VENUM := false
15+
endif
16+
endif
17+
618
LOCAL_SRC_FILES := \
19+
de_mjpegsample_NativeJpegLib.c \
720
jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \
821
jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \
922
jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \
1023
jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \
1124
jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \
1225
jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \
13-
jfdctint.c jidctflt.c jidctred.c jquant1.c \
26+
jfdctint.c jidctflt.c jquant1.c \
1427
jquant2.c jutils.c jmemmgr.c \
28+
29+
# use ashmem as libjpeg decoder's backing store
30+
#LOCAL_CFLAGS += -DUSE_ANDROID_ASHMEM
31+
#LOCAL_SRC_FILES += \
32+
jmem-ashmem.c
33+
34+
# the original android memory manager.
35+
# use sdcard as libjpeg decoder's backing store
36+
LOCAL_SRC_FILES += \
1537
jmem-android.c
1638

39+
1740
# the assembler is only for the ARM version, don't break the Linux sim
1841
ifneq ($(TARGET_ARCH),arm)
1942
ANDROID_JPEG_NO_ASSEMBLER := true
2043
endif
2144

22-
# temp fix until we understand why this broke cnn.com
23-
#ANDROID_JPEG_NO_ASSEMBLER := true
24-
2545
ifeq ($(strip $(ANDROID_JPEG_NO_ASSEMBLER)),true)
26-
LOCAL_SRC_FILES += jidctint.c jidctfst.c
46+
LOCAL_SRC_FILES += jidctint.c jidctfst.c jidctred.c
2747
else
28-
LOCAL_SRC_FILES += jidctint.c jidctfst.S
48+
ifeq ($(ANDROID_JPEG_USE_VENUM),true)
49+
LOCAL_SRC_FILES += jidctvenum.c
50+
LOCAL_SRC_FILES += asm/armv7/jdcolor-armv7.S
51+
LOCAL_SRC_FILES += asm/armv7/jdcolor-android-armv7.S
52+
LOCAL_SRC_FILES += asm/armv7/jdidct-armv7.S
53+
LOCAL_CFLAGS += -DANDROID_JPEG_USE_VENUM
54+
else # ANDROID_JPEG_USE_VENUM, false
55+
LOCAL_SRC_FILES += jidctint.c jidctred.c jidctfst.c armv6_idct.S
56+
LOCAL_CFLAGS += -DANDROID_ARMV6_IDCT
57+
endif # ANDROID_JPEG_USE_VENUM
2958
endif
3059

31-
LOCAL_CFLAGS += -DAVOID_TABLES
60+
LOCAL_CFLAGS += -DAVOID_TABLES
3261
LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays
33-
#LOCAL_CFLAGS += -march=armv6j
62+
63+
# enable tile based decode
64+
LOCAL_CFLAGS += -DANDROID_TILE_BASED_DECODE
65+
66+
ifdef NEEDS_ARM_ERRATA_754319_754320
67+
asm_flags := \
68+
--defsym NEEDS_ARM_ERRATA_754319_754320_ASM=1
69+
70+
LOCAL_CFLAGS+= \
71+
$(foreach f,$(asm_flags),-Wa,"$(f)")
72+
endif
3473

3574
LOCAL_MODULE:= jpeg
3675

37-
include $(BUILD_STATIC_LIBRARY)
76+
LOCAL_SHARED_LIBRARIES := \
77+
libcutils
78+
79+
include $(BUILD_SHARED_LIBRARY)

src/jni/jpeg/CleanSpec.mk

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright (C) 2007 The Android Open Source Project
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
# If you don't need to do a full clean build but would like to touch
17+
# a file or delete some intermediate files, add a clean step to the end
18+
# of the list. These steps will only be run once, if they haven't been
19+
# run before.
20+
#
21+
# E.g.:
22+
# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
23+
# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
24+
#
25+
# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
26+
# files that are missing or have been moved.
27+
#
28+
# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
29+
# Use $(OUT_DIR) to refer to the "out" directory.
30+
#
31+
# If you need to re-do something that's already mentioned, just copy
32+
# the command and add it to the bottom of the list. E.g., if a change
33+
# that you made last week required touching a file and a change you
34+
# made today requires touching the same file, just copy the old
35+
# touch step and add it to the end of the list.
36+
#
37+
# ************************************************
38+
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
39+
# ************************************************
40+
41+
# For example:
42+
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
43+
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
44+
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
45+
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
46+
47+
# ************************************************
48+
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
49+
# ************************************************

src/jni/jpeg/README-VeNum

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
README-VeNum
2+
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
3+
=================================================================
4+
5+
Consumers are increasingly browsing Web based photo galleries incorporating
6+
high-resolution JPEG images with their mobile devices. These images are
7+
decoded by the mobile device, and typically also scaled down to fit the user's
8+
zoom selection on the device's browser.
9+
10+
In order to improve both decode and download times, Qualcomm Innovation Center
11+
has optimized the JPEG library found on many common OS platforms such as Web
12+
OS, Android, and Chrome OS. Our team re-implemented several routines to utilize the
13+
DSP-like SIMD capabilities of the ARM NEON instruction set. These were then
14+
tuned and tested on Qualcomm's Snapdragon platform which implements the VeNum
15+
implementation of these same instructions.
16+
17+
The specific areas of focus cover VeNum/NEON acceleration of Inverse Discrete
18+
Cosine Transform (iDCT) for 8x8, 4x4, 2x2, and 1x1 block sizes and YUV to RGB
19+
color space conversion. This resulted in a range of 18-32% improvement in JPEG
20+
decode and downscale times for images greater than 2Mpixels.

src/jni/jpeg/ThirdPartyProject.prop

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2010 Google Inc. All Rights Reserved.
2+
#Fri Jul 16 10:03:09 PDT 2010
3+
currentVersion=8a
4+
version=6b
5+
isNative=true
6+
name=jpeg
7+
keywords=jpeg
8+
onDevice=true
9+
homepage=http\://www.ijg.org/

0 commit comments

Comments
 (0)