11b362b15af34006e6a11974088a46d42b903418eJohann## 21b362b15af34006e6a11974088a46d42b903418eJohann## Copyright (c) 2012 The WebM project authors. All Rights Reserved. 31b362b15af34006e6a11974088a46d42b903418eJohann## 41b362b15af34006e6a11974088a46d42b903418eJohann## Use of this source code is governed by a BSD-style license 51b362b15af34006e6a11974088a46d42b903418eJohann## that can be found in the LICENSE file in the root of the source 61b362b15af34006e6a11974088a46d42b903418eJohann## tree. An additional intellectual property rights grant can be found 71b362b15af34006e6a11974088a46d42b903418eJohann## in the file PATENTS. All contributing project authors may 81b362b15af34006e6a11974088a46d42b903418eJohann## be found in the AUTHORS file in the root of the source tree. 91b362b15af34006e6a11974088a46d42b903418eJohann## 101b362b15af34006e6a11974088a46d42b903418eJohann 111b362b15af34006e6a11974088a46d42b903418eJohann# 121b362b15af34006e6a11974088a46d42b903418eJohann# This file is to be used for compiling libvpx for Android using the NDK. 131b362b15af34006e6a11974088a46d42b903418eJohann# In an Android project place a libvpx checkout in the jni directory. 141b362b15af34006e6a11974088a46d42b903418eJohann# Run the configure script from the jni directory. Base libvpx 151b362b15af34006e6a11974088a46d42b903418eJohann# encoder/decoder configuration will look similar to: 161b362b15af34006e6a11974088a46d42b903418eJohann# ./libvpx/configure --target=armv7-android-gcc --disable-examples \ 171b362b15af34006e6a11974088a46d42b903418eJohann# --sdk-path=/opt/android-ndk-r6b/ 181b362b15af34006e6a11974088a46d42b903418eJohann# 191b362b15af34006e6a11974088a46d42b903418eJohann# When targeting Android, realtime-only is enabled by default. This can 201b362b15af34006e6a11974088a46d42b903418eJohann# be overridden by adding the command line flag: 211b362b15af34006e6a11974088a46d42b903418eJohann# --disable-realtime-only 221b362b15af34006e6a11974088a46d42b903418eJohann# 231b362b15af34006e6a11974088a46d42b903418eJohann# This will create .mk files that contain variables that contain the 241b362b15af34006e6a11974088a46d42b903418eJohann# source files to compile. 251b362b15af34006e6a11974088a46d42b903418eJohann# 261b362b15af34006e6a11974088a46d42b903418eJohann# Place an Android.mk file in the jni directory that references the 271b362b15af34006e6a11974088a46d42b903418eJohann# Android.mk file in the libvpx directory: 281b362b15af34006e6a11974088a46d42b903418eJohann# LOCAL_PATH := $(call my-dir) 291b362b15af34006e6a11974088a46d42b903418eJohann# include $(CLEAR_VARS) 30ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang# include jni/libvpx/build/make/Android.mk 311b362b15af34006e6a11974088a46d42b903418eJohann# 321b362b15af34006e6a11974088a46d42b903418eJohann# There are currently two TARGET_ARCH_ABI targets for ARM. 331b362b15af34006e6a11974088a46d42b903418eJohann# armeabi and armeabi-v7a. armeabi-v7a is selected by creating an 341b362b15af34006e6a11974088a46d42b903418eJohann# Application.mk in the jni directory that contains: 351b362b15af34006e6a11974088a46d42b903418eJohann# APP_ABI := armeabi-v7a 361b362b15af34006e6a11974088a46d42b903418eJohann# 371b362b15af34006e6a11974088a46d42b903418eJohann# By default libvpx will detect at runtime the existance of NEON extension. 381b362b15af34006e6a11974088a46d42b903418eJohann# For this we import the 'cpufeatures' module from the NDK sources. 391b362b15af34006e6a11974088a46d42b903418eJohann# libvpx can also be configured without this runtime detection method. 401b362b15af34006e6a11974088a46d42b903418eJohann# Configuring with --disable-runtime-cpu-detect will assume presence of NEON. 411b362b15af34006e6a11974088a46d42b903418eJohann# Configuring with --disable-runtime-cpu-detect --disable-neon will remove any 421b362b15af34006e6a11974088a46d42b903418eJohann# NEON dependency. 431b362b15af34006e6a11974088a46d42b903418eJohann 441b362b15af34006e6a11974088a46d42b903418eJohann# To change to building armeabi, run ./libvpx/configure again, but with 451b362b15af34006e6a11974088a46d42b903418eJohann# --target=arm5te-android-gcc and modify the Application.mk file to 461b362b15af34006e6a11974088a46d42b903418eJohann# set APP_ABI := armeabi 471b362b15af34006e6a11974088a46d42b903418eJohann# 481b362b15af34006e6a11974088a46d42b903418eJohann# Running ndk-build will build libvpx and include it in your project. 491b362b15af34006e6a11974088a46d42b903418eJohann# 501b362b15af34006e6a11974088a46d42b903418eJohann 51ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangCONFIG_DIR := $(LOCAL_PATH)/ 521b362b15af34006e6a11974088a46d42b903418eJohannLIBVPX_PATH := $(LOCAL_PATH)/libvpx 531b362b15af34006e6a11974088a46d42b903418eJohannASM_CNV_PATH_LOCAL := $(TARGET_ARCH_ABI)/ads2gas 541b362b15af34006e6a11974088a46d42b903418eJohannASM_CNV_PATH := $(LOCAL_PATH)/$(ASM_CNV_PATH_LOCAL) 551b362b15af34006e6a11974088a46d42b903418eJohann 561b362b15af34006e6a11974088a46d42b903418eJohann# Makefiles created by the libvpx configure process 571b362b15af34006e6a11974088a46d42b903418eJohann# This will need to be fixed to handle x86. 581b362b15af34006e6a11974088a46d42b903418eJohannifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 59ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang include $(CONFIG_DIR)libs-armv7-android-gcc.mk 601b362b15af34006e6a11974088a46d42b903418eJohannelse 61ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang include $(CONFIG_DIR)libs-armv5te-android-gcc.mk 621b362b15af34006e6a11974088a46d42b903418eJohannendif 631b362b15af34006e6a11974088a46d42b903418eJohann 641b362b15af34006e6a11974088a46d42b903418eJohann# Rule that is normally in Makefile created by libvpx 651b362b15af34006e6a11974088a46d42b903418eJohann# configure. Used to filter out source files based on configuration. 661b362b15af34006e6a11974088a46d42b903418eJohannenabled=$(filter-out $($(1)-no),$($(1)-yes)) 671b362b15af34006e6a11974088a46d42b903418eJohann 681b362b15af34006e6a11974088a46d42b903418eJohann# Override the relative path that is defined by the libvpx 691b362b15af34006e6a11974088a46d42b903418eJohann# configure process 701b362b15af34006e6a11974088a46d42b903418eJohannSRC_PATH_BARE := $(LIBVPX_PATH) 711b362b15af34006e6a11974088a46d42b903418eJohann 721b362b15af34006e6a11974088a46d42b903418eJohann# Include the list of files to be built 731b362b15af34006e6a11974088a46d42b903418eJohanninclude $(LIBVPX_PATH)/libs.mk 741b362b15af34006e6a11974088a46d42b903418eJohann 751b362b15af34006e6a11974088a46d42b903418eJohann# Want arm, not thumb, optimized 761b362b15af34006e6a11974088a46d42b903418eJohannLOCAL_ARM_MODE := arm 771b362b15af34006e6a11974088a46d42b903418eJohannLOCAL_CFLAGS := -O3 781b362b15af34006e6a11974088a46d42b903418eJohann 791b362b15af34006e6a11974088a46d42b903418eJohann# ----------------------------------------------------------------------------- 801b362b15af34006e6a11974088a46d42b903418eJohann# Template : asm_offsets_template 811b362b15af34006e6a11974088a46d42b903418eJohann# Arguments : 1: assembly offsets file to be created 821b362b15af34006e6a11974088a46d42b903418eJohann# 2: c file to base assembly offsets on 831b362b15af34006e6a11974088a46d42b903418eJohann# Returns : None 841b362b15af34006e6a11974088a46d42b903418eJohann# Usage : $(eval $(call asm_offsets_template,<asmfile>, <srcfile> 851b362b15af34006e6a11974088a46d42b903418eJohann# Rationale : Create offsets at compile time using for structures that are 861b362b15af34006e6a11974088a46d42b903418eJohann# defined in c, but used in assembly functions. 871b362b15af34006e6a11974088a46d42b903418eJohann# ----------------------------------------------------------------------------- 881b362b15af34006e6a11974088a46d42b903418eJohanndefine asm_offsets_template 891b362b15af34006e6a11974088a46d42b903418eJohann 901b362b15af34006e6a11974088a46d42b903418eJohann_SRC:=$(2) 911b362b15af34006e6a11974088a46d42b903418eJohann_OBJ:=$(ASM_CNV_PATH)/$$(notdir $(2)).S 921b362b15af34006e6a11974088a46d42b903418eJohann 931b362b15af34006e6a11974088a46d42b903418eJohann_FLAGS = $$($$(my)CFLAGS) \ 941b362b15af34006e6a11974088a46d42b903418eJohann $$(call get-src-file-target-cflags,$(2)) \ 951b362b15af34006e6a11974088a46d42b903418eJohann $$(call host-c-includes,$$(LOCAL_C_INCLUDES) $$(CONFIG_DIR)) \ 961b362b15af34006e6a11974088a46d42b903418eJohann $$(LOCAL_CFLAGS) \ 971b362b15af34006e6a11974088a46d42b903418eJohann $$(NDK_APP_CFLAGS) \ 981b362b15af34006e6a11974088a46d42b903418eJohann $$(call host-c-includes,$$($(my)C_INCLUDES)) \ 991b362b15af34006e6a11974088a46d42b903418eJohann -DINLINE_ASM \ 1001b362b15af34006e6a11974088a46d42b903418eJohann -S \ 1011b362b15af34006e6a11974088a46d42b903418eJohann 1021b362b15af34006e6a11974088a46d42b903418eJohann_TEXT = "Compile $$(call get-src-file-text,$(2))" 1031b362b15af34006e6a11974088a46d42b903418eJohann_CC = $$(TARGET_CC) 1041b362b15af34006e6a11974088a46d42b903418eJohann 1051b362b15af34006e6a11974088a46d42b903418eJohann$$(eval $$(call ev-build-file)) 1061b362b15af34006e6a11974088a46d42b903418eJohann 1071b362b15af34006e6a11974088a46d42b903418eJohann$(1) : $$(_OBJ) $(2) 1081b362b15af34006e6a11974088a46d42b903418eJohann @mkdir -p $$(dir $$@) 109ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang @grep $(OFFSET_PATTERN) $$< | tr -d '\#' | $(CONFIG_DIR)$(ASM_CONVERSION) > $$@ 1101b362b15af34006e6a11974088a46d42b903418eJohannendef 1111b362b15af34006e6a11974088a46d42b903418eJohann 1121b362b15af34006e6a11974088a46d42b903418eJohann# Use ads2gas script to convert from RVCT format to GAS format. This passes 1131b362b15af34006e6a11974088a46d42b903418eJohann# puts the processed file under $(ASM_CNV_PATH). Local clean rule 1141b362b15af34006e6a11974088a46d42b903418eJohann# to handle removing these 1151b362b15af34006e6a11974088a46d42b903418eJohannifeq ($(CONFIG_VP8_ENCODER), yes) 116ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang ASM_CNV_OFFSETS_DEPEND += $(ASM_CNV_PATH)/vp8_asm_enc_offsets.asm 117ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangendif 118ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangifeq ($(HAVE_NEON), yes) 119ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang ASM_CNV_OFFSETS_DEPEND += $(ASM_CNV_PATH)/vpx_scale_asm_offsets.asm 1201b362b15af34006e6a11974088a46d42b903418eJohannendif 1211b362b15af34006e6a11974088a46d42b903418eJohann 1221b362b15af34006e6a11974088a46d42b903418eJohann.PRECIOUS: %.asm.s 1231b362b15af34006e6a11974088a46d42b903418eJohann$(ASM_CNV_PATH)/libvpx/%.asm.s: $(LIBVPX_PATH)/%.asm $(ASM_CNV_OFFSETS_DEPEND) 1241b362b15af34006e6a11974088a46d42b903418eJohann @mkdir -p $(dir $@) 125ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang @$(CONFIG_DIR)$(ASM_CONVERSION) <$< > $@ 1261b362b15af34006e6a11974088a46d42b903418eJohann 127ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang# For building *_rtcd.h, which have rules in libs.mk 1281b362b15af34006e6a11974088a46d42b903418eJohannTGT_ISA:=$(word 1, $(subst -, ,$(TOOLCHAIN))) 1291b362b15af34006e6a11974088a46d42b903418eJohanntarget := libs 1301b362b15af34006e6a11974088a46d42b903418eJohann 1311b362b15af34006e6a11974088a46d42b903418eJohannLOCAL_SRC_FILES += vpx_config.c 1321b362b15af34006e6a11974088a46d42b903418eJohann 1331b362b15af34006e6a11974088a46d42b903418eJohann# Remove duplicate entries 1341b362b15af34006e6a11974088a46d42b903418eJohannCODEC_SRCS_UNIQUE = $(sort $(CODEC_SRCS)) 1351b362b15af34006e6a11974088a46d42b903418eJohann 1361b362b15af34006e6a11974088a46d42b903418eJohann# Pull out C files. vpx_config.c is in the immediate directory and 1371b362b15af34006e6a11974088a46d42b903418eJohann# so it does not need libvpx/ prefixed like the rest of the source files. 138b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian# The neon files with intrinsics need to have .neon appended so the proper 139b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian# flags are applied. 1401b362b15af34006e6a11974088a46d42b903418eJohannCODEC_SRCS_C = $(filter %.c, $(CODEC_SRCS_UNIQUE)) 141b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh VenkatasubramanianLOCAL_NEON_SRCS_C = $(filter %_neon.c, $(CODEC_SRCS_C)) 142b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh VenkatasubramanianLOCAL_CODEC_SRCS_C = $(filter-out vpx_config.c %_neon.c, $(CODEC_SRCS_C)) 1431b362b15af34006e6a11974088a46d42b903418eJohann 1441b362b15af34006e6a11974088a46d42b903418eJohannLOCAL_SRC_FILES += $(foreach file, $(LOCAL_CODEC_SRCS_C), libvpx/$(file)) 145b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh VenkatasubramanianLOCAL_SRC_FILES += $(foreach file, $(LOCAL_NEON_SRCS_C), libvpx/$(file).neon) 1461b362b15af34006e6a11974088a46d42b903418eJohann 1471b362b15af34006e6a11974088a46d42b903418eJohann# Pull out assembly files, splitting NEON from the rest. This is 1481b362b15af34006e6a11974088a46d42b903418eJohann# done to specify that the NEON assembly files use NEON assembler flags. 1491b362b15af34006e6a11974088a46d42b903418eJohannCODEC_SRCS_ASM_ALL = $(filter %.asm.s, $(CODEC_SRCS_UNIQUE)) 1501b362b15af34006e6a11974088a46d42b903418eJohannCODEC_SRCS_ASM = $(foreach v, \ 1511b362b15af34006e6a11974088a46d42b903418eJohann $(CODEC_SRCS_ASM_ALL), \ 1521b362b15af34006e6a11974088a46d42b903418eJohann $(if $(findstring neon,$(v)),,$(v))) 1531b362b15af34006e6a11974088a46d42b903418eJohannCODEC_SRCS_ASM_ADS2GAS = $(patsubst %.s, \ 1541b362b15af34006e6a11974088a46d42b903418eJohann $(ASM_CNV_PATH_LOCAL)/libvpx/%.s, \ 1551b362b15af34006e6a11974088a46d42b903418eJohann $(CODEC_SRCS_ASM)) 1561b362b15af34006e6a11974088a46d42b903418eJohannLOCAL_SRC_FILES += $(CODEC_SRCS_ASM_ADS2GAS) 1571b362b15af34006e6a11974088a46d42b903418eJohann 1581b362b15af34006e6a11974088a46d42b903418eJohannifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 1591b362b15af34006e6a11974088a46d42b903418eJohann CODEC_SRCS_ASM_NEON = $(foreach v, \ 1601b362b15af34006e6a11974088a46d42b903418eJohann $(CODEC_SRCS_ASM_ALL),\ 1611b362b15af34006e6a11974088a46d42b903418eJohann $(if $(findstring neon,$(v)),$(v),)) 1621b362b15af34006e6a11974088a46d42b903418eJohann CODEC_SRCS_ASM_NEON_ADS2GAS = $(patsubst %.s, \ 1631b362b15af34006e6a11974088a46d42b903418eJohann $(ASM_CNV_PATH_LOCAL)/libvpx/%.s, \ 1641b362b15af34006e6a11974088a46d42b903418eJohann $(CODEC_SRCS_ASM_NEON)) 1651b362b15af34006e6a11974088a46d42b903418eJohann LOCAL_SRC_FILES += $(patsubst %.s, \ 1661b362b15af34006e6a11974088a46d42b903418eJohann %.s.neon, \ 1671b362b15af34006e6a11974088a46d42b903418eJohann $(CODEC_SRCS_ASM_NEON_ADS2GAS)) 1681b362b15af34006e6a11974088a46d42b903418eJohannendif 1691b362b15af34006e6a11974088a46d42b903418eJohann 1701b362b15af34006e6a11974088a46d42b903418eJohannLOCAL_CFLAGS += \ 1711b362b15af34006e6a11974088a46d42b903418eJohann -DHAVE_CONFIG_H=vpx_config.h \ 1721b362b15af34006e6a11974088a46d42b903418eJohann -I$(LIBVPX_PATH) \ 1731b362b15af34006e6a11974088a46d42b903418eJohann -I$(ASM_CNV_PATH) 1741b362b15af34006e6a11974088a46d42b903418eJohann 1751b362b15af34006e6a11974088a46d42b903418eJohannLOCAL_MODULE := libvpx 1761b362b15af34006e6a11974088a46d42b903418eJohann 1771b362b15af34006e6a11974088a46d42b903418eJohannLOCAL_LDLIBS := -llog 1781b362b15af34006e6a11974088a46d42b903418eJohann 1791b362b15af34006e6a11974088a46d42b903418eJohannifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes) 1801b362b15af34006e6a11974088a46d42b903418eJohann LOCAL_STATIC_LIBRARIES := cpufeatures 1811b362b15af34006e6a11974088a46d42b903418eJohannendif 1821b362b15af34006e6a11974088a46d42b903418eJohann 183ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang# Add a dependency to force generation of the RTCD files. 184ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangifeq ($(CONFIG_VP8), yes) 185ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang$(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vp8_rtcd.h 186ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangendif 187ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangifeq ($(CONFIG_VP9), yes) 188ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang$(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vp9_rtcd.h 189ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangendif 190ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang$(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vpx_scale_rtcd.h 1911b362b15af34006e6a11974088a46d42b903418eJohann 1921b362b15af34006e6a11974088a46d42b903418eJohann.PHONY: clean 1931b362b15af34006e6a11974088a46d42b903418eJohannclean: 1941b362b15af34006e6a11974088a46d42b903418eJohann @echo "Clean: ads2gas files [$(TARGET_ARCH_ABI)]" 1951b362b15af34006e6a11974088a46d42b903418eJohann @$(RM) $(CODEC_SRCS_ASM_ADS2GAS) $(CODEC_SRCS_ASM_NEON_ADS2GAS) 1961b362b15af34006e6a11974088a46d42b903418eJohann @$(RM) $(patsubst %.asm, %.*, $(ASM_CNV_OFFSETS_DEPEND)) 1971b362b15af34006e6a11974088a46d42b903418eJohann @$(RM) -r $(ASM_CNV_PATH) 1981b362b15af34006e6a11974088a46d42b903418eJohann @$(RM) $(CLEAN-OBJS) 1991b362b15af34006e6a11974088a46d42b903418eJohann 2001b362b15af34006e6a11974088a46d42b903418eJohanninclude $(BUILD_SHARED_LIBRARY) 2011b362b15af34006e6a11974088a46d42b903418eJohann 202ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangifeq ($(HAVE_NEON), yes) 2031b362b15af34006e6a11974088a46d42b903418eJohann $(eval $(call asm_offsets_template,\ 204ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang $(ASM_CNV_PATH)/vpx_scale_asm_offsets.asm, \ 205ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang $(LIBVPX_PATH)/vpx_scale/vpx_scale_asm_offsets.c)) 2061b362b15af34006e6a11974088a46d42b903418eJohannendif 2071b362b15af34006e6a11974088a46d42b903418eJohann 2081b362b15af34006e6a11974088a46d42b903418eJohannifeq ($(CONFIG_VP8_ENCODER), yes) 2091b362b15af34006e6a11974088a46d42b903418eJohann $(eval $(call asm_offsets_template,\ 210ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang $(ASM_CNV_PATH)/vp8_asm_enc_offsets.asm, \ 211ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang $(LIBVPX_PATH)/vp8/encoder/vp8_asm_enc_offsets.c)) 2121b362b15af34006e6a11974088a46d42b903418eJohannendif 2131b362b15af34006e6a11974088a46d42b903418eJohann 2141b362b15af34006e6a11974088a46d42b903418eJohannifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes) 2151b362b15af34006e6a11974088a46d42b903418eJohann$(call import-module,cpufeatures) 2161b362b15af34006e6a11974088a46d42b903418eJohannendif 217