Skip to content

Commit

Permalink
Fixed bug 3694 - SDL_image fails to compile with the latest NDK (r15)
Browse files Browse the repository at this point in the history
Olli Kallioinen

Compiling SDL_image fails with the latest NDK(r15) with an error:

  SDL_image/external/jpeg-9/jidctfst.S:17:10:
  fatal error:'machine/cpu-features.h' file not found


I was thinking that maybe it was an issue with the new NDK, but the NDK developers confirmed that the header was removed on purpose:
android/ndk#443

Sylvain

Some update as I looked more closely on this.

The file jidctfst.S contains an assembly version of the fast integer inverse-DCT.
the file jidctfst.c contains a C version of this "fast" fonction.
It also exists C version "slow", which is more accurate.


SDL_images use by default the slow version. JPEG default DCT method is also to use the slow function.
To use the fast IDCT (C or Assembly), one needs to enable the compile flag in SDL IMG_jpeg.c FAST_JPEG which set dct_method to "JDCT_FASTEST".


I enabled the FAST_JPEG and used the assembly implementation. And it just did not work: images are not decoded correctly and totally screwed up.
Tried with ABI arm and armv7a, with clang and gcc. same result.

I also tried a small benchmark loading tens of images on a device. When the slow version performs in 430 ms, the C-fast version is doing that 400ms, and the assembly-fast version is doing 390. which is not that much better.

So I think, we could just allow the C fast version (which is working), for people who would enable FAST_JPEG in SDL2_image.

Here's a patch that modify Android.mk (and also the one in external/jpeg-9).
  • Loading branch information
slouken committed Sep 18, 2017
1 parent 1d642d7 commit 045d7b9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
7 changes: 1 addition & 6 deletions Android.mk
Expand Up @@ -79,19 +79,14 @@ ifeq ($(SUPPORT_JPG),true)
$(JPG_LIBRARY_PATH)/jfdctfst.c \
$(JPG_LIBRARY_PATH)/jfdctint.c \
$(JPG_LIBRARY_PATH)/jidctflt.c \
$(JPG_LIBRARY_PATH)/jidctfst.c \
$(JPG_LIBRARY_PATH)/jidctint.c \
$(JPG_LIBRARY_PATH)/jquant1.c \
$(JPG_LIBRARY_PATH)/jquant2.c \
$(JPG_LIBRARY_PATH)/jutils.c \
$(JPG_LIBRARY_PATH)/jmemmgr.c \
$(JPG_LIBRARY_PATH)/jmem-android.c

# starting with android-21, assembler support is available for armeabi-v7a
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_SRC_FILES += $(JPG_LIBRARY_PATH)/jidctfst.S
else
LOCAL_SRC_FILES += $(JPG_LIBRARY_PATH)/jidctfst.c
endif
endif

ifeq ($(SUPPORT_PNG),true)
Expand Down
13 changes: 0 additions & 13 deletions external/jpeg-9/Android.mk
Expand Up @@ -14,19 +14,6 @@ LOCAL_SRC_FILES := \
jquant2.c jutils.c jmemmgr.c \
jmem-android.c

# the assembler is only for the ARM version, don't break the Linux sim
ifneq ($(TARGET_ARCH),arm)
ANDROID_JPEG_NO_ASSEMBLER := true
endif

# temp fix until we understand why this broke cnn.com
#ANDROID_JPEG_NO_ASSEMBLER := true

ifeq ($(strip $(ANDROID_JPEG_NO_ASSEMBLER)),true)
LOCAL_SRC_FILES += jidctint.c jidctfst.c
else
LOCAL_SRC_FILES += jidctint.c jidctfst.S
endif

LOCAL_CFLAGS += -DAVOID_TABLES
LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays
Expand Down

0 comments on commit 045d7b9

Please sign in to comment.